htmlfile transport type added v4.1.0
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Wed, 14 Nov 2012 07:19:47 +0000 (08:19 +0100)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Wed, 14 Nov 2012 07:48:27 +0000 (08:48 +0100)
web/Obj/brisk.phh
web/Obj/sac-a-push.phh
web/briskin5/Obj/briskin5.phh
web/briskin5/index.php
web/index.php
web/xynt-streaming.js

index bb51cb6..2c060d2 100644 (file)
@@ -140,10 +140,10 @@ $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.0.0";
+$G_brisk_version = "4.1.0";
 
 /* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: adottato sac-a-push come motore per l\'invio dei dati in tempo reale.',
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: adottato sac-a-push come motore per l\'invio dei dati in tempo reale, nuovo trasporto httpfile per explorer.',
                                        '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.',
                                        'If you want to subscribe our <a target="_blank" href="ml-briscola+subscribe@milug.org">Mailing List</a>, click it!' ) );
@@ -2138,14 +2138,19 @@ class Room {
       printf("NEW_SOCKET (root): %d\n", intval($new_socket));
 
       $enc = get_encoding($header);
-
+      if (isset($header['User-Agent']) && strstr($header['User-Agent'], "MSIE")) {
+          $transp_type = "htmlfile";
+      }
+      else {
+          $transp_type = "iframe";
+      }
       force_no_cache($header_out);
 
       switch ($path) {
       case "":
       case "index.php":
           ob_start();
-          index_main($this, $header_out, $addr, $get, $post, $cookie);
+          index_main($this, $transp_type, $header_out, $addr, $get, $post, $cookie);
           $content = ob_get_contents();
           ob_end_clean();
 
index d582a10..c140192 100644 (file)
@@ -487,13 +487,11 @@ class Sac_a_push {
                             $addr = stream_socket_get_name($new_socket, TRUE);
                             $header_out = array();
 
-                            $enc = get_encoding($header);
-
                             $subs = SITE_PREFIX."briskin5/";
                             $subs_l = strlen($subs);
                             $rret = FALSE;
                             if (!strncmp($path, SITE_PREFIX, SITE_PREFIX_LEN)) {
-                                $rret = $this->app->request_mgr($this, $enc, $header_out, $new_socket, substr($path, SITE_PREFIX_LEN), $addr, $get, $post, $cookie);
+                                $rret = $this->app->request_mgr($this, $header, $header_out, $new_socket, substr($path, SITE_PREFIX_LEN), $addr, $get, $post, $cookie);
                             }
                             if ($rret == FALSE) { 
                                 // FIXME: manage 404 !!!
index 52cedc5..28ebe2c 100644 (file)
@@ -1392,6 +1392,13 @@ class Bin5 {
         printf("NEW_SOCKET (root): %d\n", intval($new_socket));
         
         $enc = get_encoding($header);
+        if (isset($header['User-Agent']) && strstr($header['User-Agent'], "MSIE")) {
+            $transp_type = "htmlfile";
+        }
+        else {
+            $transp_type = "iframe";
+        }
+        force_no_cache($header_out);
 
         if (($table_idx = gpcs_var('table_idx', $get, $post, $cookie)) === FALSE) 
             unset($table_idx);
@@ -1399,13 +1406,12 @@ class Bin5 {
         if (($table_token = gpcs_var('table_token', $get, $post, $cookie)) === FALSE) 
             unset($table_token);
 
-        force_no_cache($header_out);
 
         switch ($path) {
         case "":
         case "index.php":
             ob_start();
-            bin5_index_main($header_out, $addr, $get, $post, $cookie);
+            bin5_index_main($transp_type, $header_out, $addr, $get, $post, $cookie);
             $content = ob_get_contents();
             ob_end_clean();
         
index 00121b8..ca57254 100644 (file)
@@ -41,7 +41,7 @@ $mlang_bin5_index = array( 'aucwin' => array( 'it' => 'Hai vinto l\'asta.<br> Sc
                            );
 
 
-function bin5_index_main(&$header_out, $addr, $get, $post, $cookie)
+function bin5_index_main($transp_type, &$header_out, $addr, $get, $post, $cookie)
 {
     GLOBAL $G_lang, $mlang_bin5_index;
     if (($table_idx = gpcs_var('table_idx', $get, $post, $cookie)) === FALSE)
@@ -110,7 +110,7 @@ window.onload = function() {
   preferences_update();
 
   sess = "<?php echo "$sess"; ?>";
-  xstm = new xynt_streaming(window, 'iframe', null /* console */, gst, 'table_php', 'sess', sess, $('sandbox'), 'index_rd_ifra.php', function(com){eval(com);});
+  xstm = new xynt_streaming(window, "<?php echo "$transp_type"; ?>", null /* console */, gst, 'table_php', 'sess', sess, $('sandbox'), 'index_rd_ifra.php', function(com){eval(com);});
   xstm.hbit_set(heartbit);
   
   window.onbeforeunload = onbeforeunload_cb;  
index b3126e3..e716842 100644 (file)
@@ -213,7 +213,7 @@ function carousel_top()
     return (sprintf('<a target="_blank" href="http://shop.alternativeoutput.it"><img class="nobo" style="display: inline; border: 1px solid #808080;" src="img/briskshop%d.gif"></a>', $rn));
 }
 
-function index_main(&$room, &$header_out, $addr, $get, $post, $cookie)
+function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $cookie)
 {
     GLOBAL $G_with_donors, $G_donors_cur, $G_donors_all;
     GLOBAL $G_with_topbanner, $G_topbanner, $G_is_local;
@@ -233,8 +233,7 @@ function index_main(&$room, &$header_out, $addr, $get, $post, $cookie)
         unset ($table_idx);
     if (($table_token = gpcs_var('table_idx', $get, $post, $cookie)) === FALSE)
         unset ($table_token);
-    
-    
+
     // Use of proxies isn't allowed.
     if (!$G_is_local && is_proxy($addr)) {
         return FALSE;
@@ -862,7 +861,7 @@ supported by:<br>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <link rel="shortcut icon" href="img/brisk_ico.png">
 <script type="text/javascript" src="commons.js"></script> 
-<!--<script type="text/javascript" src="myconsole.js"></script> -->
+<!-- <script type="text/javascript" src="myconsole.js"></script> -->
 <script type="text/javascript" src="menu.js"></script>
 <script type="text/javascript" src="heartbit.js"></script>
 <script type="text/javascript" src="xynt-streaming.js"></script>
@@ -997,7 +996,7 @@ echo "$body"; ?>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <link rel="shortcut icon" href="img/brisk_ico.png">
 <script type="text/javascript" src="commons.js"></script>
-     <!-- <script type="text/javascript" src="myconsole.js"></script> -->
+<!-- <script type="text/javascript" src="myconsole.js"></script> -->
 <script type="text/javascript" src="menu.js"></script>
 <script type="text/javascript" src="ticker.js"></script>
 <script type="text/javascript" src="heartbit.js"></script>
@@ -1057,7 +1056,7 @@ else {
 
 ?>
      sess = "<?php echo "$sess"; ?>";
-xstm = new xynt_streaming(window, 'iframe', null /* console*/ , gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd_ifra.php', function(com){eval(com);});
+xstm = new xynt_streaming(window, "<?php echo "$transp_type"; ?>", null /* console */, gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd_ifra.php', function(com){eval(com);});
      xstm.hbit_set(heartbit);
      tra = new train($('room_tit'));
      window.onunload = onunload_cb;
index 66227d5..f703aff 100644 (file)
@@ -1,5 +1,96 @@
 // old targetpage == page and moved into start method
 
+//
+// CLASS transport_htmlfile
+//
+function transport_htmlfile(doc, page)
+{
+    this.doc = doc;
+    this.transfdoc = new ActiveXObject("htmlfile");
+    this.transfdoc.open();
+    /*this.transfdoc.write("<html><head><script>");
+    this.transfdoc.write("document.domain=\""+(doc.domain)+"\";");
+    this.transfdoc.write("</"+"script></"+"head>"); */
+    this.transfdoc.write("<html><body><iframe id='iframe'></iframe></body></html>");
+    this.transfdoc.close();
+
+    this.ifra = this.transfdoc.getElementById("iframe");
+    this.ifra.contentWindow.location.href = page;
+}
+
+transport_htmlfile.prototype = {
+    doc: null,
+    ifra: null,
+    tradoc: null,
+
+    destroy: function () { /* public */
+        if (this.ifra != null) {
+        //     this.doc.body.removeChild(this.ifra);
+        //     delete this.ifra;
+             this.ifra = null;
+        }
+
+        if (this.transfdoc) {
+            delete this.transfdoc;
+            this.transfdoc = null;
+        }
+    },
+
+    xstr_is_init: function () { /* public */
+        return (typeof(this.ifra.contentWindow.xynt_streaming) != 'undefined');
+    },
+
+    /* only after a successfull is_initialized call */
+    xstr_is_ready: function () { /* public */
+        return (this.ifra.contentWindow.xynt_streaming == "ready");
+    },
+
+    /* only after a successfull is_ready call to be sure the accessibility of the var */
+    xstr_set: function (xynt_streaming) { /* public */
+        this.ifra.contentWindow.xynt_streaming = xynt_streaming;
+    },
+
+    ctx_new_is_set: function () { /* public */
+        return (typeof(this.ifra.contentWindow.ctx_new) != 'undefined');
+    },
+
+    ctx_new_curlen_get: function () { /* public */
+        return (this.ifra.contentWindow.ctx_new.length);
+    },
+
+    ctx_new_getchar: function(idx) { /* public */
+    },
+
+    ctx_old_len_is_set: function () { /* public */
+        return (typeof(this.ifra.contentWindow.ctx_old_len) != 'undefined');
+    },
+
+    ctx_old_len_get: function () { /* public */
+        return (this.ifra.contentWindow.ctx_old_len);
+    },
+
+    ctx_old_len_set: function (len) { /* public */
+        this.ifra.contentWindow.ctx_old_len = len;
+    },
+
+    ctx_old_len_add: function (len) { /* public */
+        this.ifra.contentWindow.ctx_old_len += len;
+    },
+
+    new_part: function () { /* public */
+        return (this.ifra.contentWindow.ctx_new.substr(this.ifra.contentWindow.ctx_old_len));
+    },
+
+    scrcls_set: function (step) { /* public */
+        this.ifra.contentWindow.script_clean = step;
+    }
+}
+
+
+
+//
+// CLASS transport_iframe
+//
 function transport_iframe(doc, page)
 {
     this.doc = doc;
@@ -144,6 +235,11 @@ xynt_streaming.prototype = {
         if (this.transp_type == "iframe") {
             this.transp = new transport_iframe(this.doc, this.page);
         }
+        else if (this.transp_type == "htmlfile") {
+            this.transp = new transport_htmlfile(this.doc, this.page);
+        }
+        else
+            return;
 
         // watchdog setting
         this.watchdog_ct  = 0;
@@ -180,10 +276,13 @@ xynt_streaming.prototype = {
             do {
                 try{
                     // if (typeof(this.ifra.contentWindow.xynt_streaming) == 'undefined')
-                    if (!this.transp.xstr_is_init())
+                    if (!this.transp.xstr_is_init()) {
+                        this.log("hs::watchdog: xstr_is_init = false");
                         break;
+                    }
                 }
                 catch(b) {
+                    this.log("hs::watchdog: exception");
                    break;
                 }