cvs: pear /Forum/lib/classes/db Mysql.php MysqlStandard.php MysqlUser.php /Forum/lib/plugins plugin.php
| From: | Thomas V.V.Cox | Date: | Fri, 12 Oct 2001 17:59:07 +0000 |
| Subject: | cvs: pear /Forum/lib/classes/db Mysql.php MysqlStandard.php MysqlUser.php /Forum/lib/plugins plugin.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-990@lists.php.net to get a copy of this message | ||
cox Fri Oct 12 13:59:07 2001 EDT
Modified files:
/pear/Forum/lib/classes/db Mysql.php MysqlStandard.php
MysqlUser.php
/pear/Forum/lib/plugins plugin.php
Log:
Call-time pass-by-reference fixes
Index: pear/Forum/lib/classes/db/Mysql.php diff -u pear/Forum/lib/classes/db/Mysql.php:1.1 pear/Forum/lib/classes/db/Mysql.php:1.2 --- pear/Forum/lib/classes/db/Mysql.php:1.1 Sat Oct 6 17:59:43 2001 +++ pear/Forum/lib/classes/db/Mysql.php Fri Oct 12 13:59:07 2001 @@ -37,7 +37,7 @@ * @param string $SQL SQL query * @return resource $result MySQL result */ - function query($SQL) { + function query(&$SQL) { if($this->connect()){ if(!($result=mysql_query($SQL, $this->link))) { trigger_error("Query: <PRE>\"$SQL\"</PRE> failed: ".mysql_error($this->link),E_USER_WARNING); @@ -59,8 +59,8 @@ * @param string $SQL SQL query * @return array $row Array containing row returned. */ - function get_row($SQL){ - if($result = $this->query(&$SQL)) { + function get_row(&$SQL){ + if($result = $this->query($SQL)) { $row=mysql_fetch_assoc($result); mysql_free_result($result); } @@ -77,7 +77,7 @@ * @param string $SQL SQL Query. * @param string $field Field to use as key in $rows[$field] */ - function get_rows_by_field($SQL, $field) { + function get_rows_by_field(&$SQL, $field) { $rows=array(); if($result = $this->query($SQL)) { while($rec=mysql_fetch_assoc($result)) { @@ -96,7 +96,7 @@ * @return array $rows rows * @author Morgan Christiansson <mog@linux.nu> */ - function get_vals_by_field($SQL, $field) { + function get_vals_by_field(&$SQL, $field) { $rows=array(); if($result = $this->query($SQL)) { while($rec=mysql_fetch_assoc($result)) { Index: pear/Forum/lib/classes/db/MysqlStandard.php diff -u pear/Forum/lib/classes/db/MysqlStandard.php:1.2 pear/Forum/lib/classes/db/MysqlStandard.php:1.3 --- pear/Forum/lib/classes/db/MysqlStandard.php:1.2 Sun Oct 7 12:46:45 2001 +++ pear/Forum/lib/classes/db/MysqlStandard.php Fri Oct 12 13:59:07 2001 @@ -1,4 +1,4 @@ -<?PHP +<?PHP if(!function_exists("mysql_connect")) { trigger_error("PHP has no MySQL support installed", E_USER_ERROR); @@ -42,7 +42,7 @@ function approve_thread($forum_id, $thread_id, $status="Y") { $this->get_forum_settings($forum_id); $SQL="UPDATE $this->forums[$forum_id] SET approved='$status' WHERE forum_id='$forum_id' AND thread_id='$thread_id'"; - return $this->query(&$SQL) ? TRUE : FALSE; + return $this->query($SQL) ? TRUE : FALSE; } /** @@ -58,7 +58,7 @@ function approve_message($forum_id, $message_id, $status="Y") { $this->get_forum_settings($forum_id); $SQL = "UPDATE $this->forums[$forum_id] SET approved='$status' WHERE forum_id='$forum_id' AND thread_id='$thread_id'"; - return $this->query(&$SQL) ? TRUE : FALSE; + return $this->query($SQL) ? TRUE : FALSE; } /** @@ -78,7 +78,7 @@ $arr =& $this->forums[$forum_id]; $SQL="SELECT * FROM $FORUM[FORUM_TABLE] WHERE forum_id='$forum_id' LIMIT 1"; - $arr = $this->get_row(&$SQL); + $arr = $this->get_row($SQL); if(sizeof($arr) == 0) trigger_error("No forum data for forum_id='$forum_id'",E_USER_ERROR); @@ -103,27 +103,27 @@ switch($whattoget){ case FORUM_THREAD: $SQL="SELECT thread_id FROM ".$this->forums[$forum_id]["headers"]." WHERE forum_id='$forum_id' AND parent_id=0 AND approved='Y' ORDER BY timestamp limit $from,$to"; - $threads=implode(",", $this->get_vals_by_field(&$SQL, "thread_id")); + $threads=implode(",", $this->get_vals_by_field($SQL, "thread_id")); if($threads == "") return array(); $SQL="SELECT *,0 as replies_left FROM ".$this->forums[$forum_id]["headers"]." WHERE thread_id in ($threads) $cutoff ORDER BY timestamp"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); case FORUM_THREAD_FLOAT: //get the $count thread_id's ordered by thread_updated $SQL="SELECT thread_id FROM ".$this->forums[$forum_id]["headers"]." WHERE forum_id='$forum_id' AND parent_id=0 GROUP BY thread_id ORDER BY thread_updated DESC limit $from,$to"; - $ids="'".implode("','", $this->get_vals_by_field(&$SQL, "thread_id"))."'"; + $ids="'".implode("','", $this->get_vals_by_field($SQL, "thread_id"))."'"; if($ids == "") return array(); //get $SQL="SELECT *,0 as replies_left FROM ".$this->forums[$forum_id]["headers"]." WHERE thread_id in ($ids)"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); case FORUM_FLAT: $SQL="SELECT *,0 as replies_left FROM ".$this->forums[$forum_id]["headers"]." WHERE forum_id='$forum_id' AND parent_id=0 ORDER BY timestamp limit $from,$to"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); case FORUM_FLAT_FLOAT: $SQL="SELECT *,0 as replies_left FROM ".$this->forums[$forum_id]["headers"]." WHERE forum_id='$forum_id' AND parent_id=0 ORDER BY thread_updated DESC limit $from,$to"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); default: trigger_error("Unhandled \$whattoget: $whattoget",E_USER_ERROR); @@ -148,10 +148,10 @@ switch($whattoget) { case FORUM_ALL: $SQL="SELECT headers.*,bodies.body,0 as replies_left FROM ".$this->forums[$forum_id]["headers"]." AS headers,".$this->forums[$forum_id]["bodies"]." as bodies WHERE headers.thread_id='$thread_id' AND headers.message_id = bodies.message_id AND approved='Y'"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); case FORUM_HEADERS: $SQL="SELECT * FROM $FORUM[HEADERS] WHERE thread_id = $thread_id AND approved='Y'"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); default: trigger_error("Unhandled \$whattoget: $whattoget",E_USER_ERROR); } @@ -197,7 +197,7 @@ function get_forums($parent_id=1) { global $FORUM; $SQL="SELECT * FROM $FORUM[FORUM_TABLE] WHERE parent_id=$parent_id AND active='Y'"; - return $this->get_rows_by_field(&$SQL, "forum_id"); + return $this->get_rows_by_field($SQL, "forum_id"); } /** @@ -207,7 +207,7 @@ function get_all_forums() { global $FORUM; $SQL="SELECT * FROM $FORUM[FORUM_TABLE]"; - return $this->get_rows_by_field(&$SQL, "forum_id"); + return $this->get_rows_by_field($SQL, "forum_id"); } /** @@ -217,7 +217,7 @@ function get_all_folders() { global $FORUM; $SQL="SELECT * FROM $FORUM[FORUM_TABLE] WHERE is_folder='Y'"; - $arr = $this->get_rows_by_field(&$SQL, "forum_id"); + $arr = $this->get_rows_by_field($SQL, "forum_id"); return is_array($arr) ? $arr : array(); } @@ -332,7 +332,7 @@ $SQL="UPDATE $FORUM[FORUM_TABLE] SET\n". $this->build_set_query($settings). "WHERE forum_id='$forum_id'"; - return($this->query(&$SQL)); + return($this->query($SQL)); } @@ -360,7 +360,7 @@ KEY active (active), ) "; - $this->query(&$SQL); + $this->query($SQL); } /** Index: pear/Forum/lib/classes/db/MysqlUser.php diff -u pear/Forum/lib/classes/db/MysqlUser.php:1.1 pear/Forum/lib/classes/db/MysqlUser.php:1.2 --- pear/Forum/lib/classes/db/MysqlUser.php:1.1 Fri Oct 12 13:40:25 2001 +++ pear/Forum/lib/classes/db/MysqlUser.php Fri Oct 12 13:59:07 2001 @@ -12,7 +12,7 @@ * @package user */ class MysqlUser extends Mysql { - + /** * Gets and returns user with user_id. * @@ -23,7 +23,7 @@ */ function get_user($user,$field="user") { $SQL="SELECT * FROM $this->user_table WHERE $field='$user' LIMIT 1"; - return $this->get_row(&$SQL); + return $this->get_row($SQL); } /** @@ -42,7 +42,7 @@ ." email='$user[email]'" ." image='$user[image]'" ." signature='$user[signature]'"; - return $this->query(&$SQL); + return $this->query($SQL); } @@ -62,7 +62,7 @@ ." image='$user[image]'" ." signature='$user[signature]'" ." status='$user[status]'"; - return $this->query(&$SQL); + return $this->query($SQL); } /** Index: pear/Forum/lib/plugins/plugin.php diff -u pear/Forum/lib/plugins/plugin.php:1.2 pear/Forum/lib/plugins/plugin.php:1.3 --- pear/Forum/lib/plugins/plugin.php:1.2 Sun Oct 7 12:46:45 2001 +++ pear/Forum/lib/plugins/plugin.php Fri Oct 12 13:59:07 2001 @@ -12,10 +12,10 @@ plugin_load_all(); foreach($FORUM["PLUGINS"] as $plugin) { - if(method_exists(&$plugin,&$hook)) { + if(method_exists($plugin, $hook)) { /* Two ways to call plugins */ - call_user_method(&$hook,&$plugin,&$param); + call_user_method($hook, $plugin, $param); // $plugin->$hook(&$param); } } @@ -46,7 +46,7 @@ trigger_error("Failed to list $FORUM[LIB]",E_USER_WARNING); return FALSE; } - while($plugin = readdir(&$dir)) { + while($plugin = readdir($dir)) { if(strpos($plugin,".")) continue; if(isset($FORUM["PLUGINS"][$plugin])) continue; if(file_exists("$FORUM[LIB]/plugins/$plugin/$plugin.php")) {
Index: pear/Forum/lib/classes/db/Mysql.php diff -u pear/Forum/lib/classes/db/Mysql.php:1.1 pear/Forum/lib/classes/db/Mysql.php:1.2 --- pear/Forum/lib/classes/db/Mysql.php:1.1 Sat Oct 6 17:59:43 2001 +++ pear/Forum/lib/classes/db/Mysql.php Fri Oct 12 13:59:07 2001 @@ -37,7 +37,7 @@ * @param string $SQL SQL query * @return resource $result MySQL result */ - function query($SQL) { + function query(&$SQL) { if($this->connect()){ if(!($result=mysql_query($SQL, $this->link))) { trigger_error("Query: <PRE>\"$SQL\"</PRE> failed: ".mysql_error($this->link),E_USER_WARNING); @@ -59,8 +59,8 @@ * @param string $SQL SQL query * @return array $row Array containing row returned. */ - function get_row($SQL){ - if($result = $this->query(&$SQL)) { + function get_row(&$SQL){ + if($result = $this->query($SQL)) { $row=mysql_fetch_assoc($result); mysql_free_result($result); } @@ -77,7 +77,7 @@ * @param string $SQL SQL Query. * @param string $field Field to use as key in $rows[$field] */ - function get_rows_by_field($SQL, $field) { + function get_rows_by_field(&$SQL, $field) { $rows=array(); if($result = $this->query($SQL)) { while($rec=mysql_fetch_assoc($result)) { @@ -96,7 +96,7 @@ * @return array $rows rows * @author Morgan Christiansson <mog@linux.nu> */ - function get_vals_by_field($SQL, $field) { + function get_vals_by_field(&$SQL, $field) { $rows=array(); if($result = $this->query($SQL)) { while($rec=mysql_fetch_assoc($result)) { Index: pear/Forum/lib/classes/db/MysqlStandard.php diff -u pear/Forum/lib/classes/db/MysqlStandard.php:1.2 pear/Forum/lib/classes/db/MysqlStandard.php:1.3 --- pear/Forum/lib/classes/db/MysqlStandard.php:1.2 Sun Oct 7 12:46:45 2001 +++ pear/Forum/lib/classes/db/MysqlStandard.php Fri Oct 12 13:59:07 2001 @@ -1,4 +1,4 @@ -<?PHP +<?PHP if(!function_exists("mysql_connect")) { trigger_error("PHP has no MySQL support installed", E_USER_ERROR); @@ -42,7 +42,7 @@ function approve_thread($forum_id, $thread_id, $status="Y") { $this->get_forum_settings($forum_id); $SQL="UPDATE $this->forums[$forum_id] SET approved='$status' WHERE forum_id='$forum_id' AND thread_id='$thread_id'"; - return $this->query(&$SQL) ? TRUE : FALSE; + return $this->query($SQL) ? TRUE : FALSE; } /** @@ -58,7 +58,7 @@ function approve_message($forum_id, $message_id, $status="Y") { $this->get_forum_settings($forum_id); $SQL = "UPDATE $this->forums[$forum_id] SET approved='$status' WHERE forum_id='$forum_id' AND thread_id='$thread_id'"; - return $this->query(&$SQL) ? TRUE : FALSE; + return $this->query($SQL) ? TRUE : FALSE; } /** @@ -78,7 +78,7 @@ $arr =& $this->forums[$forum_id]; $SQL="SELECT * FROM $FORUM[FORUM_TABLE] WHERE forum_id='$forum_id' LIMIT 1"; - $arr = $this->get_row(&$SQL); + $arr = $this->get_row($SQL); if(sizeof($arr) == 0) trigger_error("No forum data for forum_id='$forum_id'",E_USER_ERROR); @@ -103,27 +103,27 @@ switch($whattoget){ case FORUM_THREAD: $SQL="SELECT thread_id FROM ".$this->forums[$forum_id]["headers"]." WHERE forum_id='$forum_id' AND parent_id=0 AND approved='Y' ORDER BY timestamp limit $from,$to"; - $threads=implode(",", $this->get_vals_by_field(&$SQL, "thread_id")); + $threads=implode(",", $this->get_vals_by_field($SQL, "thread_id")); if($threads == "") return array(); $SQL="SELECT *,0 as replies_left FROM ".$this->forums[$forum_id]["headers"]." WHERE thread_id in ($threads) $cutoff ORDER BY timestamp"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); case FORUM_THREAD_FLOAT: //get the $count thread_id's ordered by thread_updated $SQL="SELECT thread_id FROM ".$this->forums[$forum_id]["headers"]." WHERE forum_id='$forum_id' AND parent_id=0 GROUP BY thread_id ORDER BY thread_updated DESC limit $from,$to"; - $ids="'".implode("','", $this->get_vals_by_field(&$SQL, "thread_id"))."'"; + $ids="'".implode("','", $this->get_vals_by_field($SQL, "thread_id"))."'"; if($ids == "") return array(); //get $SQL="SELECT *,0 as replies_left FROM ".$this->forums[$forum_id]["headers"]." WHERE thread_id in ($ids)"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); case FORUM_FLAT: $SQL="SELECT *,0 as replies_left FROM ".$this->forums[$forum_id]["headers"]." WHERE forum_id='$forum_id' AND parent_id=0 ORDER BY timestamp limit $from,$to"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); case FORUM_FLAT_FLOAT: $SQL="SELECT *,0 as replies_left FROM ".$this->forums[$forum_id]["headers"]." WHERE forum_id='$forum_id' AND parent_id=0 ORDER BY thread_updated DESC limit $from,$to"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); default: trigger_error("Unhandled \$whattoget: $whattoget",E_USER_ERROR); @@ -148,10 +148,10 @@ switch($whattoget) { case FORUM_ALL: $SQL="SELECT headers.*,bodies.body,0 as replies_left FROM ".$this->forums[$forum_id]["headers"]." AS headers,".$this->forums[$forum_id]["bodies"]." as bodies WHERE headers.thread_id='$thread_id' AND headers.message_id = bodies.message_id AND approved='Y'"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); case FORUM_HEADERS: $SQL="SELECT * FROM $FORUM[HEADERS] WHERE thread_id = $thread_id AND approved='Y'"; - return $this->get_rows_by_field(&$SQL,"message_id"); + return $this->get_rows_by_field($SQL,"message_id"); default: trigger_error("Unhandled \$whattoget: $whattoget",E_USER_ERROR); } @@ -197,7 +197,7 @@ function get_forums($parent_id=1) { global $FORUM; $SQL="SELECT * FROM $FORUM[FORUM_TABLE] WHERE parent_id=$parent_id AND active='Y'"; - return $this->get_rows_by_field(&$SQL, "forum_id"); + return $this->get_rows_by_field($SQL, "forum_id"); } /** @@ -207,7 +207,7 @@ function get_all_forums() { global $FORUM; $SQL="SELECT * FROM $FORUM[FORUM_TABLE]"; - return $this->get_rows_by_field(&$SQL, "forum_id"); + return $this->get_rows_by_field($SQL, "forum_id"); } /** @@ -217,7 +217,7 @@ function get_all_folders() { global $FORUM; $SQL="SELECT * FROM $FORUM[FORUM_TABLE] WHERE is_folder='Y'"; - $arr = $this->get_rows_by_field(&$SQL, "forum_id"); + $arr = $this->get_rows_by_field($SQL, "forum_id"); return is_array($arr) ? $arr : array(); } @@ -332,7 +332,7 @@ $SQL="UPDATE $FORUM[FORUM_TABLE] SET\n". $this->build_set_query($settings). "WHERE forum_id='$forum_id'"; - return($this->query(&$SQL)); + return($this->query($SQL)); } @@ -360,7 +360,7 @@ KEY active (active), ) "; - $this->query(&$SQL); + $this->query($SQL); } /** Index: pear/Forum/lib/classes/db/MysqlUser.php diff -u pear/Forum/lib/classes/db/MysqlUser.php:1.1 pear/Forum/lib/classes/db/MysqlUser.php:1.2 --- pear/Forum/lib/classes/db/MysqlUser.php:1.1 Fri Oct 12 13:40:25 2001 +++ pear/Forum/lib/classes/db/MysqlUser.php Fri Oct 12 13:59:07 2001 @@ -12,7 +12,7 @@ * @package user */ class MysqlUser extends Mysql { - + /** * Gets and returns user with user_id. * @@ -23,7 +23,7 @@ */ function get_user($user,$field="user") { $SQL="SELECT * FROM $this->user_table WHERE $field='$user' LIMIT 1"; - return $this->get_row(&$SQL); + return $this->get_row($SQL); } /** @@ -42,7 +42,7 @@ ." email='$user[email]'" ." image='$user[image]'" ." signature='$user[signature]'"; - return $this->query(&$SQL); + return $this->query($SQL); } @@ -62,7 +62,7 @@ ." image='$user[image]'" ." signature='$user[signature]'" ." status='$user[status]'"; - return $this->query(&$SQL); + return $this->query($SQL); } /** Index: pear/Forum/lib/plugins/plugin.php diff -u pear/Forum/lib/plugins/plugin.php:1.2 pear/Forum/lib/plugins/plugin.php:1.3 --- pear/Forum/lib/plugins/plugin.php:1.2 Sun Oct 7 12:46:45 2001 +++ pear/Forum/lib/plugins/plugin.php Fri Oct 12 13:59:07 2001 @@ -12,10 +12,10 @@ plugin_load_all(); foreach($FORUM["PLUGINS"] as $plugin) { - if(method_exists(&$plugin,&$hook)) { + if(method_exists($plugin, $hook)) { /* Two ways to call plugins */ - call_user_method(&$hook,&$plugin,&$param); + call_user_method($hook, $plugin, $param); // $plugin->$hook(&$param); } } @@ -46,7 +46,7 @@ trigger_error("Failed to list $FORUM[LIB]",E_USER_WARNING); return FALSE; } - while($plugin = readdir(&$dir)) { + while($plugin = readdir($dir)) { if(strpos($plugin,".")) continue; if(isset($FORUM["PLUGINS"][$plugin])) continue; if(file_exists("$FORUM[LIB]/plugins/$plugin/$plugin.php")) {