Hi Bogdan,
I knew that Nathelper did some rewriting, but the circumstances required
that the thing record the private IP and a certain known port instead of
the public IP as a contact address (using fix_nated_register() to save
the other address). I wound up borrowing the code from the Nathelper
module and modifying it to accept a port argument and made it a separate
module. This way, it only rewrote the port and not left everything else
untouched.
Thanks.
Justin Pearce
Information Technology/Programming
Price Video Productions
JustinP(a)PriceVideo.com
361-572-3810
800-733-3810
Fax: 361-572-3894
www.PriceVideo.com
-----Original Message-----
From: Bogdan-Andrei Iancu [mailto:bogdan@voice-system.ro]
Sent: Monday, August 21, 2006 6:19 AM
To: Justin Pearce
Cc: Klaus Darilion; users(a)openser.org
Subject: Re: [Users] Rewriting Contact HF port
Hi Justin,
if you need save(location) to save as "received" a custom uri, you just
need to set an avp with the uri you need to be saved. See:
http://openser.org/docs/modules/1.1.x/registrar.html#AEN211
It's exactly what nathelper does.
regards,
bogdan
Justin Pearce wrote:
>Thanks, Klaus
>
>It looks like I'll have to make something similar to the nathelper
>module to do what I need.
>
>Justin Pearce
>
>-----Original Message-----
>From: Klaus Darilion [mailto:klaus.mailinglists@pernau.at]
>Sent: Monday, August 07, 2006 1:43 AM
>To: Justin Pearce
>Cc: users(a)openser.org
>Subject: Re: [Users] Rewriting Contact HF port
>
>Justin Pearce wrote:
>
>
>>I am wondering if there is a good way to rewrite the port in the
>>
>>
>contact
>
>
>>header in OpenSER 1.0.1
>>
>>
>
>1. Why do you want to rewrite the port to fixed port? NAT problems?
>
>
>
>>before it is stored in the location table?(I'm using the MySQL
>>
>>
>database
>
>
>>backend).
>>
>>Thus far, I am using "subst(/^(Contact.+):[0-9]+(.+)$/\1:5060\2/ig);"
>>just before I do
>>
>>"save("location");", but that does not seem to be working.
>>
>>
>
>subst will be applied before the message is forwarded. Thus, save()
sees
>
>the original Contact header. You either loop the modified message to
the
>
>SIP proxy again or you write your own function (similar to the function
>in nathelper module)
>
>regards
>klaus
>
>
>
>>
>>
>>Suggestions?
>>
>>
>>
>>Justin Pearce
>>
>>Information Technology/Programming
>>
>>Price Video Productions
>>
>>JustinP(a)PriceVideo.com <mailto:JustinP@PriceVideo.com>
>>
>>361-572-3810
>>
>>800-733-3810
>>
>>Fax: 361-572-3894
>>
>>www.PriceVideo.com
>>
>>
>>
>>
>>
>>
>>
>-----------------------------------------------------------------------
-
>
>
>>_______________________________________________
>>Users mailing list
>>Users(a)openser.org
>>http://openser.org/cgi-bin/mailman/listinfo/users
>>
>>
>
>
>_______________________________________________
>Users mailing list
>Users(a)openser.org
>http://openser.org/cgi-bin/mailman/listinfo/users
>
>
>
Hi all,
finally I figured out how to change the sdp - part of the message by using force_rtpproxy.
All works fine, I can make calls in both directions, but i still got two problems:
1. If someone from outside(VoIP - Provider) calls my UA, i have a ~10 sec. delay before i hear audio.
- i checked my dumpfile, and saw that the delay is between the last 180 Ringing and the 200 OK.
(- However RTP - Packets are sent before the 200 OK, after a 183-Message. Dont understand why but I dont think it matters that much.)
2. If the call is terminated from outside(VoIP - Provider) the BYE message is not handled correctly by SER.
- the previous messages from the Voip provider have all a via HF with the private IP of my UA. The BYE message doesnt have such a Via. All other Via and RR fields are present.
- also the BYE uri is somewaht strange. Instead of sip:123456@privateIPofUA it contains sip:123456@publicIPofSER.
Thanks in advance for any help Smile
Best regards
Sebastian.
> -----Ursprüngliche Nachricht-----
> Von: "Greger V. Teigre" <greger(a)teigre.com>
> Gesendet: 10.08.06 15:41:31
> An: Sebastian Gabris <Sebastian.Gabris(a)web.de>
> CC: serusers(a)lists.iptel.org
> Betreff: Re: [Serusers] Multihomed SER & NAT
fix_nated_contact() is meant for changing the IP address of the Contact
> header when SER has a public address and the UA has a private (i.e.
> behind NAT). This means that it will rewrite Contact to contain the
> source ip address:port found in the UDP/TCP header.
> This is probably correct, because I assume the UA cannot be reached
> from the outside anyway. If you record-route, subsequent requests
> should go through your ser.
>
> If you have problems with responses not being returned, have a look at
> Via headers as they control how answers to i.e an INVITE are routed
> back to the UA. You may want to have a look at the rr module double
> record route parameter to make sure that SER creates one record-route
> for the internal and one for the external interface.
> g-)
>
> Sebastian Gabris wrote:
> After reading a bit more mails, I came to two possible problems:
> 1. fix_nated_contact() needs a registrar to work properly
> I dont use a registrar, since i register at the VoIP - Provider.
> or
> 2. fix_nated_contact() is not ment to be used on this scenario
> Any ideas on this?
> Sebastian
>
>
> Hi everybody,
> need some help on nattraversal.
> i use a multihomed SER, one private IP & one public IP.
> MyUA(privateIP) <-> (privateIP)SER(publicIP) <-> UA-(VoIP - Provider, pubicIP)
> If i try to make a call from private net to public net, SER doesnt change the contact address. He changes the sdp - connection field but he, puts in the wrong IP - address.
> Instead o writing down his public IP, SER writes his private IP.
> Then SER forwards the call on his public interface to the provider, which will get wrong Contact & SDP information.
> After reviewing my logs i saw that SER does the nat_uac_test, but the fix_nat_contact & fix_sdp dont work dont do what they should do :)
> Here are the important bits of my config:
> fork=yes
> log_stderror=no mhomed=1
> listen=10.x.x.x
> listen=193.x.x.x
> loadmodule "/usr/lib/ser/modules/nathelper.so"
> modparam("usrloc", "db_mode", 0)
> modparam("registrar", "nat_flag", 6)
> modparam("nathelper", "natping_interval", 30) # Ping interval 30 s
> modparam("nathelper", "ping_nated_only", 1) # Ping only clients behind NAT
> if (nat_uac_test("3")) {
> if (method == "REGISTER" || ! search("^Record-Route:")) {
> log(2,"LOG: Someone trying to register from private IP, rewriting\n"); fix_nated_contact(); # Rewrite contact with source IP of signalling
> if (method == "INVITE") {
> fix_nated_sdp("1"); # Add direction=active to SDP
> };
> force_rport(); # Add rport parameter to topmost Via
> setflag(6); # Mark as NATed
> };
> };
> ... and so on.
> ______________________________________________________________
> Verschicken Sie romantische, coole und witzige Bilder per SMS!
> Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
> _______________________________________________
> Serusers mailing list
> Serusers(a)lists.iptel.org
> http://lists.iptel.org/mailman/listinfo/serusers
>
>
>
> _____________________________________________________________________
> Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> http://smartsurfer.web.de/?mc=100071&distributionid=000000000071
> _______________________________________________
> Serusers mailing list
> Serusers(a)lists.iptel.org
> http://lists.iptel.org/mailman/listinfo/serusers
>
>
______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
Hi Folks,
I tried to use param "db_localtime" on OpenSER 1.0.1 and 1.1.0 but openser complain with
0(28677) set_mod_param_regex: parameter <db_localtime> not found in module <acc>
and does not start.
openser.cfg looks like:
...
loadmodule "/usr/local/lib/openser/modules/acc.so"
modparam("acc", "db_localtime", 1) # use GMT time - as OpenSER doc especify
...
..
Is that a missing implementation or some thing wrong is happening?
Thanks in advance,
Telles
Thanks, Klaus
It looks like I'll have to make something similar to the nathelper
module to do what I need.
Justin Pearce
-----Original Message-----
From: Klaus Darilion [mailto:klaus.mailinglists@pernau.at]
Sent: Monday, August 07, 2006 1:43 AM
To: Justin Pearce
Cc: users(a)openser.org
Subject: Re: [Users] Rewriting Contact HF port
Justin Pearce wrote:
> I am wondering if there is a good way to rewrite the port in the
contact
> header in OpenSER 1.0.1
1. Why do you want to rewrite the port to fixed port? NAT problems?
> before it is stored in the location table?(I'm using the MySQL
database
> backend).
>
> Thus far, I am using "subst(/^(Contact.+):[0-9]+(.+)$/\1:5060\2/ig);"
> just before I do
>
> "save("location");", but that does not seem to be working.
subst will be applied before the message is forwarded. Thus, save() sees
the original Contact header. You either loop the modified message to the
SIP proxy again or you write your own function (similar to the function
in nathelper module)
regards
klaus
>
>
>
> Suggestions?
>
>
>
> Justin Pearce
>
> Information Technology/Programming
>
> Price Video Productions
>
> JustinP(a)PriceVideo.com <mailto:JustinP@PriceVideo.com>
>
> 361-572-3810
>
> 800-733-3810
>
> Fax: 361-572-3894
>
> www.PriceVideo.com
>
>
>
>
>
------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users(a)openser.org
> http://openser.org/cgi-bin/mailman/listinfo/users
I just debugged the following:
A PSTN gateway we use is completely non-responsive when
the INVITE has this:
From: Mark Kent (desk) <sip:markkent@sip.example.com>;tag=foo
Contact: Mark Kent (desk) <sip:markkent@192.0.2.216:5060>
but things work OK for this:
From: "Mark Kent (desk)" <sip:markkent@sip.example.com>;tag=foo
Contact: "Mark Kent (desk)" <sip:markkent@192.0.2.216:5060>
and also for this:
From: Mark Kent <sip:markkent@sip.example.com>;tag=foo
Contact: Mark Kent <sip:markkent@192.0.2.216:5060>
Now, I know that the EndUser box should put quotes in there to be
safe. RFC3261 says "special characters MUST be in a quoted string to
be used within a parameter value."
But that's not the point of this post... the point is,
should I be rewriting every header? Is that standard practice?
BTW, I have the same hangup with the SJphone softphone,
but there I think it's because of this:
From: "Mark Kent(mac)"<sip:MarkKent@sip.example.com>;tag=foo
See, no space between the double-quote and the left-angle-bracket.
So, should I be re-writing headers to present a single face,
independent of the EndUser boxes, to external SIP gateways?
Thanks,
-mark
P.S. FYI, the box that is not putting in the quotes is a SPA3000
running 3.1.10(GWd). A SPA942 running 4.1.10(e) puts in the quotes.
Hi Users,
For Me, in Openser + radius Authorize and Acthentication is Succeed
Very Good and Nice,
But When some to Account, I'm little sucking here
When Uac1 dials to Uac2 ,
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
radacctID | AcctSessionID | AcctuniqueID | UserName |
AcctStartTime | ActStopTime | calledID | callingID |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 12h34yy 2334juuw45
Uac1 13:10:00 00:00:00 Uac2
uac1
2 12h34yy ko34ji899
Uac2 13:11:11 13:11:11 Uac1
Uac2
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
In accountting with openser + radius in should insert only one insert for
every call made .
But I think it insert only two records only. and AcctuniqueD should me
same for each call makes then only the AcctStopTime will properly .....
in openser...
-------------------- loose record-----------------------------------
if(method=="BYE" || method=="CANCEL")
{
acc_rad_request("Stop");
unforce_rtp_proxy();
}
---------------------------- record route section------------
if( method=="INVITE" || method=="ACK")
{
acc_rad_request("Start");
forcr_rtp_proxy();
}
plz help me in that .. sorry in my english .......
--
Thanks and Regards with cheers
Sunkara Ravi Prakash (Voip Developer)
Hyperion Technology
Kondapur, Hi-tech city,
Hyderabad.
www.hyperion-tech.com
+91-9985077535
Does modparam("tm", "fr_inv_timer", 5) fires some kind of interruption
(like a failure_route) when that time (5seconds) of ringing ends? I wish
that happens so my Ser be able to send calls to voicemail after ringing
with no answer!!
Does anybody know if that happens?
Regards,
Ricardo.
Dear sunkara,
Thank you very much for your kind-hearted for answering my question, Thank you very much.
If I can ask you more, would you mind tell me what is the name the application that I can use like "serweb" in openser server ? (the suitable "serweb" for openser server) because I am building openser server. and would you mind tell me where I can get it?
Please help me, Sunkara..Please...Please...
Thank you very much...Thank you...
Regards,
Ferianto
raviprakash sunkara <sunkara.raviprakash.feb14(a)gmail.com> wrote:
Hi siregar...
I best Suggest is Not to user SERweb in openser.
It application to SER only. not For openser , if U want to configure the serweb in openser U need to modify some changes in serweb and openser tables other things..
Perhaps try it.....
Best of luck...
On 8/19/06, Ferianto siregar <ferianto_voip(a)yahoo.com> wrote: Dear all,
Thanks to all of you for your kind-hearted answering my question. Thank you very much.
Now, I am building serweb in openser. So, the client can register to become the member of communication in my openser that I have built.
1. Can "serweb" (from iptel.org) be used in openser server for building the webserver of the openser server? Or openser has it`s own webserver except "serweb"?
2.When I build serweb (from iptel.org), I have some problems. I do hope anybody can help me and give me a suggestion. Please..
The error message that I got from client browser is
Fatal error: Failed opening required 'var/www/phplib/db_mysql.inc' (include_path='.:/usr/share/pear') in /var/www/html/serweb/user_interface/prepend.php on line 23
The contain of prepend.php that shows line 23 is
require($_PHPLIB["libdir"] . "db_mysql.inc"); _/* Change this to match your database. */
I don`t know what is wrong. I do hope anybody can give me a suggestion. Please help me..Please. Thanks
Regards,
Ferianto
Note:
This is the contain of db_mysql.inc that I have configured
<?php
_/*
* Session Management for PHP3
*
* Copyright (c) 1998-2000 NetUSE AG
* Boris Erdmann, Kristian Koehntopp
*
* $Id: db_mysql.inc,v 1.1.1.1 2002/09/04 18:19:57 kozlik Exp $
*
*/
class DB_Sql {
_/* public: connection parameters */
var $Host = "localhost";
var $Database = "openser";
var $User = "openser";
var $Password = "openserrw";
_/* public: configuration parameters */
var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result()
var $Debug = 0; ## Set to 1 for debugging messages.
var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
var $Seq_Table = "db_sequence";
_/* public: result array and current row number */
var $Record = array();
var $Row;
_/* public: current error number and error text */
var $Errno = 0;
var $Error = "";
_/* public: this is an api revision, not a CVS revision. */
var $type = "mysql";
var $revision = "1.2";
_/* private: link and query handles */
var $Link_ID = 0;
var $Query_ID = 0;
_/* public: constructor */
function DB_Sql($query = "") {
$this->query($query);
}
_/* public: some trivial reporting */
function link_id() {
return $this->Link_ID;
}
function query_id() {
return $this->Query_ID;
}
_/* public: connection management */
function connect($Database = "", $Host = "", $User = "", $Password = "") {
_/* Handle defaults */
if ("" == $Database)
$Database = $this->Database;
if ("" == $Host)
$Host = $this->Host;
if ("" == $User)
$User = $this->User;
if ("" == $Password)
$Password = $this->Password;
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.
---------------------------------
Do you Yahoo!?
Next-gen email? Have it all with the all-new Yahoo! Mail Beta.
Dear sunkara,
Thank you very much for your kind-hearted for answering my question, Thank you very much.
If I can ask you more, would you mind tell me what is the name the application that I can use like "serweb" in openser server ? (the suitable "serweb" for openser server) because I am building openser server. and would you mind tell me where I can get it?
Please help me, Sunkara..Please...Please...
Thank you very much...Thank you...
Regards,
Ferianto
raviprakash sunkara <sunkara.raviprakash.feb14(a)gmail.com> wrote:
Hi siregar...
I best Suggest is Not to user SERweb in openser.
It application to SER only. not For openser , if U want to configure the serweb in openser U need to modify some changes in serweb and openser tables other things..
Perhaps try it.....
Best of luck...
On 8/19/06, Ferianto siregar <ferianto_voip(a)yahoo.com> wrote: Dear all,
Thanks to all of you for your kind-hearted answering my question. Thank you very much.
Now, I am building serweb in openser. So, the client can register to become the member of communication in my openser that I have built.
1. Can "serweb" (from iptel.org) be used in openser server for building the webserver of the openser server? Or openser has it`s own webserver except "serweb"?
2.When I build serweb (from iptel.org), I have some problems. I do hope anybody can help me and give me a suggestion. Please..
The error message that I got from client browser is
Fatal error: Failed opening required 'var/www/phplib/db_mysql.inc' (include_path='.:/usr/share/pear') in /var/www/html/serweb/user_interface/prepend.php on line 23
The contain of prepend.php that shows line 23 is
require($_PHPLIB["libdir"] . "db_mysql.inc"); /* Change this to match your database. */
I don`t know what is wrong. I do hope anybody can give me a suggestion. Please help me..Please. Thanks
Regards,
Ferianto
Note:
This is the contain of db_mysql.inc that I have configured
<?php
/*
* Session Management for PHP3
*
* Copyright (c) 1998-2000 NetUSE AG
* Boris Erdmann, Kristian Koehntopp
*
* $Id: db_mysql.inc,v 1.1.1.1 2002/09/04 18:19:57 kozlik Exp $
*
*/
class DB_Sql {
/* public: connection parameters */
var $Host = "localhost";
var $Database = "openser";
var $User = "openser";
var $Password = "openserrw";
/* public: configuration parameters */
var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result()
var $Debug = 0; ## Set to 1 for debugging messages.
var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
var $Seq_Table = "db_sequence";
/* public: result array and current row number */
var $Record = array();
var $Row;
/* public: current error number and error text */
var $Errno = 0;
var $Error = "";
/* public: this is an api revision, not a CVS revision. */
var $type = "mysql";
var $revision = "1.2";
/* private: link and query handles */
var $Link_ID = 0;
var $Query_ID = 0;
/* public: constructor */
function DB_Sql($query = "") {
$this->query($query);
}
/* public: some trivial reporting */
function link_id() {
return $this->Link_ID;
}
function query_id() {
return $this->Query_ID;
}
/* public: connection management */
function connect($Database = "", $Host = "", $User = "", $Password = "") {
/* Handle defaults */
if ("" == $Database)
$Database = $this->Database;
if ("" == $Host)
$Host = $this->Host;
if ("" == $User)
$User = $this->User;
if ("" == $Password)
$Password = $this->Password;
/* establish connection, select database */
if ( 0 == $this->Link_ID ) {
$this->Link_ID=mysql_pconnect($Host, $User, $Password);
if (!$this->Link_ID) {
$this->halt("pconnect($Host, $User, \$Password) failed.");
return 0;
}
if (!@mysql_select_db($Database,$this->Link_ID)) {
$this->halt("cannot use database ".$Database);
return 0;
}
}
return $this->Link_ID;
}
/* public: discard the query result */
function free() {
@mysql_free_result($this->Query_ID);
$this->Query_ID = 0;
}
/* public: perform a query */
function query($Query_String) {
/* No empty queries, please, since PHP4 chokes on them. */
if ($Query_String == "")
/* The empty query string is passed on from the constructor,
* when calling the class without a query, e.g. in situations
* like these: '$db = new DB_Sql_Subclass;'
*/
return 0;
if (!$this->connect()) {
return 0; /* we already complained in connect() about that. */
};
# New query, discard previous result.
if ($this->Query_ID) {
$this->free();
}
if ($this->Debug)
printf("Debug: query = %s<br>\n", $Query_String);
$this->Query_ID = @mysql_query($Query_String,$this->Link_ID);
$this->Row = 0;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
if (!$this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String);
}
# Will return nada if it fails. That's fine.
return $this->Query_ID;
}
/* public: walk result set */
function next_record() {
if (!$this->Query_ID) {
$this->halt("next_record called with no query pending.");
return 0;
}
$this->Record = @mysql_fetch_array($this->Query_ID);
$this->Row += 1;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$stat = is_array($this->Record);
if (!$stat && $this->Auto_Free) {
$this->free();
}
return $stat;
}
/* public: position in result set */
function seek($pos = 0) {
$status = @mysql_data_seek($this->Query_ID, $pos);
if ($status)
$this->Row = $pos;
else {
$this->halt("seek($pos) failed: result has ".$this->num_rows()." rows.");
/* half assed attempt to save the day,
* but do not consider this documented or even
* desireable behaviour.
*/
@mysql_data_seek($this->Query_ID, $this->num_rows());
$this->Row = $this->num_rows();
return 0;
}
return 1;
}
/* public: table locking */
function lock($table, $mode = "write") {
$query = "lock tables ";
if (is_array($table)) {
while (list($key,$value) = each($table)) {
if (!is_int($key)) {
// texts key are "read", "read local", "write", "low priority write"
$query .= "$value $key, ";
} else {
$query .= "$value $mode, ";
}
}
$query = substr($query,0,-2);
} else {
$query .= "$table $mode";
}
$res = $this->query($query);
if (!$res) {
$this->halt("lock() failed.");
return 0;
}
return $res;
}
function unlock() {
$res = $this->query("unlock tables");
if (!$res) {
$this->halt("unlock() failed.");
}
return $res;
}
/* public: evaluate the result (size, width) */
function affected_rows() {
return @mysql_affected_rows($this->Link_ID);
}
function num_rows() {
return @mysql_num_rows($this->Query_ID);
}
function num_fields() {
return @mysql_num_fields($this->Query_ID);
}
/* public: shorthand notation */
function nf() {
return $this->num_rows();
}
function np() {
print $this->num_rows();
}
function f($Name) {
if (isset($this->Record[$Name])) {
return $this->Record[$Name];
}
}
function p($Name) {
if (isset($this->Record[$Name])) {
print $this->Record[$Name];
}
}
/* public: sequence numbers */
function nextid($seq_name) {
$this->connect();
if ($this->lock($this->Seq_Table)) {
/* get sequence number (locked) and increment */
$q = sprintf("select nextid from %s where seq_name = '%s'",
$this->Seq_Table,
$seq_name);
$id = @mysql_query($q, $this->Link_ID);
$res = @mysql_fetch_array($id);
/* No current value, make one */
if (!is_array($res)) {
$currentid = 0;
$q = sprintf("insert into %s values('%s', %s)",
$this->Seq_Table,
$seq_name,
$currentid);
$id = @mysql_query($q, $this->Link_ID);
} else {
$currentid = $res["nextid"];
}
$nextid = $currentid + 1;
$q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
$this->Seq_Table,
$nextid,
$seq_name);
$id = @mysql_query($q, $this->Link_ID);
$this->unlock();
} else {
$this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
return 0;
}
return $nextid;
}
/* public: return table metadata */
function metadata($table = "", $full = false) {
$count = 0;
$id = 0;
$res = array();
/*
* Due to compatibility problems with Table we changed the behavior
* of metadata();
* depending on $full, metadata returns the following values:
*
* - full is false (default):
* $result[]:
* [0]["table"] table name
* [0]["name"] field name
* [0]["type"] field type
* [0]["len"] field length
* [0]["flags"] field flags
*
* - full is true
* $result[]:
* ["num_fields"] number of metadata records
* [0]["table"] table name
* [0]["name"] field name
* [0]["type"] field type
* [0]["len"] field length
* [0]["flags"] field flags
* ["meta"][field name] index of field named "field name"
* This last one could be used if you have a field name, but no index.
* Test: if (isset($result['meta']['myfield'])) { ...
*/
// if no $table specified, assume that we are working with a query
// result
if ($table) {
$this->connect();
$id = @mysql_list_fields($this->Database, $table);
if (!$id) {
$this->halt("Metadata query failed.");
return false;
}
} else {
$id = $this->Query_ID;
if (!$id) {
$this->halt("No query specified.");
return false;
}
}
$count = @mysql_num_fields($id);
// made this IF due to performance (one if is faster than $count if's)
if (!$full) {
for ($i=0; $i<$count; $i++) {
$res[$i]["table"] = @mysql_field_table ($id, $i);
$res[$i]["name"] = @mysql_field_name ($id, $i);
$res[$i]["type"] = @mysql_field_type ($id, $i);
$res[$i]["len"] = @mysql_field_len ($id, $i);
$res[$i]["flags"] = @mysql_field_flags ($id, $i);
}
} else { // full
$res["num_fields"]= $count;
for ($i=0; $i<$count; $i++) {
$res[$i]["table"] = @mysql_field_table ($id, $i);
$res[$i]["name"] = @mysql_field_name ($id, $i);
$res[$i]["type"] = @mysql_field_type ($id, $i);
$res[$i]["len"] = @mysql_field_len ($id, $i);
$res[$i]["flags"] = @mysql_field_flags ($id, $i);
$res["meta"][$res[$i]["name"]] = $i;
}
}
// free the result only if we were called on a table
if ($table) {
@mysql_free_result($id);
}
return $res;
}
/* public: find available table names */
function table_names() {
$this->connect();
$h = @mysql_query("show tables", $this->Link_ID);
$i = 0;
while ($info = @mysql_fetch_row($h)) {
$return[$i]["table_name"] = $info[0];
$return[$i]["tablespace_name"] = $this->Database;
$return[$i]["database"] = $this->Database;
$i++;
}
@mysql_free_result($h);
return $return;
}
/* private: error handling */
function halt($msg) {
$this->Error = @mysql_error($this->Link_ID);
$this->Errno = @mysql_errno($this->Link_ID);
if ($this->Halt_On_Error == "no")
return;
$this->haltmsg($msg);
if ($this->Halt_On_Error != "report")
die("Session halted.");
}
function haltmsg($msg) {
printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
printf("<b>MySQL Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
}
}
?>
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2�/min or less.
_______________________________________________
Users mailing list
Users(a)openser.org
http://openser.org/cgi-bin/mailman/listinfo/users
--
Thanks and Regards with cheers
Sunkara Ravi Prakash
Hyperion Technology
Kondapur, Hi-tech city,
Hyderabad.
www.hyperion-tech.com
+91-9985077535
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.
---------------------------------
How low will we go? Check out Yahoo! Messengers low PC-to-Phone call rates.