blocking_error call performed on the current caller class
[brisk.git] / web / Obj / user.phh
index cc4d211..aed566f 100644 (file)
@@ -471,110 +471,6 @@ class User {
     $this->the_end = FALSE;
   }
 
-  static function load_data($id, $sess) 
-  {
-      log_main("load_data: id [".$id."] sess [".($sess == FALSE ? "FALSE" : $sess)."] ");
-      
-      do {
-          if (($tok = @ftok(FTOK_PATH."/user".$id, "C")) == -1) {
-              log_main("ftok failed");
-              break;
-          }
-          
-          if (($shm_sz = sharedmem_sz($tok)) == -1) {
-              log_main("shmop_open failed");
-          }
-          
-          if ($shm_sz == -1)
-              $shm_sz = SHM_DIMS_U_MIN;
-          
-          if ($shm = shm_attach($tok, $shm_sz)) {
-              if (($user = @shm_get_var($shm, $tok)) == FALSE) {
-                  break;
-              }
-              if ($sess != FALSE && $user->sess != $sess) {
-                  break;
-              }
-              log_only("user ==  ".($user == FALSE ?   "FALSE" : "TRUE")."  user ===  ".($user === FALSE ? "FALSE" : "TRUE")."  user isset ".(isset($user) ?   "TRUE" : "FALSE"));
-              
-              if ($user == FALSE) {
-                  log_only("INIT MAIN DATA");
-                  
-                  // SHSPLIT FIXME: init_data for User class ??
-                  $user = self::create($id, "", "");
-                  if (@shm_put_var($shm, $tok, $user) == FALSE) {
-                      log_only("PUT_VAR FALLITA ".strlen(serialize($user)));
-                      log_only(serialize($user));
-                  }
-                  log_shme("User::save_data2");
-              }
-              else {
-                  if ($sess != FALSE) {
-                      /*
-                       *  NOTE:  this part is for check only, theoretically 
-                       *         user->step anch proxy_step are set allways at the same value
-                       */
-                      $old_step = $user->step;
-                      $arr = self::load_step($sess);
-                      $user->step = $arr['s'];
-                      if ($old_step != $user->step) {
-                          log_crit("steps are diffetents User->step ".$user->step." Old_step: ".$old_step);
-                      }
-                  }
-              }
-              $user->shm_sz = $shm_sz;
-              
-              shm_detach($shm);
-          }
-          
-          //  
-          // SHSPLIT: load users from the shared memory
-          //
-          return ($user);
-      } while (0);
-      
-      return (FALSE);
-  }
-  
-
-  static function save_data($user, $id) 
-  {
-      GLOBAL $sess;
-      
-      $shm =   FALSE;
-      
-      if (($tok = @ftok(FTOK_PATH."/user".$id, "C")) == -1) {
-          return (FALSE);
-      }
-      while ($user->shm_sz < SHM_DIMS_U_MAX) {
-          if (($shm = shm_attach($tok, $user->shm_sz)) == FALSE)
-              break;
-          
-          // log_only("PUT_VAR DI ".strlen(serialize($user)));
-          if (@shm_put_var($shm, $tok, $user) != FALSE) {
-              shm_detach($shm);
-              if ($user->sess != "")
-                  $user->save_step();
-
-              log_shme("User::save_data");
-
-              log_main("User[".$id."] saved.");
-              return (TRUE);
-          }
-          if (shm_remove($shm) === FALSE) {
-              log_only("REMOVE FALLITA");
-              break;
-          }
-          shm_detach($shm);
-          $user->shm_sz += SHM_DIMS_U_DLT;
-      } 
-      
-      if ($shm)
-          shm_detach($shm);
-      
-      return (FALSE);
-  }
-
   function myname_innerHTML()
   {
       $class_id = ($this->flags & USER_FLAG_AUTH) + 1;
@@ -587,25 +483,18 @@ class User {
 
   protected function blocking_error($is_unrecoverable)
   {
-      GLOBAL $is_page_streaming;
-      
-      $is_page_streaming = TRUE;
       log_crit("BLOCKING_ERROR UNREC: ".($is_unrecoverable ? "TRUE" : "FALSE"));
-      return (sprintf(($is_unrecoverable ? 'hstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("index.php");'));
+      return (sprintf(($is_unrecoverable ? 'xstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("index.php");'));
   }
   
   // FIXME TO SUPPORT iframe
   protected function page_sync($sess, $page, $table_idx, $table_token)
   {
-      GLOBAL $is_page_streaming;
-      
       // log_rd2("page_sync:".var_export(debug_backtrace()));
       
-      $is_page_streaming = TRUE;
-      
       log_rd2("PAGE_SYNC");
       printf("xXx USER::PAGE_SYNC [%s]\n", get_class($this));
-      return (sprintf('createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); hstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("%s");', $table_idx, $table_token, $page));
+      return (sprintf('createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); xstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("%s");', $table_idx, $table_token, $page));
   }
 
 
@@ -613,7 +502,7 @@ class User {
 
   protected function maincheck($cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_subst, &$new_step, $splashdate, $table_idx, $table_token)
   {
-      GLOBAL $G_lang, $mlang_indrd, $is_page_streaming;
+      GLOBAL $G_lang, $mlang_indrd;
       // GLOBAL $first_loop;
       GLOBAL $G_with_splash, $G_splash_content, $G_splash_interval, $G_splash_idx;
       GLOBAL $G_splash_w, $G_splash_h, $G_splash_timeout;
@@ -640,10 +529,9 @@ class User {
           
           $S_load_stat['wR_minusone']++;
           
-          if ($this->the_end == TRUE) { 
-              // log_rd2("main_check: the end".var_export(debug_backtrace()));
-              $is_page_streaming = TRUE;
-          }
+          // if ($this->the_end == TRUE) {
+          // log_rd2("main_check: the end".var_export(debug_backtrace()));
+          // }
           
           if ($this->trans_step != -1) {
               log_rd2("TRANS USATO ".$this->trans_step);
@@ -755,16 +643,19 @@ class User {
 
   public static function stream_fini($init_string, $is_unrecoverable)
 {
+    $cla = get_called_class();
+    printf("xXx user::stream_fini\n");
+
     // IF IFRAME THEN:
     $body = "";
     $body .= sprintf("<html>
 <head>
 <script type=\"text/javascript\" src=\"%scommons.js\"></script>
-<script type=\"text/javascript\" src=\"%sxynt-http-streaming-ifra.js\"></script>
+<script type=\"text/javascript\" src=\"%sxynt-streaming-ifra.js\"></script>
 <script type=\"text/javascript\">
-var http_streaming = \"ready\";", self::base_get(), self::base_get());
+var xynt_streaming = \"ready\";", self::base_get(), self::base_get());
     $body .= sprintf("
-window.onload = function () { if (http_streaming != \"ready\") { http_streaming.reload(); } };
+window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.reload(); } };
 </script>
 </head>
 <body>");
@@ -772,7 +663,7 @@ window.onload = function () { if (http_streaming != \"ready\") { http_streaming.
     $body .= sprintf("<script id='hs%d' type='text/javascript'><!--
 push(\"%s\");
 // -->
-</script>", 0, escpush(self::blocking_error($is_unrecoverable)) );
+</script>", 0, escpush($cla::blocking_error($is_unrecoverable)) );
     // ELSE IF XHR THEN:
     // return (self::blocking_error($is_unrecoverable));
     return ($body);
@@ -794,7 +685,7 @@ function stream_init($init_string, $enc, &$header_out, &$body, $get, $post, $coo
     
     printf("CLASS: [%s] base: [%s]\n", get_class($this), self::base_get());
     
-    $is_page_streaming = FALSE; // (webservers_exceeded() || stristr($HTTP_USER_AGENT, "Mozilla/5.0 (Windows NT 6.1; rv:5.0)") || stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE);
+    // (webservers_exceeded() || stristr($HTTP_USER_AGENT, "Mozilla/5.0 (Windows NT 6.1; rv:5.0)") || stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE);
 
     if ($enc != 'plain')
         $header_out['Content-Encoding'] = $enc;
@@ -819,13 +710,13 @@ function stream_init($init_string, $enc, &$header_out, &$body, $get, $post, $coo
     $body .= sprintf("<html>
 <head>
 <script type=\"text/javascript\" src=\"%scommons.js\"></script>
-<script type=\"text/javascript\" src=\"%sxynt-http-streaming-ifra.js\"></script>
+<script type=\"text/javascript\" src=\"%sxynt-streaming-ifra.js\"></script>
 <script type=\"text/javascript\">
-var http_streaming = \"ready\";", self::base_get(), self::base_get());
+var xynt_streaming = \"ready\";", self::base_get(), self::base_get());
     if ($this->rd_scristp > 0)
         $body .= sprintf("last_clean = %d;\n", ($this->rd_scristp-1));
     $body .= sprintf("
-window.onload = function () { if (http_streaming != \"ready\") { http_streaming.reload(); } };
+window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.reload(); } };
 </script> 
 </head>
 <body>");
@@ -836,7 +727,7 @@ window.onload = function () { if (http_streaming != \"ready\") { http_streaming.
 
 function stream_main(&$body, $get, $post, $cookie)
 {
-    GLOBAL $is_page_streaming, $G_splash_idx;
+    GLOBAL $G_splash_idx;
 
     $CO_splashdate = "CO_splashdate".$G_splash_idx;
     if (($splashdate = gpcs_var("$CO_splashdate", $get, $post, $cookie)) === FALSE)
@@ -846,8 +737,7 @@ function stream_main(&$body, $get, $post, $cookie)
     if (($table_token = gpcs_var("table_token", $get, $post, $cookie)) === FALSE)
         $table_token = ""; 
 
-    $is_page_streaming = FALSE;
-    log_rd2("FROM OUTSIDE - STAT: ".$this->rd_stat." SUBST: ".$this->rd_subst." STEP: ".$this->rd_step." FROM: ".$this->rd_from. "IS_PAGE:" . $is_page_streaming);
+    log_rd2("FROM OUTSIDE - STAT: ".$this->rd_stat." SUBST: ".$this->rd_subst." STEP: ".$this->rd_step." FROM: ".$this->rd_from);
     
     
     $pre_main = gettimeofday(TRUE);
@@ -863,8 +753,6 @@ push(\"%s\");
 </script>", $this->rd_scristp++, escpush($ret) );
         
         log_rd2(0, 'index_rd.php: after mop_flush (begin: '.sprintf("%f", $pre_main).')');
-        if ($is_page_streaming) 
-            return TRUE;
     }
     printf("xXx POST: rd_step %d\n", $this->rd_step);