5 * Copyright (C) 2012 Matteo Nastasi
6 * mailto: nastasi@alternativeoutput.it
7 * matteo.nastasi@milug.org
8 * web: http://www.alternativeoutput.it
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. You should have received a
19 * copy of the GNU General Public License along with this program; if
20 * not, write to the Free Software Foundation, Inc, 59 Temple Place -
21 * Suite 330, Boston, MA 02111-1307, USA.
24 require_once("${G_base}Obj/transports.phh");
28 define('USER_FLAG_AUTH', 0x02);
30 define('USER_FLAG_MAP_AUTH', 0x0c);
31 define('USER_FLAG_LISTAUTH', 0x04);
32 define('USER_FLAG_ISOLAUTH', 0x08);
34 define('USER_FLAG_DBFAILED', 0x10);
37 define('USER_FLAG_S_NORM', 0x000); // done
38 define('USER_FLAG_S_PAU', 0x100); // done
39 define('USER_FLAG_S_OUT', 0x200); // done
40 define('USER_FLAG_S_DOG', 0x300); // done
41 define('USER_FLAG_S_EAT', 0x400); // done
42 define('USER_FLAG_S_WRK', 0x500); // done
43 define('USER_FLAG_S_SMK', 0x600); // done
44 define('USER_FLAG_S_EYE', 0x700); // done
45 define('USER_FLAG_S_RABB', 0x800); // done
46 define('USER_FLAG_S_SOCC', 0x900); // done
47 define('USER_FLAG_S_BABY', 0xa00); // done
48 define('USER_FLAG_S_MOP', 0xb00); // done
49 define('USER_FLAG_S_BABBO', 0xc00); // done
50 define('USER_FLAG_S_RENNA', 0xd00); // done
51 define('USER_FLAG_S_PUPAZ', 0xe00); // done
52 define('USER_FLAG_S_VISCH', 0xf00); // done
54 define('USER_FLAG_S_ALL', 0xf00); // done
56 /* type of user normal, supporter etc ... */
57 define('USER_FLAG_TY_ALL', 0xff0000); // done
58 define('USER_FLAG_TY_NORM', 0x010000); // done
59 define('USER_FLAG_TY_SUPER', 0x020000); // done
60 define('USER_FLAG_TY_CERT', 0x040000); // done
61 // ... other usefull status ...
62 define('USER_FLAG_TY_FIRONLY', 0x200000); // done
63 define('USER_FLAG_TY_SUSPEND', 0x400000); // done
64 define('USER_FLAG_TY_DISABLE', 0x800000); // done
66 // 240 is the right value, 600 is for fwrite error test
67 define('RD_ENDTIME_DELTA', 240);
68 define('RD_KEEPALIVE_TOUT', 4);
70 $S_load_stat = array( 'rU_heavy' => 0,
78 'btn_backtotab' => array('it' => ' torna ai tavoli ',
79 'en' => ' back to tables '),
80 'btn_btotabsup' => array('it' => ' grazie della donazione, torna ai tavoli ',
81 'en' => ' thank you for donation, back to tables ')
85 var $room; // reference to the room where the user is registered
86 var $idx; // index in the room users array when you are in game
87 var $idx_orig; // index in the room table users array when you aren't in game
88 var $code; // authentication code
89 var $name; // name of the user
90 var $sess; // session of the user
91 var $ip; // ip of the user
92 var $lacc; // last access (for the cleanup)
93 var $laccwr; // last access (for the cleanup)
94 var $bantime; // timeout to temporary ban
95 var $stat; // status (outdoor, room, table, game, ...)
96 var $subst; // substatus for each status
97 var $step; // step of the current status
98 var $trans_step; // step to enable transition between pages (disable == -1)
100 var $rd_socket; // socket handle of push stream
101 var $rd_endtime; // end time for push stream
102 var $rd_stat; // actual status of push stream
103 var $rd_subst; // actual substatus of push stream
104 var $rd_step; // actual step of push stream
105 var $rd_from; // referer
106 var $rd_scristp; // current script step (for each session)
107 var $rd_kalive; // if no message are sent after RD_KEEPALIVE_TOUT secs we send a keepalive from server
108 var $rd_cache; // place where store failed fwrite data
109 var $rd_zls; // zlibstream object handle if compressed stream, else FALSE
110 var $rd_transp; // class that define stream encapsulation type (iframe, xhr, ...)
111 var $rd_is_chunked; // is the transport chunked or not ?
113 var $comm; // commands array
114 // var $asta_card; //
116 // var $handpt; // Total card points at the beginning of the current hand.
117 // var $exitislock; // Player can exit from the table ?
119 // FIXME: the table_orig field must be removed after table field verify of index management (in spawned table
120 // it is allways ZERO
121 var $table; // id of the current table when you are in game
122 var $table_orig; // id of the current table when you aren't in game
123 var $table_pos; // idx on the table
124 var $table_token;// token that identify a game on a table
125 var $flags; // Bitfield with: AUTHENTICATE: 0x02
126 var $rec; // field with user db record or FALSE
127 var $the_end; // Flag to change the end of the session
129 var $chat_lst; // Last chat line
130 var $chattime; // Array of chat times
131 var $chat_cur; // Current chat line number
132 var $chat_ban; // Time for ban chat
133 var $chat_dlt; // Delta t for ban
136 const BASE = ""; // basepath for absolute web references
141 static function create(&$room, $idx, $name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") {
142 if (($thiz = new User()) == FALSE)
145 $thiz->room = &$room;
147 $thiz->idx_orig = $idx;
152 $thiz->lacc = time();
153 $thiz->laccwr = time();
156 $thiz->subst = $subst;
158 $thiz->trans_step = -1;
159 $thiz->comm = array();
161 $thiz->rd_socket = NULL;
162 $thiz->rd_endtime = -1;
164 $thiz->rd_subst = "";
167 $thiz->rd_scristp = -1;
168 $thiz->rd_kalive = -1;
169 $thiz->rd_cache = "";
170 $thiz->rd_zls = FALSE;
171 $thiz->rd_transp = NULL;
172 $thiz->rd_is_chunked = FALSE;
174 $thiz->asta_card = -2;
175 $thiz->asta_pnt = -1;
177 $thiz->exitislock = TRUE;
182 $thiz->chattime = array_fill(0, CHAT_N, 0);
184 $thiz->chat_lst = "";
188 $thiz->table_orig = $table;
189 $thiz->table = $table;
190 $thiz->table_pos = -1;
191 $thiz->table_token= "";
192 $thiz->shm_sz = SHM_DIMS_U_MIN;
198 $this->idx = $from->idx;
199 $this->idx_orig = $from->idx;
200 $this->code = $from->code;
201 $this->name = $from->name;
202 $this->sess = $from->sess;
203 $this->ip = $from->ip;
204 $this->lacc = $from->lacc;
205 $this->laccwr = $from->laccwr;
206 $this->bantime = $from->bantime;
207 $this->stat = $from->stat;
208 $this->subst = $from->subst;
209 $this->step = $from->step;
210 $this->trans_step = $from->trans_step;
211 $this->comm = array();
213 $i_start = (1 > ($from->step - COMM_N) ? 1 : ($from->step - COMM_N));
214 for ($i = $i_start ; $i < $from->step ; $i++) {
216 if (isset($from->comm[$ii])) {
217 $this->comm[$ii] = $from->comm[$ii];
220 $this->asta_card = $from->asta_card;
221 $this->asta_pnt = $from->asta_pnt;
222 $this->handpt = $from->handpt;
223 $this->exitislock = $from->exitislock;
225 $this->flags = $from->flags;
226 $this->rec = $from->rec;
228 $this->chattime = array();
229 for ($i = 0 ; $i < CHAT_N ; $i++)
230 $this->chattime[$i] = $from->chattime[$i];
231 $this->chat_cur = $from->chat_cur;
232 $this->chat_lst = $from->chat_lst;
233 $this->chat_ban = $from->chat_ban;
234 $this->chat_dlt = $from->chat_dlt;
236 $this->table_orig = $from->table_orig;
237 $this->table = $from->table;
238 $this->table_pos = $from->table_pos;
239 $this->table_token = $from->table_token;
240 $this->the_end = $from->the_end;
241 $this->shm_sz = $from->shm_sz;
246 static function myclone($from)
248 if (($thiz = new User()) == FALSE)
256 static function spawn($from, $table, $table_pos)
258 if (($thiz = new User()) == FALSE)
261 $thiz->idx = $from->idx;
262 $thiz->idx_orig = $from->idx;
263 $thiz->code = $from->code;
264 $thiz->name = $from->name;
265 $thiz->sess = $from->sess;
266 $thiz->ip = $from->ip;
267 $thiz->lacc = $from->lacc;
268 $thiz->laccwr = $from->laccwr;
269 $thiz->bantime = $from->bantime;
270 $thiz->stat = $from->stat;
271 $thiz->subst = $from->subst;
272 $thiz->step = $from->step;
273 $thiz->trans_step = $from->trans_step;
274 $thiz->comm = array();
277 $i_start = (1 > ($from->step - COMM_N) ? 1 : ($from->step - COMM_N));
278 for ($i = $i_start ; $i < $from->step ; $i++) {
279 log_wr("TRY PUSH:".$i);
281 $thiz->comm[$ii] = $from->comm[$ii];
284 $thiz->asta_card = $from->asta_card;
285 $thiz->asta_pnt = $from->asta_pnt;
286 $thiz->handpt = $from->handpt;
287 $thiz->exitislock = $from->exitislock;
288 $thiz->the_end = $from->the_end;
290 $thiz->flags = $from->flags;
291 $thiz->rec = $from->rec;
293 $thiz->chattime = array_fill(0, CHAT_N, 0);
295 $thiz->chat_lst = "";
300 $thiz->table_orig = $table;
302 $thiz->table_pos = $table_pos;
303 $thiz->table_token = $from->table_token;
304 $thiz->shm_sz = $from->shm_sz;
309 function flags_set($flags, $mask)
311 $flags_old = $this->flags & (~$mask);
312 $this->flags = ($flags_old | ($flags & $mask));
317 if (($bdb = BriskDB::create()) == FALSE) {
320 return ($bdb->user_prefs_update($this->code, ($this->flags & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)),
321 $this->rec->supp_comp));
324 function rd_data_set($curtime, $transp, $enc, $stat, $subst, $step, $from)
326 $this->rd_endtime = $curtime + RD_ENDTIME_DELTA;
327 $this->rd_stat = $stat;
328 $this->rd_subst = $subst;
329 $this->rd_step = $step;
330 $this->rd_from = $from;
331 $this->rd_scristp = 0;
332 $this->rd_kalive = $curtime + RD_KEEPALIVE_TOUT;
333 $this->rd_zls = ZLibStream::create($enc);
334 $this->rd_transp = Transport::create($transp);
335 $this->rd_is_chunked = $this->rd_transp->is_chunked();
338 function rd_socket_get() {
339 return ($this->rd_socket);
342 function rd_socket_set($sock) {
345 $this->rd_zls->destroy();
346 $this->rd_zls = FALSE;
349 $this->rd_socket = $sock;
352 function rd_kalive_get()
354 return ($this->rd_kalive);
357 function rd_kalive_set($tm)
359 $this->rd_kalive = $tm;
362 function rd_kalive_is_expired($tm)
364 // printf("rd_kalive %d tm %d\n", $this->rd_kalive, $tm);
365 return ($this->rd_kalive < $tm);
368 function rd_endtime_is_expired($tm)
370 // printf("rd_endtime %d tm %d\n", $this->rd_kalive, $tm);
371 return ($this->rd_endtime < $tm);
374 function rd_kalive_reset($tm)
376 $this->rd_kalive = $tm + RD_KEEPALIVE_TOUT;
379 function rd_cache_get()
381 return ($this->rd_cache);
384 function rd_cache_set($cache)
386 $this->rd_cache = $cache;
389 function rd_zls_get()
391 return ($this->rd_zls);
398 function code_get() {
399 return ($this->code);
402 function stat_set($stat) {
403 log_main("sess: [".$this->sess. "] NEW STAT: [".$stat."]");
404 $this->stat = "$stat";
407 if (validate_sess($this->sess)) {
408 if (file_exists(PROXY_PATH) == FALSE)
409 mkdir(PROXY_PATH, 0775, TRUE);
410 $fp = @fopen(PROXY_PATH."/".$this->sess.".stat", 'w');
411 fwrite($fp, sprintf("%s\n",$this->stat));
417 function step_set($step)
419 $this->step = $step & 0x7fffffff;
424 function step_inc($delta = 1) {
425 $this->step += $delta;
426 /* modularization because unpack() not manage unsigned 32bit int correctly */
427 $this->step &= 0x7fffffff;
436 if (validate_sess($this->sess) == FALSE)
438 if (file_exists(PROXY_PATH) == FALSE)
439 mkdir(PROXY_PATH, 0775, TRUE);
440 if (($fp = @fopen(PROXY_PATH."/".$this->sess.".step", 'w')) == FALSE)
442 fwrite($fp, pack("LL",$this->step, $this->idx));
445 log_main("step_set [".$this->sess. "] [".$this->step."]");
453 static function load_step($sess)
457 if (validate_sess($sess) == FALSE)
460 if (file_exists(PROXY_PATH) == FALSE)
461 mkdir(PROXY_PATH, 0775, TRUE);
462 if (($fp = @fopen(PROXY_PATH."/".$sess.".step", 'rb')) == FALSE)
464 if (($s = fread($fp, 8)) == FALSE)
466 if (mb_strlen($s, "ASCII") != 8)
468 $arr = unpack('Ls/Li', $s);
471 // log_rd2("A0: ".$arr[0]." A1: ".$arr[1]);
478 log_rd2("STEP_GET [".$sess."]: return false ");
483 static function unproxy_step($sess) {
484 log_rd2("UNPROXY: ".PROXY_PATH."/".$sess.".step");
485 if (file_exists(PROXY_PATH) == FALSE)
487 @unlink(PROXY_PATH."/".$sess.".step");
492 log_legal($curtime, $this->ip, $this, "STAT:LOGOUT", '');
494 $tmp_sess = $this->sess;
496 self::unproxy_step($tmp_sess);
497 $this->name = ""; // OK here
498 while (array_pop($this->comm) != NULL);
500 $this->chattime = array_fill(0, CHAT_N, 0);
502 $this->chat_lst = "";
505 $this->the_end = FALSE;
508 function myname_innerHTML()
510 $class_id = ($this->flags & USER_FLAG_AUTH) + 1;
512 return (sprintf('$("myname").innerHTML = "<span class=\"au%d\">%s</span>";', $class_id,
513 xcape($this->name,ENT_COMPAT,"UTF-8")));
518 static function blocking_error($is_unrecoverable)
520 log_crit("BLOCKING_ERROR UNREC: ".($is_unrecoverable ? "TRUE" : "FALSE"));
521 return (sprintf(($is_unrecoverable ? 'xstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("index.php");'));
524 // FIXME TO SUPPORT iframe
525 protected function page_sync($sess, $page, $table_idx, $table_token)
527 // log_rd2("page_sync:".var_export(debug_backtrace()));
529 log_rd2("PAGE_SYNC");
530 printf("xXx USER::PAGE_SYNC [%s]\n", get_class($this));
531 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));
534 protected function maincheck($get, $post, $cookie)
536 GLOBAL $G_lang, $mlang_indrd;
537 // GLOBAL $first_loop;
538 GLOBAL $G_with_splash, $G_splash_content, $G_splash_interval, $G_splash_idx;
539 GLOBAL $G_splash_w, $G_splash_h, $G_splash_timeout;
540 GLOBAL $G_lice_vers, $G_lice_fname, $G_lice_dthard, $G_lice_dtsoft, $G_lice_idx;
544 $CO_splashdate = "CO_splashdate".$G_splash_idx;
546 if (($splashdate = gpcs_var("$CO_splashdate", $get, $post, $cookie)) === FALSE)
549 log_rd("maincheck begin");
554 /* Nothing changed, return. */
555 if ($this->rd_step == $this->step)
558 log_rd2("do other cur_stat[".$this->rd_stat."] user->stat[".$this->stat."] cur_step[".$this->rd_step."] user_step[".$this->step."]");
560 if ($this->rd_step == -1) {
562 * if $this->rd_step == -1 load the current state from the main struct
565 $S_load_stat['wR_minusone']++;
567 // if ($this->the_end == TRUE) {
568 // log_rd2("main_check: the end".var_export(debug_backtrace()));
571 if ($this->trans_step != -1) {
572 log_rd2("TRANS USATO ".$this->trans_step);
573 $this->rd_step = $this->trans_step;
574 $this->trans_step = -1;
577 log_rd2("TRANS NON ATTIVATO");
582 /* this part I suppose is read only on $this->room structure */
583 if ($this->rd_step == -1) {
584 log_rd2("PRE-NEWSTAT: ".$this->stat);
586 if ($this->stat == 'room') {
587 log_rd("roomma ".$this->step);
589 if ($this->rec !== FALSE) {
590 if ($curtime > $G_lice_dtsoft || $curtime > $G_lice_dthard) {
591 if (versions_cmp($this->rec->lice_vers_get(), $G_lice_vers) < 0) { // comparison between user version and current version
592 if ($curtime > $G_lice_dtsoft) {
594 $ret .= show_notify_document("Versione corrente: [".$this->rec->lice_vers_get()."] Versione sito: ".$G_lice_vers,
595 0, array("Accetto.", "Rifiuto.", "Leggo poi.", /* , "Scarico." */),
597 $ret .= sprintf("act_licencemgr('soft', g_nd.ret_get(), '%s', '%s');",
598 xcape($this->rec->lice_vers_get()), xcape($G_lice_vers));
600 else if ($curtime > $G_lice_dthard) {
602 $ret .= show_notify_document("Versione corrente: [".$this->rec->lice_vers_get()."] Versione sito: ".$G_lice_vers,
603 0, array("Accetto.", "Rifiuto." /* , "Scarico." */),
605 $ret .= sprintf("act_licencemgr('hard', g_nd.ret_get(), '%s', '%s');",
606 xcape($this->rec->lice_vers_get()), xcape($G_lice_vers));
610 /* $ret .= show_notify_ex(str_replace("\n", " ", "Versione corrente: [".$this->rec->lice_vers_get()."] Versione sito: ".$G_lice_vers), */
611 /* ($is_super ? 0 : $G_splash_timeout), */
612 /* // $mlang_indrd[($is_super ? 'btn_btotabsup' : 'btn_backtotab')][$G_lang], */
613 /* $mlang_indrd['btn_backtotab'][$G_lang], */
614 /* $G_splash_w, $G_splash_h, true, */
615 /* ($is_super ? 0 : $G_splash_timeout)); */
616 /* $ret .= sprintf('|createCookie("CO_lice_date%d", %d, 24*365, cookiepath);', $G_lice_idx, $curtime); */
622 if ($G_with_splash &&
623 ($splashdate < $curtime - $G_splash_interval ||
624 $splashdate > $curtime)) {
625 $is_super = $this->flags & USER_FLAG_TY_SUPER;
626 $ret .= show_notify_ex(str_replace("\n", " ", $G_splash_content[$G_lang]),
627 ($is_super ? 0 : $G_splash_timeout),
628 // $mlang_indrd[($is_super ? 'btn_btotabsup' : 'btn_backtotab')][$G_lang],
629 $mlang_indrd['btn_backtotab'][$G_lang],
630 $G_splash_w, $G_splash_h, true,
631 ($is_super ? 0 : $G_splash_timeout));
632 $ret .= sprintf('|createCookie("CO_splashdate%d", %d, 24*365, cookiepath);', $G_splash_idx, $curtime);
634 $ret .= $this->room->show_room($this->step, $this);
636 // TODO uncomment and test
637 /* NOTE the sets went common */
638 $this->rd_stat = $this->stat;
639 $this->rd_subst = $this->subst;
640 $this->rd_step = $this->step;
647 else if ($this->stat == 'table') {
649 printf("xXx USER::MAINCHECK1 [%s]\n", get_class($this));
651 return ($this->page_sync($this->sess, "briskin5/index.php", $this->table, $this->table_token));
653 log_rd2("NEWSTAT: ".$this->stat);
654 } /* if ($this->rd_step == -1) { */
656 /* $sem = Room::lock_data(FALSE); */
657 $S_load_stat['rU_heavy']++;
659 if ($this->rd_step < $this->step) {
661 if ($this->rd_step + COMM_N < $this->step) {
662 if (($this->rd_stat != $this->stat)) {
663 $to_stat = $this->stat;
664 /* Room::unlock_data($sem); */
666 printf("xXx USER::MAINCHECK2 [%s]\n", get_class($this));
667 return ($this->page_sync($this->sess, ($to_stat == "table" ? "briskin5/index.php" : "index.php"), $this->table, $this->table_token));
669 log_rd2("lost history, refresh from scratch");
673 for ($i = $this->rd_step ; $i < $this->step ; $i++) {
675 log_rd2("ADDED TO THE STREAM: ".$this->comm[$ii]);
676 if ($this->comm[$ii] == "") {
677 if ($i == $this->rd_step)
682 $ret .= $this->comm[$ii];
684 $this->rd_stat = $this->stat;
685 $this->rd_subst = $this->subst;
686 $this->rd_step = $this->step;
689 log_rd2($this->step, 'index_rd.php: after ret set');
691 if ($this->the_end == TRUE) {
692 log_rd2("LOGOUT BYE BYE!!");
693 log_auth($this->sess, "Explicit logout.");
695 if ($this->the_end == TRUE) {
698 if ($this->subst == 'sitdown') {
699 log_load("ROOM WAKEUP");
700 $this->room->room_wakeup($this);
702 else if ($this->subst == 'standup')
703 $this->room->room_outstandup($this);
705 log_rd2("LOGOUT FROM WHAT ???");
707 } /* if ($this->the_end == TRUE) { ... */
708 } /* if ($this->the_end == TRUE) { ... */
709 } /* if ($this->rd_step < $this->step) { */
711 /* Room::unlock_data($sem); */
712 } /* else of if ($this->rd_step == -1) { */
716 } // function maincheck (...
718 public static function stream_fini($transp, $init_string, $is_unrecoverable)
720 printf("xXx user::stream_fini\n");
722 // FIXME: dynamic "Transport_" type
723 $trans_class = Transport::gettype($transp);
724 $body = $trans_class::fini($init_string, self::base_get(), static::blocking_error($is_unrecoverable));
727 // return (static::blocking_error($is_unrecoverable));
741 function stream_init($init_string, $enc, $header, &$header_out, &$body, $get, $post, $cookie)
745 printf("CLASS: [%s] base: [%s]\n", get_class($this), self::base_get());
747 log_load("index_rd_init.php");
749 if (($from = gpcs_var('from', $get, $post, $cookie)) === FALSE)
751 if (($stat = gpcs_var('stat', $get, $post, $cookie)) === FALSE)
753 if (($subst = gpcs_var('subst', $get, $post, $cookie)) === FALSE)
755 if (($step = gpcs_var('step', $get, $post, $cookie)) === FALSE)
757 if (($transp = gpcs_var('transp', $get, $post, $cookie)) === FALSE)
760 $this->rd_data_set($curtime, $transp, $enc, $stat, $subst, $step, $from);
762 $ret = $this->rd_transp->init($enc, $header, &$header_out, $init_string, self::base_get(), $this->rd_scristp);
764 if ($ret === FALSE) {
773 function stream_main(&$body, $get, $post, $cookie)
775 log_rd2("FROM OUTSIDE - STAT: ".$this->rd_stat." SUBST: ".$this->rd_subst." STEP: ".$this->rd_step." FROM: ".$this->rd_from);
778 $pre_main = gettimeofday(TRUE);
780 $old_stat = $this->rd_stat;
781 $old_subst = $this->rd_subst;
782 $old_step = $this->rd_step;
783 printf("xXx PRE : rd_step %d\n", $this->rd_step);
784 if (($ret = $this->maincheck($old_stat, $old_subst, $old_step, $get, $post, $cookie)) != FALSE) {
785 $body .= $this->rd_transp->chunk( $this->rd_scristp++, $ret);
786 log_rd2(0, 'index_rd.php: after mop_flush (begin: '.sprintf("%f", $pre_main).')');
788 printf("xXx POST: rd_step %d\n", $this->rd_step);
793 function stream_keepalive($with_ping)
795 return ($this->rd_transp->chunk( $this->rd_scristp++, ($with_ping ? "act_ping();" : NULL)));
798 function stream_close()
800 return ($this->rd_transp->close());
803 static function base_get()
805 $c = get_called_class();
806 printf("CALLED_CLASS: [%s]\n", $c);
810 function is_supp_custom()
812 if ($this->rec != FALSE) {
813 if ($this->flags & USER_FLAG_TY_SUPER) {
817 if ($this->rec->last_dona > 1356994800) {
825 function is_chunked()
827 return $this->rd_is_chunked;
831 function chunked_content($content)
834 $cont_comp = $this->rd_zls->compress_chunk($content);
837 $cont_comp = $content;
839 $cont_comp_l = mb_strlen($cont_comp, "ASCII");
840 // printf("CHUNK: [%s]\n", $content);
842 if ($this->is_chunked()) {
843 return (sprintf("%X\r\n", $cont_comp_l).$cont_comp."\r\n");
850 function chunked_fini()
852 return sprintf("0\r\n");