[Users] I have problem in serweb. Please help me..Please..

Ferianto siregar ferianto_voip at yahoo.com
Fri Aug 18 09:45:25 CEST 2006


Dear all,
First of all, I would like to say thanks to all of you who has been helped me,  so I have succeed to build my openser server. Thank you very much. Thanks 
Now, I am building a serweb. So, the client can register easily from their computer to  the openser server. So, they can join the voip communication by using the openser server that I have been built.
But, When I tried to build the serweb, I have a problem. This is the error message that I have received from the client browser:
  Parse error: parse error, unexpected T_VARIABLE in /var/www/html/serweb/config.php on line 217
 
 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
  What`s wrong in the configuration? I do hope anyone can help me..Please..

2. can openser use serweb? because as I know, serweb is used for SER. or the openser has it`s own "serweb"? can anybody can tell me what is it?


Note:
This is the configuration in serweb that I have made. I am so sorry because the configuration is too long. Sorry.

1. config.php
  <?
  /*
   * $Id: config.php,v 1.30 2003/12/12 22:03:10 jiri Exp $
   */
   
  class Csub_not {
        var $uri, $desc;
        function Csub_not($uri, $desc){
              $this->uri=$uri;
              $this->desc=$desc;
        }
  }
   
  class CREG_list_item {
        var $reg, $label;
        function CREG_list_item($reg, $label){
              $this->reg=$reg;
              $this->label=$label;
        }
  }
   
  class Capplet_params {
        var $name, $value;
        function Capplet_params($name, $value){
              $this->name=$name;
              $this->value=$value;
        }
  }
   
  class Ctab{
        var $name, $page, $enabled;
        function Ctab($enabled, $name, $page){
              $this->name=$name;
              $this->page=$page;
              $this->enabled=$enabled;
        }
  }
   
  class Cconfig {
        var $db_host;
        var $db_name;
        var $db_user;
        var $db_pass;
   
        var $table_subscriber;
        var $table_pending;
        var $table_grp;
        var $table_aliases;
        var $table_location;
        var $table_missed_calls;
        var $table_accounting;
        var $table_phonebook;
        var $table_event;
        var $table_netgeo_cache;
        var $table_ser_mon;
        var $table_ser_mon_agg;
        var $table_message_silo;
        var $table_voice_silo;
   
        var $voice_silo_dir;
        var $greetings_spool_dir;
   
        var $show_voicemail_acl;
        var $show_voice_silo;
   
        var $enable_dial_voicemail;
        var $setup_jabber_account;
   
        var $enable_test_firewall;
        var $stun_applet_width;
        var $stun_applet_height;
        var $stun_class;
        var $stun_archive;
        var $stun_server;
        var $stun_port;
        var $stun_retransmit;
        var $stun_sourceport;
   
        var $grp_values;
   
        var $realm;
        var $domainname;
   
        var $first_alias_number;
   
        var $new_alias_expires;
        var $new_alias_q;
        var $new_alias_callid;
        var $new_alias_cseq;
   
        var $pre_uid_expires;
   
        var $psignature;
   
        var $web_contact;
        var $fifo_server;
        var $reply_fifo_filename;
        var $reply_fifo_path;
   
        var $fifo_aliases_table;
        var $ul_table;
        var $ul_priority;
        var $ul_replication;
   
        var $im_length;
        var $default_domain;
   
        var $root_path;
        var $root_uri;
        var $img_src_path;
        var $js_src_path;
        var $style_src_path;
        var $zonetab_file;
   
        var $charset;
   
        var $default_width;
   
        var $num_of_showed_items;
        var $max_showed_rows;
   
        var $enable_tabs;
   
        var $sub_not;
   
        var $mail_header_from;
   
        var $mail_forgot_pass;
        var $forgot_pass_subj;
        var $mail_register;
        var $register_subj;
   
        // web pages which should be virtually included  in beginning and
        // end of every serweb page
        var $prolog;
        var $separator;
        var $epilog;
   
        var $terms_and_conditions;
   
        var $metar_event_uri;
        var $metar_from_sip_uri;
        var $metar_na_message;
        
        var $ser_moni_marginal_period_length;
        var $ser_moni_aggregation_interval;
        var $clear_text_pw;
        var $ul_multidomain;
   
        var $ctd_target;
        var $ctd_uri;
   
        function Cconfig(){
              ////////////////////////////////////////////////////////////////
              //            configure database
   
              /* these are the defaults with which SER installs; if you changed
                 the SER account for MySQl, you need to update here 
              */
   
              $this->db_host="202.95.149.250";          //database host
              $this->db_name="openser";                 //database name
              $this->db_user="openser";                 //database conection user
              $this->db_pass="openserrw";               //database conection password
   
   
              /* ------------------------------------------------------------*/
              /*      basic local configuration options                      */
              /* ------------------------------------------------------------*/
              /* you need to align these values to your local server settings */
   
              /* the web path bellow which serweb's "admin" and "user_interface" 
                 directories begin to spread; If set up to be in root (http://www/admin ...),
             set just "/" here. Set a specific path otherwise, e.g., "/iptel/html/". 
                 Don't forget trailing slash.  
                    Hint: if path incorrect, image buttons do not show up
              */
              $this->root_path="/serweb/";
              /* roo uri of your server */
              /* $this->root_uri="http://192.168.2.16"; */
              $this->root_uri="http://".$_SERVER['SERVER_NAME'];
   
              /* where is your zone file on your server ? */
              $this->zonetab_file =   "/usr/share/zoneinfo/zone.tab";
              /* serweb will send confirmation emails and SIP IMs -- what sender 
                 address should it claim ?
                 should appear in them ?
              */
              $this->mail_header_from="registrar at pcr.ac.id";              
              $this->web_contact="sip:daemon at 202.95.149.250";
              /* spool directory with voicemail messages */
              $this->voice_silo_dir = '/var/spool/voicemail/'; 
              /* directory with voicemail greetings */
              $this->greetings_spool_dir = '/var/greetings/';
              /* serweb talks to SER via FIFO -- this is FIFO's name,
                 it must have the same value as SER's fifo config param
              */
              $this->fifo_server="/tmp/openser_fifo";
              /* these are absolute web paths to HTML documents surrounding
                 serweb pages -- these may typically include banner, trailers,
                 and whatever else appropriate to your web design; make sure
                 the values point to existing files; the files should include
                 at least:
             prolog: <body> or <body><h1>, etc.
                 separator: may be empty, or </h1><hr> etc.
             epilog: </body>
              */
              $this->prolog="/serweb/prolog.html";
              $this->separator="/serweb/separator.html";
              $this->epilog="/serweb/epilog.html";
   
              /* content of html <title> tag */
              $this->title="sip.pcr.ac.id, the IP Telephony Site";
   
              /* your domain name */
              $this->realm="pcr.ac.id"
              $this->domainname="pcr.ac.id"
              $this->default_domain="pcr.ac.id"
                    ereg_replace( "(www\.|sip\.)?(.*)", "\\2",  $_SERVER['SERVER_NAME']);
              /* initial nummerical alias for new subscriber -- don't forget to
                 align your SER routing script to it !
              */
              $this->first_alias_number=82000;
   
   
              /* info email address */
              $this->infomail      =      "info at pcr.ac.id";
              /* email address for questions concerning registration */
              $this->regmail      =      "registrar at pcr.ac.id";
   
              /* alternate development settings ...
              $this->zonetab_file =      "d:/data/http/iptel/_data/zone.tab";            
              $this->root_path="/~iptel/";
              $this->mail_header_from="php.kk at kufr.cz";             
              $this->voice_silo_dir = 'c:/temp/'; 
              $this->greetings_spool_dir = 'c:/temp/';
              $this->fifo_server="d:/temp/tmp";                           //path to fifo server
              */
   
   
              /* ------------------------------------------------------------*/
              /* serweb appearance                                           */
              /* ------------------------------------------------------------*/
   
              /* which tabs should show in user's profile ? those set to false
                 by default are experimental features which have not been tested
                 yet
              */
                    
              $this->enable_tabs[1]=true;                           //enable tab my account
              $this->enable_tabs[2]=true;                           //enable tab phonebook
              $this->enable_tabs[3]=true;                     //enable tab missed calls
              $this->enable_tabs[4]=true;                     //enable tab accounting
              $this->enable_tabs[5]=true;                           //enable tab send IM
              $this->enable_tabs[6]=false;                    //enable tab notification subscription
              $this->enable_tabs[7]=true;                     //enable tab message store
   
              /* admin tabs definitions
                    Ctab (enabled, name_of_tab, php_script)
              */
              $this->admin_tabs[]=new Ctab (true, "users", "users.php");
              $this->admin_tabs[]=new Ctab (true, "server monitoring", "openser_moni.php");
   
              $this->default_width=564;                             //width of usable area
   
              $this->num_of_showed_items=20;       /* num of showed items in the list of users */
              $this->max_showed_rows=50;          /* maximum of showed items in "user find" */
   
              /* show test firewall/NAT button (see also advanced FW/NAT settings bellow */
              $this->enable_test_firewall=false;           
   
              /* experimental/incomplete features turned off: voicemail
                 and set up a jabber account for each new SIP user too
              */
              $this->show_voicemail_acl=false; /* show voicemail in ACL list */
              $this->show_voice_silo=false; /* show voice messages in silo too */
              $this->enable_dial_voicemail=false;
              $this->enable_tabs[8]=false;                    //enable tab voicemail
              $this->setup_jabber_account=false;
   
              /* ------------------------------------------------------------*/
              /* ACLs                                                        */
              /* ------------------------------------------------------------*/
   
              /* there may be SIP contacts which you wish to prevent from being added
                 through serweb to avoid loops, forwarding to unfriendly domains, etc.
                 use these REGexs  to specify which contacts you do not wish;
                 the first value includes banned REs, the second displays error message
                 displayed to users if they attempt to introduce a banned contact
              */
              $this->denny_reg[]=new CREG_list_item("gateway\.pcr.ac.id$","local forwarding prohibited");
              $this->denny_reg[]=new CREG_list_item("gateway","gateway contacts prohibited");
   
              /* SER configuration script may check for group membership of users 
                 identified using digest authentication; e.g., it may only allow
                 international calls to callers who are members of 'int' group;
                 this is a list of groups that serweb allows to set -- they need to
                 correspond to names of groups used in SER's membership checks
              */
              $this->grp_values[]="voicemail";
              $this->grp_values[]="ld";
              $this->grp_values[]="local";
              $this->grp_values[]="int";
   
   
   
              /* ------------------------------------------------------------*/
              /* text                                                                                   */
              /* ------------------------------------------------------------*/
              /* human-readable text containing messages displayed to users
                 in web or sent by email; you may need to hire a lawyer ,
                 a word-smith, a diplomat or a translator to get it right :)
              */
   
   
              /* text of password-reminder email */
              $this->forgot_pass_subj="your login information";
              $this->mail_forgot_pass="Hello,\n".
                    "now you can access to your account at the folowing URL within 1 hour:\n".
                    $this->root_uri.$this->root_path."user_interface/my_account.php?#session#\n\n".
                    "We recommend change your password after you login\n\n";
   
              /* text of confirmation email sent during account registration  */
              $this->register_subj="Your ".$this->domainname." Registration";
              $this->mail_register=
                    "Thank you for registering with ".$this->domainname.".\n\n".
                    "We are reserving the following SIP address for you: #sip_address#\n\n".
                    "To finalize your registration please check the following URL within ".
                    "24 hours:\n".
                    $this->root_uri.$this->root_path."user_interface/reg/confirmation.php?nr=#confirm#\n\n".
                    "(If you confirm later you will have to re-register.)\n\n".
                    "Windows Messenger users may look at additional configuration hints at\n".
                    "http://www.iptel.org/phpBB/viewtopic.php?topic=11&forum=1&0\n";
   
              /* terms and conditions as they appear on the subscription webpage */
              $this->terms_and_conditions=
                    "BY PRESSING THE 'I ACCEPT' BUTTON, YOU (HEREINAFTER THE 'USER') ARE ".
                    "STATING THAT YOU AGREE TO ACCEPT AND BE BOUND BY ALL OF THE TERMS AND ".
                    "CONDITIONS OF THIS AGREEMENT.  DO NOT PROCEED IF YOU ARE UNABLE TO AGREE".
                    " TO THE TERMS AND CONDITIONS OF THIS AGREEMENT. THESE TERMS AND CONDITIONS ".
                    "OF SERVICE FOR USE OF ".$this->domainname." SIP SERVER (THE 'AGREEMENT')".
                    " CONSTITUTE A LEGALLY BINDING CONTRACT BETWEEN ".$this->domainname.
                    " AND THE ENTITY THAT AGREES TO AND ACCEPTS THESE TERMS AND CONDITIONS. ".
                    "ACCESS TO ".$this->domainname."'s SESSION INITIATION PROTOCOL SERVER ".
                    "('SIP SERVER') IS BEING PROVIDED ON AN 'AS IS' AND 'AS AVAILABLE' BASIS, ".
                    "AND ".$this->domainname." MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY ".
                    "KIND, WHETHER EXPRESS OR IMPLIED, WITH RESPECT TO USER'S ACCESS OF THE ".
                    "SIP SERVER, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, ".
                    "NONINFRINGEMENT, TITLE OR FITNESS FOR A PARTICULAR PURPOSE. FURTHER, ".
                    $this->domainname." MAKES NO REPRESENTATIONS OR WARRANTIES THAT THE SIP ".
                    "SERVER, OR USER'S ACCESS THERETO, WILL BE AVAILABLE AT ANY GIVEN TIME, ".
                    "OR WILL BE FREE FROM ERRORS, DEFECTS, OMISSIONS, INACCURACIES, OR FAILURES".
                    " OR DELAYS IN DELIVERY OF DATA. USER ASSUMES, AND ".$this->domainname.
                    " DISCLAIM, TOTAL RISK, RESPONSIBILITY, AND LIABILITY FOR USER'S ACCESS TO ".
                    "AND USE OF THE SIP SERVER.\n\n".
                    "Access to ".$this->domainname." SIP Server is being provided on a ".
                    "non-exclusive basis. User acknowledges and understands that ".
                    $this->domainname." SIP site is in a developmental stage and that ".
                    $this->domainname." makes no guarantees regarding the availability or ".
                    "functionality thereof. User may not sublicense its access rights to the ".
                    "SIP Server to any third party. \n\n".
                    "USER AGREES TO INDEMNIFY, DEFEND AND HOLD iptel.org, ITS AFFILIATES, ".
                    "DIRECTORS, OFFICERS, EMPLOYEES, AGENTS AND LICENSORS HARMLESS FROM AND ".
                    "AGAINST ANY AND ALL CLAIMS, ACTIONS, EXPENSES, LOSSES, AND LIABILITIES ".
                    "(INCLUDING COURTS COSTS AND REASONABLE ATTORNEYS' FEES), ".
                    "ARISING FROM OR RELATING TO THIS AGREEMENT INCLUDING USER'S ACCESS TO ".
                    "AND USE OF THE SIP SERVER TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,".
                    " IN NO EVENT SHALL ".$this->domainname." OR ANY OF ITS LICENSORS, BE LIABLE ".
                    "FOR ANY INDIRECT, SPECIAL, PUNITIVE, EXEMPLARY, OR CONSEQUENTIAL DAMAGES, ".
                    "ARISING OUT OF THE ACCESS TO OR USE OF OR INABILITY TO ACCESS OR USE THE ".
                    "SIP SERVER, OR THAT RESULT FROM MISTAKES, OMISSIONS, INTERRUPTIONS, ".
                    "DELETIONS OF FILES, ERRORS, DEFECTS, DELAYS IN TRANSMISSION OR OPERATION OR ".
                    "ANY FAILURE OF PERFORMANCE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH ".
                    "DAMAGES. \n\n".
                    "If User commits, in ".$this->domainname."'s  sole determination, a default ".
                    "of these terms and conditions, ".$this->domainname." may immediately ".
                    "terminate User's access to the SIP Server. Furthermore, ".$this->domainname.
                    " reserves the right to discontinue offering access to the SIP Server at any ".
                    "time. \n\n".
   
                    "User may not assign its rights hereunder without the prior written ".
                    "consent of ".$this->domainname.". User agrees to comply with all laws, ".
                    "regulations and other legal requirements that apply to these terms and ".
                    "conditions.  \n\n".
                    "If any provision of this Agreement is held to be unenforceable for any ".
                    "reason, such provision shall be reformed only to the extent necessary to ".
                    "comply with applicable laws, and the remainder shall remain in full force ".
                    "and effect. \n\n".
                    "Any failure of ".$this->domainname." to enforce any provision of this ".
                    "Agreement shall not constitute a waiver of any rights under such provision ".
                    "or any other provision of this Agreement. \n\n".
                    "USER ACKNOWLEDGES THAT IT HAS READ THIS AGREEMENT, UNDERSTANDS IT, AND ".
                    "AGREES THAT IT IS THE COMPLETE AND EXCLUSIVE STATEMENT OF THE ENTIRE ".
                    "AGREEMENT BETWEEN COMPANY AND ".$this->domainname." WITH RESPECT TO THE ".
                    "SUBJECT MATTER HEREIN, AND SUPERSEDES ALL PRIOR AND CONTEMPORANEOUS ".
                    "PROPOSALS, DISCUSSIONS, AGREEMENTS, UNDERSTANDINGS, AND COMMUNICATIONS, ".
                    "WHETHER WRITTEN OR ORAL AND MAY BE AMENDED ONLY IN A WRITING EXECUTED BY ".
                    "BOTH USER AND ".$this->domainname.". \n\n";
   
              /* =========================================================== */
          /* ADVANCED SETTINGS                                           */
              /* =========================================================== */
   
              /* ------------------------------------------------------------*/
              /* applications (experimental)                                 */
              /* ------------------------------------------------------------*/
   
              /* subscribe-notify -- list of events to which a user can subscribe and
                 is then notified with an instant message, if they occur; experimental
              */
              $this->sub_not[]=new Csub_not("sip:weather at pcr.ac.id".
                    ";type=temperature;operator=lt;value=0","temperature is too low");
              $this->sub_not[]=new Csub_not("sip:weather at pcr.ac.id".
                    ";type=wind;operator=gt;value=10","wind is too fast");
              $this->sub_not[]=new Csub_not("sip:weather at pcr.ac.id;".
                    "type=pressure;operator=lt;value=1000","pressure is too low");
              $this->sub_not[]=new Csub_not("sip:weather at pcr.ac.id;type=metar",
                    "send METAR data");
   
              /* metar wheather application */
              //this is an identificator in event table for sending METAR data
              $this->metar_event_uri="sip:weather at pcr.ac.id;type=metar";
              //from header in sip message
              $this->metar_from_sip_uri="sip:daemon at pcr.ac.id";
              // N/A message - is sended to user when we can't get his location or METAR data
              $this->metar_na_message="sorry we can't get your location or METAR data for you";
   
   
              /* ------------------------------------------------------------*/
              /*            configure FW/NAT detection applet                */
              /* ------------------------------------------------------------*/
   
              /* the applet is used to detect whether user is behind firewall or NAT */
   
              //width of NAT detection applet
              $this->stun_applet_width=350;                   
              //height of NAT detection applet
              $this->stun_applet_height=100;                        
              //starting class of NAT detection applet
              $this->stun_class="STUNClientApplet.class"; 
              //jar archive with NAT detection applet - optional - you can comment 
              // it if you don't use jar archive
          $this->stun_archive="STUNClientApplet.jar";             
   
              /* applet parameters: */
   
              /* STUN server address - must be same as web server address because 
                 the java security manager allows only this one
              */
              $this->stun_applet_param[]=new Capplet_params("server", "sip.pcr.ac.id");
   
              /* STUN server port. The Default value is 1221 - optional - you can comment 
                    it if you want use default value
              */
              $this->stun_applet_param[]=new Capplet_params("port", 1221);
              /* destination port for the first probing attempt -- just set up a simple
                 tcp echo server there; we use the first TCP connection to determine
                 local IP address, which can't be learned from systems setting due to
               security manager ; default is 5060
              */
              $this->stun_applet_param[]=new Capplet_params("tcp_dummyport", 5061);
   
              /* Number of times to resend a STUN message to a STUN server. The 
                    Default is 9 times - optional - you can comment it if you want 
                    use default value
              */
              // $this->stun_applet_param[]=new Capplet_params("retransmit", 9);
   
              /* Specify source port of UDP packet to be sent from. The Default value 
                 is 5000 - optional - you can comment it if you want use default value
              */
              // $this->stun_applet_param[]=new Capplet_params("sourceport", 5000);
   
   
   
              /* ------------------------------------------------------------*/
              /*            configure server monitoring                             */
              /* ------------------------------------------------------------*/
   
              /* if you change this values, please delete all data from table 
                 "table_ser_mon_agg" and "table_ser_mon" by reason that the 
                    aggregated data may be calculated bad if you don't do it
              */
   
              /* length of marginal period in seconds */
              $this->ser_moni_marginal_period_length=60*5;   //5 minutes
              
              /* length of interval (in seconds) for which will data stored, 
                 data older then this interval will be deleted
              */
              $this->ser_moni_aggregation_interval=60*15;     //15 minut
   
              /* ------------------------------------------------------------*/
              /*            click to dial                                    */
              /* ------------------------------------------------------------*/
   
              /* address of the final destination to which we want to transfer
                 initial CSeq and CallId */
              $this->ctd_target="sip:23 at 202.95.14.250";
   
              /* address of user wishing to initiate conversation */
              $this->ctd_uri="sip:44 at 202.95.149.250";
              
              /* from header for click-to-dial request */
              $this->ctd_from      =      "sip:controller at pcr.ac.id";
              
              /* ------------------------------------------------------------*/
              /* Values you typically do NOT want to change unless you know  *
          /* well what you are doing                                     *
              /* ------------------------------------------------------------*/
   
              /* Unless you used brute-force to change SER table names */
              $this->table_subscriber="subscriber";
              $this->table_pending="pending";
              $this->table_grp="grp";
              $this->table_aliases="aliases";
              $this->table_location="location";
              $this->table_missed_calls="missed_calls";
              $this->table_accounting="acc";
              $this->table_phonebook="phonebook";
              $this->table_event="event";
              $this->table_netgeo_cache="netgeo_cache";
              $this->table_ser_mon="server_monitoring";
              $this->table_ser_mon_agg="server_monitoring_agg";
              $this->table_message_silo="silo";
              $this->table_voice_silo="voice_silo";
   
              /* these are table names as reffered from script and via FIFO */
              $this->ul_table="location";
              $this->fifo_aliases_table="aliases";
   
              /* relative paths of serweb tree */
              $this->img_src_path =   $this->root_path."img/";
              $this->js_src_path =    $this->root_path."styles/";
              $this->style_src_path = $this->root_path."styles/";
              $this->user_pages_path = $this->root_path."user_interface/";
              $this->admin_pages_path = $this->root_path."admin/";
   
              /* values used for names of reply fifos -- they change radnomly */
              $this->reply_fifo_filename="webfifo_".rand();
              $this->reply_fifo_path="/tmp/".$this->reply_fifo_filename;
              /* development value
              $this->reply_fifo_path="d:/temp/".$this->reply_fifo_filename; */      
   
              /* serweb version */
              $this->psignature="Web_interface_Karel_Kozlik-0.9";
   
              /* IM paging configuration */
              $this->charset="windows-1250";
              $this->im_length=1300;
   
              /* expiration times, priorities, etc. for usrloc/alias contacts */
              $this->new_alias_expires='567648000';
              $this->new_alias_q=1.00;
              $this->new_alias_callid="web_call_id at fox";
              $this->new_alias_cseq=1;
              $this->ul_priority="1.00";
              /* replication support ? (a new ser feature) */
              $this->ul_replication=1;
              /* fifo expects usernames AND domainnames ? make sure this
                 option is synchronized with usrloc's use_domain option      */
              $this->ul_multidomain=0;
   
              /* seconds in which expires "get pass session" */
              $this->pre_uid_expires=3600;                
              /* is the sql database query for user authentication formed
                 with clear text password or a hashed one; the former is less
                 secure the latter works even if password hash is incorrect,
                 which sometimes happens, when it is calculated from an
                 incorrect domain during installation process
              */
              $this->clear_text_pw=1;
   
        }
  }
   
  $config=new Cconfig();
  ?>
   
  2. db_mysql.inc   <?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);
    }
   
  }
  ?>
   
  3. prepend.php   <?php
  /*
   * Session Management for PHP3
   *
   * Copyright (c) 1998-2000 NetUSE AG
   *                    Boris Erdmann, Kristian Koehntopp
   *
   * $Id: prepend.php,v 1.1.1.1 2002/09/04 18:19:41 kozlik Exp $
   *
   */ 
   
  $_PHPLIB = array();
   
  # Can't control your include path?
  # Point this to your PHPLIB base directory. Use a trailing "/"!
  $_PHPLIB["libdir"]  = "var/www/phplib/";
   
   
  require "../config.php";
  require "../functions.php";
  require "../page.php";
   
  require($_PHPLIB["libdir"] . "db_mysql.inc");  /* Change this to match your database. */
  require($_PHPLIB["libdir"] . "ct_sql.inc");    /* Change this to match your data storage container */
  require($_PHPLIB["libdir"] . "session.inc");   /* Required for everything below.      */
  require($_PHPLIB["libdir"] . "auth.inc");      /* Disable this, if you are not using authentication. */
  require($_PHPLIB["libdir"] . "perm.inc");      /* Disable this, if you are not using permission checks. */
  require($_PHPLIB["libdir"] . "user.inc");      /* Disable this, if you are not using per-user variables. */
   
  /* Additional require statements go below this line */
  # require($_PHPLIB["libdir"] . "menu.inc");      /* Enable to use Menu */
   
  /* Additional require statements go before this line */
   
  require($_PHPLIB["libdir"] . "local.inc");     /* Required, contains your local configuration. */
   
  require($_PHPLIB["libdir"] . "page.inc");      /* Required, contains the page management functions. */
   
  ?>
   
  I do hope anybody can help me..I am so sorry because this message is too long..Sorry..Thank you very much.. Thank you


Regards,


Ferianto


 		
---------------------------------
Do you Yahoo!?
 Next-gen email? Have it all with the  all-new Yahoo! Mail Beta.
 			
---------------------------------
Do you Yahoo!?
 Everyone is raving about the  all-new Yahoo! Mail Beta.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kamailio.org/pipermail/users/attachments/20060818/a4e61f58/attachment.htm 


More information about the Users mailing list