Updating site for newer PHP version
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 1 Dec 2016 19:15:25 +0000 (14:15 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 1 Dec 2016 19:15:25 +0000 (14:15 -0500)
Going to new server. Updating the code for newer PHP version.

admin/Contact/mailout.phtml
admin/Contact/query_contact.phtml
admin/Toolbox/update_bus.phtml
classes/class_db.inc
classes/class_tellfriend.inc
classes/class_template.inc
setup.phtml
sitemap.inc

index b5db9fc..1ac0450 100755 (executable)
@@ -16,34 +16,34 @@ $BodyFilename = $Filename.".body";
 $ToFilename = $Filename.".to";
 $ReadyFilename = $Filename.".ready";
 
-if(!$dbd = db_connect(CONN_STR)) 
+if(!$dbd = db_connect(CONN_STR))
        html_error(DB_ERROR_MSG,1);
 $postmail = stripslashes($postmail);
-$postmail = eregi_replace("SELECT.*FROM","SELECT email INTO TEMPORARY temp_table FROM",$postmail);
-$postmail = eregi_replace("ORDER BY.*","",$postmail);
+$postmail = preg_replace("%SELECT.*FROM%","SELECT email INTO TEMPORARY temp_table FROM",$postmail);
+$postmail = preg_replace("%ORDER BY.*%","",$postmail);
 $postmail .= " AND ".MAILOK." = 't'";
 $postmail .= ";CREATE INDEX email_indx on temp_table (email);";
 
-if(!$mailres = db_exec($dbd,$postmail)) 
+if(!$mailres = db_exec($dbd,$postmail))
        html_error(DB_ERROR_MSG.__LINE__.$postmail,1);
 
-$mailqs = "SELECT 
+$mailqs = "SELECT
                   DISTINCT ON (email) email
                   FROM         temp_table
                   GROUP BY email;";
 flush();
-if(!$mailres = db_exec($dbd,$mailqs)) 
+if(!$mailres = db_exec($dbd,$mailqs))
        html_error(DB_ERROR_MSG.__LINE__.$mailqs,1);
 
 if(db_numrows($mailres)>0)
        {
-       for($a=0;$a<db_numrows($mailres);$a++) 
+       for($a=0;$a<db_numrows($mailres);$a++)
                {
-               $mvdata = db_fetch_array($mailres,$a,PGSQL_ASSOC);      
-               $email = trim($mvdata["email"]); 
+               $mvdata = db_fetch_array($mailres,$a,PGSQL_ASSOC);
+               $email = trim($mvdata["email"]);
                if($email)
                        {
-                       $mail[] = $email;       
+                       $mail[] = $email;
                        }
                }
        }
@@ -62,8 +62,8 @@ else {
 if($mail != "") {
        // I am changing this to a two part mime type email
        // html and text
-       // using class_html     
-       $responseqs = "SELECT   * 
+       // using class_html
+       $responseqs = "SELECT   *
                                   FROM         news_response
                                   WHERE        id = 1";
        if(!$resres = db_exec($dbd,$responseqs))
@@ -90,7 +90,7 @@ if($mail != "") {
        $data['image2'] = add_image($responserow["image2"],"left");
        $data['image3'] = add_image($responserow["image3"],"right");
        $data['url'] = URL_BASE;
-       
+
        $html = explode_template(NEWSLETTER_PROTOTYPE,$data);
        // text part of email
        $text = strip_tags($message);
@@ -101,7 +101,7 @@ if($mail != "") {
        $text .= "with the word \"CANCEL\" on the subject line. You will then be removed \n";
        $text .= "from future mailings.\n";
        $text .= "-------------------------------------------------------------------\n";
-       
+
        // Write the temp.header file
        $glm_headers = "NotifyAddr: ".OWNER_EMAIL."\n"
                . "ProcessName: ".SITENAME."\n"
@@ -120,7 +120,7 @@ if($mail != "") {
                                "Subject: $subject\n".
                                "Reply-to: ".REPLY_TO."\n".
                                "Mime-Version: 1.0\n".
-                               "Content-Type: multipart/alternative; boundary=ContentBoundry\n\n";     
+                               "Content-Type: multipart/alternative; boundary=ContentBoundry\n\n";
        $fp = fopen($BodyFilename,"w");
        if(HTML_EMAIL=="ON"){
                $bodyhtml = '--ContentBoundry
@@ -137,7 +137,7 @@ Content-Type: text/html; charset="US-ASCII"
        }
        else{
                fputs($fp,$headers,strlen($headers));
-               fputs($fp,$text,strlen($text)); 
+               fputs($fp,$text,strlen($text));
        }
        fclose($fp);
        // write the temp.ready file and your done!
index fd297ed..19e7982 100755 (executable)
@@ -7,30 +7,30 @@ session_start();
 session_register("sess_vars");
 $sess_vars = $HTTP_POST_VARS;
 if(!isset($query_no)) {
-       /* The fields array is sent as a string 
+       /* The fields array is sent as a string
                split it out using : as delimiter */
-       $fvalue = ereg_replace("^:","",$fvalue);
-       $fields = split(":",$fvalue);
-       $rfvalue = ereg_replace("^:","",$rfvalue);
-       $return_fields = split(":",$rfvalue);
-       $dates = ereg_replace("^:","",$rdvalue);
-       $dates = split(":",$dates);
+       $fvalue = preg_replace("%^:%","",$fvalue);
+       $fields = preg_split("%:%",$fvalue);
+       $rfvalue = preg_replace("%^:%","",$rfvalue);
+       $return_fields = preg_split("%:%",$rfvalue);
+       $dates = preg_replace("%^:%","",$rdvalue);
+       $dates = preg_split("%:%",$dates);
 
        if(!isset($search)) {
                header("Location: index.phtml");
        }
        /* Chop off whitespaces spaces */
        $search = chop(trim($search));
-       if($search == "") 
+       if($search == "")
                $ALL = TRUE;
 
        function getKeywords($keywords) {
                /* Replace the whitespace with a , */
-               $keywords = ereg_replace(" ",",",$keywords);
-       
-               while(ereg(",,",$keywords)) {
+               $keywords = preg_replace("% %",",",$keywords);
+
+               while(preg_match("%,,%",$keywords)) {
                /* Replace the ,, with a , */
-                       $keywords = ereg_replace(",,",",",$keywords);
+                       $keywords = preg_replace("%,,%",",",$keywords);
                }
                $seperated = explode(",",$keywords);
                /* Return exploded string */
@@ -58,7 +58,7 @@ if(!isset($query_no)) {
                        $compare = "AND";
                        $NOT = TRUE;
                break;
-       
+
                default:
                        echo "not valid";
                break;
@@ -68,26 +68,26 @@ if(!isset($query_no)) {
                for($rip=0;$rip<count($keywords);$rip++) {
                        $keywords[$rip] = trim($keywords[$rip]);
                        /* if * is at the begging the replace with .* */
-                       $keywords[$rip] = ereg_replace("[\x2a]",".*",$keywords[$rip]);
-                       $keywords[$rip] = ereg_replace("[\x3f]",".?",$keywords[$rip]);
-                       $keywords[$rip] = ereg_replace("[\x2b]",".+",$keywords[$rip]);
+                       $keywords[$rip] = preg_replace("%[\x2a]%",".*",$keywords[$rip]);
+                       $keywords[$rip] = preg_replace("%[\x3f]%",".?",$keywords[$rip]);
+                       $keywords[$rip] = preg_replace("%[\x2b]%",".+",$keywords[$rip]);
                }
        }
        else {
                $keywords = trim($keywords);
                /* if * is at the begging the replace with .* */
-               $keywords = ereg_replace("[\x2a]",".*",$keywords);
-               $keywords = ereg_replace("[\x3f]",".?",$keywords);
-               $keywords = ereg_replace("[\x2b]",".+",$keywords);
+               $keywords = preg_replace("%[\x2a]%",".*",$keywords);
+               $keywords = preg_replace("%[\x3f]%",".?",$keywords);
+               $keywords = preg_replace("%[\x2b]%",".+",$keywords);
        }
-       
+
        switch($alter) {
                /* $alter defines where to look in fields */
                case "1":
                        $begin = "^";
                        $end = "";
                break;
-       
+
                case "2":
                        $begin = "";
                        $end = " *$";
@@ -98,7 +98,7 @@ if(!isset($query_no)) {
                        $end = "";
                break;
        }
-       
+
        $operator = " ";
        if($NOT) {
                $operator .= "!~";
@@ -135,7 +135,7 @@ if(!isset($query_no)) {
                        $query_string .= ",";
                }
        }
-       if(!$ALL) {     
+       if(!$ALL) {
                $query_string .= "\nFROM\t".TABLE." \nWHERE\t".WHERE."\nAND\t";
                $query_string .= "(";
                for($b=0;$b<count($fields);$b++) {
@@ -186,7 +186,7 @@ if(!isset($query_no)) {
                $tp_str = mktime(0,0,0,$tp_month,$tp_day,$tp_year);
                $fa_str = mktime(0,0,0,$fa_month,$fa_day,$fa_year);
                $ta_str = mktime(0,0,0,$ta_month,$ta_day,$ta_year);
-               
+
                if($fp_str<$tp_str) {
                        $fp_date = $fp_month."/".$fp_day."/".$fp_year;
                        $tp_date = $tp_month."/".$tp_day."/".$tp_year;
@@ -213,7 +213,7 @@ if(!isset($query_no)) {
        if(isset($fc_month)) {
                $fc_str = mktime(0,0,0,$fc_month,$fc_day,$fc_year);
                $tc_str = mktime(0,0,0,$tc_month,$tc_day,$tc_year);
-               
+
                if($fc_str<$tc_str) {
                        $fc_date = $fc_month."/".$fc_day."/".$fc_year;
                        $tc_date = $tc_month."/".$tc_day."/".$tc_year;
@@ -226,11 +226,11 @@ if(!isset($query_no)) {
                        $query_string .= " AND create_date < '$tc_date'";
                }
        }
-}      
+}
 else {
        if(!$dbd = db_connect()) html_error(DB_ERROR_MSG,0);
 
-       $qs = "SELECT   query_name,query,delimiter,file 
+       $qs = "SELECT   query_name,query,delimiter,file
                   FROM         query_db
                   WHERE        id = $query_no";
 
@@ -310,7 +310,7 @@ html_nav_table($nav,$navWidth);
        <?if(isset($query_name)) {
        echo "Query ".$query_name." Recalled";
        }?>
-       
+
        <form action="list_contact.phtml" method="POST">
        <input type="hidden" name="delimiter" value="<?echo $delimiter?>">
        <input type="hidden" name="file" value="<?echo $file?>">
@@ -351,19 +351,19 @@ html_nav_table($nav,$navWidth);
 if(!$dbd = db_connect()) html_error("Cant connect",0);
 
 $qs = "SELECT  id
-          FROM         query_db 
+          FROM         query_db
           WHERE        query_name = '(current)'";
 
 if(!$res = @db_exec($dbd,$qs)) html_error(DB_ERROR_MSG.$qs,0);
 
 if(!$row = @db_fetch_array($res,0,PGSQL_ASSOC)) {
-       $qs = "INSERT 
+       $qs = "INSERT
                   INTO         query_db
                                        (query_name,query,file,delimiter)
                   VALUES       ('(current)','$query','$file','$delimiter')";
 }
 else {
-       $qs = "UPDATE   query_db 
+       $qs = "UPDATE   query_db
                   SET          query = '$query',
                                        file = '$file',
                                        delimiter = '$delimiter'
@@ -372,6 +372,6 @@ else {
 @db_close($dbd);
 
 if(!db_auto_exec($qs)) html_error(DB_ERROR_MSG.$qs,0);
-         
+
 footer();
 ?>
index 54cc92d..66a938d 100755 (executable)
@@ -86,12 +86,12 @@ if( $REQUEST_METHOD == "POST" || $Command == "Move" ) {
                        break;
 
                case "Update":
-                       $oldcatid = ereg_replace("^:","",$oldcatid);
+                       $oldcatid = preg_replace("%^:%","",$oldcatid);
                        $oldcatid = split(":",$oldcatid);
 
                        if($category)
                        {
-                               $category = ereg_replace("^:","",$category);
+                               $category = preg_replace("%^:%","",$category);
                                $catid = split(":",$category);
                        }
 /*
@@ -287,7 +287,7 @@ if( $REQUEST_METHOD == "POST" || $Command == "Move" ) {
                case "Insert":
                        if($category)
                        {
-                               $category = ereg_replace("^:","",$category);
+                               $category = preg_replace("%^:%","",$category);
                                $catid = split(":",$category);
                        }
                        if(!$dbd = db_connect()) html_error(DB_ERROR_MSG,0);
@@ -484,7 +484,7 @@ if( $REQUEST_METHOD == "POST" || $Command == "Move" ) {
                        break;
 
                case "Delete":
-                       $oldcatid = ereg_replace("^:","",$oldcatid);
+                       $oldcatid = preg_replace("%^:%","",$oldcatid);
                        $oldcatid = split(":",$oldcatid);
 
                        $qs = "DELETE FROM bus
@@ -555,9 +555,9 @@ if( $REQUEST_METHOD == "POST" || $Command == "Move" ) {
                        break;
 
                case "Cancel":
-                       $oldcatid = ereg_replace("^:","",$oldcatid);
+                       $oldcatid = preg_replace("%^:%","",$oldcatid);
                        $oldcatid = split(":",$oldcatid);
-                       $catid = ereg_replace("^:","",$oldcatid);
+                       $catid = preg_replace("%^:%","",$oldcatid);
                        $catid = split(":",$oldcatid);
                        $location = "list_bus.phtml?catid=".$oldcatid[0]."&".SID;
                        break;
index fdbad6b..2b05b26 100755 (executable)
@@ -1,6 +1,6 @@
 <?php
 // $Id: class_db.inc,v 1.1.1.1 2006/07/13 13:53:50 matrix Exp $
-class GLM_DB 
+class GLM_DB
        {
                /** @var host database host server name */
                var $host;
@@ -16,23 +16,21 @@ class GLM_DB
                var $conn;
                /** @var trans bool if true a transaction is in process */
                var $trans;
-               /** @var dbd connection object from postgres */
-               var $dbd;
                function GLM_DB( $conn = CONN_STR )
                {
                        $this->host = "";
                        $this->dbname = "";
                        $this->user = "nobody";
-                       $this->password = "";   
+                       $this->password = "";
                        $this->conn = $conn;
-                       $this->trans = 0;       
+                       $this->trans = 0;
                        $this->dbd = "";
                }
 
                /** db_connect
-                 Creates a connection to database specified $conn_str, 
-                 and returns a boolean for success.                    
-                 @param conn_str       Connect String                                          
+                 Creates a connection to database specified $conn_str,
+                 and returns a boolean for success.
+                 @param conn_str       Connect String
                  @param fail_mode      Failure Mode
                  TRUE = Abort with HTML
                  FALSE = Return with fail code
@@ -43,7 +41,7 @@ class GLM_DB
                {
                        if( isset( $this->dbd ) && $this->dbd != "" )
                        {
-                               return( $this->dbd );   
+                               return( $this->dbd );
                        }
                        switch ( DB_TYPE )
                        {
@@ -53,7 +51,7 @@ class GLM_DB
                                                $conn = $this->conn;// CONN_STR;
                                        }
                                        else
-                                       {       
+                                       {
                                                $conn .= ( $this->host ) ? 'host='.$this->host.' ' : '';
                                                $conn .= ( $this->dbname ) ? 'dbname='.$this->dbname.' ' : '';
                                                $conn .= ( $this->user ) ? 'user='.$this->user." " : '';
@@ -69,12 +67,12 @@ class GLM_DB
                                        return( 0 );
                                        break;
                        }
-                       return( $this->dbd );           
+                       return( $this->dbd );
                }
-               /** db_close 
-                 Closes the connection to database specified by the handle dbd 
-                 returns a boolean for success                                         
-                 @returns bool - Returns 1 on success 0 if dbd is not a valid connection       
+               /** db_close
+                 Closes the connection to database specified by the handle dbd
+                 returns a boolean for success
+                 @returns bool - Returns 1 on success 0 if dbd is not a valid connection
                 */
 
                function db_close()
@@ -90,16 +88,16 @@ class GLM_DB
                }
 
                /** db_exec
-                 Execute an SQL query, * returning a valid result index or zero(0) on  
-                 failure.                                                              
-                 @param $qs -- SQL query string                                
-                 @returns int Returns a valid result index on success 0 on failure     
+                 Execute an SQL query, * returning a valid result index or zero(0) on
+                 failure.
+                 @param $qs -- SQL query string
+                 @returns int Returns a valid result index on success 0 on failure
                 */
                function db_exec( $qs )
                {
                        if( !$this->dbd )
                        {
-                               $this->dbd = $this->db_connect();       
+                               $this->dbd = $this->db_connect();
                        }
                        switch ( DB_TYPE )
                        {
@@ -114,12 +112,12 @@ class GLM_DB
                }
 
                /** db_fetch_array
-                 Stores the data in associative indices, using the field names as      
-                 keys.                                                                 
-                 @param $res -- valid database result index                    
-                 @param $i -- row number                                       
-                 @param $type -- PGSQL_ASSOC,PGSQL_BOTH,PGSQL_NUM                                      
-                 @returns array Returns an associative array of key-value pairs                
+                 Stores the data in associative indices, using the field names as
+                 keys.
+                 @param $res -- valid database result index
+                 @param $i -- row number
+                 @param $type -- PGSQL_ASSOC,PGSQL_BOTH,PGSQL_NUM
+                 @returns array Returns an associative array of key-value pairs
                 */
 
                function db_fetch_array( $res, $i, $type )
@@ -137,9 +135,9 @@ class GLM_DB
                }
 
                /** db_freeresult
-                 Free result memory.                                                   
-                 @param $res -- valid database result index                    
-                 @returns bool - Returns 1 for success 0 for failure                   
+                 Free result memory.
+                 @param $res -- valid database result index
+                 @returns bool - Returns 1 for success 0 for failure
                 */
 
                function db_freeresult( $res )
@@ -157,9 +155,9 @@ class GLM_DB
                }
 
                /** db_numrows
-                 Determine number of rows in a result index                            
-                 @param $res -- valid database result index                    
-                 @returns int - Returns number of rows                                 
+                 Determine number of rows in a result index
+                 @param $res -- valid database result index
+                 @returns int - Returns number of rows
                 */
 
                function db_numrows( $res )
@@ -177,14 +175,14 @@ class GLM_DB
                        return( $ret );
                }
                /** db_auto_get_array
-                 The auto function for retrieving an array based soley on a query      
-                 string. This function makes the connection, does the exec, fetches    
-                 the array, closes the connection, frees memory used by the result,    
-                 and then returns the array                                            
-                 @param $qs    SQL query string                                
-                 @param $i             row number                                      
-                 @param $type  PGSQL_ASSOC or PGSQL_BOTH or PSQL_NUM                                           
-                 @returns array - Returns an associative array of key-value pairs              
+                 The auto function for retrieving an array based soley on a query
+                 string. This function makes the connection, does the exec, fetches
+                 the array, closes the connection, frees memory used by the result,
+                 and then returns the array
+                 @param $qs    SQL query string
+                 @param $i             row number
+                 @param $type  PGSQL_ASSOC or PGSQL_BOTH or PSQL_NUM
+                 @returns array - Returns an associative array of key-value pairs
                 */
 
                function db_auto_array( $qs, $i, $type )
@@ -212,12 +210,12 @@ class GLM_DB
                }
 
                /** db_auto_exec
-                 The auto function for executing a query.                              
-                 This function makes the connection, does the exec, fetches            
-                 the array, closes the connection, frees memory used by the result,    
-                 and then returns success (not a valid result index)                   
-                 @param $qs    SQL query string                                
-                 @returns int - Returns 1 for success 0 for failure                    
+                 The auto function for executing a query.
+                 This function makes the connection, does the exec, fetches
+                 the array, closes the connection, frees memory used by the result,
+                 and then returns success (not a valid result index)
+                 @param $qs    SQL query string
+                 @returns int - Returns 1 for success 0 for failure
                 */
 
                function db_auto_exec( $qs )
@@ -231,21 +229,21 @@ class GLM_DB
                        {
                                return( 0 );
                        }
-                       else 
+                       else
                        {
                                return( 1 );
                        }
                }
                /** db_auto_get_data
-                 @discussion   The auto function for retrieving an array based soley on a query        
-                 string. This function makes the connection, does the exec, fetches    
-                 the array, closes the connection, frees memory used by the result,    
-                 and then returns the array                                            
-                 @param string $qs     SQL query string                                
-                 @returns      Returns an associative array of key-value pairs or 0 on error   
+                 @discussion   The auto function for retrieving an array based soley on a query
+                 string. This function makes the connection, does the exec, fetches
+                 the array, closes the connection, frees memory used by the result,
+                 and then returns the array
+                 @param string $qs     SQL query string
+                 @returns      Returns an associative array of key-value pairs or 0 on error
                 */
 
-               function db_auto_get_data( $qs ) 
+               function db_auto_get_data( $qs )
                {
                        if( !$this->dbd )
                        {
@@ -260,7 +258,7 @@ class GLM_DB
                        {
                                $data[$i] = $this->db_fetch_array ($res, $i, PGSQL_ASSOC );
                        }
-                       if( isset( $data ) && $data != "" )     
+                       if( isset( $data ) && $data != "" )
                        {
                                return( $data );
                        }
@@ -271,7 +269,7 @@ class GLM_DB
                }
 
                /** trans_start
-                 Start a postgres transaction 
+                 Start a postgres transaction
                  @returns bool true if sucessful
                 */
                function trans_start()
@@ -297,7 +295,7 @@ class GLM_DB
                }
 
                /** trans_end
-                 Commit the postgres transaction  
+                 Commit the postgres transaction
                  @returns bool true if successful
                 */
                function trans_end()
@@ -315,9 +313,9 @@ class GLM_DB
                                return( false );
                }
                /** trans_exec
-                 exec a postgres query in a 
+                 exec a postgres query in a
                  postgres transaction
-                 @param string query 
+                 @param string query
                 */
                function trans_exec( $query )
                {
index 810b158..7e190f3 100755 (executable)
@@ -19,13 +19,13 @@ var $formvals;      // Set to zero by default, but if there are form processing error
        @param base_url full path to this file -$PHP_SELF for use in form action=""
        @param message string message to go in the email
        @param thankyou string message to display after posting
-       @return void 
+       @return void
        */
        function glm_tellfriend($base_url,$message='',$thankyou='',$postto='')
        {
                // Base url is not optional, so just set it directly
                $this->base_url=$base_url;
-               
+
                // set post to
                if($postto==''){
                        $dvar=explode('/',$_SERVER[PHP_SELF]);
@@ -36,7 +36,7 @@ var $formvals;        // Set to zero by default, but if there are form processing error
                }
                // Set the formvals to 0
                $this->formvals=0;
-               
+
                // Set message text
                if($message!='')
                {
@@ -60,18 +60,18 @@ Message from {senders_name}:
                }
                // End of constructor method
        }
-       
+
        /**  show_form
        shows the Tell a Friend form
        @param int r number of rows in the message textarea
        @param int c number of columns in the message textarea
-       @return void 
-       */ 
+       @return void
+       */
        function show_form($r=3,$c=30)
        {
                // $r is the number of rows on the message
                // $c is the number of columns on the message
-               
+
                if($this->formvals == 0)
                {
                        $fname='';
@@ -113,29 +113,29 @@ Message from {senders_name}:
                        <input type="submit" name="submit" id="submit" value="Send Email">
                </div>
                ';
-               
+
                $output.="</form>\n</div>\n";
                echo $output;
                //phpinfo();
        }
-       
+
        /**  valid email
-       Checks for a valid format and good (mx check) 
+       Checks for a valid format and good (mx check)
        email address.
        @param string email the email address as string.
-       @return boolean 
-       */ 
-       function valid_email ($email) { 
+       @return boolean
+       */
+       function valid_email ($email) {
                $check='';
                $validate_email_temp='';
-               if (eregi('^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$', $email, $check)) { 
-                       if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) { 
-                               return TRUE; 
-                       } 
-               } 
-               return FALSE; 
+               if (preg_match('%^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$%i', $email, $check)) {
+                       if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) {
+                               return TRUE;
+                       }
+               }
+               return FALSE;
        }
-       
+
        /** process_form
        validates the email addresses, htmlspecialchars the message, sends the email
        @return boolean
@@ -168,7 +168,7 @@ Message from {senders_name}:
                                "yname" =>$_POST[senders_name],
                                "yemail" =>$_POST[senders_email],
                                "msg" =>$_POST[message]);
-                               
+
                                for($i=0;$i<sizeof($error);$i++)
                                {
                                        echo $error[$i];
@@ -186,16 +186,16 @@ Message from {senders_name}:
                                $thankyou = str_replace('{friend_name}',$_POST[friend_name],$thankyou);
                                $subject = $_POST[senders_name].' wanted you to see this site';
                                $headers = "From: ".$_POST[senders_email]."\r\n";
-                               
+
                                mail($_POST[friend_email],"Tell a friend",$message,$headers);
-                               
+
                                //echo "<BR>Mail command params\n".$_POST[friend_email]." \n<br>".$subject."\n<br>".$message."\n\n";
                                echo $thankyou;
                        }
-                       
+
                }
        }
-       
+
        function jfdi()
        {
                if(isset($_POST[submit]))
index 4598840..cd4eaab 100755 (executable)
@@ -35,7 +35,7 @@ class GLM_TEMPLATE{
        /** @var items The items array*/
        var $items;
        /** @var type The type*/
-       var $type;      
+       var $type;
        /** @var whole_thread The thread string*/
        var $whole_thread;
        /** @var thread_count The thread count*/
@@ -58,15 +58,15 @@ class GLM_TEMPLATE{
        * that extends this one and setting new vars in the constructor.
        *
        * @param $catid: catid Must be set
-       * 
-       * @return void 
-       * @access 
+       *
+       * @return void
+       * @access
        **/
        function GLM_TEMPLATE( $catid, $DB = NULL )
        {
                $this->get_catid( $catid );         // sets $this->catid
-               $this->set_DB( &$DB );                  // using a reference to $DB (should be started on setup.phtml
-               $this->header_begin = "<h1>";   // class="content" should not be used anymore 
+               $this->set_DB( $DB );                   // using a reference to $DB (should be started on setup.phtml
+               $this->header_begin = "<h1>";   // class="content" should not be used anymore
                $this->header_end = "</h1>";    // create style for p h1 h2 tags if needed try to keep it clean
                $this->subheader_begin = "<h2>";// should not be using h3 here duh go from 1 to 2 instead
                $this->subheader_end = "</h2>"; // like your suppose to
@@ -76,16 +76,16 @@ class GLM_TEMPLATE{
                $this->whole_thread = "";               // do not touch this it is used for menu generation
                $this->thread_count = 1;                // also used for menu generation
                $this->php_ext = '.phtml';              // defaults to .phtml
-               $this->set_pages( &$GLOBALS['PAGES'] );
+               $this->set_pages( $GLOBALS['PAGES'] );
        }
-       
+
 
        /**
-        * set_active_query: some toolboxes have an active flag some do not 
-        * so this is to allow both with and without a flag. 
-        * 
-        * @return 
-        * @access 
+        * set_active_query: some toolboxes have an active flag some do not
+        * so this is to allow both with and without a flag.
+        *
+        * @return
+        * @access
         **/
        function set_active_query()
        {
@@ -95,15 +95,15 @@ class GLM_TEMPLATE{
                }
                return( $this->active_query );
        }
-       
+
 
        /**
           * get_hit_count: find out how many top level categories have at least one category under
           * them.
           * @param $&$DB : Database object
-          * 
-          * @return 
-          * @access 
+          *
+          * @return
+          * @access
           **/
        function get_hit_count( &$DB )
        {
@@ -119,13 +119,13 @@ class GLM_TEMPLATE{
                        return( count( $res ) );
                }
        }
-       
+
        /**
        * get_seo_url: grab category part of the seoarch engine friendly url
        looks at define for seo_url to see weather to use the seach engine friendly url's or not
-        * @param $id: 
+        * @param $id:
         * @param $$slash = 1 : to put a slash on end or not
-        * 
+        *
         * @return string $url for page.
         * @access public
         **/
@@ -157,7 +157,7 @@ class GLM_TEMPLATE{
                {
                        $url = $this->get_base_url( $id );
                        $url .= $this->php_ext.'?catid='.$id;
-               }       
+               }
                if( $GLM_SERVER_ID == "ws1.gaslightmedia.com" )
                {
                        str_replace("index.phtml","",$url);
@@ -166,8 +166,8 @@ class GLM_TEMPLATE{
        }
        /**
        * set_DB: set the DB up to be that of the global one if it exists
-        * @param $$DB : the DB object 
-        * 
+        * @param $$DB : the DB object
+        *
         * @return void
         * @access public
         **/
@@ -175,35 +175,35 @@ class GLM_TEMPLATE{
        {
                if( isset( $DB ) )
                {
-                       $this->DB =& $DB;
+                       $this->DB = $DB;
                }
                else
                {
-                       $this->DB =& new GLM_DB();
+                       $this->DB = new GLM_DB();
                }
        }
 
        /**
-       * set_pages: grab the globals for the pages an use this for 
+       * set_pages: grab the globals for the pages an use this for
                the pages array for the class
-        * 
+        *
         * @return void
-        * @access public 
+        * @access public
         **/
        function set_pages( $pages )
        {
                if( is_array( $pages ) )
                {
-                       $this->pages =& $pages;
+                       $this->pages = $pages;
                }
        }
-       
+
        /**
        * set_catid:Set the class catid var
        * @param $catid: $catid
-       * 
-       * @return void 
-       * @access public 
+       *
+       * @return void
+       * @access public
        **/
        function set_catid( $catid )
        {
@@ -219,9 +219,9 @@ class GLM_TEMPLATE{
 
        /**
         * get_id_from_path_info: takes the path_info and gets a catid from bus_category table
-        * @param $PATH_INFO: GLOBAL PATH_INFO 
-        * @param $&$dbd : object database 
-        * 
+        * @param $PATH_INFO: GLOBAL PATH_INFO
+        * @param $&$dbd : object database
+        *
         * @return int catid
         * @access public
         **/
@@ -234,7 +234,7 @@ class GLM_TEMPLATE{
                        $it=$var_array[(sizeof($var_array) - $chop)];
                        if( $it != "" && $it != "blank")
                                {
-                                       $catid = GLM_TEMPLATE::get_id_from_name( $it,"bus_category", &$dbd );
+                                       $catid = GLM_TEMPLATE::get_id_from_name( $it,"bus_category", $dbd );
                                }
                }
                return( $catid );
@@ -242,9 +242,9 @@ class GLM_TEMPLATE{
 
        /**
         * get_catid: calls the get_id_from_path and can be placed into the consructor
-        * 
-        * @return int catid 
-        * @access public 
+        *
+        * @return int catid
+        * @access public
         **/
        function get_catid( $catid )
        {
@@ -254,12 +254,12 @@ class GLM_TEMPLATE{
                }
                if(!isset($_GET[page]))
                {
-                       $this->catid = $this->get_id_from_path_info( $PATH_INFO, &$this->DB );
+                       $this->catid = $this->get_id_from_path_info( $PATH_INFO, $this->DB );
                }
                else
                {
-                       $this->catid = $this->get_id_from_name($page, "bus_category",&$this->DB);
-               }       
+                       $this->catid = $this->get_id_from_name($page, "bus_category",$this->DB);
+               }
                return( $this->catid );
        }
 
@@ -267,10 +267,10 @@ class GLM_TEMPLATE{
        * set_contact:Set the contact string
 
        * @param $text: The text as string
-       * @param $email: email if givin 
-       * 
-       * @return string $text 
-       * @access 
+       * @param $email: email if givin
+       *
+       * @return string $text
+       * @access
        **/
        function set_contact( $text, $email )
        {
@@ -288,9 +288,9 @@ class GLM_TEMPLATE{
        /**
        * set_text:Set the contact string
        * @param $text: The text as string
-       * 
+       *
        * @return string $text
-       * @access 
+       * @access
        **/
        function set_text( $text )
        {
@@ -309,7 +309,7 @@ class GLM_TEMPLATE{
 
        /**
         * get_image_path: get image path from the size used
-        * 
+        *
         * @return path for images
         * @access public
         **/
@@ -328,17 +328,17 @@ class GLM_TEMPLATE{
                        return( THUMB_PATH );
                }
        }
-       
+
        /**
        * set_img:Set the image string
        * @param $image: The image
        * @param $size: The path
        * @param $align: The alignment
        * @param $name: The image_name (displayed under image)
-       * @param $title: Title if given 
-       * 
-       * @return 
-       * @access 
+       * @param $title: Title if given
+       *
+       * @return
+       * @access
        **/
        function set_img( $image, $size, $align, $title )
        {
@@ -384,9 +384,9 @@ class GLM_TEMPLATE{
        * set_url:Set the url string
        * @param $url: The url
        * @param $text: The text as string
-       * 
+       *
        * @return string $text
-       * @access 
+       * @access
        **/
        function set_url( $url, $text )
        {
@@ -405,16 +405,16 @@ class GLM_TEMPLATE{
                                $url = '<p><a href="http://'.$url.'" target="_blank">'.$text.'</a></p>';
                        }
                }
-               return( $url ); 
+               return( $url );
        }
 
        /**
        * set_email:Set the email string
        * @param $email: The email as string
        * @param $contact: The contactname this is used as the link text
-       * 
-       * @return string $text 
-       * @access 
+       *
+       * @return string $text
+       * @access
        **/
        function set_email( $email, $contact )
        {
@@ -431,21 +431,21 @@ class GLM_TEMPLATE{
                                <p><strong>Email:</strong>&nbsp;&nbsp;<a href="mailto:'.$email.'" target="_blank">'.$email.'</a></p>';
                        }
                }
-               return( $email );       
+               return( $email );
        }
 
        /**
        * set_header:Set the header string
        * @param $text: The text as string
-       * 
-       * @return string $text 
-       * @access 
+       *
+       * @return string $text
+       * @access
        **/
        function set_header( $text )
        {
                if( $text != "" )
                {
-                       $text = $this->header_begin.$text.$this->header_end;    
+                       $text = $this->header_begin.$text.$this->header_end;
                }
                return( $text );
        }
@@ -454,15 +454,15 @@ class GLM_TEMPLATE{
        * set_subheader:Set the subheader string
        * @param $text: The text as string
 
-       * 
-       * @return string $text 
-       * @access 
+       *
+       * @return string $text
+       * @access
        **/
        function set_subheader( $text )
        {
                if( $text != "" )
                {
-                       $text = $this->subheader_begin.$text.$this->subheader_end;      
+                       $text = $this->subheader_begin.$text.$this->subheader_end;
                }
                return( $text );
        }
@@ -470,15 +470,15 @@ class GLM_TEMPLATE{
        /**
        * set_phone:Set the phone string
        * @param $text: The text as string
-       * 
-       * @return string $text 
-       * @access 
+       *
+       * @return string $text
+       * @access
        **/
        function set_phone( $text )
        {
                if( $text != "" )
                {
-                       $text = '<p><strong>Phone:</strong>&nbsp;&nbsp;'.$text.'</p>';  
+                       $text = '<p><strong>Phone:</strong>&nbsp;&nbsp;'.$text.'</p>';
                }
                return( $text );
        }
@@ -486,16 +486,16 @@ class GLM_TEMPLATE{
        /**
        * set_fax:Set the fax string
        * @param $text: The text as string
-       * 
-       * @return string $text 
-       * @access 
+       *
+       * @return string $text
+       * @access
        **/
        function set_fax( $text )
        {
                if( $text != "" )
                {
                        $text = '
-                       <p><strong>Fax:</strong>&nbsp;&nbsp;'.$text.'</p>';     
+                       <p><strong>Fax:</strong>&nbsp;&nbsp;'.$text.'</p>';
                }
                return( $text );
        }
@@ -504,9 +504,9 @@ class GLM_TEMPLATE{
        * set_file:Set the file string
        * @param $text: The text as string
        * @param $name: The file name displayed
-       * 
-       * @return string $text 
-       * @access 
+       *
+       * @return string $text
+       * @access
        **/
        function set_file( $text, $name )
        {
@@ -514,7 +514,7 @@ class GLM_TEMPLATE{
                {
                        $outtext = '
                        <p class="fileupload">';
-                       if(ereg("[.]([a-zA-Z]{3}$)",$text,$tmp))
+                       if(preg_match("%[.]([a-zA-Z]{3}$)%",$text,$tmp))
                        {
                                $outtext .= '<span class="'.$tmp[1].'">&nbsp;</span>';
                        }
@@ -533,9 +533,9 @@ class GLM_TEMPLATE{
        /**
        * set_address:set_address
        * @param $data: data contain the address info for display.
-       * 
+       *
        * @return string $address
-       * @access 
+       * @access
        **/
        function set_address( $data )
        {
@@ -547,7 +547,7 @@ class GLM_TEMPLATE{
                if( $data["city"] && $data["state"] && $data["zip"] )
                {
                        $address .= '<br>'.$data["city"].', '.$data["state"].' '.$data["zip"];
-               }       
+               }
                elseif( $data["city"] && $data["state"] )
                {
                        $address .= '<br>'.$data["city"].', '.$data["state"];
@@ -564,16 +564,16 @@ class GLM_TEMPLATE{
 
        /**
        * get_all:Does the query and set_data calls boths arrays
-       * 
+       *
        * @return void
-       * @access 
+       * @access
        **/
        function get_all( $type = NULL )
        {
-               $catid = $this->catid; 
+               $catid = $this->catid;
                if( $type == 1 || !$type )
                {
-                       $cat_query = "select * from bus_category where id = $catid ".$this->active_query." order by pos";  
+                       $cat_query = "select * from bus_category where id = $catid ".$this->active_query." order by pos";
                        $res = $this->set_data( $this->DB->db_auto_get_data( $cat_query ) );
                        $this->data = $res[0];
                }
@@ -588,9 +588,9 @@ class GLM_TEMPLATE{
        * set_data:Calls each function of the class
        * based on the key af the array $data[0][$key]
        * @param $data: The input array from db query
-       * 
+       *
        * @return array data The finished array
-       * @access 
+       * @access
        **/
        function set_data( $data )
        {
@@ -621,7 +621,7 @@ class GLM_TEMPLATE{
                                        }
                                        elseif( strstr($key,"url") && strstr($key,"name") && $value!="" )
                                        {
-                                       }       
+                                       }
                                        elseif( strstr($key,"descr") && $value != "" )
                                        {
                                                $data[$k][$key] = GLM_TEMPLATE::set_text( $value );
@@ -679,18 +679,18 @@ class GLM_TEMPLATE{
                                                $data[$k][$key] = GLM_TEMPLATE::set_text( $value );
                                        }
                                }
-                       }       
+                       }
                        return( $data );
-               }       
+               }
                return( false );
        }
 
        /**
        * load_static_page:using object buffer include the page $catid.phtml from static dir
        and return it as string
-       * 
-       * @return string $text 
-       * @access 
+       *
+       * @return string $text
+       * @access
        **/
        function load_static_page()
        {
@@ -706,10 +706,10 @@ class GLM_TEMPLATE{
 
        /**
        * clean_text:Do some text clean up.
-       * @param $output: 
-       * 
+       * @param $output:
+       *
        * @return string text cleaned
-       * @access 
+       * @access
        **/
        function clean_text($output)
        {
@@ -721,9 +721,9 @@ class GLM_TEMPLATE{
        /**
        * get_category: grab just category contents
        * @param $catid: id of bus_category
-       * @param $DB: 
+       * @param $DB:
        * @param $$showimg=1: weather or not to show category image
-       * 
+       *
        * @return string $output
        * @access public
        **/
@@ -733,7 +733,7 @@ class GLM_TEMPLATE{
                {
                        $this->get_template( "cat" );
                }
-                       
+
                if( !$this->data )
                {
                        $this->get_all( 1 );
@@ -768,9 +768,9 @@ class GLM_TEMPLATE{
 
        /**
         * get_page: replacing template_parser with get-page function
-        * 
-        * @return 
-        * @access 
+        *
+        * @return
+        * @access
         **/
        function get_page( $showimg = 1,$showdiv=1 )
        {
@@ -781,9 +781,9 @@ class GLM_TEMPLATE{
 
         /**
          * get_template: get the template type of the bus_category
-         * @param $$type : 'cat' or 'list' 
-         * 
-         * @return void 
+         * @param $$type : 'cat' or 'list'
+         *
+         * @return void
          * @access public
          **/
        function get_template( $type )
@@ -796,7 +796,7 @@ class GLM_TEMPLATE{
                                switch( $data[0]['template'] )
                                {
                                        case "5":
-                                       case "4":       
+                                       case "4":
                                        case "2":
                                                $this->img_align = "left";
                                        break;
@@ -814,12 +814,12 @@ class GLM_TEMPLATE{
                                                $this->img_align = "right";
                                                $this->img_alternate = 0;
                                        break;
-                                       case "4":       
+                                       case "4":
                                                $this->img_align = "right";
                                                $this->img_alternate = 1;
                                        break;
 
-                                       case "3":       
+                                       case "3":
                                                $this->img_align = "left";
                                                $this->img_alternate = 1;
                                        break;
@@ -829,7 +829,7 @@ class GLM_TEMPLATE{
                                                $this->img_alternate = 0;
                                        break;
 
-                                       case "1":       
+                                       case "1":
                                                $this->img_align = "right";
                                                $this->img_alternate = 0;
                                        break;
@@ -840,13 +840,13 @@ class GLM_TEMPLATE{
                        break;
                }
                return( $this->template = $data[0]['template'] );
-       }       
+       }
        /**
-       * template_parser:This function creates data 
+       * template_parser:This function creates data
        * and items arrays and does the output for the page.
-       * 
+       *
        * @return void
-       * @access 
+       * @access
        **/
        function get_listings()
        {
@@ -855,19 +855,19 @@ class GLM_TEMPLATE{
                {
                        $this->get_template( "list" );
                }
-               
+
                if( !is_array( $this->items ) )
                {
                        $this->get_all( 2 );
                }
 
-               // load any static category page from the static directory 
+               // load any static category page from the static directory
                // hard codded content would have $catid.phtml page for it
                $output .= $this->load_static_page();
                switch($this->type)
                {
 
-                       default:        
+                       default:
                        if(is_array($this->items))
                        {
                                foreach($this->items as $key=>$val)
@@ -903,26 +903,26 @@ class GLM_TEMPLATE{
        /**
        * sub_nav:Create a sub navigation 4 across
        * @param $catid: The catid for the page
-       * 
+       *
        * @return void
-       * @access 
+       * @access
        **/
        function sub_nav($catid)
        {
                //$catid = $this->get_parentid($catid);
-               $query = "SELECT id,category FROM bus_category WHERE and parent = $catid ".$this->active_query." ORDER BY pos"; 
+               $query = "SELECT id,category FROM bus_category WHERE and parent = $catid ".$this->active_query." ORDER BY pos";
                $data = $this->DB->db_auto_get_data($query);
                if(is_array($data))
                {
-                       $counter = 1;   
+                       $counter = 1;
                        foreach($data as $key=>$val)
                        {
                                $url = $this->get_seo_url( $val['id'] );
                                //GLM_TEMPLATE::set_name_url( GLM_TEMPLATE::get_category_Name( $val['id'],"bus_category",$this->DB ) );
                                echo '<a href="'.$url.'">';
                                        echo $val["category"];
-                                       echo '</a><br>';        
-                       }       
+                                       echo '</a><br>';
+                       }
                }
        }
 
@@ -930,18 +930,18 @@ class GLM_TEMPLATE{
        * get_home_events: get events flaged as home events
        * @param $DB: DB reference to DB obj
 
-       * 
-       * @returnvoid 
-       * @access 
+       *
+       * @returnvoid
+       * @access
        **/
        function get_home_events()
        {
-               $query = "SELECT id,header,substr(descr,0,30) as descr, bdate, edate    
+               $query = "SELECT id,header,substr(descr,0,30) as descr, bdate, edate
                FROM event WHERE home = 't'";
                $data = $this->DB->db_auto_get_data($query);
                if(is_array($data))
                {
-                       $output = '<div id="events">UPCOMING EVENTS<div id="eventsbox"> 
+                       $output = '<div id="events">UPCOMING EVENTS<div id="eventsbox">
                                        ';
                        foreach($data as $key=>$value)
                        {
@@ -967,23 +967,23 @@ class GLM_TEMPLATE{
        * @param $sdate: start date
        * @param $edate: end date
        * @param $dateType: dateType Postgres,etc
-       * 
-       * @return string  
-       * @access 
+       *
+       * @return string
+       * @access
        **/
        function get_event_date($sdate,$edate,$dateType)
        {
                switch($dateType)
                {
                        case "Postgres":
-                       if(ereg("([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})",$sdate,$spt))
+                       if(preg_match("%([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})%",$sdate,$spt))
                        {
                                $mon = $spt[1];
                                $day = $spt[2];
                                $yr = $spt[3];
                        }
 
-                       if(ereg("([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})",$edate,$ept))
+                       if(preg("%([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})%",$edate,$ept))
                        {
                                $mon2 = $ept[1];
                                $day2 = $ept[2];
@@ -1002,41 +1002,41 @@ class GLM_TEMPLATE{
 
                }$start = mktime(0,0,0,$mon,$day,$yr);
                $end = mktime(0,0,0,$mon2,$day2,$yr2);
-               if ($day == $day2 && $mon == $mon2 && $yr == $yr2) 
+               if ($day == $day2 && $mon == $mon2 && $yr == $yr2)
                {
-                       $dateparam = "F jS, Y"; 
+                       $dateparam = "F jS, Y";
                        $date_begin = date($dateparam, $start) ;
                        $date_end = "";
                }
-               elseif ($day == $day2 AND $mon == $mon2 AND $yr != $yr2) 
+               elseif ($day == $day2 AND $mon == $mon2 AND $yr != $yr2)
                {
                        $dateparam1 = "F jS, Y -";
                        $dateparam2 = "Y";
                        $date_begin = date($dateparam1, $start);
                        $date_end = date($dateparam2, $end);
                }
-               elseif ($day != $day2 AND $mon == $mon2 AND $yr == $yr2) 
+               elseif ($day != $day2 AND $mon == $mon2 AND $yr == $yr2)
                {
                        $dateparam1 = "F jS -";
                        $dateparam2 = "jS, Y";
                        $date_begin = date($dateparam1, $start);
                        $date_end = date($dateparam2, $end);
                }
-               elseif ($day != $day2 AND $mon == $mon2 AND $yr != $yr2) 
+               elseif ($day != $day2 AND $mon == $mon2 AND $yr != $yr2)
                {
                        $dateparam1 = "F jS, Y -";
                        $dateparam2 = "F jS, Y";
                        $date_begin = date($dateparam1, $start);
                        $date_end = date($dateparam2, $end);
                }
-               elseif ($yr == $yr2) 
+               elseif ($yr == $yr2)
                {
                        $dateparam1 = "F jS -";
                        $dateparam2 = "F jS, Y";
                        $date_begin = date($dateparam1, $start);
                        $date_end = date($dateparam2, $end);
                }
-               else 
+               else
                {
                        $dateparam1 = "F jS, Y -";
                        $dateparam2 = "F jS, Y";
@@ -1049,12 +1049,12 @@ class GLM_TEMPLATE{
 
        /**
        * is_sub_id:Check to see if catid is sub of category
-       * @param $catid: the catid looking at 
+       * @param $catid: the catid looking at
        * @param $category: to see if it is in category
        * @param $DB: Db object reference
-       * 
-       * @return bool 
-       * @access 
+       *
+       * @return bool
+       * @access
        **/
        function is_sub_id($catid,$category,&$DB)
        {
@@ -1071,21 +1071,21 @@ class GLM_TEMPLATE{
                }
                else
                {
-                       return( $this->is_sub_id($parent,$category,&$DB) );     
+                       return( $this->is_sub_id($parent,$category,$DB) );
                }
        }
 
        /**
        * get_parent: get parent for this category
-       * @param $catid: id 
+       * @param $catid: id
        * @param $DB: database obj
-       * 
+       *
        * @return int $parent
-       * @access 
+       * @access
        **/
        function get_parent($catid,&$DB)
        {
-               $query = "SELECT parent FROM bus_category WHERE id = $catid ORDER BY pos";      
+               $query = "SELECT parent FROM bus_category WHERE id = $catid ORDER BY pos";
                $data = $DB->db_auto_get_data($query);
                if(is_array($data))
                {
@@ -1096,7 +1096,7 @@ class GLM_TEMPLATE{
                        else
                        {
                                return( $data[0]["parent"] );
-                               //return(GLM_TEMPLATE::get_parent($data[0]["parent"],&$DB));
+                               //return(GLM_TEMPLATE::get_parent($data[0]["parent"],$DB));
                        }
 
                }
@@ -1108,26 +1108,26 @@ class GLM_TEMPLATE{
 
        /**
        * get_sub_nav:
-       * @param $catid: 
-       * @param $DB: 
-       * 
-       * @return 
-       * @access 
+       * @param $catid:
+       * @param $DB:
+       *
+       * @return
+       * @access
        **/
        function get_sub_nav($catid,&$DB)
        {
-               $parentid = GLM_TEMPLATE::get_parent($catid,&$DB);
+               $parentid = GLM_TEMPLATE::get_parent($catid,$DB);
                //echo $parentid.'<br>';
-               $query = "SELECT id,category FROM bus_category WHERE parent = $parentid ".$this->active_query." ORDER BY pos";  
+               $query = "SELECT id,category FROM bus_category WHERE parent = $parentid ".$this->active_query." ORDER BY pos";
                $data = $DB->db_auto_get_data($query);
                if(is_array($data))
                {
                        $output = '<div id="subnav">';
-                               $counter = 1;   
+                               $counter = 1;
                                foreach($data as $key=>$val)
                                {
                                        $url = $this->get_seo_url( $val['id'] );
-                                       if(GLM_TEMPLATE::is_sub_id($catid,$parentid,&$DB) && (GLM_TEMPLATE::is_sub_id($catid,$val['id'],&$DB) || $val['id'] == $catid) )
+                                       if(GLM_TEMPLATE::is_sub_id($catid,$parentid,$DB) && (GLM_TEMPLATE::is_sub_id($catid,$val['id'],$DB) || $val['id'] == $catid) )
                                        {
                                                $output .=  '<a class="current" href="'.$url.'">';
                                        }
@@ -1136,12 +1136,12 @@ class GLM_TEMPLATE{
                                                $output .=  '<a href="'.$url.'">';
                                        }
                                        $output .=  $val["category"];
-                                       $output .=  '</a>';     
-                                       if( GLM_TEMPLATE::is_sub_id($catid,$val['id'],&$DB) && GLM_TEMPLATE::has_subs($val['id'],&$DB))
+                                       $output .=  '</a>';
+                                       if( GLM_TEMPLATE::is_sub_id($catid,$val['id'],$DB) && GLM_TEMPLATE::has_subs($val['id'],$DB))
                                        {
-                                               $output .= GLM_TEMPLATE::get_sub_nav($val["id"],&$DB,$catid);
-                                       }       
-                               }       
+                                               $output .= GLM_TEMPLATE::get_sub_nav($val["id"],$DB,$catid);
+                                       }
+                               }
                                $output .= '</div>';
                        $output = GLM_TEMPLATE::clean_text($output);
                        echo $output;
@@ -1151,15 +1151,15 @@ class GLM_TEMPLATE{
 
        /**
        * has_subs:
-       * @param $catid: 
-       * @param $DB: 
-       * 
-       * @return 
-       * @access 
+       * @param $catid:
+       * @param $DB:
+       *
+       * @return
+       * @access
        **/
        function has_subs($catid,&$DB)
        {
-               $query = "SELECT id FROM bus_category WHERE parent = $catid ".$this->active_query." ORDER BY pos";      
+               $query = "SELECT id FROM bus_category WHERE parent = $catid ".$this->active_query." ORDER BY pos";
                $data = $DB->db_auto_get_data($query);
                if(is_array($data))
                {
@@ -1176,34 +1176,34 @@ class GLM_TEMPLATE{
        * get_parentid:Get the highest level parent id (not 0 )for the category.
        * @param $id: The catid for the page.
        * @param $DB: obj
-       * 
-       * @return int $parent 
-       * @access 
+       *
+       * @return int $parent
+       * @access
        **/
        function get_parentid($id,&$DB)
        {
                if( $id == 0 )
                {
-                       return( 0 );            
+                       return( 0 );
                }
                $qs = "select parent from bus_category where id = $id";
-               $parentrow = $DB->db_auto_get_data( $qs );        
+               $parentrow = $DB->db_auto_get_data( $qs );
                if($parentrow[0]['parent'] == 0)
                {
                        return($id);
                }
                else
                {
-                       return( GLM_TEMPLATE::get_parentid($parentrow[0]['parent'],&$DB) );
+                       return( GLM_TEMPLATE::get_parentid($parentrow[0]['parent'],$DB) );
                }
        }
 
        /**
        * show_catimg:output the category image.
        * @param $catid: The catid for the page.
-       * 
-       * @return void 
-       * @access 
+       *
+       * @return void
+       * @access
        **/
        function show_catimg($catid)
        {
@@ -1225,10 +1225,10 @@ class GLM_TEMPLATE{
        /**
        * get_catheader:output the category name.
        * @param $catid: The catid for the page
-       * @param $DB: db obj 
-       * 
-       * @return void 
-       * @access 
+       * @param $DB: db obj
+       *
+       * @return void
+       * @access
        **/
        function get_catheader($catid,$DB)
        {
@@ -1244,14 +1244,14 @@ class GLM_TEMPLATE{
                }
                return( $header );
        }
-       
+
                /**
        * get_catintro: return the category page name.
        * @param $catid: The catid for the page
-       * @param $DB: db obj 
-       * 
-       * @return void 
-       * @access 
+       * @param $DB: db obj
+       *
+       * @return void
+       * @access
        **/
        function get_catintro($catid)
        {
@@ -1270,10 +1270,10 @@ class GLM_TEMPLATE{
 
        /**
        * show_catheader:
-       * @param $catid: 
-       * 
-       * @return 
-       * @access 
+       * @param $catid:
+       *
+       * @return
+       * @access
        **/
        function show_catheader($catid)
        {
@@ -1292,9 +1292,9 @@ class GLM_TEMPLATE{
 
        /**
        * get_menu_string:get categories for the phplayermenu
-       * 
-       * @return string 
-       * @access 
+       *
+       * @return string
+       * @access
        **/
        function get_menu_string()
        {
@@ -1304,7 +1304,7 @@ class GLM_TEMPLATE{
                $string = GLM_TEMPLATE::convert_to_thread($newdata,$newdata[0]);
                return($string);
        }
-       
+
        function get_menu_array()
        {
                $query = "SELECT id,parent,category FROM bus_category WHERE active='t' ORDER BY parent,pos";
@@ -1315,10 +1315,10 @@ class GLM_TEMPLATE{
 
        /**
        * sort_childs:
-       * @param $threads: 
-       * 
-       * @return 
-       * @access 
+       * @param $threads:
+       *
+       * @return
+       * @access
        **/
        function sort_childs($threads)
        {
@@ -1331,14 +1331,14 @@ class GLM_TEMPLATE{
 
        /**
        * convert_to_thread:
-       * @param $threads: 
-       * @param $thread: 
-       * 
-       * @return 
-       * @access 
+       * @param $threads:
+       * @param $thread:
+       *
+       * @return
+       * @access
        **/
        function convert_to_thread($threads, $thread)
-       {    
+       {
                foreach($thread as $parent=>$value)
                {
                        $this->whole_thread .= str_repeat(".",$this->thread_count);
@@ -1347,7 +1347,7 @@ class GLM_TEMPLATE{
                        $this->whole_thread .= "|".$url;
                        $this->whole_thread .="\n";
                        if($threads[$parent])
-                       {       
+                       {
                                $this->thread_count++;
                                GLM_TEMPLATE::convert_to_thread($threads, $threads[$parent]);
                        }
@@ -1363,20 +1363,20 @@ class GLM_TEMPLATE{
                $row=$this->DB->db_auto_get_data($qs);
                return $row[0]['count'];
        }
-       
+
        /**
        * get_ancesters:get the ancesters for this category
        * @param $catid: catid
        * @param $count: starting counter
-       * 
-       * @return array 
-       * @access 
+       *
+       * @return array
+       * @access
        **/
        function get_ancesters($catid,$count)
        {
                if($catid)
                {
-                       $query = "SELECT        id,category,parent 
+                       $query = "SELECT        id,category,parent
                        FROM    bus_category
                        WHERE   id = ".$catid."
                        ".$this->active_query;
@@ -1387,7 +1387,7 @@ class GLM_TEMPLATE{
                        $this->ancesters[$count]['id'] = $id;
                        $this->ancesters[$count]['label'] = $category;
 
-                       $url = $this->get_seo_url( $id ); 
+                       $url = $this->get_seo_url( $id );
                        $this->ancesters[$count]['link'] = $url;
                        GLM_TEMPLATE::get_ancesters($parent,$count+1,$conn);
 
@@ -1401,22 +1401,22 @@ class GLM_TEMPLATE{
                $description = substr( strip_tags( $data[0]['description'] ), 0, 50 );
                return( $description );
        }
-       
+
        function title()
        {
                $query = "select category,intro from bus_category where id = ".$this->catid;
                $data = $this->DB->db_auto_get_data( $query );
-               if( $data[0]['intro'] ) 
+               if( $data[0]['intro'] )
                {
                        $title = strip_tags( $data[0]['intro'] );
-               }       
+               }
                else
                {
                        $title = strip_tags( $data[0]['category'] );
                }
                return( $title.' - ' );
        }
-       
+
        function get_bottom_nav($parent=0)
        {
                $return='';
@@ -1436,32 +1436,32 @@ class GLM_TEMPLATE{
                        return $return;
                }
        }
-       
+
        function cat_lineage($id)
        {
                $qs = "SELECT parent FROM bus_category WHERE id=$id AND active='t'";
                $row=$this->DB->db_auto_get_data($qs);
-               
+
                if($row[0]['parent']!=0)
                {
                        $this->lineage[] = $row[0]['parent'];
                        $this->cat_lineage($row[0]['parent']);
                }
-               
+
        }
        /**
         * make_ul_menu: create url list of categories
-        * @param $parent: parent to start from 
+        * @param $parent: parent to start from
         * @param $$url='': page to go to
-        * @param $$catid=0: 
-        * 
-        * @return 
-        * @access 
+        * @param $$catid=0:
+        *
+        * @return
+        * @access
         **/
        function make_ul_menu($parent=0)
        {
                $this->cat_lineage($this->catid);
-               
+
                $qs="SELECT id,category FROM bus_category WHERE parent=$parent AND active='t' ORDER BY pos";
                $row=$this->DB->db_auto_get_data($qs);
                if(!is_array($row))
@@ -1482,8 +1482,8 @@ class GLM_TEMPLATE{
                        {
                                $url = $this->get_seo_url( $row[$i]['id'] );
                                $ret2='';
-                               
-                               if( $this->catid == $row[$i]['id'] )    
+
+                               if( $this->catid == $row[$i]['id'] )
                                {
                                        $urlstyle= ' id="current"';
                                        $listyle=' id="active"';
@@ -1502,10 +1502,10 @@ class GLM_TEMPLATE{
                        return $return."</ul>";
                }
        }
-       
 
-       
-       
+
+
+
        function make_demo_ul_menu($parent=0)
        {
                $qs="SELECT id,category FROM bus_category WHERE parent=$parent AND active='t' ORDER BY pos";
@@ -1524,24 +1524,24 @@ class GLM_TEMPLATE{
                        {
                                $return="<ul>\n";
                        }
-                       
+
                        for($i=0;$i<sizeof($row);$i++)
                        {
-                               /* 
+                               /*
                                $query = "select parent from bus_category where id = $catid;";
                                $parent_data = $this->DB->db_auto_get_data( $query );
                                $par = $parent_data[0]['parent']; */
-                               
+
                                $url = $this->get_seo_url( $row[$i]['id'] );
-                               
+
                                $ret2='';
                                /* if( $par == $this->catid )
                                {
                                        $ret2=$this->make_ul_menu($this->catid);//'index.phtml');
                                } */
-                               
+
                                $return.="\n<li>".'<a href="'.$url.'"';
-                                       if( $this->catid == $row[$i]['id'] )    
+                                       if( $this->catid == $row[$i]['id'] )
                                {
                                        $return .= ' id="current"';
                                }
@@ -1551,7 +1551,7 @@ class GLM_TEMPLATE{
                        return $return."</ul>\n";
                }
        }
-       
+
        function make_custom_menu($parent,$url='',$onhome=0)
        {
                $url==''?$url=$_SERVER['PHP_SELF']:'';
@@ -1564,7 +1564,7 @@ class GLM_TEMPLATE{
                {
                        $qs="SELECT id,category,image FROM bus_category WHERE parent=$parent $opt AND active='t' ORDER BY pos";
                }
-               
+
                $row=$this->DB->db_auto_get_data($qs);
                if(!is_array($row))
                {
@@ -1589,19 +1589,19 @@ class GLM_TEMPLATE{
                        {
                                $return.='<img src="'.THUMB.$row[$i][image].'">';
                        }
-                       
+
                        $return.='</a>'."</div>$brtag\n";
                }
                        return $return;
                }
        }
-       
+
        /**
        * print_ancesters:print out the ancesters
        * @param $catid: the id to start at.
-       * 
-       * @return 
-       * @access 
+       *
+       * @return
+       * @access
        **/
        function print_ancesters($catid)
         {
@@ -1612,12 +1612,12 @@ class GLM_TEMPLATE{
                                                {
                                                        $url = $this->get_seo_url( 1 );
                                                        $outarray[] = '<a href="'.$url.'">Home</a>';
-                                               }       
+                                               }
                         for($i=0;$i<$end;$i++)
                         {
                                                        $outarray[] = '<a href="'.BASE_URL.$string[$i]["link"].'">'.$string[$i]["label"].'</a>';
                         }
-                                               $outarray[] = $this->get_catheader( $catid, &$this->DB );
+                                               $outarray[] = $this->get_catheader( $catid, $this->DB );
                         if( is_array( $outarray ) && count( $outarray ) > 1 )
                         {
                                 $out .= implode( " <b>&raquo;</b> ", $outarray );
@@ -1628,15 +1628,15 @@ class GLM_TEMPLATE{
 
        /**
        * build_picklist:
-       * @param $fieldname: 
-       * @param $data: 
-       * @param $selected: 
-       * @param $$type = "standard": 
-       * @param $$auto = 0: 
-       * @param $$width = NULL : 
-       * 
-       * @return 
-       * @access 
+       * @param $fieldname:
+       * @param $data:
+       * @param $selected:
+       * @param $$type = "standard":
+       * @param $$auto = 0:
+       * @param $$width = NULL :
+       *
+       * @return
+       * @access
        **/
        function build_picklist( $fieldname, $data, $selected, $type = "standard",$auto = 0,$width = NULL )
        {
@@ -1660,7 +1660,7 @@ class GLM_TEMPLATE{
                {
                        case "multiple":
                        $str = "<SELECT id=\"".$fieldname."\" NAME=\"".$fieldname."\" multiple size=\"10\" ".$autosubmit.">\n";
-                               while( list($key, $val) = each($data) ) 
+                               while( list($key, $val) = each($data) )
                                {
                                        if( in_array($key,$sel) )
                                        {
@@ -1675,7 +1675,7 @@ class GLM_TEMPLATE{
                                break;
                        case "simple":
                        $str = "<SELECT id=\"".$fieldname."\" NAME=\"$fieldname\" ".$autosubmit.">\n";
-                               for( $i=0 ; $i<count($data) ; $i++ ) 
+                               for( $i=0 ; $i<count($data) ; $i++ )
                                {
                                        $select = (in_array($data[$i],$sel)) ? " SELECTED ":"";
                                        $str .= "       <OPTION VALUE=\"".$data[$i]."\"".$select.">".$data[$i]."\n";
@@ -1685,7 +1685,7 @@ class GLM_TEMPLATE{
                                case "standard":
                        default:
                        $str = "<SELECT id=\"".$fieldname."\" NAME=\"$fieldname\" ".$autosubmit.">\n";
-                               while( list($key, $val) = each($data) ) 
+                               while( list($key, $val) = each($data) )
                                {
                                        $select = (in_array($key,$sel)) ? " SELECTED ":"";
                                        $str .= "       <OPTION VALUE=\"$key\"".$select.">$val\n";
@@ -1698,19 +1698,19 @@ class GLM_TEMPLATE{
 
        /**
        * keyword_replace:
-       * @param $string: 
-       * 
-       * @return 
-       * @access 
+       * @param $string:
+       *
+       * @return
+       * @access
        **/
        function keyword_replace($string)
        {
                if($search = strstr($string,"{"))
                {
-                       if(ereg("\{([A-Za-z0-9\&\-\,\'\" ]*)\}",$string,$needle))
+                       if(preg_match("%\{([A-Za-z0-9\&\-\,\'\" ]*)\}%",$string,$needle))
                        {
                                if($needle[0] != "")
-                               {               
+                               {
                                        // first check to see if it matches bus_category keyword
                                        $qs = "SELECT   id,category
                                        FROM            bus_category
@@ -1719,7 +1719,7 @@ class GLM_TEMPLATE{
                                        // first check to see if it matches bus_category keyword
                                        if( $keyres = $this->DB->db_auto_get_data($qs) )
                                        {
-                                               //$parent = $this->get_parentid($keyres[0]['id'],&$this->DB);
+                                               //$parent = $this->get_parentid($keyres[0]['id'],$this->DB);
                                                $url = $this->get_seo_url( $keyres[0]['id'] );
                                                $replacement = "<a href=\"".$url."\">".$keyres[0]['category']."</a>";
                                                $string = str_replace($needle[0],$replacement,$string);
@@ -1736,24 +1736,24 @@ class GLM_TEMPLATE{
                                                }
                                        }
                                }
-                       }               
+                       }
                        else
                        {
                                return($string);
                        }
                        if($search = strstr($string,"{"))
                        return($this->keyword_replace($string));
-               }       
-               return($string);        
+               }
+               return($string);
        }
        /**
        * getIdFromName:
-       * @param $name: 
-       * @param $table: 
-       * @param $DB: 
-       * 
-       * @return 
-       * @access 
+       * @param $name:
+       * @param $table:
+       * @param $DB:
+       *
+       * @return
+       * @access
        **/
        function get_id_from_name( $name, $table, &$DB)
        {
@@ -1765,18 +1765,18 @@ class GLM_TEMPLATE{
                {
                        return( $name );
                }
-               if( ereg("(.*)/$",$name,$tmp) )
+               if( preg_match("%(.*)/$%",$name,$tmp) )
                {
                        $name = $tmp[1];
                }
                $category = "category";
-               if( ereg("-([0-9]*)$",$name,$tmp ) )
+               if( preg_match("%-([0-9]*)$%",$name,$tmp ) )
                {
                        $id = $tmp[1];
                        return( $id );
                }
-               // should already be returning id at this point 
-               // putting the _id on the end of all url's as 
+               // should already be returning id at this point
+               // putting the _id on the end of all url's as
                // the other way is very inifiecent for the database.
                $name = str_replace( "-"," ",$name );
                $query = "select id from $table where trim(lower(replace(replace(replace(replace(replace(replace($category,'\'',''),'/',''),'-',' '),'#',''),'&',''),'?',''))) = '".trim(strtolower($name))."'";
@@ -1809,12 +1809,12 @@ class GLM_TEMPLATE{
 
        /**
        * getCategoryName:
-       * @param $id: 
-       * @param $table: 
-       * @param $&$DB : 
-       * 
-       * @return 
-       * @access 
+       * @param $id:
+       * @param $table:
+       * @param $&$DB :
+       *
+       * @return
+       * @access
        **/
        function get_category_name( $id, $table,&$DB )
        {
@@ -1840,7 +1840,7 @@ class GLM_TEMPLATE{
                {
 
                        $add = '-'.$id;
-                       if( $data[0]['category'] ) 
+                       if( $data[0]['category'] )
                        {
                                $category = $data[0]['category'].$add;
                        }
@@ -1850,7 +1850,7 @@ class GLM_TEMPLATE{
                        }
                        else
                        {
-                               $category = $add; 
+                               $category = $add;
                        }
                        return( $category );
                }
@@ -1859,10 +1859,10 @@ class GLM_TEMPLATE{
 
        /**
        * setNameUrl:
-       * @param $$name : 
-       * 
-       * @return 
-       * @access 
+       * @param $$name :
+       *
+       * @return
+       * @access
        **/
        function set_name_url( $name )
        {
@@ -1876,18 +1876,18 @@ class GLM_TEMPLATE{
        }
 
        /**  valid email
-       Checks for a valid format and good (mx check) 
+       Checks for a valid format and good (mx check)
        email address.
        @param string email the email address as string.
-       @return boolean 
-       */ 
-       function valid_email ($email) { 
-               if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$", $email, $check)) { 
-                       if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) { 
-                               return TRUE; 
-                       } 
-               } 
-               return FALSE; 
+       @return boolean
+       */
+       function valid_email ($email) {
+               if (preg_match("%^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$%i", $email, $check)) {
+                       if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) {
+                               return TRUE;
+                       }
+               }
+               return FALSE;
        }
 }
 ?>
index 31e69f8..93b0e3b 100755 (executable)
@@ -1,4 +1,5 @@
 <?php
+extract($_REQUEST);
 ini_set('include_path', '/usr/share/pear' . ':' .ini_get('include_path'));
 /** @header Gaslight Media Toolbox�
   Media Toolbox(R)
@@ -12,7 +13,7 @@ ini_set('include_path', '/usr/share/pear' . ':' .ini_get('include_path'));
 if( !isset($SITEINFO) )
        {
 
-               if(!isset($DEBUG))      
+               if(!isset($DEBUG))
                {
                        $DEBUG = (isset($mysecretcode) && $mysecretcode == 1234);
                }
@@ -24,9 +25,9 @@ if( !isset($SITEINFO) )
 
                /*
                 *
-                *      Customer Setup 
-                *      Database setup 
-                *      Email Setup 
+                *      Customer Setup
+                *      Database setup
+                *      Email Setup
                 *
                 */
                define("SITENAME","The Lindy"); // used for outputing name of site in admin area
@@ -34,12 +35,12 @@ if( !isset($SITEINFO) )
                define("DB_TYPE", "postgres");  // DB library only knows postgres (FUTURE EXPANSION)
                define("DB_ERROR_MSG", "an error has occured with the database!");      // default error message
                define("MULTIPLE_CAT",0);               // weather or not to use many to many relations
-               define("CAT_LOCK",0);                   // If set to 1 or true will lock the categories 
+               define("CAT_LOCK",0);                   // If set to 1 or true will lock the categories
                define("ENTRIES_PER_PAGE",10);  // default per page number
                define("HTML_HELP_CODE",1);     // this is being depreciated for general help guides
                define("PRODUCTION_MODE","ON"); // used in the email out for contact DB
                define("HTML_EMAIL","ON");      // turn ON for html emails
-               define("ACTIVE_FLAG",1);                // turn on if bus_category table has active bool field 
+               define("ACTIVE_FLAG",1);                // turn on if bus_category table has active bool field
                define("DELUXE_TOOLBOX",1);             // used for the toolbox deluxe vrs.
                define("SEO_URL",1);                    // weather to use Search Engine Optimisezd url's requires .htaccess enabled
                /*
@@ -50,21 +51,32 @@ if( !isset($SITEINFO) )
 
                // Find where this file is located
 
-               $BASE_PATH              = dirname( __FILE__ );
-
-               $CALLED_FROM_DIR        = substr( dirname($HTTP_SERVER_VARS["PATH_TRANSLATED"]), strlen($BASE_PATH) );
-
-               if( ($x = strlen($CALLED_FROM_DIR)) > 0 )
-                       $base_url       = $HTTP_HOST.substr( dirname($SCRIPT_NAME), 0, -strlen($CALLED_FROM_DIR) );
-               else
-               {
-                       $script_name_dir = dirname($SCRIPT_NAME);
-                       if( $script_name_dir == "/" )
-                               $script_name_dir = "";
-                       $base_url       = $HTTP_HOST.$script_name_dir;
-               }
-
-               $BASE_URL = "http://".$base_url;
+               // Find where this file is located
+        $BASE_PATH   = dirname(__FILE__);
+        $php_version = phpversion();
+        // If php5 or above
+        if (version_compare($php_version, '5.0.0', '>')) {
+            $CALLED_FROM_DIR = substr(dirname($_SERVER['SCRIPT_FILENAME']), strlen($BASE_PATH));
+            define('GLM_HOST_ID', $_ENV['GLM_HOST_ID']);
+            define('PHP5', true);
+        } else {
+            $CALLED_FROM_DIR = substr(dirname($HTTP_SERVER_VARS['PATH_TRANSLATED']), strlen($BASE_PATH));
+            define('GLM_HOST_ID', $_SERVER['GLM_HOST_ID']);
+            define('PHP5', false);
+        }
+
+        if (($x = strlen($CALLED_FROM_DIR)) > 0) {
+            $base_url = $_SERVER['HTTP_HOST'] . substr(dirname($_SERVER['SCRIPT_NAME']), 0, -strlen($CALLED_FROM_DIR));
+        } else {
+            $script_name_dir = dirname($_SERVER['SCRIPT_NAME']);
+            if ($script_name_dir == '/') {
+                $script_name_dir = '';
+            }
+            $base_url = $_SERVER['HTTP_HOST'] . $script_name_dir;
+        }
+        // Added to strip any trailing /'s to make sure we don't end up with many
+        $base_url = preg_replace('|/*$|', '', $base_url);
+        $BASE_URL = "http://$base_url";
                $BASE_SECURE_URL = "https://".$base_url;
 
                // Indicate that this file has been referenced
@@ -78,20 +90,20 @@ if( !isset($SITEINFO) )
                 *
                 */
 
-               switch( $GLM_SERVER_ID )
-               {
-
-                       case "devsys.gaslightmedia.com":        
-                               //error_reporting(E_ERROR);
-                       //      ini_set("display_errors","1");
+        switch ($_ENV['GLM_HOST_ID']) {
+        case 'DEVELOPMENT':
+               case "devsys.gaslightmedia.com":
+                       error_reporting(E_ALL ^ E_NOTICE);
+                       ini_set("display_errors","1");
                                // Use the $BASE_URL for secure URL on Devsys
-                               $BASE_SECURE_URL = $BASE_URL;   
-define("CONN_STR","host=devsys dbname=thelindy");
+                               $BASE_SECURE_URL = $BASE_URL;
+define("CONN_STR","host=devdb user=nobody dbname=thelindy");
                                define("OWNER_EMAIL", "ove@gaslightmedia.com,raleigh@gaslightmedia.com");               // site owner's email address
                                define("REPLY_TO", "ove@gaslightmedia.com");                    // the reply-to field for email's
                        break;
 
-                       case "ws1.gaslightmedia.com":
+        case 'PRODUCTION':
+               case "ws1.gaslightmedia.com":
                                error_reporting(0);
                                ini_set("display_errors","0");
                                $BASE_SECURE_URL = "https://".$base_url;
@@ -100,7 +112,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                                define("REPLY_TO", "info@spectrusinc.com");                      // the reply-to field for email's
                        break;
 
-                       default:        // There should be no need for any settings here
+               default:        // There should be no need for any settings here
                        break;
 
                }
@@ -116,28 +128,28 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                define("HELP_IMG",URL_BASE."images/help.gif");          // help image url (depriated)
                define("ORIGINAL_PATH", BASE."images/original/");       // path of original images
                define("RESIZED_PATH", BASE."images/resized/");         // path of first resized image
-               define("MIDSIZED_PATH", BASE."images/midsized/");       // path of half sized of resized 
+               define("MIDSIZED_PATH", BASE."images/midsized/");       // path of half sized of resized
                define("THUMB_PATH", BASE."images/thumb/");                     // path of thumbnail directory
                if( $_SERVER['HTTPS'] == "on" )
                {
                        define("ORIGINAL", $BASE_SECURE_URL."/images/original/");       // url of original images
-                       define("RESIZED", $BASE_SECURE_URL."/images/resized/");         // url of resized 
+                       define("RESIZED", $BASE_SECURE_URL."/images/resized/");         // url of resized
                        define("MIDSIZED", $BASE_SECURE_URL."/images/midsized/");       // url of midsized
                        define("THUMB", $BASE_SECURE_URL."/images/thumb/");                     // url of thumbnail
                }
                else
                {
                        define("ORIGINAL", URL_BASE."images/original/");        // url of original images
-                       define("RESIZED", URL_BASE."images/resized/");          // url of resized 
+                       define("RESIZED", URL_BASE."images/resized/");          // url of resized
                        define("MIDSIZED", URL_BASE."images/midsized/");        // url of midsized
                        define("THUMB", URL_BASE."images/thumb/");                      // url of thumbnail
                }
-               
-               /** these are the image sizing defines USE THESE ONLY 
+
+               /** these are the image sizing defines USE THESE ONLY
                  only allowed string of 'WxH[<>]' [-quality Percentage]
                 */
                define("ITEM_RESIZED", "'287>' -quality 60");           // used in convert call to resize images
-               define("ITEM_MIDSIZED", "'200>' -quality 60");          
+               define("ITEM_MIDSIZED", "'200>' -quality 60");
                define("ITEM_THUMB","'120>' -quality 50");
 
                define("FOOTER_IMG", URL_BASE."images/logosmall.gif");
@@ -272,7 +284,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                $states["YT"] =  "Yukon";
                $states["Asia"] =  "Asia";
                $states["Australia"] =  "Australia";
-               $states["Bahamas"] =  "Bahamas"; 
+               $states["Bahamas"] =  "Bahamas";
                $states["Caribbean"] =  "Caribbean";
                $states["Costa Rica"] =  "Costa Rica";
                $states["South America"] =  "South America";
@@ -290,7 +302,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                {
                        $cfile[$i]=str_replace("\n",'',$cfile[$i]);
                        $cfile[$i]=str_replace("\r",'',$cfile[$i]);
-                       
+
                        $curr_cun=explode(';',$cfile[$i]);      // Still some work to do, because the file is in the wrong order Value=>Key
                        $country_codes[$curr_cun[1]]=$curr_cun[0];
                }
@@ -303,47 +315,47 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                 * @param $Num: Credit Card Number
                 * @param $Name = '': Type of Card
                 * @param $Accepted='' : Accepted array
-                * 
-                * @return bool 
-                * @access 
+                *
+                * @return bool
+                * @access
                 **/
-               function CreditVal($Num, $Name = '', $Accepted='') 
-               { 
+               function CreditVal($Num, $Name = '', $Accepted='')
+               {
                        $Name = strtolower( $Name );
                        $Accepted = strtolower( $Accepted );
                        $GoodCard = 1;
-                       $Num = ereg_replace("[^[:digit:]]", "", $Num); 
-                       switch ($Name) 
-                       { 
+                       $Num = preg_replace("%[^[:digit:]]%", "", $Num);
+                       switch ($Name)
+                       {
 
-                               case "mastercard" : 
-                                       $GoodCard = ereg("^5[1-5].{14}$", $Num); 
-                               break; 
+                               case "mastercard" :
+                                       $GoodCard = preg("%^5[1-5].{14}$%", $Num);
+                               break;
 
-                               case "visa" : 
-                                       $GoodCard = ereg("^4.{15}$|^4.{12}$", $Num); 
-                               break; 
+                               case "visa" :
+                                       $GoodCard = preg("%^4.{15}$|^4.{12}$%", $Num);
+                               break;
 
-                               case "americanexpress" : 
-                                       $GoodCard = ereg("^3[47].{13}$", $Num); 
-                               break; 
+                               case "americanexpress" :
+                                       $GoodCard = preg("%^3[47].{13}$%", $Num);
+                               break;
 
-                               case "discover" : 
-                                       $GoodCard = ereg("^6011.{12}$", $Num); 
-                               break; 
+                               case "discover" :
+                                       $GoodCard = preg("%^6011.{12}$%", $Num);
+                               break;
 
-                               case "dinerscard" : 
-                                       $GoodCard = ereg("^30[0-5].{11}$|^3[68].{12}$", $Num); 
+                               case "dinerscard" :
+                                       $GoodCard = preg("%^30[0-5].{11}$|^3[68].{12}$%", $Num);
                                break;
 
                                default:
-                               if( ereg("^5[1-5].{14}$", $Num) ) $Name = "mastercard";
-                               if( ereg("^4.{15}$|^4.{12}$", $Num) ) $Name = "visa";
-                               if( ereg("^3[47].{13}$", $Num) ) $Name = "americanexpress";
-                               if( ereg("^6011.{12}$", $Num) ) $Name = "discover";
-                               if( ereg("^30[0-5].{11}$|^3[68].{12}$", $Num) ) $Name="dinerscard";
+                               if( preg_match("%^5[1-5].{14}$%", $Num) ) $Name = "mastercard";
+                               if( preg_match("%^4.{15}$|^4.{12}$%", $Num) ) $Name = "visa";
+                               if( preg_match("%^3[47].{13}$%", $Num) ) $Name = "americanexpress";
+                               if( preg_match("%^6011.{12}$%", $Num) ) $Name = "discover";
+                               if( preg_match("%^30[0-5].{11}$|^3[68].{12}$%", $Num) ) $Name="dinerscard";
                                break;
-                       } 
+                       }
 
                        // If there's a limit on card types we accept, check for it here.
                        if( $Accepted )
@@ -357,28 +369,28 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                                if( !$type_verified ) return(FALSE);
                        }
 
-                       $Num = strrev($Num); 
+                       $Num = strrev($Num);
 
-                       $Total = 0; 
+                       $Total = 0;
 
-                       for ($x=0; $x<strlen($Num); $x++) 
-                       { 
-                               $digit = substr($Num,$x,1); 
-                               if ($x/2 != floor($x/2)) 
-                               { 
-                                       $digit *= 2; 
-                                       if (strlen($digit) == 2)  
-                                               $digit = substr($digit,0,1) + substr($digit,1,1); 
-                               } 
-                               $Total += $digit; 
-                       } 
-                       if ($GoodCard && $Total % 10 == 0) 
+                       for ($x=0; $x<strlen($Num); $x++)
                        {
-                               return(true); 
+                               $digit = substr($Num,$x,1);
+                               if ($x/2 != floor($x/2))
+                               {
+                                       $digit *= 2;
+                                       if (strlen($digit) == 2)
+                                               $digit = substr($digit,0,1) + substr($digit,1,1);
+                               }
+                               $Total += $digit;
+                       }
+                       if ($GoodCard && $Total % 10 == 0)
+                       {
+                               return(true);
                        }
-                       else 
+                       else
                        {
-                               return(false); 
+                               return(false);
                        }
                }
                /* DataBase Library */
@@ -386,14 +398,14 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                /**
                 * db_connect :Creates a connection to database specified $conn_str
                 * @param $conn="" : connection string
-                * 
-                * @return index or bool 
-                * @access 
+                *
+                * @return index or bool
+                * @access
                 **/
-               function db_connect($conn="") 
+               function db_connect($conn="")
                {
 
-                       switch (DB_TYPE) 
+                       switch (DB_TYPE)
                        {
                                case "postgres":
                                        if($conn == "")
@@ -408,16 +420,16 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                }
 
                /**
-                * db_close :Closes the connection to database specified by the handle dbd      
-                * @param $$dbd : database handle 
-                * 
-                * @return bool 
-                * @access 
+                * db_close :Closes the connection to database specified by the handle dbd
+                * @param $$dbd : database handle
+                *
+                * @return bool
+                * @access
                 **/
-               function db_close($dbd) 
+               function db_close($dbd)
                {
 
-                       switch (DB_TYPE) 
+                       switch (DB_TYPE)
                        {
                                case "postgres":
                                        $ret = pg_close($dbd);
@@ -432,16 +444,16 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                /**
                        NOTICE DON'T USE THIS
                 * db_pconnect :Creates a persistant connection to database specified in $conn_str
-                * @param $$conn="" : connection string 
-                * 
-                * @return 
-                * @access 
+                * @param $$conn="" : connection string
+                *
+                * @return
+                * @access
                 **/
-               function db_pconnect($conn="") 
+               function db_pconnect($conn="")
                {
                        return( false );
 
-                       switch (DB_TYPE) 
+                       switch (DB_TYPE)
                        {
                                case "postgres":
                                        if($conn == "")
@@ -457,16 +469,16 @@ define("CONN_STR","host=ds1 dbname=thelindy");
 
                /**
                 * db_exec : Execute an SQL query
-                * @param $dbd: database handle 
+                * @param $dbd: database handle
                 * @param $$qs : Query
-                * 
+                *
                 * @return int Returns a valid result index on success 0 on failure
-                * @access 
+                * @access
                 **/
-               function db_exec($dbd, $qs) 
+               function db_exec($dbd, $qs)
                {
 
-                       switch (DB_TYPE) 
+                       switch (DB_TYPE)
                        {
                                case "postgres":
                                        $ret = pg_exec($dbd, $qs);
@@ -480,19 +492,19 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                }
 
                /**
-                * db_fetch_array :Stores the data in associative indices, using the field names as     
+                * db_fetch_array :Stores the data in associative indices, using the field names as
                 * keys.
                 * @param $res: valid database result index
                 * @param $i: row number
-                * @param $$type : database type 
-                * 
+                * @param $$type : database type
+                *
                 * @return array Returns an associative array of key-value pairs
-                * @access 
+                * @access
                 **/
-               function db_fetch_array($res, $i, $type) 
+               function db_fetch_array($res, $i, $type)
                {
 
-                       switch (DB_TYPE) 
+                       switch (DB_TYPE)
                        {
                                case "postgres":
                                        $row = pg_fetch_array($res, $i, $type);
@@ -508,14 +520,14 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                /**
                 * db_freeresult :Free result memory.
                 * @param $$res : valid database result index
-                * 
+                *
                 * @return bool - Returns 1 for success 0 for failure
-                * @access 
+                * @access
                 **/
-               function db_freeresult($res) 
+               function db_freeresult($res)
                {
 
-                       switch (DB_TYPE) 
+                       switch (DB_TYPE)
                        {
                                case "postgres":
                                        $ret = pg_freeresult($res);
@@ -531,14 +543,14 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                /**
                 * db_numrows :Determine number of rows in a result index
                 * @param $$res : valid database result index
-                * 
+                *
                 * @return int - Returns number of rows
-                * @access 
+                * @access
                 **/
-               function db_numrows($res) 
+               function db_numrows($res)
                {
 
-                       switch (DB_TYPE) 
+                       switch (DB_TYPE)
                        {
                                case "postgres":
                                        $ret = pg_numrows($res);
@@ -558,18 +570,18 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                 ***********************************************************************/
 
                /**
-                * db_auto_array :The auto function for retrieving an array based soley on a query      
-                * string. This function makes the connection, does the exec, fetches   
-                * the array, closes the connection, frees memory used by the result,   
+                * db_auto_array :The auto function for retrieving an array based soley on a query
+                * string. This function makes the connection, does the exec, fetches
+                * the array, closes the connection, frees memory used by the result,
                 * and then returns the array
                 * @param $qs: SQL query string
                 * @param $i: row number
                 * @param $$type : PGSQL_ASSOC or PGSQL_BOTH or PSQL_NUM
-                * 
+                *
                 * @return array - Returns an associative array of key-value pairs
-                * @access 
+                * @access
                 **/
-               function db_auto_array($qs, $i, $type) 
+               function db_auto_array($qs, $i, $type)
                {
 
                        $dbd = db_connect();
@@ -595,17 +607,17 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                }
 
                /**
-                * db_auto_exec :The auto function for executing a query.                               
-                * This function makes the connection, does the exec, fetches           
-                * the array, closes the connection, frees memory used by the result,   
+                * db_auto_exec :The auto function for executing a query.
+                * This function makes the connection, does the exec, fetches
+                * the array, closes the connection, frees memory used by the result,
                 * and then returns success (not a valid result index)
                 * @param $qs: SQL query string
                 * @param $$conn="" : Connect String
-                * 
+                *
                 * @return int - Returns 1 (or oid, if available) for success 0 for failure
-                * @access 
+                * @access
                 **/
-               function db_auto_exec($qs, $conn="") 
+               function db_auto_exec($qs, $conn="")
                {
 
                        if($conn == "")
@@ -613,12 +625,12 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                        $dbd = db_connect($conn);
                        if(!$dbd)
                                return(0);
-                       if(!db_exec($dbd, $qs)) 
+                       if(!db_exec($dbd, $qs))
                        {
                                db_close($dbd);
                                return(0);
                        }
-                       else 
+                       else
                        {
                                db_close($dbd);
                                return(1);
@@ -626,18 +638,18 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                }
 
                /**
-                * db_auto_get_data :The auto function for retrieving an array based soley on a query   
-                string. This function makes the connection, does the exec, fetches     
-                the array, closes the connection, frees memory used by the result,     
+                * db_auto_get_data :The auto function for retrieving an array based soley on a query
+                string. This function makes the connection, does the exec, fetches
+                the array, closes the connection, frees memory used by the result,
                 and then returns the array
                 * @param $qs:  SQL query string
                 * @param $CONN_STR: Connect String
                 * @param $$fail_mode=0 : Failure Mode
-                * 
+                *
                 * @return array Returns an associative array of key-value pairs
-                * @access 
+                * @access
                 **/
-               function db_auto_get_data($qs,$conn = CONN_STR,$fail_mode=0) 
+               function db_auto_get_data($qs,$conn = CONN_STR,$fail_mode=0)
                {
 
                        if( !($dbd = db_connect($conn)) )
@@ -658,7 +670,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                        }
 
                        db_close( $dbd );
-                       if(isset($data) && $data!="")   
+                       if(isset($data) && $data!="")
                        {
                                return( $data );
                        }
@@ -671,13 +683,13 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                /* HTML Libraries */
 
                /**
-                * html_footer :Generates a footer table on the bottom of the page it's called on.      
+                * html_footer :Generates a footer table on the bottom of the page it's called on.
                 and closes out the body and html tags.
-                * 
-                * @return void 
-                * @access 
+                *
+                * @return void
+                * @access
                 **/
-               function html_footer() 
+               function html_footer()
                {
                        $footer_table_width = "400";
                        $footer_table_align = "center";
@@ -702,15 +714,15 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                }
 
                /**
-                * html_error :Generates a footer table on the bottom of the page it's called on.       
+                * html_error :Generates a footer table on the bottom of the page it's called on.
                 and closes out the body and html tags.
                 * @param $msg: string error message to be displayed
                 * @param $$bail : bool whether or not to exit() after $msg
-                * 
-                * @return void 
-                * @access 
+                *
+                * @return void
+                * @access
                 **/
-               function html_error($msg, $bail) 
+               function html_error($msg, $bail)
                {
                        ?>
                                <table summary="Error Information" class="errortable" cellspacing="0">
@@ -732,11 +744,11 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                 * html_nav_table :Generates a navigation table on the page it's called on.
                 * @param $nav: associative array with entries like:$nav[text][url]
                 * @param $$w : max width of table
-                * 
-                * @return void 
-                * @access 
+                *
+                * @return void
+                * @access
                 **/
-               function html_nav_table($nav, $w) 
+               function html_nav_table($nav, $w)
                {
                        $nav_table_table_width = "400";
                        $nav_table_table_align = "center";
@@ -747,7 +759,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                                $i = 0;
                        $width = 100 / $w;
 
-                       while(list($text, $url) = each($nav)) 
+                       while(list($text, $url) = each($nav))
                        {
                                $i++;
                                if(($i == (count($nav))) && (($w % $i) != 1))
@@ -782,16 +794,16 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                }
 
                /**
-                * html_header :Opens up the html tags, and includes the style sheet link                       
+                * html_header :Opens up the html tags, and includes the style sheet link
                 generates a header table on the top of the page it's called on.
-                * @param $title: Page Title 
-                * @param $msg: message to display 
+                * @param $title: Page Title
+                * @param $msg: message to display
                 * @param $$img : image to display
-                * 
-                * @return void 
-                * @access 
+                *
+                * @return void
+                * @access
                 **/
-               function html_header($title, $msg, $img) 
+               function html_header($title, $msg, $img)
                {
                        $header_table_width = "400";
                        $header_table_align = "center";
@@ -809,7 +821,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                                <tr class="headertr">
                                <td class="headertd">
                                <?
-                               if($img) 
+                               if($img)
                                {
                                        ?>
                                                <img src="<?echo IMG_BASE.$img?>" alt="<?echo HEAD?>" border="0">
@@ -828,22 +840,22 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                }
 
                /**
-                * form_header :Opens up the form tag, and includes the hidden assoc array as hidden    
+                * form_header :Opens up the form tag, and includes the hidden assoc array as hidden
                 fields.
                 * @param $action: string form action string
                 * @param $method: string Method of form
                 * @param $$hidden = "" : assoc array with $hidden($name => $value)
-                * 
-                * @return void 
-                * @access 
+                *
+                * @return void
+                * @access
                 **/
-               function form_header($action, $method, $hidden = "") 
+               function form_header($action, $method, $hidden = "")
                {
-                       echo "<form action=\"$action\" method=\"$method\" 
+                       echo "<form action=\"$action\" method=\"$method\"
                                enctype=\"multipart/form-data\">";
-                       if($hidden != "" && is_array($hidden)) 
-                       {               
-                               foreach($hidden as $key=>$value) 
+                       if($hidden != "" && is_array($hidden))
+                       {
+                               foreach($hidden as $key=>$value)
                                {
                                        echo "<input type=\"hidden\" name=\"$key\" value=\"$value\">";
                                }
@@ -857,13 +869,13 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                 * @param $$rows = 15: int4 number of rows in textarea box
                 * @param $$cols = 50: int4 number of cols in textarea box
                 * @param $$wrap = "virtual"  : string the wrap value for the textarea box
-                * 
-                * @return void 
-                * @access 
+                *
+                * @return void
+                * @access
                 **/
-               function text_area($name, $value, $rows = 15, $cols = 50, $wrap = "virtual" ) 
+               function text_area($name, $value, $rows = 15, $cols = 50, $wrap = "virtual" )
                {
-                       echo "<td class=\"navtd2\"><textarea id=\"$name\" name=\"$name\" cols=\"$cols\" 
+                       echo "<td class=\"navtd2\"><textarea id=\"$name\" name=\"$name\" cols=\"$cols\"
                                rows=\"$rows\" wrap=\"$wrap\" maxlength=\"8104\">$value</textarea></td>";
                }
 
@@ -872,13 +884,13 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                 * @param $name: string name of text box
                 * @param $value: string value of text box
                 * @param $$size = 35 : string size of text box
-                * 
-                * @return void 
-                * @access 
+                *
+                * @return void
+                * @access
                 **/
-               function text_box($name, $value, $size = 35) 
+               function text_box($name, $value, $size = 35)
                {
-                       echo "<td class=\"navtd2\"><input type=\"text\" name=\"$name\" 
+                       echo "<td class=\"navtd2\"><input type=\"text\" name=\"$name\"
                                value=\"$value\" size=\"$size\"></td>";
                }
 
@@ -886,16 +898,16 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                 * form_footer :Closes up the form tag, and includes the submit button
                 * @param $name: string form action string
                 * @param $$suppress = 0: string Method of form
-                * @param $$cs : int colspan for td 
-                * 
-                * @return void 
-                * @access 
+                * @param $$cs : int colspan for td
+                *
+                * @return void
+                * @access
                 **/
-               function form_footer($name, $suppress = 0, $cs) 
+               function form_footer($name, $suppress = 0, $cs)
                {
                        echo "<tr><td colspan=\"$cs\" align=center>
                                <input type=\"SUBMIT\" name=\"Command\" value=\"$name\">";
-                       if($suppress == 1) 
+                       if($suppress == 1)
                        {
                                echo "<input type=\"SUBMIT\" name=\"Command\" value=\"Delete\">";
                        }
@@ -906,21 +918,21 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                /* Graphics Libraries */
 
                /**
-                * process_image :Main function for image processing                                    
-                * NOTES:                                                               
-                * This function does the following:                       
+                * process_image :Main function for image processing
+                * NOTES:
+                * This function does the following:
                 *
-                * 1) places image into original folder                    
+                * 1) places image into original folder
                 *
                 * 2) makes three images from original size and places them
                 * into the RESIZED, MIDSIZED, and THUMB folders
                 * @param $image: The variable of the image being post from the form
                 * @param $$image_name : The variable_name of the image being post
-                * 
+                *
                 * @return string - Returns $image_name
-                * @access 
+                * @access
                 **/
-               function process_image ($image,$image_name) 
+               function process_image ($image,$image_name)
                {
                        /*      LOOK for these as defined in the top of this page
                                $ITEM_ORIGINAL = "'600>' -quality 60";
@@ -928,19 +940,19 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                                $ITEM_MIDSIZED = "'210>' -quality 60";
                                $ITEM_THUMB = "'120>' -quality 50";
                         */
-                       if(!defined("ORIGINAL_PATH")) 
+                       if(!defined("ORIGINAL_PATH"))
                        {
                                html_error("this not defined original_path",1);
                        }
-                       if(!defined("RESIZED_PATH")) 
+                       if(!defined("RESIZED_PATH"))
                        {
                                html_error("this not defined resized_path",1);
                        }
-                       if(!defined("MIDSIZED_PATH")) 
+                       if(!defined("MIDSIZED_PATH"))
                        {
                                html_error("this not defined midsized_path",1);
                        }
-                       if(!defined("THUMB_PATH")) 
+                       if(!defined("THUMB_PATH"))
                        {
                                html_error("this not defined thumb_path",1);
                        }
@@ -958,11 +970,11 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                 * @param $image: path to image which needs to be resized
                 * @param $thumb: path where resized image will live
                 * @param $$size : using axis size of new image
-                * 
-                * @return array $img_resize_array 
-                * @access 
+                *
+                * @return array $img_resize_array
+                * @access
                 **/
-               function img_resize($path2image,$path2thumb,$size) 
+               function img_resize($path2image,$path2thumb,$size)
                {
                        exec( "type convert", $output, $return );
                        if( $return == 0 )
@@ -987,33 +999,33 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                }
 
                /**
-                * img_upload :Function moves the image to the destination directory 
-                Checking to make sure that it does not have same named file in dicectory.                      
+                * img_upload :Function moves the image to the destination directory
+                Checking to make sure that it does not have same named file in dicectory.
                 Image must be either jpg ,png or gif format file to be uploaded.
                 * @param $form_field: $form_field of image
                 * @param $img_name: $form_field of image with _name
                 * @param $$destination_path : path to store uploaded image
-                * 
+                *
                 * @return array $img_upload_array
-                * @access 
+                * @access
                 **/
-               function img_upload($form_field,$img_name,$destination_path) 
+               function img_upload($form_field,$img_name,$destination_path)
                {
-                       if (ereg("[!@#$%^&()+={};:\'\" ]",$img_name)) 
+                       if (preg_match("%[!@#$\%^&()+={};:\'\" ]%",$img_name))
                        {
-                               $img_name = ereg_replace("[!@#$%^&()+={};:\'\" ]","-",$img_name);
+                               $img_name = preg_replace("%[!@#$\%^&()+={};:\'\" ]%","-",$img_name);
                        }
 
                        $size = getImageSize($form_field);
 
-                       if( $size[2] == 1 || $size[2] == 2 || $size[2] == 3 ) 
+                       if( $size[2] == 1 || $size[2] == 2 || $size[2] == 3 )
                        {
                                $i = "0";
                                $d = dir($destination_path);
                                $img_name_in_use = "FALSE";
-                               while($entry=$d->read()) 
+                               while($entry=$d->read())
                                {
-                                       if ($entry == $img_name) 
+                                       if ($entry == $img_name)
                                        {
                                                $img_name_in_use = "TRUE";
                                        }
@@ -1021,7 +1033,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                                }
                                $d->close();
 
-                               if ($img_name_in_use == "TRUE") 
+                               if ($img_name_in_use == "TRUE")
                                {
                                        $new_img_name = mktime().$img_name;
                                        $new_img_location = $destination_path.'/'.$new_img_name;
@@ -1032,7 +1044,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
 
                                        $img_upload_array = array("$new_img_name","$new_img_location");
                                }
-                               else 
+                               else
                                {
                                        $new_img_name = $img_name;
                                        $new_img_location = $destination_path.'/'.$new_img_name;
@@ -1044,7 +1056,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                                        $img_upload_array = array("$new_img_name","$new_img_location");
                                }
                        }
-                       else 
+                       else
                        {
                                echo '<p style="background-color:red;color:white;">'
                                        .'The file you uploaded was of an incorect type, please only upload .gif,.png or .jpg files'
@@ -1064,23 +1076,23 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                 * @param $form_field: $form_field of image
                 * @param $file_name: $form_field of image with _name
                 * @param $$destination_path : path to store uploaded image
-                * 
+                *
                 * @return string $file_upload
-                * @access 
+                * @access
                 **/
-               function file_upload($form_field,$file_name,$destination_path) 
+               function file_upload($form_field,$file_name,$destination_path)
                {
-                       if (ereg("[!@#$%^&()+={};:\'\" ]",$file_name)) 
+                       if (preg_match("%[!@#$\%^&()+={};:\'\" ]%",$file_name))
                        {
-                               $file_name = ereg_replace("[!@#$%^&()+={};:\'\" ]","_",$file_name);
+                               $file_name = preg_replace("%[!@#$\%^&()+={};:\'\" ]:","_",$file_name);
                        }
 
                        $i = "0";
                        $d = dir($destination_path);
                        $file_name_in_use = "FALSE";
-                       while($entry=$d->read()) 
+                       while($entry=$d->read())
                        {
-                               if ($entry == $file_name) 
+                               if ($entry == $file_name)
                                {
                                        $file_name_in_use = "TRUE";
                                }
@@ -1088,7 +1100,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                        }
                        $d->close();
 
-                       if ($file_name_in_use == "TRUE") 
+                       if ($file_name_in_use == "TRUE")
                        {
                                $new_file_name = mktime().$file_name;
                                $new_file_location = $destination_path.'/'.$new_file_name;
@@ -1099,7 +1111,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
 
                                $file_upload = $new_file_name;
                        }
-                       else 
+                       else
                        {
                                $new_file_name = $file_name;
                                $new_file_location = $destination_path.'/'.$new_file_name;
@@ -1118,26 +1130,26 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                /**
                 * http_strip :Strips the http:// part from start of string
                 * @param $&$string : $string
-                * 
+                *
                 * @return string $stirng minus http:// in front
-                * @access 
+                * @access
                 **/
-               function http_strip(&$string) 
+               function http_strip(&$string)
                {
                        $test_string = strtolower($string);
-                       if(substr($test_string,0,7) == "http://") 
+                       if(substr($test_string,0,7) == "http://")
                        {
                                $string = substr($string,7);
                        }
                }
 
                /**
-                * footer : used for admin page footer to close out the top function 
-                * 
-                * @return void 
-                * @access 
+                * footer : used for admin page footer to close out the top function
+                *
+                * @return void
+                * @access
                 **/
-               function footer() 
+               function footer()
                {
                        ?>
                                </td>
@@ -1160,11 +1172,11 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                 * @param $message: The title
                 * @param $hp: The help file to use
                 * @param $$hp2 = NULL : The help file to use (links to gaslightmedia.com)
-                * 
-                * @return void 
-                * @access 
+                *
+                * @return void
+                * @access
                 **/
-               function top($message, $hp,$hp2 = NULL) 
+               function top($message, $hp,$hp2 = NULL)
                {
                        ?>
                                <html>
@@ -1176,7 +1188,7 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                                echo '
                                <script type="text/javascript" language="JavaScript">
                                _editor_url = "'.URL_BASE.'admin/htmlarea/";
-                       </script>'; 
+                       </script>';
 
                        echo '<script type="text/javascript" src="'.URL_BASE.'admin/htmlarea/htmlarea.js"></script>';
                        echo '<script type="text/javascript" src="'.URL_BASE.'admin/htmlarea/lang/en.js"></script>';
@@ -1207,10 +1219,10 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                                if($hp2 != "")
                                {
                                        echo '<a style="color:white;"
-                                               href="http://www.gaslightmedia.com/manuals/html/'.$hp2.'.html" 
+                                               href="http://www.gaslightmedia.com/manuals/html/'.$hp2.'.html"
                                                target="_blank">Online Help Guide</a>&nbsp;';
                                        echo '<a style="color:white;"
-                                               href="http://www.gaslightmedia.com/manuals/pdf/'.$hp2.'.pdf" 
+                                               href="http://www.gaslightmedia.com/manuals/pdf/'.$hp2.'.pdf"
                                                target="_blank">Printable Help Guide</a>';
                                }
                                else
@@ -1246,14 +1258,14 @@ define("CONN_STR","host=ds1 dbname=thelindy");
 
                /**
                 * top2 : alias to top()
-                * @param $message: message title 
-                * @param $hp: help file 
+                * @param $message: message title
+                * @param $hp: help file
                 * @param $$hp2 = NULL : gaslight help file
-                * 
-                * @return 
-                * @access 
+                *
+                * @return
+                * @access
                 **/
-               function top2($message, $hp,$hp2 = NULL) 
+               function top2($message, $hp,$hp2 = NULL)
                {
                        // make this an alias to top()
                        // by calling top instead of adding extra code
@@ -1372,9 +1384,9 @@ define("CONN_STR","host=ds1 dbname=thelindy");
                   * htmlcode: generator for the javascript code to be called after the textareas
                   * to set up htmlarea
                   * do not use insertimage
-                  * 
-                  * @return 
-                  * @access 
+                  *
+                  * @return
+                  * @access
                   **/
                function htmlcode()
                {
@@ -1383,7 +1395,7 @@ echo '
 <style type="text/css">
     /*<![CDATA[*/
         <!--
-                .textarea { height: '.$h.' px; width: '.$w.' px; } 
+                .textarea { height: '.$h.' px; width: '.$w.' px; }
         -->
         /*]]>*/
     </style>
@@ -1428,7 +1440,7 @@ echo '
                  echo '
      initdocument = function () {
         var editor = new HTMLArea("description");
-  
+
                ';
 
        echo '
@@ -1454,7 +1466,7 @@ echo '
          }
                  echo ', "htmlmode", "separator",
                  "copy", "cut", "paste", "space", "undo", "redo" ]
-       ];      
+       ];
        ';
                if( HTMLAREA_CONTEXT_MENU )
                {
@@ -1471,31 +1483,31 @@ echo '
                if( HTMLAREA_TABLES )
                {
   echo '
-  
+
   // register the TableOperations plugin
-  editor.registerPlugin(TableOperations); 
+  editor.registerPlugin(TableOperations);
   ';
                }
          if( HTMLAREA_CHARACTER_MAP )
          {
   echo '
-  
+
   // register the CharacterMap plugin
-  editor.registerPlugin(CharacterMap); 
+  editor.registerPlugin(CharacterMap);
   ';
          }
   echo '
   editor.generate();
-      } 
+      }
         function addEvent(obj, evType, fn)
-        { 
-                if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; } 
-                else if (obj.attachEvent) {  var r = obj.attachEvent("on"+evType, fn);  return r;  } 
-                else {  return false; } 
-        } 
+        {
+                if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; }
+                else if (obj.attachEvent) {  var r = obj.attachEvent("on"+evType, fn);  return r;  }
+                else {  return false; }
+        }
         addEvent(window, \'load\', initdocument);
     //]]>
-    </script>  
+    </script>
                                ';
        /*
                        echo "<script type=\"text/javascript\" src=\"".BASE_URL."admin/htmlarea/plugins/CharacterMap/character-map.js\"></script>
@@ -1507,7 +1519,7 @@ echo '
                                HTMLArea.loadPlugin(\"CharacterMap\");
                                HTMLArea.loadPlugin(\"TableOperations\");
                                HTMLArea.loadPlugin(\"ImageManager\");
-                               var editor = new HTMLArea(\"editor\");  
+                               var editor = new HTMLArea(\"editor\");
                                var config = new HTMLArea.Config();
                        editor.registerPlugin(\"CharacterMap\");
                        editor.registerPlugin(\"TableOperations\");
@@ -1536,34 +1548,34 @@ echo '
                /**
                 * date_entry : Generate the select boxes for date entry
                 * month-day-year as drop down select
-                * @param $month: 
-                * @param $day: 
-                * @param $year: 
-                * @param $month_name: name of select month 
-                * @param $day_name: name of select day 
+                * @param $month:
+                * @param $day:
+                * @param $year:
+                * @param $month_name: name of select month
+                * @param $day_name: name of select day
                 * @param $$year_name : name of select year
-                * 
-                * @return 
-                * @access 
+                *
+                * @return
+                * @access
                 **/
-               function date_entry($month,$day,$year,$month_name,$day_name,$year_name) 
+               function date_entry($month,$day,$year,$month_name,$day_name,$year_name)
                {
                        $cur_date = getdate();
 
-                       if($month == "") 
+                       if($month == "")
                        {
                                $month = $cur_date['mon'];
                        }
-                       if($day == "") 
+                       if($day == "")
                        {
                                $day = $cur_date['mday'];
-                       }       
-                       if($year == "") 
+                       }
+                       if($year == "")
                        {
                                $year = $cur_date['year'];
                        }
                        $date = '<SELECT NAME="'.$month_name.'">';
-                       for($i=1;$i<13;$i++) 
+                       for($i=1;$i<13;$i++)
                        {
                                $date .= '<OPTION VALUE="';
                                if($i < 10)
@@ -1571,34 +1583,34 @@ echo '
                                        $date .= "0";
                                }
                                $date .= $i.'"';
-                               if($i == $month) 
+                               if($i == $month)
                                {
                                        $date .= ' SELECTED';
                                }
-                               $date .= '>'.$i;        
+                               $date .= '>'.$i;
                        }
                        $date .= '</SELECT>';
                        $date .= '<SELECT NAME="'.$day_name.'">';
-                       for($i=1;$i<32;$i++) 
+                       for($i=1;$i<32;$i++)
                        {
                                $date .= '<OPTION VALUE="';
-                               if($i < 10) 
+                               if($i < 10)
                                {
                                        $date .= "0";
                                }
                                $date .= $i.'"';
-                               if($i == $day) 
+                               if($i == $day)
                                {
                                        $date .= ' SELECTED';
                                }
-                               $date .= '>'.$i;        
-                       }       
+                               $date .= '>'.$i;
+                       }
                        $date .= '</SELECT>';
                        $date .= '<SELECT NAME="'.$year_name.'">';
-                       for($i=2000;$i<2023;$i++) 
+                       for($i=2000;$i<2023;$i++)
                        {
                                $date .= '<OPTION VALUE="'.$i.'"';
-                               if($i == $year) 
+                               if($i == $year)
                                {
                                        $date .= ' SELECTED';
                                }
@@ -1606,38 +1618,38 @@ echo '
                        }
                        $date .= '</SELECT>';
                        return $date;
-               }       
+               }
 
                /**
                 * contact_date_entry : build select boxes for date entry going backwords in years
-                * @param $month: 
-                * @param $day: 
-                * @param $year: 
+                * @param $month:
+                * @param $day:
+                * @param $year:
                 * @param $month_name: name of select month
                 * @param $day_name: name of select day
                 * @param $$year_name : name of select year
-                * 
+                *
                 * @return void
-                * @access 
+                * @access
                 **/
-               function contact_date_entry($month,$day,$year,$month_name,$day_name,$year_name) 
+               function contact_date_entry($month,$day,$year,$month_name,$day_name,$year_name)
                {
                        $cur_date = getdate();
 
-                       if($month == "") 
+                       if($month == "")
                        {
                                $month = $cur_date['mon'];
                        }
-                       if($day == "") 
+                       if($day == "")
                        {
                                $day = $cur_date['mday'];
-                       }       
-                       if($year == "") 
+                       }
+                       if($year == "")
                        {
                                $year = $cur_date['year'];
                        }
                        $date = '<SELECT NAME="'.$month_name.'">';
-                       for($i=1;$i<13;$i++) 
+                       for($i=1;$i<13;$i++)
                        {
                                $date .= '<OPTION VALUE="';
                                if($i < 10)
@@ -1645,35 +1657,35 @@ echo '
                                        $date .= "0";
                                }
                                $date .= $i.'"';
-                               if($i == $month) 
+                               if($i == $month)
                                {
                                        $date .= ' SELECTED';
                                }
-                               $date .= '>'.$i;        
+                               $date .= '>'.$i;
                        }
                        $date .= '</SELECT>';
                        $date .= '<SELECT NAME="'.$day_name.'">';
-                       for($i=1;$i<32;$i++) 
+                       for($i=1;$i<32;$i++)
                        {
                                $date .= '<OPTION VALUE="';
-                               if($i < 10) 
+                               if($i < 10)
                                {
                                        $date .= "0";
                                }
                                $date .= $i.'"';
-                               if($i == $day) 
+                               if($i == $day)
                                {
                                        $date .= ' SELECTED';
                                }
-                               $date .= '>'.$i;        
-                       }       
+                               $date .= '>'.$i;
+                       }
                        $date .= '</SELECT>';
                        $date .= '<SELECT NAME="'.$year_name.'">';
                        $ystart = $cur_date['year'] - 10;
-                       for($i=$ystart;$i<=$year;$i++) 
+                       for($i=$ystart;$i<=$year;$i++)
                        {
                                $date .= '<OPTION VALUE="'.$i.'"';
-                               if($i == $year) 
+                               if($i == $year)
                                {
                                        $date .= ' SELECTED';
                                }
@@ -1685,35 +1697,35 @@ echo '
 
                /**
                 * time_entry : build select boxes for time entry
-                * @param $H: 
-                * @param $m: 
-                * @param $F: 
+                * @param $H:
+                * @param $m:
+                * @param $F:
                 * @param $H_name: name of select hour
                 * @param $m_name: name of select min
                 * @param $$F_name : name of select sec
-                * 
-                * @return 
-                * @access 
+                *
+                * @return
+                * @access
                 **/
-               function time_entry($H,$m,$F,$H_name,$m_name,$F_name) 
+               function time_entry($H,$m,$F,$H_name,$m_name,$F_name)
                {
                        $cur_date = getdate();
 
-                       if($H == "") 
+                       if($H == "")
                        {
                                $H = $cur_date['hours'];
                        }
-                       if($m == "") 
+                       if($m == "")
                        {
                                $m = $cur_date['minutes'];
-                       }       
-                       if($H>12) 
+                       }
+                       if($H>12)
                        {
                                $F = "PM";
                                $H = $H - 12;
                        }
                        $time = "Hr:<SELECT NAME=\"$H_name\" size=\"1\">";
-                       for($i=1;$i<=12;$i++) 
+                       for($i=1;$i<=12;$i++)
                        {
                                $time .= "<OPTION VALUE=\"";
                                if($i < 10)
@@ -1721,43 +1733,43 @@ echo '
                                        $time .= "0";
                                }
                                $time .= "$i\"";
-                               if($i == $H) 
+                               if($i == $H)
                                {
                                        $time .= " SELECTED";
                                }
-                               $time .= ">$i\n";       
+                               $time .= ">$i\n";
                        }
                        $time .= "</SELECT>\n";
                        $time .= "Min:<SELECT NAME=\"$m_name\" size=\"1\">";
-                       for($i=0;$i<60;$i=$i+15) 
+                       for($i=0;$i<60;$i=$i+15)
                        {
                                $time .= "<OPTION VALUE=\"";
-                               if($i < 10) 
+                               if($i < 10)
                                {
                                        $time .= "0";
                                }
                                $time .= "$i\"";
-                               if($i == $m) 
+                               if($i == $m)
                                {
                                        $time .= " SELECTED";
                                }
                                $time .= ">";
-                               if($i < 10) 
+                               if($i < 10)
                                {
                                        $time .= "0";
                                }
-                               $time .= "$i\n";        
-                       }       
+                               $time .= "$i\n";
+                       }
                        $time .= "</SELECT>";
                        $time .= "<SELECT NAME=\"$F_name\" size=\"1\">";
                        $time .= "<OPTION VALUE=\"AM\"";
-                       if($F == "AM") 
+                       if($F == "AM")
                        {
                                $time .= " SELECTED";
                        }
                        $time .= ">AM\n";
                        $time .= "<OPTION VALUE=\"PM\"";
-                       if($F == "PM") 
+                       if($F == "PM")
                        {
                                $time .= " SELECTED";
                        }
@@ -1769,21 +1781,21 @@ echo '
                /**
                 * get_parentid: get the (highest level) parent category for this id
                 * @param $id: id from bus_category table
-                * 
-                * @return int parent  
-                * @access 
+                *
+                * @return int parent
+                * @access
                 **/
                function get_parentid( $id )
                {
                        static $parentshow;
                        if( $id == 0 )
                        {
-                               return( 0 );            
+                               return( 0 );
                        }
                        if(!is_array($parentshow))
                        {
                                $qs = "select parent from bus_category where id = $id";
-                               $parentrow = db_auto_get_data( $qs );     
+                               $parentrow = db_auto_get_data( $qs );
                        }
                        if($parentrow[0]['parent'] == 0)
                        {
@@ -1803,9 +1815,9 @@ echo '
                 * @param $$type = "standard": type Standard,multi
                 * @param $$auto = 0: auto
                 * @param $$width = NULL : width width controlled by css
-                * 
-                * @return void 
-                * @access 
+                *
+                * @return void
+                * @access
                 **/
                function build_picklist( $fieldname, $data, $selected, $type = "standard",$auto = 0,$width = NULL )
                {
@@ -1825,7 +1837,7 @@ echo '
                        {
                                case "multiple":
                                        $str = "<SELECT NAME=\"".$fieldname."\" multiple size=\"10\" ".$autosubmit.">\n";
-                               while( list($key, $val) = each($data) ) 
+                               while( list($key, $val) = each($data) )
                                {
                                        if( in_array($key,$sel) )
                                        {
@@ -1838,7 +1850,7 @@ echo '
                                break;
                                case "simple":
                                        $str = "<SELECT NAME=\"$fieldname\" ".$autosubmit.">\n";
-                               for( $i=0 ; $i<count($data) ; $i++ ) 
+                               for( $i=0 ; $i<count($data) ; $i++ )
                                {
                                        $select = (in_array($data[$i],$sel)) ? " SELECTED ":"";
                                        $str .= "       <OPTION VALUE=\"".$data[$i]."\"".$select.">".$data[$i]."\n";
@@ -1848,7 +1860,7 @@ echo '
                                case "standard":
                                default:
                                        $str = "<SELECT NAME=\"$fieldname\" ".$autosubmit.">\n";
-                                       while( list($key, $val) = each($data) ) 
+                                       while( list($key, $val) = each($data) )
                                        {
                                                $select = (in_array($key,$sel)) ? " SELECTED ":"";
                                                $str .= "       <OPTION VALUE=\"$key\"".$select.">$val\n";
@@ -1862,29 +1874,29 @@ echo '
                }
 
                /**
-                * create_page_links:Create prev and next links 
+                * create_page_links:Create prev and next links
                 * to page through the results.
                 * @param $totalnum: The total result of the query
                 * @param $num: The total result for the page
                 * @param $$start=0: The starting num defaults to 0
                 * @param $params: variables to add to the url
                 * @param $ENTRIES_PER_PAGE: number of items on page defaults to the ENTRIES_PER_PAGE
-                * 
-                * @return string of links 
-                * @access 
+                *
+                * @return string of links
+                * @access
                 **/
                function create_page_links($totalnum,$num,$start=0,$params,$page_length=ENTRIES_PER_PAGE)
                {
                        // find out which page we're on.
                        if($totalnum!=0)
-                       {  
-                               $total_pages = floor($totalnum / $page_length);         // total pages = the total result divided by page length rounded down 
+                       {
+                               $total_pages = floor($totalnum / $page_length);         // total pages = the total result divided by page length rounded down
                                $total_pages++;                                                                         // then add one
                                if($start == 0)                                                                         // if start is 0 then page is one
                                {
-                                       $page = 1;                                                                              
+                                       $page = 1;
                                }
-                               else    
+                               else
                                {
                                        $page = ($start / $page_length) + 1;
                                }
@@ -1898,10 +1910,10 @@ echo '
                        {
                                $end = $totalnum;
                        }
-                       $last = $start - $page_length;  
+                       $last = $start - $page_length;
                        if(($start - $page_length) < 0)
                                $prev = "";
-                       else    
+                       else
                                $prev = "<span class=\"accenttext\">[</span><a class=\"small\"
                                        href=\"$GLOBALS[PHP_SELF]?start=".$last."&$params\">PREVIOUS PAGE</a><span
                                        class=\"accenttext\"> ]</span>";
@@ -1909,14 +1921,14 @@ echo '
                                $next = "<span class=\"accenttext\">[</span><a class=\"small\"
                                        href=\"$GLOBALS[PHP_SELF]?start=".$end."&$params\">NEXT PAGE</a><span
                                        class=\"accenttext\"> ]</span>";
-                       else    
+                       else
                                $next = "";
-                       $starting = $start + 1; 
+                       $starting = $start + 1;
                        $last_c = $start + $num;
                        $links = '<center><span class="pagetitle">Listings Displayed: </span><span
                                class="accenttext">'.$starting.' to '.$last_c.'</span>
-                               <span class="pagetitle"> of '.$totalnum.'<br></span> '.$prev. ' &nbsp; <span 
-                               class="pagetitle"></span> '.$next.'<BR></span></center>';       
+                               <span class="pagetitle"> of '.$totalnum.'<br></span> '.$prev. ' &nbsp; <span
+                               class="pagetitle"></span> '.$next.'<BR></span></center>';
                        return($links);
                }
        }
index 652335d..0daca90 100755 (executable)
@@ -1,16 +1,16 @@
 <?php
 /*
  * =====================================================================================
- * 
+ *
  *        Filename:  sitemap.inc
- * 
+ *
  *     Description:  output site map for Petoskey Chamber
- * 
+ *
  *         Version:  1.0
  *         Created:  09/30/2004 04:07:26 PM EDT
  *        Revision:  none
- * 
- *         Company: Gaslight Media  
+ *
+ *         Company: Gaslight Media
  *<style type="text/css">
 <!--
 div#sitemap {width: 100%;overflow:hidden;font-family: arial, helvetica, sans-serif; font-size: 12px;}
@@ -28,12 +28,12 @@ div#sitemap dt a:active {color: #369;}
 div#sitemap dt a:hover {color: #000;}
 div#sitemap dd {margin: 0; padding: 0;}
 -->
-</style> 
+</style>
  * =====================================================================================
  */
 
 class Thread
-{    
+{
        var $begin_level = "<ul>";
     var $end_level = "</ul>";
     var $begin_item = "<li>";
@@ -41,11 +41,11 @@ class Thread
     var $whole_thread;
        var $search = "";
        var $DB;
-       
+
     function Thread($code="",&$DB)
-    {    
+    {
                if(!empty($code))
-        {    
+        {
                        $this->begin_level = $code[begin_level];
             $this->end_level = $code[end_level];
             $this->begin_item = $code[begin_item];
@@ -59,7 +59,7 @@ class Thread
     }
 
     function sortChilds($threads)
-    {    
+    {
                while(list($var, $value) = each($threads))
             $childs[$value[parent]][$value[id]] = $value;
         return $childs;
@@ -69,22 +69,22 @@ class Thread
           * convertToThread: outputs the array with the correct styles and code applied
           * @param $threads: Thread array
           * @param $thread: Start with thread[0] will work it way down
-          * 
+          *
           * @return whole_thread
-          * @access public 
+          * @access public
           **/
     function convertToThread($threads, $thread)
-    {    
+    {
                global $toolbox;
                static $p;
                $this->whole_thread .= $this->begin_level;
         while(list($parent, $value) = each($thread))
-        {    
+        {
                        $this->whole_thread .= $this->begin_item . "<dl><dt>" ;
-                       
+
                        $category = $toolbox->get_seo_url( $value['id'] );
-                       $this->whole_thread .= '<a href="'.$category.'">'; 
-                       $this->whole_thread .= $value["category"] 
+                       $this->whole_thread .= '<a href="'.$category.'">';
+                       $this->whole_thread .= $value["category"]
                        . "</a></dt><dd>".$value["descr"]."..</dd></dl>"
                        . $this->end_item ."\n";
             if($threads[$parent] )
@@ -100,15 +100,15 @@ function sitemap_keyword_replace($string)
        {
                if($search = strstr($string,"{"))
                {
-                       if(ereg("\{([A-Za-z0-9\&\-\,\'\" ]*)\}",$string,$needle))
+                       if(preg_match("%\{([A-Za-z0-9\&\-\,\'\" ]*)\}%",$string,$needle))
                        {
                                if($needle[0] != "")
-                               {               
+                               {
                                        $qs = "SELECT   id,category
                                        FROM            bus_category
                                        WHERE   trim(keyword) = '".trim($needle[1])."'";
 
-                                       $keyres = $GLOBALS['toolbox']->DB->db_auto_get_data($qs);                                       
+                                       $keyres = $GLOBALS['toolbox']->DB->db_auto_get_data($qs);
                                        if($keyres[0]['id']==1)
                                        {
                                                $page="";
@@ -116,14 +116,14 @@ function sitemap_keyword_replace($string)
                                        $replacement = "".$keyres[0]['category']."";
                                        $string = str_replace($needle[0],$replacement,$string);
                                }
-                       }               
+                       }
                        else{
                                return($string);
                        }
                        if($search = strstr($string,"{"))
                        return($this->sitemap_keyword_replace($string));
-               }       
-               return($string);        
+               }
+               return($string);
        }
 if( $nf == 1 )
        {
@@ -132,15 +132,15 @@ if( $nf == 1 )
 function make_teaser($text, $maxlength, $strip_tags=FALSE)
 {
     if($strip_tags){ $text = strip_tags($text); }
-    
+
     if(strlen($text) > $maxlength)
-    {     
+    {
         $pos = strpos($text, ' ', $maxlength);
         $text = substr($text, 0, $pos);
     }
-    
+
     return $text;
-} 
+}
 $query = "select * from bus_category order by parent,pos";
 $data = $toolbox->DB->db_auto_get_data($query);
 if(is_array($data))
@@ -159,7 +159,7 @@ if(is_array($data))
        }
 $links = array("begin_level" => "<ul>","end_level" => "</ul>","begin_item" => "<li>","end_item" => "</li>");
 if(is_array($threads)) {
-       $myThread = new Thread($links,&$toolbox->DB); 
+       $myThread = new Thread($links,&$toolbox->DB);
        $converted = $myThread->sortChilds($threads); //sort threads by parent
        print $myThread->convertToThread($converted, $converted[0]); //print the threads
 }