remove all reference operator because with php5 pass by reference is the default...
[brisk.git] / web / briskin5 / Obj / briskin5.phh
index e05e7b9..06f737e 100644 (file)
@@ -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()
+  //   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);
+  //   }
+
+  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');
-    }
-
-    $oret = &$ret;
-    return ($oret);
+      $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()
@@ -319,7 +323,7 @@ class Table_briskin5 extends Table {
     log_main("bunch_make end");
   }
 
-  function init(&$userarr)
+  function init($userarr)
   {
     /* MOVED INTO SPAWN
     $this->mazzo    =  rand(0,PLAYERS_N-1);
@@ -330,14 +334,14 @@ class Table_briskin5 extends Table {
     */
     for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
       $this->total[$i] = 0;
-      $user_cur = &$userarr[$this->player[$i]];
+      $user_cur = $userarr[$this->player[$i]];
       $user_cur->exitislock = TRUE;
     }
 
     log_main("table::init: ci siamo");
   }
 
-  function game_init(&$userarr)
+  function game_init($userarr)
   {
     log_rd2("GSTART 4");
 
@@ -355,7 +359,7 @@ class Table_briskin5 extends Table {
     
     for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
       $this->asta_pla[$i] = TRUE;
-      $user_cur = &$userarr[$this->player[$i]];
+      $user_cur = $userarr[$this->player[$i]];
       $user_cur->subst = 'asta';
       $user_cur->asta_card = -2;
       $user_cur->asta_pnt  = -1;
@@ -390,9 +394,9 @@ class Table_briskin5 extends Table {
   }
 
 
-  function exitlock_show(&$userarr, $table_pos)
+  function exitlock_show($userarr, $table_pos)
   {
-    $ct = $this->exitlock_calc(&$userarr, $table_pos);
+    $ct = $this->exitlock_calc($userarr, $table_pos);
 
     $ret = sprintf('exitlock_show(%d, %s);', $ct, 
                   ($userarr[$this->player[$table_pos]]->exitislock ? 'true' : 'false'));
@@ -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);
 
@@ -527,14 +527,14 @@ class Briskin5 {
       exit;
     }
 
-    $user  =& $room->user;
-    $table =& $room->table[$table_idx];
+    $user  = $room->user;
+    $table = $room->table[$table_idx];
 
     log_wr("Briskin5 constructor");
 
     for ($i = 0 ; $i < $table->player_n ; $i++) {
       $user[$table->player[$i]]->table_token = $table_token;
-      $this->user[$i] =& User_briskin5::spawn(&$user[$table->player[$i]], $table_idx, $i);
+      $this->user[$i] =& User_briskin5::spawn($user[$table->player[$i]], $table_idx, $i);
     }
     $this->table[0] =& Table_briskin5::spawn(&$table);
 
@@ -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,20 +569,21 @@ class Briskin5 {
       log_main(sprintf("get_user: Wrong strlen [%s]",$sess));
     }
 
-    return ($G_false);
+    return (FALSE);
   }
 
 
   function garbage_manager($force)
   {
-    
+    GLOBAL $G_base;
+
     /* Garbage collector degli utenti in timeout */
     $ismod = FALSE;
     $curtime = time();
     if ($force || $this->garbage_timeout < $curtime) {
       
       for ($i = 0 ; $i < BRISKIN5_MAX_PLAYERS ; $i++) {
-       $user_cur = &$this->user[$i];
+       $user_cur = $this->user[$i];
        if ($user_cur->sess == "" || 
            ($user_cur->stat == 'table' && ($user_cur->subst == 'shutdowned' || $user_cur->subst == 'shutdowner')))
          continue;
@@ -606,13 +607,13 @@ class Briskin5 {
             /* se gli altri utenti non erano d'accordo questo utente viene bannato */
             $remcalc = $this->table[0]->exitlock_calc(&$this->user, $user_cur->table_pos);
             if ($remcalc < 3) {
-                require_once("/var/www/webspace/trusty/Obj/hardban.phh");
+                require_once("${G_base}Obj/hardban.phh");
                 Hardbans::add(($user_cur->flags & USER_FLAG_AUTH ? $user_cur->name : FALSE),
                               $user_cur->ip, $user_cur->sess, $user_cur->laccwr + BAN_TIME);
             }
             //      $user->bantime = $user->laccwr + BAN_TIME;
 
-           $this->table_wakeup(&$user_cur);
+           $this->table_wakeup($user_cur);
          }
        }
       }
@@ -631,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;
@@ -677,7 +678,7 @@ class Briskin5 {
     if ($doexit)
       exit();
     
-    return ($G_false);
+    return (FALSE);
   }
   
 
@@ -790,7 +791,7 @@ class Briskin5 {
   }
 
 
-  function chatt_send(&$user, $mesg)
+  function chatt_send($user, $mesg)
   {
     GLOBAL $mlang_brisk, $G_lang;
 
@@ -819,7 +820,7 @@ class Briskin5 {
       // update local graph
       // update remote graphs
       for ($i = 0 ; $i < BRISKIN5_MAX_PLAYERS ; $i++) {
-       $user_cur = &$this->user[$i];
+       $user_cur = $this->user[$i];
        //      if ($user_cur->sess == '' || $user_cur->stat != 'room')
        if ($user_cur->sess == '')
          continue;
@@ -907,7 +908,7 @@ class Briskin5 {
     }
   }
 
-  function table_wakeup(&$user)
+  function table_wakeup($user)
   {
     $table = &$this->table[0];
 
@@ -1084,7 +1085,7 @@ Examples                    of $is_transition, $is_again:
 function show_table(&$room, &$user, $sendstep, $is_transition, $is_again)
 {
   $table_idx = $user->table;
-  $table = &$room->table[$table_idx];
+  $table     = $room->table[$table_idx];
   $table_pos = $user->table_pos;
 
   $ret = "table_init();";
@@ -1316,7 +1317,7 @@ function show_table_info(&$room, &$table, $table_pos)
   GLOBAL $G_lang, $mlang_bin5_bin5;
 
   $ret = "";
-  $user = &$room->user[$table->player[$table_pos]];
+  $user = $room->user[$table->player[$table_pos]];
 
   $pnt_min = $table->points_n - MAX_POINTS < 0 ? 0 : $table->points_n - MAX_POINTS;
   $noty = sprintf('<table class=\"points\"><tr><th></th>');
@@ -1496,4 +1497,17 @@ function game_result($asta_pnt, $pnt)
   }
 }
 
+function log_points($curtime, $user, $where, $mesg) 
+{
+  GLOBAL $_SERVER;
+
+  if (($fp = @fopen(LEGAL_PATH."/points.log", 'a')) != FALSE) {
+    /* Unix time | session | nickname | IP | where was | mesg */
+    fwrite($fp, sprintf("%ld|%s|%s|%s|%s|%s|%s|\n", $curtime, $user->sess,
+                        ($user->flags & USER_FLAG_AUTH ? 'A' : 'N'),
+                        $user->name, $_SERVER['REMOTE_ADDR'], $where , $mesg));
+    fclose($fp);
+  }
+}
+
 ?>