modified check to skip chatt call to be able to log all msg in moderation
[brisk.git] / web / Obj / brisk.phh
index db99007..9cfa723 100644 (file)
@@ -77,6 +77,7 @@ define('DBG_CRIT', 0x0400);
 define('DBG_LMOP', 0x0800);
 define('DBG_TRAC', 0x1000);
 define('DBG_SHME', 0x2000);
+define('DBG_ENGI', 0x4000);
 // NOTE: BRISK DEBUG must be a numerical constant, not the result of operations on symbols 
 define('BRISK_DEBUG', 0x0800);
 
@@ -140,12 +141,12 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi',
 $G_lng = langtolng($G_lang);
 
 $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "4.6.0";
+$G_brisk_version = "4.8.0";
 
 /* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: aggiunti script di avvio automatico, gestione dei segnali e logging dell\' ultima connessione.',
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: prova il nuovo azioni->preferenze.',
                                        'Se vuoi iscriverti alla <a target="_blank" href="mailto:ml-briscola+subscribe@milug.org">Mailing List</a>, cliccala!' ),
-                       'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: usage of reader/writer locking instead of generic exclusive locking.',
+                       'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: server-side infrastructure to manage user preferences added and S customization added.',
                                        'If you want to subscribe our <a target="_blank" href="ml-briscola+subscribe@milug.org">Mailing List</a>, click it!' ) );
 
 $G_room_help = array( 'it' => '
@@ -600,11 +601,6 @@ class Table {
     }
   }
 
-
-
-  //      $ret .= table_act_content(($user->subst == 'standup'), $this->table[$i]->player_n, $i, $user->table, 
-  //                              ($this->table[$i]->auth_only == FALSE ? TRUE : $user->flags & USER_FLAG_AUTH));
-
   // function act_content($isstanding, $sitted, $table, $cur_table, $allowed)
   function act_content($user)
   {
@@ -697,13 +693,123 @@ class Delay_Manager
 
 class Client_prefs {
     var $listen;
+    var $supp_comp;
+
+    function Client_prefs()
+    {
+    }
+
+    static function from_user($user)
+    {
+        $thiz = new Client_prefs();
+        $thiz->user_load($user);
 
-    function Client_prefs($listen)
+        return ($thiz);
+    }
+
+    static function from_json($json)
     {
-        $this->listen = $listen;
+        $thiz = new Client_prefs();
+        if ($thiz->json_load($json) == FALSE) {
+            unset($thiz);
+            return (FALSE);
+        }
+
+        return ($thiz);
+    }
+
+    function user_load($user)
+    {
+        fprintf(STDERR, "QQ %s: %x\n", __FUNCTION__, $user->flags);
+        $this->listen = ($user->flags & USER_FLAG_MAP_AUTH) >> 2;
+        if ($user->rec != FALSE) {
+            $this->supp_comp = $user->rec->supp_comp;
+        }
+        else {
+            $this->supp_comp = "000000000000";
+        }
+
+        fprintf(STDERR, "QQ %s: LISTEN: %d\n", __FUNCTION__, $this->listen);
+    }
+
+    function json_load($json_s)
+    {
+        $ret = FALSE;
+
+        do {
+            if (gettype($json_s) == "string") {
+                if (($json = json_decode($json_s)) == FALSE)
+                    break;
+            }
+            else {
+                $json = $json_s;
+            }
+            if ($this->listen < 0 || $this->listen > 2)
+                break;
+            $this->listen = $json->listen;
+
+            if (mb_strlen($json->supp_comp, "ASCII") != 12)
+                break;
+
+            for ($i = 0, $idx = 0 ; $i < 12 ; $i++) {
+                if (($json->supp_comp[$i] >= '0' && $json->supp_comp[$i] <= '9') ||
+                    ($json->supp_comp[$i] >= 'a' && $json->supp_comp[$i] <= 'f'))
+                    continue;
+                break;
+            }
+            if ($i < 12)
+                break;
+            $this->supp_comp = $json->supp_comp;
+            $ret = TRUE;
+        } while (FALSE);
+
+        return ($ret);
+    }
+
+    function store($user, $is_save)
+    {
+        // save into DB
+        fprintf(STDERR, "QQ %s::%s PRE: %x\n", __CLASS__, __FUNCTION__,
+                $user->flags & (~USER_FLAG_AUTH));
+        $user->flags_set(($this->listen << 2), USER_FLAG_MAP_AUTH);
+        fprintf(STDERR, "QQ %s::%s %x\n", __CLASS__, __FUNCTION__,
+                $user->flags);
+        if ($user->is_supp_custom()) {
+            $user->rec->supp_comp = $this->supp_comp;
+        }
+        if ($is_save)
+            $user->store_set();
     }
 }
 
+class ModerationItem
+{
+    var $table;
+    var $date;
+    var $content;
+    function ModerationItem($where, $date, $content)
+    {
+        $this->where   = $where;
+        $this->time    = $time;
+        $this->content = $content;
+    }
+}
+
+class Moderation
+{
+    var $row;
+
+    function Moderation()
+    {
+        $this->item = Array();
+    }
+
+    function get_all()
+    {
+        return json_encode($this->item);
+    }
+}
 
 class Room
 {
@@ -880,7 +986,7 @@ class Room
        
        if ($user_cur->sess == "") 
             continue;
-       
+
        if ($user_cur->lacc + EXPIRE_TIME_RD < ($curtime - $delta)) {
             // Auto logout dell'utente
             log_rd2("AUTO LOGOUT.".($user_cur->lacc + EXPIRE_TIME_RD)." curtime - delta ".($curtime - $delta));
@@ -926,17 +1032,19 @@ class Room
     
     $ret = sprintf('gst.st = %d; ',  $user_step);
 
-    $prefs = new Client_prefs(($user->flags & USER_FLAG_MAP_AUTH) >> 2);
-    $ret .= sprintf('var prefs_new = prefs_load(\'%s\'); console.log(prefs_new);', json_encode($prefs));
+    $prefs = Client_prefs::from_user($user);
+    $ret .= sprintf('prefs_load(\'%s\', false, false);', json_encode($prefs));
 
-    if ($user->flags & USER_FLAG_ISOLAUTH) {
-      $ret .= 'list_set(\'isolation\', false, \''.$mlang_brisk['tit_onisol'][$G_lang].'\' ); ';
-    }
-    else if ($user->flags & USER_FLAG_LISTAUTH) {
-      $ret .= 'list_set(\'auth\', false, \''.$mlang_brisk['tit_onauth'][$G_lang].'\' ); ';
-    }
-    else {
-      $ret .= 'list_set(\'all\', false, \'\' ); ';
+    if(false) {
+        if ($user->flags & USER_FLAG_ISOLAUTH) {
+            $ret .= 'list_set(\'isolation\', false, \''.$mlang_brisk['tit_onisol'][$G_lang].'\' ); ';
+        }
+        else if ($user->flags & USER_FLAG_LISTAUTH) {
+            $ret .= 'list_set(\'auth\', false, \''.$mlang_brisk['tit_onauth'][$G_lang].'\' ); ';
+        }
+        else {
+            $ret .= 'list_set(\'all\', false, \'\' ); ';
+        }
     }
 
     if ($user->subst == 'standup')
@@ -958,8 +1066,6 @@ class Room
     for ($i = 0 ; $i < TABLES_N ; $i++) {
 
       $ret .= $this->table_content($user, $i);
-      // $ret .= table_act_content(($user->subst == 'standup'), $this->table[$i]->player_n, $i, $user->table, 
-      //                          ($this->table[$i]->auth_only == FALSE ? TRUE : $user->flags & USER_FLAG_AUTH));
       $ret .=  $this->table[$i]->act_content($user);
       if ($this->table[$i]->wag_own != -1) 
         $ret .= sprintf('tra.add(%d, "%s: %s"); ', $i,  $this->user[$this->table[$i]->wag_own]->name, $this->table[$i]->wag_com);
@@ -1023,7 +1129,7 @@ class Room
       $user_cur = $this->user[$i];
       if ($user_cur->sess == '' || $user_cur->stat != 'room')
        continue;
-      
+
       // log_main("VALORI: name: ".$user_cur->name."from_table: ".$from_table."  tab: ".$user_cur->table." taix: ".$table_idx."  ucur: ".$user_cur."  us: ".$user);
 
       $ret = "gst.st = ".($user_cur->step+1)."; ".($remove_wagon ? sprintf("tra.rem(%d);",$table_idx) : "");
@@ -1047,15 +1153,11 @@ class Room
          // clean the action buttons in other tables
          for ($e = 0 ; $e < TABLES_N ; $e++) {
            if ($this->table[$e]->player_n < PLAYERS_N) {
-             // $ret .= table_act_content(TRUE, 0, $e, $user->table, 
-              //                           ($this->table[$e]->auth_only == FALSE ? TRUE : $user->flags & USER_FLAG_AUTH));
               $ret .= $this->table[$e]->act_content($user);
             }
          }
        }
        else {
-         // $ret .= table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table,
-          //                           ($table->auth_only == FALSE ? TRUE : $user_cur->flags & USER_FLAG_AUTH));
           $ret .= $table->act_content($user_cur);
        }
       }
@@ -1130,8 +1232,6 @@ class Room
        $ret .= $this->table_content($user_cur, $table_idx);
        $ret .= $this->standup_content($user_cur);
        
-       // $ret .= table_act_content(FALSE, 0, $table_idx, $user_cur->table,
-        //                           ($table->auth_only == FALSE ? TRUE : $user_cur->flags & USER_FLAG_AUTH));
         $ret .= $table->act_content($user_cur);
 
 
@@ -1159,8 +1259,6 @@ class Room
        log_main("JOIN_WAKEUP wup_idx ".$wup_idx."  wup_n ".$user_wup_n);
 
        log_main("JOIN_WAKEUP more");
-       // $ret .= table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table,
-        //                           ($table->auth_only == FALSE ? TRUE : $user_cur->flags & USER_FLAG_AUTH));
         $ret .= $table->act_content($user_cur);
 
        log_main("JOIN_WAKEUP end more");
@@ -1190,7 +1288,7 @@ class Room
       $user_cur = $this->user[$i];
       if ($user_cur->sess == '' || $user_cur->stat != 'room')
       continue;
-      
+
       $ret = "gst.st = ".($user_cur->step+1)."; ";
       if ($table_idx > -1)
        $ret .= $this->table_content($user_cur, $table_idx);
@@ -1247,8 +1345,6 @@ class Room
       }
       else if ($table_idx > -1) {
        if ($table->player_n == PLAYERS_N) {
-         // $ret .= table_act_content(($user_cur->subst == 'standup'), PLAYERS_N, $table_idx, $user_cur->table,
-          ///                      ($table->auth_only == FALSE ? TRUE : $user_cur->flags & USER_FLAG_AUTH));
           $ret .= $table->act_content($user_cur);
        }
       }
@@ -1342,8 +1438,7 @@ class Room
         /* MLANG: "Alarm <b>%s</b> inviato a <b>%s</b>." */
         $prestr = sprintf($mlang_brisk['alarret'][$G_lang], xcape(substr($msg, strlen($alarm_check))), 
                            ($target == "" ? $mlang_brisk['tit_all'][$G_lang] : xcape($target)) );
-        $to_user = sprintf('chatt_sub("%s", [2, "%s"],%s);', 
-                           $dt, NICKSERV, $prestr);
+        $to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],%s);', $dt, NICKSERV, $prestr);
 
         $msg = sprintf("<br><b>%s<br><br>%s</b><br><br>",
                        $dt.NICKSERV, xcape(substr($msg, strlen($alarm_check))));
@@ -1358,7 +1453,7 @@ class Room
         $flags_old = 0;
         if ($user->stat == 'room' && $user->subst == 'sitdown' &&
             $user->table >= TABLES_AUTH_N) {
-          $to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['listmust'][$G_lang]);
+          $to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['listmust'][$G_lang]);
           
         }
         else {
@@ -1391,7 +1486,7 @@ class Room
       }
       else {
         /* MLANG: "<b>Per autenticare qualcuno devi a tua volta essere autenticato.</b>", "Il nickname deve contenere almeno una lettera dell\'alfabeto o una cifra.", "Nickname <b>%s</b> gi&agrave; in uso." */
-        $to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['authmust'][$G_lang]);
+        $to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['authmust'][$G_lang]);
       }
     }
     else if (strncmp($msg, "/mesgtoadm", 8) == 0) {
@@ -1400,7 +1495,7 @@ class Room
       }
       else {
         /* MLANG: "<b>Per inviare un messaggio devi essere autenticato.</b>" */
-        $to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['mesgmust'][$G_lang]);
+        $to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['mesgmust'][$G_lang]);
       }
     }
     else if (strncmp($msg, "/nick ", 6) == 0) {
@@ -1408,7 +1503,7 @@ class Room
 
       do {
         if (($name_new = validate_name(substr($msg, 6))) == FALSE) {
-          $to_user = sprintf('chatt_sub("%s", [2,"%s"],"%s");', $dt, NICKSERV, $mlang_brisk['nickmust'][$G_lang]);
+          $to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['nickmust'][$G_lang]);
           break;
         }
 
@@ -1423,7 +1518,7 @@ class Room
           }
         if ($i <  MAX_PLAYERS) {
           $prestr = sprintf($mlang_brisk['nickdupl'][$G_lang], xcape($name_new));
-          $to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $prestr);
+          $to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $prestr);
           break;
         }
         
@@ -1441,7 +1536,7 @@ class Room
               }
             }
             else {
-              $to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['authchan'][$G_lang]);
+              $to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['authchan'][$G_lang]);
               break;
             }
           }
@@ -1454,7 +1549,7 @@ class Room
                 /* MLANG: "Il nickname <b>\'%s\'</b> &egrave; gi&agrave; registrato, <b>se il suo proprietario si autentificher&agrave; verrai rinominato d\'ufficio come ghost<i>N</i>.</b>" */
                 if ($bdb->login_exists($name_new)) {
                     $prestr = sprintf($mlang_brisk['nickjust'][$G_lang], xcape($name_new));
-                    $to_user .= sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $prestr);
+                    $to_user .= sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $prestr);
                 }
             }
         }
@@ -1521,14 +1616,13 @@ class Room
         }
         else {
           /* MLANG: "Questo stato non esiste." */
-          $to_user = sprintf('chatt_sub("%s", [2,"%s"],"%s");', $dt, NICKSERV, $mlang_brisk['statunkn'][$G_lang]);
+          $to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_brisk['statunkn'][$G_lang]);
           break;
         }
 
         log_main("chatt_send start set");
-        if (($user->flags & USER_FLAG_S_ALL) != $st) {
-          $update_room = TRUE;
-          $user->flags = ($user->flags & ~USER_FLAG_S_ALL) | $st;
+        if ($user->flags_vlt_set($st, USER_FLAG_S_ALL)) {
+            $update_room = TRUE;
         }
       } while (0);
     } // nick chat command
@@ -1554,10 +1648,10 @@ class Room
       }
 
       if ($only_you) {
-        $to_user = sprintf('chatt_sub("%s", [%d, "%s"],"%s");', $dt, $user->flags, xcape($user->name), xcape("== chat ban =="));
+          $to_user = sprintf('chatt_sub("%s", [%d, %d, "%s"],"%s");', $dt, $user->flags, $user->flags_vlt, xcape($user->name), xcape("== chat ban =="));
       }
       else {
-        $to_user = sprintf('chatt_sub("%s", [%d, "%s"],"%s");', $dt, $user->flags, xcape($user->name), xcape($msg));
+          $to_user = sprintf('chatt_sub("%s", [%d, %d, "%s"],"%s");', $dt, $user->flags, $user->flags_vlt, xcape($user->name), xcape($msg));
        // temporary silentiation for troll (will became array check)
        // if (strcasecmp($user->name,'JackRokka') != 0 && $user->sess != '47ea653f602e8')
         $to_room = $to_user;
@@ -1587,33 +1681,44 @@ class Room
     }
 
     if ($to_room != FALSE) {
-      for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
-        $user_cur = $this->user[$i];
-        if ($target != "" && $user_cur->name != $target)
-          continue;
-        if ($user_cur->sess == '' || $user_cur->stat == 'table' || $user->idx_get() == $i)
-          continue;
-        
-        if ($is_normchat == TRUE) {
-          // use MAP_AUTH to check if auth or isolation
-          if ($user_cur->flags & USER_FLAG_MAP_AUTH) {
-            if (($user->flags & USER_FLAG_AUTH) == 0) {
-              continue;
+        for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+            $user_cur = $this->user[$i];
+            if ($target != "" && $user_cur->name != $target)
+                continue;
+            if ($user_cur->sess == '')
+                continue;
+
+            if ($user_cur->flags_vlt_get(USER_FLAG_MODER)) {
+                $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('g_moder.add([%d, "%s", %d, "%s", "%s"]);' ,
+                                                                     $curtime, "userid",
+                                                                     ($user->stat == 'table' ? $user->table : -1),
+                                                                     xcape($user->name), xcape($msg) );
+                $user_cur->step_inc();
             }
-          }
-        }
-        /*
-        else if ($is_ticker) {
-          if (($user_cur->flags & USER_FLAG_MAP_AUTH) == USER_FLAG_ISOLAUTH) {
-            if ($user->table >= TABLES_AUTH_N)
+            
+            if ($user_cur->stat == 'table' || $user->idx_get() == $i)
+                continue;
+
+            if ($is_normchat == TRUE) {
+                // use MAP_AUTH to check if auth or isolation
+                if ($user_cur->flags & USER_FLAG_MAP_AUTH) {
+                    if (($user->flags & USER_FLAG_AUTH) == 0) {
+                        continue;
+                    }
+                }
+            }
+            /*
+              else if ($is_ticker) {
+              if (($user_cur->flags & USER_FLAG_MAP_AUTH) == USER_FLAG_ISOLAUTH) {
+              if ($user->table >= TABLES_AUTH_N)
               continue;
-          }
+              }
+              }
+            */
+            $user_cur->comm[$user_cur->step % COMM_N] =  "gst.st = ".($user_cur->step+1)."; ";
+            $user_cur->comm[$user_cur->step % COMM_N] .= $to_room; 
+            $user_cur->step_inc();
         }
-        */
-        $user_cur->comm[$user_cur->step % COMM_N] =  "gst.st = ".($user_cur->step+1)."; ";
-        $user_cur->comm[$user_cur->step % COMM_N] .= $to_room; 
-        $user_cur->step_inc();
-      }
     }
     
     if ($to_tabl) {
@@ -1821,31 +1926,39 @@ class Room
       $this->user[$idx]->bantime = 0;
       $this->user[$idx]->ip = $ip;
 
+      $this->user[$idx]->rec = $authenticate;
+      fprintf(STDERR, "MOP: [%s]\n", $authenticate->supp_comp);
       $this->user[$idx]->flags = $user_type;
       $this->user[$idx]->flags |= ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00);
       $this->user[$idx]->flags |= ( ($pass != FALSE && $bdb == FALSE) ? USER_FLAG_DBFAILED : 0x00);
       log_auth("XXX", sprintf("FLAGS: [%x]", $this->user[$idx]->flags));
-
       
       if ($authenticate != FALSE) {
-        $this->user[$idx]->code = $authenticate->code_get();
-        $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
-
-        if (isset($cookie['CO_list'])) {
-          if (strcmp($cookie['CO_list'], "auth") == 0) {
-            $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
-            $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
-          }
-          if (strcmp($cookie['CO_list'], "isolation") == 0) {
-            $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
-            $this->user[$idx]->flags |= USER_FLAG_ISOLAUTH;
+          $this->user[$idx]->code = $authenticate->code_get();
+          if (0 == 1) {
+              // all this part is included in the db server
+              $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
+
+              if (isset($cookie['CO_list'])) {
+                  fprintf(STDERR, "QQ: %s CO_list: [%s]\n", __FUNCTION__, $cookie['CO_list']);
+                  if (strcmp($cookie['CO_list'], "auth") == 0) {
+                      $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
+                      $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
+                  }
+                  if (strcmp($cookie['CO_list'], "isolation") == 0) {
+                      $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
+                      $this->user[$idx]->flags |= USER_FLAG_ISOLAUTH;
+                  }
+                  else {
+                      $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
+                  }
+              }
           }
           else {
-            $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
+              fprintf(STDERR, "QQ: CO_list not set flags: %x\n", __FUNCTION__, $this->user[$idx]->flags);
           }
-        }
       }
-      
+      fprintf(STDERR, "QQ %s: flag %x\n", __FUNCTION__, $this->user[$idx]->flags);
       if ($ghost > -1) {
         log_main("ghost: rename!");
         $ghost_user = $this->user[$ghost];
@@ -2130,20 +2243,31 @@ class Room
     
     $content = ' j_stand_cont( [ ';
 
+    $user_cur_id = $user->idx_get();
     for ($i = 0 , $ct = 0 ; $i < MAX_PLAYERS ; $i++) {
-      if ($this->user[$i]->sess == "" || $this->user[$i]->stat != "room" || $this->user[$i]->name == "")
-        continue;
-      
-      $flags = $this->user[$i]->flags;
-      
-      if ($this->user[$i]->subst == "standup") {
-          if ($user->idx_get() == $i) { 
-              $flags |= 1;
-          }
-          
-          $content .= sprintf('%s[ %d, "%s" ]',($ct > 0 ? ', ' : ''), $flags, xcape($this->user[$i]->name));
-          $ct++;
-      }
+        if ($this->user[$i]->sess == "" || $this->user[$i]->stat != "room" || $this->user[$i]->name == "")
+            continue;
+
+        $flags = $this->user[$i]->flags;
+        $flags_vlt = $this->user[$i]->flags_vlt;
+
+        // sql record exists AND last donate > 2013-01-01
+        if ($this->user[$i]->is_supp_custom()) {
+            $supp_comp_s = sprintf(', "%s"', $this->user[$i]->rec->supp_comp);
+        }
+        else {
+            $supp_comp_s = '';
+        }
+
+        if ($this->user[$i]->subst == "standup") {
+            if ($user_cur_id == $i) {
+                $flags |= 1;
+            }
+            $content .= sprintf('%s[ %d, %d, "%s"%s ]',($ct > 0 ? ', ' : ''),
+                                $flags, $flags_vlt,
+                                xcape($this->user[$i]->name), $supp_comp_s);
+            $ct++;
+        }
     }
     $content .= ' ]);';
     
@@ -2165,18 +2289,26 @@ class Room
     if ($user->stat != 'room')
       return;
     
+    $user_cur_id = $user->idx_get();
     $content = "[ ";
     for ($i = 0 ; $i < $table->player_n ; $i++) {
         $user_cur = $this->user[$table->player[$i]];
         
         $flags = $user_cur->flags;
-        
-        if ($user->idx_get() == $table->player[$i]) 
+        $flags_vlt = $user_cur->flags_vlt;
+
+        if ($user_cur_id == $table->player[$i])
             $flags |= 1;
         
         log_main($user_cur->name. sprintf(" IN TABLE [%d]", $table_idx));
-        
-        $content .= sprintf('%s[ %d, "%s" ]',($i == 0 ? '' : ', '), $flags, xcape($user_cur->name));
+        if ($user_cur->is_supp_custom())
+            $supp_comp_s = sprintf(', "%s"', $user_cur->rec->supp_comp);
+        else
+            $supp_comp_s = '';
+
+        $content .= sprintf('%s[ %d, %d, "%s"%s ]',($i == 0 ? '' : ', '),
+                            $flags, $flags_vlt,
+                            xcape($user_cur->name), $supp_comp_s);
     }
 
     $content .= ' ]';
@@ -2188,7 +2320,9 @@ class Room
 
   function request_mgr(&$s_a_p, $header, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie)
   {
-      printf("NEW_SOCKET (root): %d\n", intval($new_socket));
+      GLOBAL $G_black_list;
+
+      printf("NEW_SOCKET (root): %d PATH [%s]\n", intval($new_socket), $path);
 
       $enc = get_encoding($header);
       if (isset($header['User-Agent'])) {
@@ -2212,17 +2346,24 @@ class Room
           $content = ob_get_contents();
           ob_end_clean();
 
-          $s_a_p->pgflush_try_add($enc, $new_socket, 20, $header_out, $content);
+          // fprintf(STDERR, "\n\nCONTENT [%s]\n\n", $content);
+          $s_a_p->pendpage_try_addflush($new_socket, 20, $enc, $header_out, $content);
           return TRUE;
 
           break;
       case "index_wr.php":
+          //
+          // Enhance required: in the POST case, after the header you must get content
+          //                   from the socket, waiting if necessary
+          //
+
+          fprintf(STDERR, "\n\nDENTRO QUI\n\n");
           ob_start();
           index_wr_main($this, $addr, $get, $post, $cookie);
           $content = ob_get_contents();
           ob_end_clean();
           
-          $s_a_p->pgflush_try_add($enc, $new_socket, 20, $header_out, $content);
+          $s_a_p->pendpage_try_addflush($new_socket, 20, $enc, $header_out, $content);
           return TRUE;
 
           break;
@@ -2235,7 +2376,7 @@ class Room
                   
                   $content = User::stream_fini($transp, $s_a_p->rndstr, TRUE);
 
-                  $s_a_p->pgflush_try_add($enc, $new_socket, 20, $header_out, $content);
+                  $s_a_p->pendpage_try_addflush($new_socket, 20, $enc, $header_out, $content);
                   return TRUE;
 
                   break;
@@ -2265,7 +2406,7 @@ class Room
               fflush($new_socket);
               
               
-              $s_a_p->socks_set($new_socket, $user);
+              $s_a_p->socks_set($new_socket, $user, NULL);
               $user->rd_socket_set($new_socket);
               printf(" - qui ci siamo - ");
               return TRUE;
@@ -2273,7 +2414,20 @@ class Room
           
           return FALSE;
           break;
-
+      case 'test.php':
+          if (!(BRISK_DEBUG & DBG_ENGI))
+              return (FALSE);
+          fprintf(STDERR, "TEST.PHP running\n");
+          if (isset($post['data'])) {
+              $content = $post['data'];
+          }
+          else {
+              $content = "NO DATA AVAILABLE";
+          }
+          $header_out['Content-Type'] = 'text/plain';
+          $s_a_p->pendpage_try_addflush($new_socket, 20, $enc, $header_out, $content);
+          return TRUE;
+          break;
       default:
           /* FAR TODO: move all into an array of registered sub-apps */
           $subs = "briskin5/";
@@ -2728,7 +2882,7 @@ function root_welcome($user)
   $dt = date("H:i ", $curtime);
     
   for ($i = 0 ; $i < count($root_wellarr[$G_lang]) ; $i++)
-    $ret .= sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, str_replace('"', '\"', $root_wellarr[$G_lang][$i]));
+    $ret .= sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, str_replace('"', '\"', $root_wellarr[$G_lang][$i]));
 
   return ($ret);
 }