From 312a6acc00ec7f331ab461894c319776eec95cae Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 10 Mar 2011 23:24:21 +0100 Subject: [PATCH] G_false reference and all explicit pass by references removed --- web/Obj/auth.phh | 19 ++++--- web/Obj/brisk.phh | 99 ++++++++++++++--------------------- web/Obj/dbase_base.phh | 4 +- web/Obj/dbase_file.phh | 14 ++--- web/Obj/dbase_pgsql.phh | 67 +++++++++--------------- web/Obj/hardban.phh | 17 +++--- web/briskin5/Obj/briskin5.phh | 78 +++++++++++++-------------- web/briskin5/Obj/placing.phh | 4 +- web/index.php | 4 +- web/index_wr.php | 4 +- 10 files changed, 131 insertions(+), 179 deletions(-) diff --git a/web/Obj/auth.phh b/web/Obj/auth.phh index 29769a2..963755a 100644 --- a/web/Obj/auth.phh +++ b/web/Obj/auth.phh @@ -70,13 +70,13 @@ class Challenges { log_auth("xxx", sprintf("Challenges::add [%s]\n", $login)); // FIXME Checks here if ($login == '') { - return ($G_false); + return (FALSE); } // log_auth("xxx", "LOOPI tstamp: ".$this->item[$i]->tstamp." curtime: ".$curtime); - if (($chal = new Challenge($login, $token, $ip, $tstamp)) == null) { - return ($G_false); + if (($chal = new Challenge($login, $token, $ip, $tstamp)) == FALSE) { + return (FALSE); } $this->item[$this->item_n] = $chal; @@ -151,7 +151,7 @@ class Challenges { } // Static functions - static function &create() + static function create() { $chal =& new Challenges(); @@ -160,9 +160,9 @@ class Challenges { return $chal; } - function &load_data() + function load_data() { - GLOBAL $G_false, $sess; + GLOBAL $sess; $doexit = FALSE; do { if (($tok = @ftok(FTOK_PATH."/challenges", "B")) == -1) { @@ -199,18 +199,17 @@ class Challenges { $chals->garbage_manager(); - $ret = &$chals; - return ($ret); + return ($chals); } while (0); if ($doexit) exit(); - return ($G_false); + return (FALSE); } - function save_data(&$chals) + function save_data($chals) { $shm = FALSE; $oldmod = $chals->mod; diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index c5bc2de..5249ff5 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -131,7 +131,6 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi', ); -$G_false = FALSE; $G_lng = langtolng($G_lang); $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); @@ -384,12 +383,10 @@ class Table { { } - function &create($idx) + function create($idx) { - GLOBAL $G_false; - if (($thiz =& new Table()) == FALSE) - return ($G_false); + return (FALSE); $thiz->idx = $idx; $thiz->player = array(); @@ -408,10 +405,8 @@ class Table { return ($thiz); } - function copy(&$from) + function copy($from) { - GLOBAL $G_false; - $this->idx = $from->idx; $this->player = array(); for ($i = 0 ; $i < $from->player_n ; $i++) @@ -432,24 +427,20 @@ class Table { $this->wakeup_time = $from->wakeup_time; } - function &myclone(&$from) + function myclone($from) { - GLOBAL $G_false; - if (($thiz =& new Table()) == FALSE) - return ($G_false); + return (FALSE); $this->copy($from); return ($thiz); } - function &spawn(&$from) + function spawn($from) { - GLOBAL $G_false; - if (($thiz =& new Table()) == FALSE) - return ($G_false); + return (FALSE); $thiz->idx = $from->idx; $thiz->player = array(); @@ -471,11 +462,11 @@ class Table { return ($thiz); } - function wag_set(&$user, $mesg) + function wag_set($user, $mesg) { log_main("WAG_SET"); - $this->wag_own = &$user; + $this->wag_own = $user; $this->wag_com = $mesg; $this->wag_tout = 0; } @@ -645,13 +636,11 @@ class User { function User() { } - function &create($idx, $name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") { - GLOBAL $G_false; - + function create($idx, $name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") { // error_log("User::create BEGIN", 0); if (($thiz =& new User()) == FALSE) - return ($G_false); + return (FALSE); $thiz->idx = $idx; $thiz->code = -1; @@ -687,10 +676,8 @@ class User { return ($thiz); } - function copy(&$from) + function copy($from) { - GLOBAL $G_false; - $this->idx = $from->idx; $this->code = $from->code; $this->name = $from->name; @@ -735,24 +722,20 @@ class User { } - function &myclone(&$from) + function myclone($from) { - GLOBAL $G_false; - if (($thiz =& new User()) == FALSE) - return ($G_false); + return (FALSE); $thiz->copy($from); return ($thiz); } - function &spawn(&$from, $table, $table_pos) + function spawn($from, $table, $table_pos) { - GLOBAL $G_false; - if (($thiz =& new User()) == FALSE) - return ($G_false); + return (FALSE); $thiz->idx = $from->idx; $thiz->code = $from->code; @@ -879,9 +862,9 @@ class User { // SHSPLIT save and load function for the User class. - function &load_data($id) + function load_data($id) { - GLOBAL $G_false, $sess; + GLOBAL $sess; // error_log("User::load_data BEGIN", 0); @@ -926,14 +909,13 @@ class User { // // SHSPLIT: load users from the shared memory // - $ret = &$user; - return ($ret); + return ($user); } while (0); if ($doexit) exit(); - return ($G_false); + return (FALSE); } @@ -1961,9 +1943,9 @@ class Room { return; } // function chatt_send( ... - function &get_user($sess, &$idx) + function get_user($sess, &$idx) { - GLOBAL $PHP_SELF, $G_false; + GLOBAL $PHP_SELF; if (validate_sess($sess)) { for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { @@ -1982,11 +1964,11 @@ class Room { log_main(sprintf("get_user: Wrong strlen [%s]",$sess)); } - return ($G_false); + return (FALSE); } /* - * function &add_user(&$room, &$sess, &$idx, $name, $pass, $ip) + * function add_user(&$room, &$sess, &$idx, $name, $pass, $ip) * * RETURN VALUE: * if ($idx > -1 && ret == FALSE) => duplicated nick @@ -1997,14 +1979,12 @@ class Room { * if ($idx == -$idx && ret == user) => SUCCESS (but the login exists in the auth db) */ - function &add_user(&$sess, &$idx, $name, $pass, $ip) + function add_user(&$sess, &$idx, $name, $pass, $ip) { - GLOBAL $G_base, $G_false, $CO_list; + GLOBAL $G_base, $CO_list; $idx = 0; - error_log("add_user: G_false: [".$G_false."]", 0); - $authenticate = FALSE; $user_type = 0; $login_exists = FALSE; @@ -2016,7 +1996,7 @@ class Room { if (($name_new = validate_name($name)) == FALSE) { $idx = -2; - return ($G_false); + return (FALSE); } log_auth("XXX", sprintf("ARRIVA: [%s] pass:[%s]", $sess, ($pass == FALSE ? "FALSE" : $pass))); @@ -2034,12 +2014,12 @@ class Room { log_auth("XXX", "authenticate: ".($authenticate != FALSE ? "TRUE" : "FALSE")); if ($authenticate != FALSE) { - error_log(print_r(&$authenticate, TRUE),0); + // error_log(print_r(&$authenticate, TRUE),0); $user_type = $authenticate->type_get(); } else { $idx = -3; - return ($G_false); + return (FALSE); } } else { @@ -2205,10 +2185,10 @@ class Room { return ($ret); } - return ($G_false); + return (FALSE); } - function standup_update(&$user) + function standup_update($user) { for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { $user_cur = &$this->user[$i]; @@ -2234,17 +2214,17 @@ class Room { } // Static functions - static function &create() + static function create() { - $room =& new Room(); + $room = new Room(); return $room; } - function &load_data() + function load_data() { - GLOBAL $G_false, $sess; + GLOBAL $sess; $doexit = FALSE; // error_log("Room::load_data BEGIN", 0); @@ -2276,10 +2256,10 @@ class Room { // error_log("DE CHE", 0); - $room =& Room::create(); + $room = Room::create(); if (Room::save_data($room) == FALSE) - return $G_false; + return FALSE; return $room; } @@ -2295,14 +2275,13 @@ class Room { // // SHSPLIT: load users from the shared memory // - $ret = &$room; - return ($ret); + return ($room); } while (0); if ($doexit) exit(); - return ($G_false); + return (FALSE); } diff --git a/web/Obj/dbase_base.phh b/web/Obj/dbase_base.phh index 83d49e6..43b568d 100644 --- a/web/Obj/dbase_base.phh +++ b/web/Obj/dbase_base.phh @@ -39,9 +39,9 @@ class LoginDBItem { $this->type = $type; } - static function &LoginDBItemFromRecord($rec) + static function LoginDBItemFromRecord($rec) { - $ret =& new LoginDBItem($rec->code, $rec->login, $rec->pass, + $ret = new LoginDBItem($rec->code, $rec->login, $rec->pass, $rec->email, $rec->type); return ($ret); diff --git a/web/Obj/dbase_file.phh b/web/Obj/dbase_file.phh index 9e8331a..13dce47 100644 --- a/web/Obj/dbase_file.phh +++ b/web/Obj/dbase_file.phh @@ -38,7 +38,7 @@ class BriskDB { log_main("BriskDB create:end"); } - static function &create() + static function create() { $ret = new BriskDB(); @@ -87,10 +87,8 @@ class BriskDB { return ($this->item[$idx]->login); } - function &getitem_bylogin($login, &$id) + function getitem_bylogin($login, &$id) { - GLOBAL $G_false; - log_main("login_exists: ".$login); /* check the existence of the nick in the BriskDB */ @@ -103,7 +101,7 @@ class BriskDB { } } $id = -1; - return ($G_false); + return (FALSE); } function getmail($login) @@ -134,11 +132,9 @@ class BriskDB { return (FALSE); } - function &login_verify($login, $pass) + function login_verify($login, $pass) { - GLOBAL $G_false; - - $ret = &$G_false; + $ret = FALSE; log_main("login_verify: ".$login); diff --git a/web/Obj/dbase_pgsql.phh b/web/Obj/dbase_pgsql.phh index c69ab16..004edb9 100644 --- a/web/Obj/dbase_pgsql.phh +++ b/web/Obj/dbase_pgsql.phh @@ -44,15 +44,13 @@ class DBConn $this->db = DBConn::$dbcnnx; } - static function &create() + static function create() { - GLOBAL $G_dbauth, $G_false; + GLOBAL $G_dbauth; - $ret = &$G_false; - if (DBConn::$dbcnnx == FALSE) { if (!(DBConn::$dbcnnx = @pg_connect ($G_dbauth))) { - return ($ret); + return (FALSE); } } @@ -77,9 +75,9 @@ class BriskDB $this->dbconn = $dbconn; } - static function &create() + static function create() { - GLOBAL $DOCUMENT_ROOT, $G_dbpfx, $G_false; + GLOBAL $DOCUMENT_ROOT, $G_dbpfx; $ret = FALSE; @@ -92,10 +90,7 @@ class BriskDB $ret = new BriskDB($dbconn); } while (0); - if ($ret) - return ($ret); - else - return ($G_false); + return ($ret); } function users_load() @@ -118,15 +113,15 @@ class BriskDB return FALSE; } - function &getrecord_bylogin($login) { - GLOBAL $G_false, $G_dbpfx; + function getrecord_bylogin($login) { + GLOBAL $G_dbpfx; $user_sql = sprintf("SELECT * FROM %susers WHERE login = lower('%s') AND (type & CAST (X'%08x' as integer)) = 0;", $G_dbpfx, escsql($login), USER_FLAG_TY_DISABLE); if (($user_pg = pg_query($this->dbconn->db(), $user_sql)) == FALSE) - return $ret; + return FALSE; if (pg_numrows($user_pg) != 1) - return $ret; + return FALSE; $user_obj = pg_fetch_object($user_pg, 0); @@ -135,12 +130,10 @@ class BriskDB - function &login_verify($login, $pass) + function login_verify($login, $pass) { - GLOBAL $G_dbpfx, $G_false; + GLOBAL $G_dbpfx; - error_log("dbase_pgsql G_false: [".$G_false."]", 0); - $ret = FALSE; log_main("login_verify: ".$login); @@ -151,37 +144,35 @@ class BriskDB //O log_main("login_verify: BEGIN"); if (($user_obj = $this->getrecord_bylogin($login)) == FALSE) { - return $G_false; + return FALSE; } - error_log("G_false: [".$G_false."] user_obj: ".print_r($user_obj, TRUE), 0); - log_main("login[".$user_obj->code."]: ".$user_obj->login); /* if it exists check for a valid challenge */ if (($a_sem = Challenges::lock_data()) != FALSE) { - error_log("loop-2", 0); + // error_log("loop-2", 0); if (($chals = &Challenges::load_data()) != FALSE) { - error_log("loop-1", 0); + // error_log("loop-1", 0); for ($e = 0 ; $e < $chals->item_n ; $e++) { - error_log("loop", 0); + // error_log("loop", 0); log_main("challenge[".$e."]: ".$chals->item[$e]->login); if (strcmp($login, $chals->item[$e]->login) == 0) { - error_log("loop2", 0); + // error_log("loop2", 0); log_main("login_verify [".$pass."] with [".md5($chals->item[$e]->token.$user_obj->pass)."]"); if (strcmp($pass, md5($chals->item[$e]->token.$user_obj->pass)) == 0) { - error_log("loop3", 0); + // error_log("loop3", 0); log_main("login_verify SUCCESS for ".$login); $chals->rem($login); $ret = LoginDBItem::LoginDBItemFromRecord($user_obj); - error_log("dbitem: ".print_r($ret, TRUE)); + // error_log("dbitem: ".print_r($ret, TRUE)); break; } } } // end for ($e = 0 ... - error_log("end loop-1", 0); + // error_log("end loop-1", 0); } if ($chals->ismod()) { @@ -194,18 +185,11 @@ class BriskDB // O } // if (strcasecmp($this->item[$i]->login, ... //O } - error_log("return: ".($G_false == FALSE ? "FALSE" : "not FALSE"), 0); - - if ($ret) - return ($ret); - else - return ($G_false); + return ($ret); } - function &getitem_bylogin($login, &$id) { - GLOBAL $G_false; - - $ret = &$G_false; + function getitem_bylogin($login, &$id) { + $ret = FALSE; $id = -1; log_main("getitem_bylogin: ".$login); @@ -248,10 +232,9 @@ class BriskDB return TRUE; } - function &getdbconn() + function getdbconn() { - $ret = $this->dbconn; - return ($ret); + return ($this->dbconn); } // ttok text UNIQUE, diff --git a/web/Obj/hardban.phh b/web/Obj/hardban.phh index 99b7033..ffec9c6 100644 --- a/web/Obj/hardban.phh +++ b/web/Obj/hardban.phh @@ -66,8 +66,8 @@ class Hardbans { log_auth("xxx", sprintf("Hardbans::add [%s]\n", $login)); - if (($chal = new Hardban($login, $ip, $session, $timeout)) == null) { - return ($G_false); + if (($chal = new Hardban($login, $ip, $session, $timeout)) == FALSE) { + return (FALSE); } $this->item[$this->item_n] = $chal; @@ -143,7 +143,7 @@ class Hardbans { } // Static functions - static function &create() + static function create() { $chal =& new Hardbans(); @@ -152,9 +152,9 @@ class Hardbans { return $chal; } - function &load_data() + function load_data() { - GLOBAL $G_false, $sess; + GLOBAL $sess; $doexit = FALSE; do { if (($tok = @ftok(FTOK_PATH."/hardbans", "B")) == -1) { @@ -191,18 +191,17 @@ class Hardbans { $hban->garbage_manager(TRUE); - $ret = &$hban; - return ($ret); + return ($hban); } while (0); if ($doexit) exit(); - return ($G_false); + return (FALSE); } - function save_data(&$hban) + function save_data($hban) { $shm = FALSE; $oldmod = $hban->mod; diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 3e5c685..0c36306 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -170,12 +170,10 @@ class Table_briskin5 extends Table { /* CREATE() NOT USED - function &create($idx) + function create($idx) { - GLOBAL $G_false; - if (($thiz =& new Table_briskin5()) == FALSE) - return ($G_false); + return (FALSE); $thiz->create($idx); @@ -206,12 +204,10 @@ class Table_briskin5 extends Table { */ /* CLONE() NOT USED - function &myclone(&$from) + function myclone(&$from) { - GLOBAL $G_false; - if (($thiz =& new Table_briskin5()) == FALSE) - return ($G_false); + return (FALSE); parent::copy($from); @@ -250,18 +246,17 @@ class Table_briskin5 extends Table { parent::copy($from); } - function &spawn(&$from) + function spawn(&$from) { - GLOBAL $G_false; - if (($thiz =& new Table_briskin5()) == FALSE) - return ($G_false); + return (FALSE); $thiz->parentcopy($from); log_main("PLAYER_N - spawn.".$thiz->player_n); - $thiz->card = &$thiz->bunch_create(); + $thiz->card = array(); + $thiz->bunch_create(); $thiz->mazzo = rand(0,PLAYERS_N-1); $thiz->points_n = 0; $thiz->mult = 1; @@ -279,17 +274,26 @@ class Table_briskin5 extends Table { } - function &bunch_create() - { - $ret = array(); - - for ($i = 0 ; $i < (BRISKIN5_PLAYERS_N == 5 ? 40 : 24) ; $i++) { - // for ($i = 0 ; $i < 40 ; $i++) { - $ret[$i] =& new Card($i, 'bunch', 'no_owner'); - } + // function bunch_create_old() function AND + // { + // $ret = array(); + // + // for ($i = 0 ; $i < (BRISKIN5_PLAYERS_N == 5 ? 40 : 24) ; $i++) { + // // for ($i = 0 ; $i < 40 ; $i++) { + // $ret[$i] =& new Card($i, 'bunch', 'no_owner'); + // } + // + // $oret = &$ret; + // return ($oret); + // } - $oret = &$ret; - return ($oret); + function bunch_create() + { + $ret = array(); + + for ($i = 0 ; $i < (BRISKIN5_PLAYERS_N == 5 ? 40 : 24) ; $i++) { + $this->card[$i] = new Card($i, 'bunch', 'no_owner'); + } } function bunch_make() @@ -428,11 +432,9 @@ class User_briskin5 extends User { } /* CREATE NOT USED - function &create($name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") { - GLOBAL $G_false; - + function create($name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") { if (($thiz =& new User()) == FALSE) - return ($G_false); + return (FALSE); $thiz->asta_card = -2; $thiz->asta_pnt = -1; @@ -461,12 +463,10 @@ class User_briskin5 extends User { } /* CLONE NOT USED - function &myclone(&$from) + function myclone(&$from) { - GLOBAL $G_false; - if (($thiz =& new User()) == FALSE) - return ($G_false); + return (FALSE); $thiz->copy($from); @@ -474,12 +474,12 @@ class User_briskin5 extends User { } */ - function &spawn(&$from, $table, $table_pos) + function spawn(&$from, $table, $table_pos) { - GLOBAL $G_false, $CO_bin5_pref_ring_endauct; + GLOBAL $CO_bin5_pref_ring_endauct; if (($thiz =& new User_briskin5()) == FALSE) - return ($G_false); + return (FALSE); $thiz->parentcopy($from); @@ -548,9 +548,9 @@ class Briskin5 { } - function &get_user($sess, &$idx) + function get_user($sess, &$idx) { - GLOBAL $PHP_SELF, $G_false; + GLOBAL $PHP_SELF; if (validate_sess($sess)) { for ($i = 0 ; $i < BRISKIN5_MAX_PLAYERS ; $i++) { @@ -569,7 +569,7 @@ class Briskin5 { log_main(sprintf("get_user: Wrong strlen [%s]",$sess)); } - return ($G_false); + return (FALSE); } @@ -632,7 +632,7 @@ class Briskin5 { // // static functions // - function &load_data($table_idx, $table_token = "") + function load_data($table_idx, $table_token = "") { GLOBAL $G_false, $sess; $doexit = FALSE; @@ -678,7 +678,7 @@ class Briskin5 { if ($doexit) exit(); - return ($G_false); + return (FALSE); } diff --git a/web/briskin5/Obj/placing.phh b/web/briskin5/Obj/placing.phh index 81a4417..d6d6547 100644 --- a/web/briskin5/Obj/placing.phh +++ b/web/briskin5/Obj/placing.phh @@ -49,7 +49,7 @@ class Ptsgam { $this->gam = $gam; } - function &myclone() + function myclone() { $ret = new Ptsgam($this->username, $this->pts, $this->gam); @@ -177,7 +177,7 @@ function placing_date($mtime) } -function placing_show_file(&$user, $ty, $subty) +function placing_show_file($user, $ty, $subty) { $tail = FALSE; diff --git a/web/index.php b/web/index.php index 551dd79..5fd269d 100644 --- a/web/index.php +++ b/web/index.php @@ -225,7 +225,7 @@ function main() GLOBAL $G_with_topbanner, $G_topbanner, $G_is_local; GLOBAL $G_with_sidebanner, $G_sidebanner; GLOBAL $G_with_sidebanner2, $G_sidebanner2; - GLOBAL $G_with_poll, $G_false; + GLOBAL $G_with_poll; GLOBAL $sess, $name, $pass_private, $table_idx, $table_token, $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER; GLOBAL $G_lang, $G_lng, $mlang_room; $is_login = FALSE; @@ -234,8 +234,6 @@ function main() $standup = ""; $ACTION = "login"; - error_log("main: G_false: [".$G_false."]", 0); - if (isset($BRISK_SHOWHTML) == FALSE) { $is_table = FALSE; $sem = Room::lock_data(); diff --git a/web/index_wr.php b/web/index_wr.php index 1c8dd20..9ac86bf 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -165,12 +165,10 @@ if (($user = &$room->get_user($sess, &$idx)) == FALSE) { echo show_notify(str_replace("\n", " ", $G_room_roadmap[$G_lang]), 0, $mlang_indwr['btn_close'][$G_lang], 400, 200); } else if ($argz[0] == 'placing') { - GLOBAL $G_false; - require_once("briskin5/Obj/briskin5.phh"); require_once("briskin5/Obj/placing.phh"); - echo show_notify(str_replace("\n", " ", placings_show($G_false)), 0, $mlang_indwr['btn_close'][$G_lang], 800, 600); + echo show_notify(str_replace("\n", " ", placings_show(FALSE)), 0, $mlang_indwr['btn_close'][$G_lang], 800, 600); } else if ($argz[0] == 'whysupport') { echo show_notify(str_replace("\n", " ", $G_room_whysupport[$G_lang]), 0, $mlang_indwr['btn_close'][$G_lng], 400, 200); -- 2.17.1