fix missing bold for your account item
[brisk.git] / web / xynt_test01.php
index 7cafda6..4c1c43b 100644 (file)
@@ -1,11 +1,18 @@
 <?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).",
                "Restart: da 1 a 8 ogni secondo, pausa 16 secondi (status passa ad arancione e poi a rosso), poi ricomincia (e status torna a verde).",
                "Pausa: da 1 a 5 ogni secondo, pausa 3 secondi, e poi 8 e 9 ogni secondo, e poi ricomincia (status sempre verde).",
                "Keyword: da 1 a 5 ogni secondo, @BEGIN@, @END@, @BEGIN@ xxx yyy @END@, 9, (status sempre verde).",
-               "Reload limiter: da 1 a 8 ogni secondo e chiude, 9 setta e chiude subito,<br>il client aspetta 3 secondi, e poi da 10 a N ogni secondo, (status sempre verde).");
+               "Reload limiter: da 1 a 8 ogni secondo e chiude, 9 setta e chiude subito,<br>il client aspetta 3 secondi, e poi da 10 a N ogni secondo, (status sempre verde).",
+               "Esegue un comando, manda loc_new a un valore irraggiungibile, stoppa il processore di comandi e poi dà un comando teoricamente irraggiungibile.");
 
 
 // trim(mb_convert_case($split[0], MB_CASE_TITLE, 'UTF-8'))
@@ -61,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];
 
@@ -69,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;
@@ -101,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();
     }
@@ -126,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;
@@ -148,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');
@@ -252,6 +263,17 @@ if (isset($isstream) && $isstream == "true") {
                     sleep(1);
             }
         }
+        break;
+    case 7:
+        $chunk = $trobj->chunk(1, sprintf("gst.st++; \$('container').innerHTML = 'prima';"));
+        print($chunk);
+
+        $chunk = $trobj->chunk(2, sprintf("gst.st++; gst.st_loc_new++; xstm.stop();"));
+        print($chunk);
+
+        $chunk = $trobj->chunk(3, sprintf("gst.st++; \$('container').innerHTML = 'dopo';"));
+        print($chunk);
+
         break;
     }
 
@@ -278,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();
  }
@@ -289,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");
 }