Merge remote-tracking branch 'origin/together-for-fun' into nginx
authorMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 9 Jul 2017 17:02:31 +0000 (19:02 +0200)
committerMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 9 Jul 2017 17:02:31 +0000 (19:02 +0200)
Conflicts:
web/briskin5/Obj/briskin5.phh
web/briskin5/index_wr.php
web/briskin5/stat-day.php
web/briskin5/statadm.php

17 files changed:
INSTALL.sh
WARNING.txt
web/Obj/brisk.phh
web/Obj/dbase_file.phh
web/Obj/dbase_pgsql.phh
web/Obj/hardban.phh
web/Obj/sac-a-push.phh
web/Obj/transports.phh
web/Obj/user.phh
web/briskin5/Obj/briskin5.phh
web/briskin5/index.php
web/briskin5/index_wr.php
web/commons.js
web/index.php
web/index_wr.php
web/xynt-streaming.js
web/xynt_test01.php

index 4dd75ee..1966c41 100755 (executable)
@@ -364,6 +364,8 @@ if [ "$web_only" = "FALSE" ]; then
     done
     chmod -R 777 ${proxy_path}/bin5
 
+    mkdir -p "${legal_path}"
+    chmod 777 "${legal_path}"
 fi
 install -d ${web_path}__
 for i in $(find web -type d | grep '/' | sed 's/^....//g'); do
@@ -373,6 +375,10 @@ done
 for i in $(find web -name '.htaccess' -o -name '*.php' -o -name '*.phh' -o -name '*.pho' -o -name '*.css' -o -name '*.js' -o -name '*.mp3' -o -name '*.swf' -o -name 'terms-of-service*' | sed 's/^....//g'); do
     install -m 644 "web/$i" "${web_path}__/$i"
 done
+
+# hardlink for nginx managed websocket files.
+ln "${web_path}__/xynt_test01.php" "${web_path}__/xynt_test01_wss.php"
+
 if [ "$test_add" = "TRUE" ]; then
     for i in $(find webtest -name '.htaccess' -o -name '*.php' -o -name '*.phh' -o -name '*.pho' -o -name '*.css' -o -name '*.js' -o -name '*.mp3' -o -name '*.swf' -o -name 'terms-of-service*' | sed 's/^........//g'); do
         install -m 644 "webtest/$i" "${web_path}__/$i"
index a15fc68..edd81bc 100644 (file)
@@ -2,10 +2,12 @@ APACHE2 CONFIGURATION IS CHANGED ! THIS IS A SAMPLE:
 
 ProxyPassMatch ^/brisk/.*\.(png|gif|jpg|css|js)$ !
     ProxyPass /brisk/briskin5/index_rd.php fd:///var/www/brisk-priv/brisk.sock keepalive=Off connectiontimeout=5 timeout=30
+    ProxyPass /brisk/briskin5/index_rd_wss.php fd:///var/www/brisk-priv/brisk.sock keepalive=Off connectiontimeout=5 timeout=30
     ProxyPass /brisk/briskin5/index_wr.php fd:///var/www/brisk-priv/brisk.sock keepalive=Off connectiontimeout=5 timeout=30
     ProxyPass /brisk/briskin5/briskin5/index.php fd:///var/www/brisk-priv/brisk.sock keepalive=Off connectiontimeout=5 timeout=30
     ProxyPass /brisk/briskin5/index.php fd:///var/www/brisk-priv/brisk.sock keepalive=Off connectiontimeout=5 timeout=30
     ProxyPass /brisk/index_rd.php fd:///var/www/brisk-priv/brisk.sock keepalive=Off connectiontimeout=5 timeout=30
+    ProxyPass /brisk/index_rd_wss.php fd:///var/www/brisk-priv/brisk.sock keepalive=Off connectiontimeout=5 timeout=30
     ProxyPass /brisk/index_wr.php fd:///var/www/brisk-priv/brisk.sock keepalive=Off connectiontimeout=5 timeout=30
     ProxyPass /brisk/index.php fd:///var/www/brisk-priv/brisk.sock keepalive=Off connectiontimeout=5 timeout=30
 --------
index bd834d8..c89d6ac 100644 (file)
@@ -2803,9 +2803,10 @@ class Brisk
 
           break;
       case "index_rd.php":
+      case "index_rd_wss.php":
           if (($transp  = gpcs_var('transp', $get, $post, $cookie)) === FALSE)
               $transp = "iframe";
-          if ($transp == 'websocket')
+          if ($transp == 'websocket' || $transp == 'websocketsec')
               $enc = 'plain';
 
           do {
@@ -2871,7 +2872,7 @@ class Brisk
           $subs = "briskin5/";
           $subs_l = strlen($subs);
           if (!strncmp($path, $subs, $subs_l)) {
-              $ret = Bin5::request_mgr(&$s_a_p, $header, &$header_out, &$new_socket, substr($path, $subs_l) , $addr, $get, $post, $cookie);
+              $ret = Bin5::request_mgr($s_a_p, $header, $header_out, $new_socket, substr($path, $subs_l) , $addr, $get, $post, $cookie);
               return ($ret);
           }
           break;
index d917a81..9461f1e 100644 (file)
@@ -166,7 +166,7 @@ class BriskDB {
                     }
                     
                     if ($chals->ismod()) {
-                        Challenges::save_data(&$chals);
+                        Challenges::save_data($chals);
                     }
                     
                     Challenges::unlock_data($a_sem);
index 4aa11de..74a5dbd 100644 (file)
@@ -430,7 +430,7 @@ class BriskDB
             }
 
             if ($chals->ismod()) {
-                Challenges::save_data(&$chals);
+                Challenges::save_data($chals);
             }
 
             Challenges::unlock_data($a_sem);
index bcc983d..47fd0b1 100644 (file)
@@ -283,7 +283,7 @@ class Hardbans {
           }
         } // for (...
         if ($hban->ismod()) {
-          Hardbans::save_data(&$hban);
+          Hardbans::save_data($hban);
         }
       } // if (load_data
       Hardbans::unlock_data($a_sem);
@@ -305,7 +305,7 @@ class Hardbans {
         $hban->add_item($login, $ip, $session, $timeout);
 
         if ($hban->ismod()) {
-          Hardbans::save_data(&$hban);
+          Hardbans::save_data($hban);
         }
       } // if (load_data
       Hardbans::unlock_data($a_sem);
index a3fe932..46227fc 100644 (file)
@@ -571,7 +571,7 @@ class Sac_a_push {
 
     function pendpage_try_addcont(&$new_socket, $tout, $method, $header, $get, $post, $cookie, $path, $addr, $rest, $cont)
     {
-        $pendpage = PendingPage::pendingpage_continue(&$new_socket, $this->curtime, $tout, $method,
+        $pendpage = PendingPage::pendingpage_continue( $new_socket, $this->curtime, $tout, $method,
                                                            $header,           $get, $post, $cookie,
                                                              $path,          $addr, $rest, $cont);
 
@@ -1033,7 +1033,7 @@ class Sac_a_push {
                 return cmd_return(401, 'malformed cmd');
             }
             $idx = -1;
-            if (($user = $this->app->get_user($cmd['sess'], &$idx)) == FALSE)
+            if (($user = $this->app->get_user($cmd['sess'], $idx)) == FALSE)
                 return cmd_return(402, 'user not found');
 
             if (($user->flags & USER_FLAG_TY_ADMIN) == 0x00)
index 5f269d7..3422c23 100644 (file)
@@ -93,7 +93,7 @@ class Transport_template {
 class Transport_websocket {
     protected $magicGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
 
-    function Transport_websocket() {
+    function Transport_websocket($secure = FALSE) {
         $this->headerOriginRequired                 = false;
         $this->headerSecWebSocketProtocolRequired   = false;
         $this->headerSecWebSocketExtensionsRequired = false;
@@ -386,15 +386,19 @@ class Transport_websocket {
         }
 
         if (!isset($headers['Host']) || !$this->checkHost($headers['Host'])) {
+            // error_log('bad 1');
             $headers_out['HTTP-Response'] = "400 Bad Request";
         }
         if (!isset($headers['Upgrade']) || strtolower($headers['Upgrade']) != 'websocket') {
+            // error_log('bad 2 ' . $headers['Upgrade']);
             $headers_out['HTTP-Response'] = "400 Bad Request";
         }
         if (!isset($headers['Connection']) || strpos(strtolower($headers['Connection']), 'upgrade') === FALSE) {
+            // error_log('bad 3');
             $headers_out['HTTP-Response'] = "400 Bad Request";
         }
         if (!isset($headers['Sec-Websocket-Key'])) {
+            // error_log('bad 4');
             $headers_out['HTTP-Response'] = "400 Bad Request";
         } else {
         }
@@ -410,11 +414,13 @@ class Transport_websocket {
         if ( ($this->headerSecWebSocketProtocolRequired && !isset($headers['Sec-Websocket-Protocol']))
              || ($this->headerSecWebSocketProtocolRequired &&
                  !$this->checkWebsocProtocol($headers['Sec-Websocket-Protocol']))) {
+            // error_log('bad 5');
             $headers_out['HTTP-Response'] = "400 Bad Request";
         }
         if ( ($this->headerSecWebSocketExtensionsRequired  && !isset($headers['Sec-Websocket-Extensions']))
              || ($this->headerSecWebSocketExtensionsRequired &&
                  !$this->checkWebsocExtensions($headers['Sec-Websocket-Extensions'])) ) {
+            // error_log('bad 6');
             $headers_out['HTTP-Response'] = "400 Bad Request";
         }
 
@@ -603,8 +609,8 @@ class Transport {
 
     static function create($transp)
     {
-        if ($transp == 'websocket') {
-            return new Transport_websocket();
+        if ($transp == 'websocket' || $transp == 'websocketsec') {
+            return new Transport_websocket($transp == 'websocketsec');
         }
         else if ($transp == 'xhr') {
             return new Transport_xhr();
@@ -626,4 +632,4 @@ class Transport {
         }
     }
 }
-?>
\ No newline at end of file
+?>
index 000ad97..305dd34 100644 (file)
@@ -831,7 +831,7 @@ function stream_init($init_string, $enc, $header, &$header_out, &$body, $get, $p
     
     $this->rd_data_set($curtime, $transp, $enc, $stat, $subst, $step, $from);
     
-    $ret = $this->rd_transp->init($enc, $header, &$header_out, $init_string, self::base_get(), $this->rd_scristp);
+    $ret = $this->rd_transp->init($enc, $header, $header_out, $init_string, self::base_get(), $this->rd_scristp);
 
     if ($ret === FALSE) {
         return FALSE;
index 5e22966..c9002b9 100644 (file)
@@ -572,7 +572,7 @@ class Bin5_table extends Table {
             $this->mazzo = $match_data['mazzo_next'];
             $this->mult  = $match_data['mult_next'];
             $this->match_id = $match_id;
-            $this->game_init(&$bri->user);
+            $this->game_init($bri->user);
 
             /* reload of the page with the new layout */
             for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
@@ -587,7 +587,7 @@ class Bin5_table extends Table {
                 $user_cur->comm[$user_cur->step % COMM_N] = "";
                 $user_cur->step_inc();
 
-                $user_cur->comm[$user_cur->step % COMM_N] = show_table(&$bri, &$user_cur, $user_cur->step+1, TRUE, FALSE);
+                $user_cur->comm[$user_cur->step % COMM_N] = show_table($bri, $user_cur, $user_cur->step+1, TRUE, FALSE);
                 $user_cur->step_inc();
             }
             return (TRUE);
@@ -1005,7 +1005,7 @@ class Bin5_user extends User {
               log_load("RESYNC");
               /* NOTE: $this->room is associated with the current $bri object */
               printf("xXx CLASS NAME [%s]\n", get_class($this->room));
-              $ret = show_table(&$this->room, $this, $this->step, FALSE, FALSE);
+              $ret = show_table($this->room, $this, $this->step, FALSE, FALSE);
           }
           log_rd2("NEWSTAT: ".$this->stat);
 
@@ -1117,7 +1117,7 @@ class Bin5 {
             $user[$table->player[$i]]->table_token = $table_token;
             $this->user[$i] = Bin5_user::spawn($user[$table->player[$i]], $this, $table_idx, $i, $get, $post, $cookie);
         }
-        $this->table[0] = Bin5_table::spawn(&$table);
+        $this->table[0] = Bin5_table::spawn($table);
 
         log_main("TABLE_OLD_WIN - Bin5:".$this->table[0]->old_asta_win);
 
@@ -1210,7 +1210,7 @@ class Bin5 {
                         $user_cur->the_end = TRUE;
 
                         /* se gli altri utenti non erano d'accordo questo utente viene bannato */
-                        $remcalc = $this->table[0]->exitlock_calc(&$this->user, $user_cur->table_pos);
+                        $remcalc = $this->table[0]->exitlock_calc($this->user, $user_cur->table_pos);
                         if ($remcalc < 3) {
                             require_once("${G_base}Obj/hardban.phh");
                             Hardbans::add(($user_cur->is_auth() ? $user_cur->name : FALSE),
@@ -1430,7 +1430,7 @@ class Bin5 {
         case "":
         case "index.php":
             ob_start();
-            bin5_index_main($transp_type, $header_out, $addr, $get, $post, $cookie);
+            bin5_index_main($transp_type, $header, $header_out, $addr, $get, $post, $cookie);
             $content = ob_get_contents();
             ob_end_clean();
 
@@ -1458,9 +1458,10 @@ class Bin5 {
 
             break;
         case "index_rd.php":
+        case "index_rd_wss.php":
             if (($transp  = gpcs_var('transp', $get, $post, $cookie)) === FALSE)
                 $transp = "iframe";
-            if ($transp == 'websocket')
+            if ($transp == 'websocket' || $transp == 'websocketsec')
                 $enc = 'plain';
 
             do {
@@ -1560,7 +1561,7 @@ function show_table(&$bri, &$user, $sendstep, $is_transition, $is_again)
     $table_pos = $user->table_pos;
 
     $ret = "table_init();";
-    $ret .= $table->exitlock_show(&$bri->user, $table_pos);
+    $ret .= $table->exitlock_show($bri->user, $table_pos);
     if (!$is_again) {
         /* GENERAL STATUS */
         $user_rules = $user->rules_get();
@@ -1593,7 +1594,7 @@ function show_table(&$bri, &$user, $sendstep, $is_transition, $is_again)
     }
     /* NOTIFY FOR THE CARD MAKER */
     if ($is_transition) { //  && $user->subst ==  "asta" superfluo
-        $ret .= show_table_info(&$bri, &$table, $table_pos);
+        $ret .= show_table_info($bri, $table, $table_pos);
         $ret .= "setTimeout(preload_images, 500, g_preload_img_arr, g_imgct);";
     }
     else {
index deeeba5..64e7bc5 100644 (file)
@@ -46,9 +46,13 @@ $mlang_bin5_index = array( 'aucwin' => array( 'it' => 'Hai vinto l\'asta.<br> Sc
                            );
 
 
-function bin5_index_main($transp_type, &$header_out, $addr, $get, $post, $cookie)
+function bin5_index_main($transp_type, $header, &$header_out, $addr, $get, $post, $cookie)
 {
     GLOBAL $G_lang, $mlang_bin5_index;
+
+    $transp_port = ((array_key_exists("X-Forwarded-Proto", $header) &&
+                     $header["X-Forwarded-Proto"] == "https") ? 443 : 80);
+
     if (($table_idx = gpcs_var('table_idx', $get, $post, $cookie)) === FALSE)
         unset ($table_idx);
     if (($laststate = gpcs_var('laststate', $get, $post, $cookie)) === FALSE)
@@ -110,7 +114,7 @@ window.onload = function() {
   preferences_update();
 
   sess = "<?php echo "$sess"; ?>";
-  xstm = new xynt_streaming(window, "<?php echo "$transp_type"; ?>", 80, 2, null /* console */, gst, 'table_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);});
+  xstm = new xynt_streaming(window, <?php printf("\"%s\", %d", $transp_type, $transp_port); ?>,  2, null /* console */, gst, 'table_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);});
   xstm.hbit_set(heartbit);
   
   window.onbeforeunload = onbeforeunload_cb;  
index a80a554..09c030a 100644 (file)
@@ -56,7 +56,7 @@ function bin5_index_wr_main(&$bin5, $remote_addr_full, $get, $post, $cookie)
 
     log_wr(0, 'bin::index_wr.php: COMM: '.xcapemesg($mesg));
 
-    if (($user = &$bin5->get_user($sess, &$idx)) == FALSE) {
+    if (($user = &$bin5->get_user($sess, $idx)) == FALSE) {
         echo "Get User Error";
         log_wr("Get User Error");
         return FALSE;
@@ -102,12 +102,12 @@ function bin5_index_wr_main(&$bin5, $remote_addr_full, $get, $post, $cookie)
         if ($argz[0] == 'tableinfo') {
             log_wr("PER DI TABLEINFO");
             $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
-            $user->comm[$user->step % COMM_N] .= show_table_info(&$bin5, &$table, $user->table_pos);
+            $user->comm[$user->step % COMM_N] .= show_table_info($bin5, $table, $user->table_pos);
             log_wr($user->comm[$user->step % COMM_N]);
             $user->step_inc();
         }
         else if ($argz[0] == 'chatt') {
-            $bin5->chatt_send(&$user, $mesg);
+            $bin5->chatt_send($user, $mesg);
         }
         else if ($argz[0] == 'preferences_update') {
             log_wr("PER DI PREFERENCES_UPDATE");
@@ -127,10 +127,10 @@ function bin5_index_wr_main(&$bin5, $remote_addr_full, $get, $post, $cookie)
 
             $logout_cont = TRUE;
             if ($remcalc >= 3) {
-                $lockcalc = $table->exitlock_calc(&$bin5->user, $user->table_pos);
+                $lockcalc = $table->exitlock_calc($bin5->user, $user->table_pos);
                 if ($lockcalc < 3) {
                     $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
-                    $user->comm[$user->step % COMM_N] .= $table->exitlock_show(&$bin5->user, $user->table_pos);
+                    $user->comm[$user->step % COMM_N] .= $table->exitlock_show($bin5->user, $user->table_pos);
                     $user->comm[$user->step % COMM_N] .=  show_notify("<br>I dati presenti sul server non erano allineati con quelli inviati dal tuo browser, adesso lo sono. Riprova ora.", 2000, "torna alla partita.", 400, 100);
 
                     log_wr($user->comm[$user->step % COMM_N]);
@@ -169,12 +169,12 @@ function bin5_index_wr_main(&$bin5, $remote_addr_full, $get, $post, $cookie)
         }
         else if ($user->subst == 'asta') {
             if ($argz[0] == 'lascio') {
-                if ($table->rules->engine(&$bin5, $curtime, BIN5_RULES_ABANDON, $user)) {
+                if ($table->rules->engine($bin5, $curtime, BIN5_RULES_ABANDON, $user)) {
                     for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
                         $user_cur = &$bin5->user[$table->player[$i]];
 
                         $ret = sprintf('gst.st = %d;', $user_cur->step+1);
-                        $ret .= show_table(&$bin5,&$user_cur,$user_cur->step+1, TRUE, TRUE);
+                        $ret .= show_table($bin5, $user_cur,$user_cur->step+1, TRUE, TRUE);
                         $user_cur->comm[$user_cur->step % COMM_N] = $ret;
                         $user_cur->step_inc();
                     }
@@ -483,10 +483,10 @@ function bin5_index_wr_main(&$bin5, $remote_addr_full, $get, $post, $cookie)
                     if ($table->turn == (BIN5_PLAYERS_N * BIN5_CARD_HAND)) { /* game finished */
                         log_wr(sprintf("GIOCO FINITO !!!"));
 
-                        if ($table->rules->engine(&$bin5, $curtime, BIN5_RULES_FINISH, $user)) {
+                        if ($table->rules->engine($bin5, $curtime, BIN5_RULES_FINISH, $user)) {
                             for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
                                 $user_cur = &$bin5->user[$table->player[$i]];
-                                $retar[$i] .= show_table(&$bin5,&$user_cur,$user_cur->step+1,TRUE, TRUE);
+                                $retar[$i] .= show_table($bin5, $user_cur, $user_cur->step+1, TRUE, TRUE);
                             }
                         }
                     }
@@ -498,7 +498,7 @@ function bin5_index_wr_main(&$bin5, $remote_addr_full, $get, $post, $cookie)
                         $user_cur->step_inc();
                     }
 
-                    log_wr(sprintf("TURN: %d",$table->turn));
+                    log_wr(sprintf("TURN: %d", $table->turn));
                     /* Have played all the players ? */
                     /* NO:  switch the focus and enable the next player to play. */
 
index cefb6c0..29f6056 100644 (file)
@@ -1388,7 +1388,7 @@ function url_complete(parent, url)
     }
 
     // alert("host: ["+host+"]  path: ["+path+"]");
-    if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/' || url.substring(0,4) == 'ws:/') {
+    if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/' || url.substring(0,4) == 'ws:/' || url.substring(0,5) == 'wss:/') {
         return (url);
     }
     else if (url.substring(0,1) == '/') {
index 2a83a6b..478d880 100644 (file)
@@ -360,6 +360,9 @@ function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_f
     GLOBAL $G_lang, $G_lng, $mlang_room;
     GLOBAL $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER, $_COOKIE;
 
+    $transp_port = ((array_key_exists("X-Forwarded-Proto", $header) &&
+                     $header["X-Forwarded-Proto"] == "https") ? 443 : 80);
+
     if (($sess = gpcs_var('sess', $get, $post, $cookie)) === FALSE)
         $sess = "";
     if (($name = gpcs_var('name', $get, $post, $cookie)) === FALSE)
@@ -431,7 +434,7 @@ function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_f
             log_main("pre garbage_manager UNO");
             $brisk->garbage_manager(TRUE);
             log_main("post garbage_manager");
-            if (($user = &$brisk->get_user($sess, &$idx)) != FALSE) {
+            if (($user = $brisk->get_user($sess, $idx)) != FALSE) {
                 if ($user->the_end == FALSE) {
                     $brisk->sess_cur_set($user->sess);
                     log_main("user stat: ".$user->stat);
@@ -464,7 +467,7 @@ function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_f
             /* try login */
 
             if ($banned == FALSE &&
-                ($user = $brisk->add_user(&$sess, &$idx, $name, $pass_private,
+                ($user = $brisk->add_user($sess, $idx, $name, $pass_private,
                                           $remote_addr, $header, $cookie)) != FALSE) {
                 $brisk->sess_cur_set($user->sess);
                 $ACTION = "room";
@@ -649,7 +652,7 @@ google_color_text = "404040";
 google_color_url = "000000";
 //-->
 </script>
-<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';
+<script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';
             $banner_top_right = carousel_top();
         }
         else {
@@ -668,7 +671,7 @@ google_color_text = "404040";
 google_color_url = "000000";
 //-->
 </script>
-<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';
+<script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';
         }
     }
     else { // !$G_is_local
@@ -1250,7 +1253,7 @@ cookie_law(null);
         sidebanners_init($G_sidebanner_idx);
 ?>
      sess = "<?php echo "$sess"; ?>";
-xstm = new xynt_streaming(window, "<?php echo "$transp_type"; ?>", 80, 2, null /* console */, gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);});
+xstm = new xynt_streaming(window, <?php printf("\"%s\", %d", $transp_type, $transp_port); ?>, 2, null /* console */, gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);});
      xstm.hbit_set(heartbit);
      tra = new train($('room_tit'));
      window.onunload = onunload_cb;
index c427c3d..48b3c14 100644 (file)
@@ -166,7 +166,7 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie)
     $curtime = time();
     $dt = date("H:i ", $curtime);
 
-    if (($user = $brisk->get_user($sess, &$idx)) == FALSE) {
+    if (($user = $brisk->get_user($sess, $idx)) == FALSE) {
         $argz = explode('|', xcapemesg($mesg));
 
         if ($argz[0] == 'getchallenge') {
@@ -196,7 +196,7 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie)
                         echo '1|';
                     }
                     if ($chals->ismod()) {
-                        Challenges::save_data(&$chals);
+                        Challenges::save_data($chals);
                     }
                 }
 
@@ -421,7 +421,7 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie)
         if ($user->subst == 'sitdown' || $user->stat == 'table')
             $brisk->room_wakeup($user);
         else if ($user->subst == 'standup')
-            $brisk->room_outstandup(&$user);
+            $brisk->room_outstandup($user);
         else {
             log_rd2("SHUTDOWN FROM WHAT ???");
         }
@@ -767,7 +767,7 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie)
 
         }
         else if ($argz[0] == 'chatt') {
-            $brisk->chatt_send(&$user, xcapemesg($mesg), $mlang_indwr);
+            $brisk->chatt_send($user, xcapemesg($mesg), $mlang_indwr);
         }
         else if ($argz[0] == 'tosmgr') {
             // check IF is authnticated user, both terms of service versions matches
@@ -923,7 +923,9 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie)
                         $bin5_user_cur->trans_step = $user_cur->step + 1;
                         $bin5_user_cur->comm[$bin5_user_cur->step % COMM_N] = "";
                         $bin5_user_cur->step_inc();
-                        $bin5_user_cur->comm[$bin5_user_cur->step % COMM_N] = show_table(&$bin5,&$bin5_user_cur,$bin5_user_cur->step+1,TRUE,FALSE);
+                        $bin5_user_cur->comm[$bin5_user_cur->step % COMM_N] = show_table($bin5, $bin5_user_cur,
+                                                                                         $bin5_user_cur->step+1,
+                                                                                         TRUE, FALSE);
                         $bin5_user_cur->step_inc();
 
                         log_wr("TRY PRESAVE: ".$bin5_user_cur->step." TRANS STEP: ".$bin5_user_cur->trans_step);
index 610d701..47059a4 100644 (file)
@@ -5,7 +5,16 @@
 //
 function transport_ws(doc, xynt_streaming, page)
 {
-    this.name = "WebSocket";
+    // if four arguments manage if WS or WSS connection
+    if (arguments.length > 3)
+        this.is_secure = arguments[3];
+    else
+        this.is_secure = false;
+
+    if (this.is_secure)
+        this.name = "WebSocketSecure";
+    else
+        this.name = "WebSocket";
     this.ctx_new = "";
     var self = this;
 
@@ -13,7 +22,7 @@ function transport_ws(doc, xynt_streaming, page)
     this.failed = false;
     this.xynt_streaming = xynt_streaming;
     try {
-this.xynt_streaming.log("PAGE: "+page);
+        this.xynt_streaming.log("PAGE: "+page);
         this.ws = new WebSocket(page);
         this.ws.onopen = function () {
             self.xynt_streaming.log("onopen");
@@ -622,24 +631,34 @@ xynt_streaming.prototype = {
         // page arrangement
         this.page = url_complete(this.win.location.href, this.page);
 
+        // DEFAULT TRANSPORT PROTOCOL HERE websocketsec, websocket
         if (this.transp_fback > 0) {
-            transp_type = "websocket";
-            transp_port = (this.transp_fback == 2 ? 80 : 8080);
+            transp_type = "websocketsec";
+            transp_port = (this.transp_fback == 2 ? 443 : 8080);
         }
         else {
             transp_type = this.transp_type;
             transp_port = this.transp_port;
         }
 
-        if (transp_type == "websocket") {
-            var end_proto, first_slash;
+        if (transp_type == "websocket" || transp_type == "websocketsec") {
+            var end_proto, first_slash, newpage;
 
             // change protocol
             this.log("precha ["+this.page+"]");
-            end_proto = this.page.indexOf("://");
-            first_slash = this.page.substring(end_proto+3).indexOf("/");
+            if (transp_type == "websocketsec") {
+                newpage = this.page.replace(/\.php$/g, "_wss.php").replace(/\.php\?/g, "_wss.php?");
+                }
+            else {
+                newpage = this.page;
+                }
+            end_proto = newpage.indexOf("://");
+            first_slash = newpage.substring(end_proto+3).indexOf("/");
 
-            page = "ws://" + this.page.substring(end_proto+3, end_proto+3+first_slash) + ":" + transp_port + this.page.substring(end_proto+3 + first_slash);
+            page = (transp_type == "websocketsec" ? "wss://" : "ws://")
+                + newpage.substring(end_proto+3, end_proto+3 + first_slash) + ":"
+                + transp_port + newpage.substring(end_proto+3 + first_slash);
+            // this.log("MOP WS: " + page);
         }
         else {
             page = this.page;
@@ -652,7 +671,11 @@ xynt_streaming.prototype = {
 
         try {
             // transport instantiation
-            if (transp_type == "websocket") {
+            if (transp_type == "websocketsec") {
+                page = url_append_args(page, "transp", "websocketsec");
+                this.transp = new transport_ws(this.doc, this, page, true);
+            }
+            else if (transp_type == "websocket") {
                 page = url_append_args(page, "transp", "websocket");
                 this.transp = new transport_ws(this.doc, this, page);
             }
index 01adb53..4c1c43b 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+foreach (array('isstream', 'f_test', 'f_trans', 'f_port', 'f_fback', 'sess', 'stat',
+               'subst', 'step', 'from', 'transp') as $i) {
+    if (isset($_REQUEST[$i])) {
+        $$i = $_REQUEST[$i];
+    }
+}
 
 $desc = array( "Semplice: da 1 a 9 ogni secondo, poi ricomincia (status sempre verde).",
                "Continuo: da 1 a N ogni secondo, ricomincia ogni 9 (status sempre verde).",
@@ -62,7 +68,8 @@ function headers_render($header, $len)
     return (TRUE);
 }
 
-$transs = array( "iframe", "websocket", "xhr", "htmlfile" );
+$transs = array( "iframe", "websocket", "websocketsec", "xhr", "htmlfile" );
+$trans_ports = array( "iframe"=>80, "websocket"=>80, "websocketsec"=>443, "xhr"=>80, "htmlfile"=>80 );
 if (!isset($f_trans))
     $f_trans = $transs[0];
 
@@ -70,7 +77,7 @@ if (!isset($f_test))
     $f_test = 1;
 
 if (!isset($f_port))
-    $f_port = 80;
+    $f_port = NULL;
 
 if (!isset($f_fback))
     $f_fback = 0;
@@ -102,12 +109,14 @@ function xcape($s)
 }
 
 if (isset($isstream) && $isstream == "true") {
-
     require_once("Obj/transports.phh");
 
     if (isset($transp) && $transp == "websocket") {
         $trobj = new Transport_websocket();
     }
+    else if (isset($transp) && $transp == "websocketsec") {
+        $trobj = new Transport_websocket(TRUE);
+    }
     else if (isset($transp) && $transp == "xhr") {
         $trobj = new Transport_xhr();
     }
@@ -127,6 +136,7 @@ if (isset($isstream) && $isstream == "true") {
             $init_string .= chr(mt_rand(65, 90));
     }
     $headers_in = getallheaders();
+    // error_log(print_r($headers_in, TRUE));
     $headers = array();
     foreach ($headers_in as $header_in => $value) {
         $headers[mb_convert_case($header_in, MB_CASE_TITLE, 'UTF-8')] = $value;
@@ -149,7 +159,7 @@ if (isset($isstream) && $isstream == "true") {
         fclose($fp);
     }
 
-    if (isset($transp) && $transp == "websocket") {
+    if (isset($transp) && ($transp == "websocket" || $transp == "websocketsec")) {
         header_remove('Connection');
         header_remove('Content-Encoding');
         header_remove('Content-Type');
@@ -290,7 +300,8 @@ if (isset($isstream) && $isstream == "true") {
      var gst = new globst();
      window.onload = function() {
 
-         xstm = new xynt_streaming(window, "<?php echo "$f_trans";?>", <?php echo "$f_port";?>, <?php echo "$f_fback";?>, console, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=<?php echo "$f_test";?>', function(com){eval(com);});
+         xstm = new xynt_streaming(window, "<?php echo "$f_trans";?>", <?php
+    echo ($f_port == NULL ? "${trans_ports[$f_trans]}" : "$f_port" );?>, <?php echo "$f_fback";?>, console, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=<?php echo "$f_test";?>', function(com){eval(com);});
      xstm.hbit_set(heartbit);
      xstm.start();
  }
@@ -301,13 +312,13 @@ if (isset($isstream) && $isstream == "true") {
 <div>
 <?php
 
-
-
 printf("<table>");
 for ($test = 1 ; $test <= count($desc) ; $test++) {
     printf("<tr>");
     foreach ($transs as $trans) {
-        printf("<td style=\"padding: 8px; border: 1px solid black;\"><a href=\"?f_trans=%s&f_test=%d&f_port=%d&f_fback=%d\">Test %s %02d (port %d (fb %d))</a></td>", $trans, $test, $f_port, $f_fback, $trans, $test, $f_port, $f_fback);
+        printf("<td style=\"padding: 8px; border: 1px solid black;\"><a href=\"?f_trans=%s&f_test=%d%s&f_fback=%d\">Test %s %02d (port %d (fb %d))</a></td>", $trans, $test,
+               ($f_port == NULL ? "" : sprintf("&f_port=%d", $f_port)), $f_fback, $trans, $test,
+               ($f_port == NULL ? $trans_ports[$trans] : $f_port ), $f_fback);
     }
     printf("</tr>\n");
 }