From 76dd115bd02080044e739b5249332780a5aa06e3 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 30 Dec 2016 16:03:50 -0500 Subject: [PATCH] Update for php version changes. Update all ereg or ereg_replace funcions to preg_match and preg_replace. Update Toolbox for php version updates. --- admin/Toolbox/edit_bus.phtml | 3 +- admin/Toolbox/edit_bus_category.phtml | 2 +- admin/Toolbox/index.phtml | 2 +- admin/Toolbox/list_bus_category.phtml | 41 +- admin/Toolbox/update_bus.phtml | 52 +- admin/Toolbox/update_bus_category.phtml | 6 +- classes/class_db.inc | 116 ++-- classes/class_events.inc | 118 ++-- classes/class_tellfriend.inc | 50 +- classes/class_template.inc | 552 +++++++++--------- classes/glm-Events-calendar-2-0.phtml | 50 +- setup.phtml | 718 ++++++++++++------------ 12 files changed, 858 insertions(+), 852 deletions(-) diff --git a/admin/Toolbox/edit_bus.phtml b/admin/Toolbox/edit_bus.phtml index 37b73a0..444aff8 100755 --- a/admin/Toolbox/edit_bus.phtml +++ b/admin/Toolbox/edit_bus.phtml @@ -98,7 +98,8 @@ else echo ""; echo ""; - if(isset($id) && $id != "") { + if(isset($id) && $id != ""){ + $oldalt = array(); $qs = "SELECT bc.id as catid, bcb.id as id,bc.category,bcb.pos FROM bus_category bc,bus_category_bus bcb,bus b WHERE bcb.busid = $id diff --git a/admin/Toolbox/edit_bus_category.phtml b/admin/Toolbox/edit_bus_category.phtml index 405b68e..9c6fd27 100755 --- a/admin/Toolbox/edit_bus_category.phtml +++ b/admin/Toolbox/edit_bus_category.phtml @@ -127,7 +127,7 @@ foreach($row as $key=>$value) { case "keyword": echo ""; - text_box("keyword",$value); + text_box("keyword",htmlspecialchars($value)); echo ""; break; diff --git a/admin/Toolbox/index.phtml b/admin/Toolbox/index.phtml index 550afb8..5d3a295 100755 --- a/admin/Toolbox/index.phtml +++ b/admin/Toolbox/index.phtml @@ -1,3 +1,3 @@ - diff --git a/admin/Toolbox/list_bus_category.phtml b/admin/Toolbox/list_bus_category.phtml index 62ad8cf..afebad8 100755 --- a/admin/Toolbox/list_bus_category.phtml +++ b/admin/Toolbox/list_bus_category.phtml @@ -1,23 +1,18 @@
Pages:
Keyword:
-
- diff --git a/admin/Toolbox/update_bus.phtml b/admin/Toolbox/update_bus.phtml index 70aebb5..e529ef5 100755 --- a/admin/Toolbox/update_bus.phtml +++ b/admin/Toolbox/update_bus.phtml @@ -15,7 +15,7 @@ $location = "../list_bus.phtml?catid=$catid"; http_strip($url); -if( $REQUEST_METHOD == "POST" || $Command == "Move" ) { +if( $_POST || $Command == "Move" ) { switch($Command) { @@ -86,13 +86,13 @@ if( $REQUEST_METHOD == "POST" || $Command == "Move" ) { break; case "Update": - $oldcatid = ereg_replace("^:","",$oldcatid); - $oldcatid = split(":",$oldcatid); + $oldcatid = preg_replace("%^:%","",$oldcatid); + $oldcatid = preg_split("%:%",$oldcatid); if($category) { - $category = ereg_replace("^:","",$category); - $catid = split(":",$category); + $category = preg_replace("%^:%","",$category); + $catid = preg_split("%:%",$category); } /* echo "
";
@@ -287,8 +287,8 @@ if(	$REQUEST_METHOD == "POST" || $Command == "Move"	) {
 		case "Insert":
 			if($category)
 			{
-				$category = ereg_replace("^:","",$category);
-				$catid = split(":",$category);
+				$category = preg_replace("%^:%","",$category);
+				$catid = preg_split("%:%",$category);
 			}
 			if(!$dbd = db_connect()) html_error(DB_ERROR_MSG,0);
 			$tmp = "";
@@ -387,24 +387,24 @@ if(	$REQUEST_METHOD == "POST" || $Command == "Move"	) {
 					$qs = "INSERT INTO ".TABLE." 
 								(".ID.", $tmp )
 						   VALUES
-								(nextval('".SEQUENCE."'), $tmp_value)";
+								(nextval('".SEQUENCE."'), $tmp_value) RETURNING id";
 					if(!$res = db_exec($dbd,$qs)) 
 					{
 						die( pg_errormessage($dbd).$qs );
 					}
-					if(!$oid = pg_GetLastOid($res)) 
-					{
-						die( pg_errormessage($dbd).$qs );
-						html_error("CANT GET LAST OID",1);
-					}
+					//if(!$oid = pg_GetLastOid($res))
+					//{
+						//die( pg_errormessage($dbd).$qs );
+						//html_error("CANT GET LAST OID",1);
+					//}
 					
-					$qs = "SELECT 	id
-						   FROM 	bus 
-						   WHERE	oid = $oid";
-					if(!$res = db_exec($dbd,$qs))
-					{
-						html_error(DB_ERROR_MSG.$qs,0);
-					}
+					//$qs = "SELECT 	id
+					//	   FROM 	bus
+					//	   WHERE	oid = $oid";
+					//if(!$res = db_exec($dbd,$qs))
+					//{
+						//html_error(DB_ERROR_MSG.$qs,0);
+					//}
 					$row = db_fetch_array($res,0,PGSQL_ASSOC);
 					if(is_array($catid))
 					{
@@ -484,8 +484,8 @@ if(	$REQUEST_METHOD == "POST" || $Command == "Move"	) {
 			break;
 	
 		case "Delete":
-			$oldcatid = ereg_replace("^:","",$oldcatid);
-			$oldcatid = split(":",$oldcatid);
+			$oldcatid = preg_replace("%^:%","",$oldcatid);
+			$oldcatid = preg_split("%:%",$oldcatid);
 	
 			$qs = "DELETE FROM bus
 				   WHERE id = $id";
@@ -555,10 +555,10 @@ if(	$REQUEST_METHOD == "POST" || $Command == "Move"	) {
 			break;
 	
 		case "Cancel":
-			$oldcatid = ereg_replace("^:","",$oldcatid);
-			$oldcatid = split(":",$oldcatid);
-			$catid = ereg_replace("^:","",$oldcatid);
-			$catid = split(":",$oldcatid);
+			$oldcatid = preg_replace("%^:%","",$oldcatid);
+			$oldcatid = preg_split("%:%",$oldcatid);
+			$catid = preg_replace("%^:%","",$oldcatid);
+			$catid = preg_split("%:%",$oldcatid);
 			$location = "list_bus.phtml?catid=".$oldcatid[0]."&".SID; 
 			break;
 	
diff --git a/admin/Toolbox/update_bus_category.phtml b/admin/Toolbox/update_bus_category.phtml
index 88f6549..c5efc66 100755
--- a/admin/Toolbox/update_bus_category.phtml
+++ b/admin/Toolbox/update_bus_category.phtml
@@ -2,7 +2,11 @@
 //$Id: update_bus_category.phtml,v 1.1.1.1 2006/03/27 14:44:12 cscott Exp $
 include("../../setup.phtml");
 $description = ( trim( strip_tags( $description ) ) != "" ) ? $description :'';
-if($REQUEST_METHOD == "POST" || $Command == "Move") {
+$category    = addslashes(stripslashes($category));
+$description = addslashes(stripslashes($description));
+$intro       = addslashes(stripslashes($intro));
+$imagename   = addslashes(stripslashes($imagename));
+if($_POST || $Command == "Move") {
 	switch($Command) {
 
 		case "Move":
diff --git a/classes/class_db.inc b/classes/class_db.inc
index c0ff126..6db152b 100755
--- a/classes/class_db.inc
+++ b/classes/class_db.inc
@@ -1,6 +1,6 @@
 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 )
 		{
diff --git a/classes/class_events.inc b/classes/class_events.inc
index 0655b56..ca397e5 100755
--- a/classes/class_events.inc
+++ b/classes/class_events.inc
@@ -12,7 +12,7 @@ class GLM_EVENTS extends GLM_TEMPLATE{
 		$this->topicid = $topicid;
 		$this->page_name = $GLOBALS['PHP_SELF'];
 	}
-	
+
 	// date helper funcs
 	function lastDayOfMonth($timestamp = '')
 	{
@@ -33,28 +33,28 @@ class GLM_EVENTS extends GLM_TEMPLATE{
 	       date("Y",$timestamp)
 	   ));
 	}
-	
+
 	// end date helper
-	
-	
+
+
 	function get_by_topic($topic)
 	{
 		// method fetches events based on topic id
-		
+
 		if(!$year)
 			{
 				$year = date("Y");
 			}
 		if(!$month || $month == "All")
 			{
-				$month = date("n");	
+				$month = date("n");
 			}
-		if(ereg("^0([0-9]).*",$month,$part))
+		if(preg_match("%^0([0-9]).*%",$month,$part))
 			$month = $part[1];
 		$st = mktime(0,0,0,$month,1,$year);
 		$starting = date("m-d-Y",$this->firstDayOfMonth($st));
 		$ending = date("m-d-Y",$this->lastDayOfMonth($st));
-		
+
 		$query = "SET DATESTYLE TO 'SQL,US';
 		SELECT   	id,header,
 			date_part('month',bdate) as mon,
@@ -67,9 +67,9 @@ class GLM_EVENTS extends GLM_TEMPLATE{
 			btime,etime,descr,loc,contact,email,url,img,daysow,reacur
 			FROM		event
 			WHERE    	visable = 't'";
-			
+
 			$topqs=" AND topicid = $topic ";
-			
+
 			if($topic!='All')
 			{
 				$query.=$topqs;
@@ -82,9 +82,9 @@ class GLM_EVENTS extends GLM_TEMPLATE{
 
 	/**
 	* getEventSearch:
-	* 
-	* @return 
-	* @access 
+	*
+	* @return
+	* @access
 	**/
 	function get_event_search( $cal = 0 )
 	{
@@ -97,7 +97,7 @@ class GLM_EVENTS extends GLM_TEMPLATE{
 
 		if( $this->topicid != 24 && $this->topicid != 'All' && $this->topicid != '' )
 		{
-			$topic_qs = ' and topicid = '.$this->topicid; 
+			$topic_qs = ' and topicid = '.$this->topicid;
 		}
 
 		// Month part do not change
@@ -115,18 +115,18 @@ class GLM_EVENTS extends GLM_TEMPLATE{
 
 		$page = BASE_URL.'events.phtml';
 
-		for($i=0;$iDB->db_fetch_array($result,$i,PGSQL_ASSOC); 
+			$data = $this->DB->db_fetch_array($result,$i,PGSQL_ASSOC);
 			$s_month = $data['d1_month'];
 			$s_year = $data['d1_year'];
 			$e_month = $data['d2_month'];
 			$e_year = $data['d2_year'];
 
-			$watchdog = 20; 
-			for( $y=$s_year, $m=$s_month; !($y==$e_year && $m==$e_month+1) ; ) 
+			$watchdog = 20;
+			for( $y=$s_year, $m=$s_month; !($y==$e_year && $m==$e_month+1) ; )
 			{
-				if( $m == 13 ) 
+				if( $m == 13 )
 				{
 					$y++;
 					$m = 1;
@@ -148,9 +148,9 @@ class GLM_EVENTS extends GLM_TEMPLATE{
 		}
 
 		// Selections part
-		while( list($key,$value) = each($selection)) 
+		while( list($key,$value) = each($selection))
 		{
-			$qs = "SELECT  
+			$qs = "SELECT
 			DISTINCT $key
 			FROM 	event
 			WHERE 	visable = 't'
@@ -162,12 +162,12 @@ class GLM_EVENTS extends GLM_TEMPLATE{
 
 			echo "