- static function garbage_time_is_expired($tab_id, $tm)
- {
- $ret = TRUE;
- $fp = FALSE;
- do {
- if (file_exists(BIN5_PROXY_PATH."/table".$tab_id) == FALSE)
- mkdir(BIN5_PROXY_PATH."/table".$tab_id, 0775, TRUE);
- if (($fp = @fopen(BIN5_PROXY_PATH."/table".$tab_id."/garbage_time.expired", 'rb')) == FALSE)
- break;
- if (($s = fread($fp, 4)) == FALSE)
- break;
- if (mb_strlen($s, "ASCII") != 4)
- break;
- $arr = unpack('Le', $s);
- if ($arr['e'] > $tm)
- $ret = FALSE;
- } while (0);
-
- if ($fp != FALSE)
- fclose($fp);
-
- log_rd2("END: return ".($ret ? "TRUE" : "FALSE"));
-
- return ($ret);
- }
+ if (($table_idx = gpcs_var('table_idx', $get, $post, $cookie)) === FALSE)
+ unset($table_idx);
+
+ if (($table_token = gpcs_var('table_token', $get, $post, $cookie)) === FALSE)
+ unset($table_token);
+
+
+ switch ($path) {
+ case "":
+ case "index.php":
+ ob_start();
+ bin5_index_main($transp_type, $header_out, $addr, $get, $post, $cookie);
+ $content = ob_get_contents();
+ ob_end_clean();
+
+ $s_a_p->pendpage_try_addflush($new_socket, 20, $enc, $header_out, $content);
+ return TRUE;
+
+ break;
+ case "index_wr.php":
+ // FIXME $content can be unset
+ if (isset($table_idx) && isset($table_token)) {
+ if (($bri = $s_a_p->app->match_get($table_idx, $table_token)) != FALSE) {
+ ob_start();
+ bin5_index_wr_main($bri, $addr, $get, $post, $cookie);
+ $content = ob_get_contents();
+ ob_end_clean();
+ }
+ else {
+ $content = "Bin5 Load data error";
+ }
+ }
+ else {
+ $content = "Bin5 Load data error";
+ }
+ $s_a_p->pendpage_try_addflush($new_socket, 20, $enc, $header_out, $content);
+ return TRUE;
+
+ break;
+ case "index_rd_ifra.php":
+ do {
+ if (!isset($table_idx)
+ || !isset($table_token)
+ || !isset($cookie['sess'])
+ || ($bri = $s_a_p->app->match_get($table_idx, $table_token)) == NULL
+ || (($user = $bri->get_user($cookie['sess'], $idx)) == FALSE)) {
+
+ $content = Bin5_user::stream_fini($transp_type, $s_a_p->rndstr, TRUE);
+ $s_a_p->pendpage_try_addflush($new_socket, 20, $enc, $header_out, $content);
+
+ return TRUE;
+ break;
+ }
+ // close a previous opened index_read_ifra socket, if exists
+ if (($prev = $user->rd_socket_get()) != NULL) {
+ $s_a_p->socks_unset($user->rd_socket_get());
+ fclose($user->rd_socket_get());
+ printf("CLOSE AND OPEN AGAIN ON IFRA2\n");
+ $user->rd_socket_set(NULL);
+ }
+
+ $content = "";
+ $user->stream_init($s_a_p->rndstr, $enc, $header, $header_out, $content, $get, $post, $cookie);
+ $response = headers_render($header_out, -1).chunked_content($user->rd_zls_get(), $content);
+ $response_l = mb_strlen($response, "ASCII");
+
+ $wret = @fwrite($new_socket, $response, $response_l);
+ if ($wret < $response_l) {
+ printf("TROUBLES WITH FWRITE: %d\n", $wret);
+ $user->rd_cache_set(mb_substr($content, $wret, $response_l - $wret, "ASCII"));
+ }
+ else {
+ $user->rd_cache_set("");
+ }
+ fflush($new_socket);
+
+
+ $s_a_p->socks_set($new_socket, $user, NULL);
+ $user->rd_socket_set($new_socket);
+ printf(" - qui ci siamo - ");
+ return TRUE;
+ } while (FALSE);
+
+ return FALSE;
+ break;
+
+ default:
+ return FALSE;
+ break;
+ }