version updated
[brisk.git] / web / Obj / brisk.phh
index 058cf34..9c026f0 100644 (file)
@@ -141,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.7.0";
+$G_brisk_version = "4.9.0";
 
 /* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: aggiunta infrastruttura per gestire le preferenze utente lato server e la personalizzazione delle S di supporter.',
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: aggiunto WebSocket come sistema preferenziale di comunicazione.',
                                        '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>: server-side infrastructure to manage user preferences added and S customization added.',
+                       'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: added WebSocket as preferential communication system.',
                                        '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' => '
@@ -779,7 +779,7 @@ class Client_prefs {
         $user->flags_set(($this->listen << 2), USER_FLAG_MAP_AUTH);
         fprintf(STDERR, "QQ %s::%s %x\n", __CLASS__, __FUNCTION__,
                 $user->flags);
-        if ($user->rec != FALSE && $user->rec->last_dona > 1356994800) {
+        if ($user->is_supp_custom()) {
             $user->rec->supp_comp = $this->supp_comp;
         }
         if ($is_save)
@@ -1292,54 +1292,53 @@ class Room
 
   function room_sitdown($user, $table_idx)
   {
-    log_main("room_sitdown ".($user == FALSE ? "USER: FALSE" : "USER: ".$user->name));
-
-    $train_app = "";
-
-    if ($table_idx > -1 && $table_idx < TABLES_N) { 
-      $table = $this->table[$table_idx];
-
-      // wagon shutdown 
-      if ($table->wag_own != -1 && $table->player_n == PLAYERS_N) {        
-        for ($i = 0 ; $i < TABLES_N ; $i++) {
-            if ($table->wag_own == $table->player[$i]) {
-                $train_app = sprintf("tra.rem(%d); ", $table_idx); 
-                $table->wag_reset(time());
-                break;
-            }
-       }
-      }
-    }
-
-    for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
-      $ret = "";
-      $user_cur = $this->user[$i];
-      if ($user_cur->sess == '' || $user_cur->stat != 'room')
-      continue;
+      log_main("room_sitdown ".($user == FALSE ? "USER: FALSE" : "USER: ".$user->name));
       
-      $ret = "gst.st = ".($user_cur->step+1)."; ".$train_app;
-      if ($table_idx > -1)
-      $ret .= $this->table_content($user_cur, $table_idx);
-      $ret .= $this->standup_content($user_cur);
+      $train_app = "";
       
-      if ($user->idx_get() == $i) {
-       $ret .=  'subst = "sitdown"; tra.hide(); ';
-       // clean the action buttons in other tables
-       for ($e = 0 ; $e < TABLES_N ; $e++) {
-         // $ret .= table_act_content(FALSE, 0, $e, $user_cur->table, FALSE);
-          $ret .= $this->table[$e]->act_content($user_cur);
-       }
+      if ($table_idx > -1 && $table_idx < TABLES_N) { 
+          $table = $this->table[$table_idx];
+          
+          // wagon shutdown 
+          if ($table->wag_own != -1 && $table->player_n == PLAYERS_N) {        
+              for ($i = 0 ; $i < TABLES_N ; $i++) {
+                  if ($table->wag_own == $table->player[$i]) {
+                      $train_app = sprintf("tra.rem(%d); ", $table_idx); 
+                      $table->wag_reset(time());
+                      break;
+                  }
+              }
+          }
       }
-      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);
-       }
+      
+      for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+          $ret = "";
+          $user_cur = $this->user[$i];
+          if ($user_cur->sess == '' || $user_cur->stat != 'room')
+              continue;
+          
+          $ret = "gst.st = ".($user_cur->step+1)."; ".$train_app;
+          if ($table_idx > -1)
+              $ret .= $this->table_content($user_cur, $table_idx);
+          $ret .= $this->standup_content($user_cur);
+          
+          if ($user->idx_get() == $i) {
+              $ret .=  'subst = "sitdown"; tra.hide(); ';
+              // clean the action buttons in other tables
+              for ($e = 0 ; $e < TABLES_N ; $e++) {
+                  $ret .= $this->table[$e]->act_content($user_cur);
+              }
+          }
+          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);
+              }
+          }
+          $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+          $user_cur->step_inc();
       }
-      $user_cur->comm[$user_cur->step % COMM_N] = $ret;
-      $user_cur->step_inc();
-    }
   }
 
   function chatt_send($user, $mesg)
@@ -2231,7 +2230,7 @@ class Room
       $flags = $this->user[$i]->flags;
 
       // sql record exists AND last donate > 2013-01-01
-      if ($this->user[$i]->rec != FALSE && $this->user[$i]->rec->last_dona > 1356994800) {
+      if ($this->user[$i]->is_supp_custom()) {
           $supp_comp_s = sprintf(', "%s"', $this->user[$i]->rec->supp_comp);
       }
       else {
@@ -2279,7 +2278,7 @@ class Room
             $flags |= 1;
         
         log_main($user_cur->name. sprintf(" IN TABLE [%d]", $table_idx));
-        if ($user_cur->rec != FALSE && $user_cur->rec->last_dona > 1356994800)
+        if ($user_cur->is_supp_custom())
             $supp_comp_s = sprintf(', "%s"', $user_cur->rec->supp_comp);
         else
             $supp_comp_s = '';
@@ -2297,6 +2296,8 @@ class Room
 
   function request_mgr(&$s_a_p, $header, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie)
   {
+      GLOBAL $G_black_list;
+
       printf("NEW_SOCKET (root): %d PATH [%s]\n", intval($new_socket), $path);
 
       $enc = get_encoding($header);
@@ -2343,6 +2344,7 @@ class Room
 
           break;
       case "index_rd_ifra.php":
+          // $enc = 'plain';
           do {
               if (!isset($cookie['sess'])
                   || (($user = $this->get_user($cookie['sess'], $idx)) == FALSE)) {
@@ -2365,9 +2367,8 @@ class Room
               }
 
               $content = "";
-              $user->stream_init($s_a_p->rndstr, $enc, $header_out, $content, $get, $post, $cookie);
-              
-              $response = headers_render($header_out, -1).chunked_content($user->rd_zls_get(), $content);
+              $user->stream_init($s_a_p->rndstr, $enc, $header, $header_out, $content, $get, $post, $cookie);
+              $response = headers_render($header_out, -1).$user->chunked_content($content);
               $response_l = mb_strlen($response, "ASCII");
               
               $wret = @fwrite($new_socket, $response, $response_l);