5 * Copyright (C) 2006-2011 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.
25 // require_once("Obj/brisk.phh");
26 // require_once("Obj/proxyscan.phh");
27 // require_once("briskin5/Obj/briskin5.phh");
30 "GGZDGDRBXDWFXHGPYAAVDXEKFDUWSTEDTDVXBXQPMZAIFPNLRPTWMJAZRHXTIRNZ"
31 ."HTZXAUVJDCLXENDCLIZXSSEQQGUADYEKNNANJWEGRUFHPLUNSEROZQJSLMUYNUVG"
32 ."FPLQAGCMTTGIRRXZFBFQFTRBYPHTWFSXFKHKYBRDAOSOURCMEVGPVXJVUQAOCFPV"
33 ."OQSUBOYWOZLDGRPQQIBNOTHFUHTCRRZOBCUONAXIYUYCJBFTVNWIITVHBYLNMPWR"
34 ."LPMMIROZVRUNYXSJSMJINSXGACXDMJAEPNFFAERHVDJELXSPPJWKMNFGVGAPTIMR"
35 ."VMVMVCLWKMPOAJWZGPSPFEXVNQANXGLZIQSCBIYVFSTXZOODZYCXUVUZFCLFGHUJ"
36 ."TXZWFHSMFJQAZOQRANKZJAUJHFJIKHIIEQUSDXUBRPQBKMIAVTWYQEOIMYKKDTEV"
37 ."EYERPXKFJXWNIMJPOFFMWJCJSLFZKPNRNVXIDLUSRVBGLUCQZCUQCZNAORDXMRSS"
38 ."UBNMPXJDQXXLMQRCTOCCJJWHFSUWBNWXWZHPKWYYKPZIMBXTYAZXJJQS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."PYIFTUDCMWRQBZDROXTTVTAOOIQHIWOZESRHKPNGNCSHNAVEWUSGOTZCRNFSIXGF"
85 ."QJUMUFPEZBFPOVGZZDCGDKEODSWAPNDNHVJUQDYLCXWNXSCDFFFPBTDOIZIZLBBP"
86 ."ZXZYWTTPEUUCKXGBTXAJBAXYLMUVWWGWZYTXTKYVRXSOXOBHERLZJPRDXIQZRQLU"
87 ."TXCLIJNKIRWMVQEJTLHZIDTNGBOYSULGWUTSYTKGNMGZFWKXCCZXGOQGZNQFZJUK"
88 ."JMBQPQPZOPYTQMPEFTZUDLIIBZAZSZAPNILMIKMPKXJIRHRQMFSTJKAPIIQWOFYQ"
89 ."HGANJGJSUGDIENDVEQFEMUJBGMZBPHLOARCVGMUUCHLCDDNKSJSCKYSALUAGUZFN"
90 ."YVURVLREBESGXPANIDKGLPJZGXLKFKTPEQBQEINOYYZTBMPFBLBKIKVPAPFDKKRZ"
91 ."YMVUBYCYTRXCIICUPTXKGQOIJSVSWPYVALIROWGVXDXGNSRVZOLEJHNRSUKHNTRJ"
92 ."LQZQKBEFXYKIPXJRZMQMJKUGCNUKBZBWABPLHMAJJZVBCWOQYCLSGDUKJSTHTVXV"
93 ."OUGJVADGJWGVNBNXYRZDSNLOZDIQRKOQAKJJDKXRMMTXRVTLOMTETNROPDYNXAGR";
95 $S_load_stat = array( 'rU_heavy' => 0,
102 $mlang_indrd = array(
103 'btn_backtotab' => array('it' => ' torna ai tavoli ',
104 'en' => ' back to tables '),
105 'btn_btotabsup' => array('it' => ' grazie della donazione, torna ai tavoli ',
106 'en' => ' thank you for donation, back to tables ')
109 // Use of proxies isn't allowed.
114 log_load("index_rd.php");
116 // $first_loop = TRUE;
119 if (DEBUGGING == "local" && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
120 echo "Debugging time!";
124 function blocking_error($is_unrecoverable)
126 GLOBAL $is_page_streaming;
128 $is_page_streaming = TRUE;
129 log_crit("BLOCKING_ERROR UNREC: ".($is_unrecoverable ? "TRUE" : "FALSE"));
130 return (sprintf(($is_unrecoverable ? 'hstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("index.php");'));
133 function page_sync($sess, $page, $table_idx, $table_token)
135 GLOBAL $is_page_streaming;
137 log_rd2("page_sync:".var_export(debug_backtrace()));
139 $is_page_streaming = TRUE;
141 log_rd2("PAGE_SYNC");
142 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));
148 function maincheck(&$room, &$user, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_subst, &$new_step)
150 GLOBAL $G_lang, $mlang_indrd, $is_page_streaming;
151 // GLOBAL $first_loop;
152 GLOBAL $G_with_splash, $G_splash_content, $G_splash_interval, $G_splash_idx;
153 GLOBAL $G_splash_w, $G_splash_h, $G_splash_timeout;
154 $CO_splashdate = "CO_splashdate".$G_splash_idx;
155 GLOBAL $$CO_splashdate;
159 log_rd("maincheck begin");
166 // NOTE: qui forse si potrebbe fallback-are a una User::load_data
167 // anche se non ce ne dovrebbe essere mai la necessità
168 /* if (($proxy_step = User::load_step($sess)) == FALSE) { */
169 /* log_only2("R"); */
170 /* ignore_user_abort(FALSE); */
171 /* return (blocking_error(TRUE)); */
175 /* Sync check (read only without modifications */
176 ignore_user_abort(TRUE);
179 /* /\* shared locking to load info *\/ */
180 /* if (($sem = Room::lock_data(FALSE)) == FALSE) { */
181 /* // wait 20 secs, then restart the xhr */
182 /* ignore_user_abort(FALSE); */
183 /* return ("sleep(gst,20000);|hstm.xhr_abort();"); */
186 /* // Verifica l'expire time lato server */
187 /* if (($user = User::load_data($proxy_step['i'], $sess)) == FALSE) { */
188 /* Room::unlock_data($sem); */
189 /* ignore_user_abort(FALSE); */
190 /* return (blocking_error(TRUE)); */
192 /* if lacc time great than STREAM_TIMEOUT or the room garbage_time is expired
193 switch to exclusive locking and verify again the conditions */
194 if ((($curtime - $user->lacc) > STREAM_TIMEOUT) || Room::garbage_time_is_expired($curtime)) {
195 /* there is some info that require to change data, switch to exclusive locking */
196 // Room::unlock_data($sem);
197 /* if (($sem = Room::lock_data(TRUE)) == FALSE) { */
198 /* // wait 20 secs, then restart the xhr */
199 /* ignore_user_abort(FALSE); */
200 /* return ("sleep(gst,20000);|hstm.xhr_abort();"); */
202 $S_load_stat['lL_laccgarb']++;
204 // load again the data after locking
206 // Verifica l'expire time lato server
207 /* if (($user = User::load_data($proxy_step['i'], $sess)) == FALSE) { */
208 /* Room::unlock_data($sem); */
209 /* ignore_user_abort(FALSE); */
210 /* return (blocking_error(TRUE)); */
213 if (($curtime - $user->lacc) >= STREAM_TIMEOUT) {
214 $S_load_stat['wU_lacc_upd']++;
215 $user->lacc = $curtime;
216 // lacc field updated
217 /* User::save_data($user, $user->idx); */
220 if (Room::garbage_time_is_expired($curtime)) {
223 $S_load_stat['wR_garbage']++;
224 /* if (($room = Room::load_data()) == FALSE) { */
225 /* Room::unlock_data($sem); */
226 /* ignore_user_abort(FALSE); */
227 /* return (blocking_error(TRUE)); */
229 log_main("pre garbage_manager TRE");
230 $room->garbage_manager(FALSE);
231 /* Room::save_data($room); */
235 log_main("infolock: U");
236 /* Room::unlock_data($sem); */
237 ignore_user_abort(FALSE);
241 // if ($first_loop == TRUE) {
242 // if (($sem = Room::lock_data(TRUE)) != FALSE) {
243 // // Aggiorna l'expire time lato server
244 // $S_load_stat['U_first_loop']++;
245 // if (($user = User::load_data($proxy_step['i'], $sess)) == FALSE) {
246 // Room::unlock_data($sem);
247 // ignore_user_abort(FALSE);
248 // return (blocking_error(TRUE));
250 // $user->lacc = $curtime;
251 // // lacc field updated
252 // User::save_data($user, $user->idx);
254 // if (Room::garbage_time_is_expired($curtime)) {
257 // $S_load_stat['R_garbage']++;
258 // if (($room = Room::load_data()) == FALSE) {
259 // Room::unlock_data($sem);
260 // ignore_user_abort(FALSE);
261 // return (blocking_error(TRUE));
263 // log_main("pre garbage_manager TRE");
264 // $room->garbage_manager(FALSE);
265 // Room::save_data($room);
268 // log_main("infolock: U");
269 // Room::unlock_data($sem);
270 // ignore_user_abort(FALSE);
271 // } // if (($sem = Room::lock_data(TRUE)) != FALSE) {
273 // // wait 20 secs, then restart the xhr
274 // ignore_user_abort(FALSE);
276 // return ("sleep(gst,20000);|hstm.xhr_abort();");
278 // $first_loop = FALSE;
279 // } // if ($first_loop == TRUE) {
281 /* if ($cur_step == $proxy_step['s']) { */
282 /* log_main("infolock: P"); */
283 /* return (FALSE); */
286 /* log_only2("R"); */
289 $S_load_stat['rU_heavy']++;
290 /* if ($user == FALSE) { */
292 /* ignore_user_abort(TRUE); */
293 /* if (($sem = Room::lock_data(FALSE)) == FALSE) */
296 /* log_main("infolock: P"); */
297 /* if (($user = User::load_data($proxy_step['i'], $sess)) == FALSE) { */
302 /* if ($sem != FALSE) */
303 /* Room::unlock_data($sem); */
305 /* ignore_user_abort(FALSE); */
306 /* if ($user == FALSE) { */
307 /* return (blocking_error(TRUE)); */
311 /* Nothing changed, return. */
312 if ($cur_step == $user->step)
315 log_rd2("do other cur_stat[".$cur_stat."] user->stat[".$user->stat."] cur_step[".$cur_step."] user_step[".$user->step."]");
317 if ($cur_step == -1) {
319 * if $cur_step == -1 load the current state from the main struct
322 /* unset the $user var to reload it from main structure */
325 ignore_user_abort(TRUE);
326 /* $sem = Room::lock_data(TRUE); */
327 /* if (($room = Room::load_data()) == FALSE) { */
328 /* Room::unlock_data($sem); */
329 /* ignore_user_abort(FALSE); */
330 /* return (blocking_error(TRUE)); */
332 $S_load_stat['wR_minusone']++;
334 /* if (($user = $room->get_user($sess, $idx)) == FALSE) { */
335 /* Room::unlock_data($sem); */
336 /* ignore_user_abort(FALSE); */
337 /* return (blocking_error(TRUE)); */
340 if ($user->the_end == TRUE) {
341 log_rd2("main_check: the end".var_export(debug_backtrace()));
342 $is_page_streaming = TRUE;
345 if ($user->trans_step != -1) {
346 log_rd2("TRANS USATO ".$user->trans_step);
347 $cur_step = $user->trans_step;
348 $user->trans_step = -1;
350 /* Room::save_data($room); */
351 /* Room::unlock_data($sem); */
352 ignore_user_abort(FALSE);
355 log_rd2("TRANS NON ATTIVATO");
356 // ARRAY_POP DISABLED
357 // log_rd2("TRANS NON ATTIVATO, clean del comm array");
358 // while (($el = array_pop($user->comm)) != NULL) {
359 // log_rd2("clean element [".$el."]");
361 // // $user->step_inc(COMM_N + 1);
362 // Room::save_data($room);
363 // // $new_step = $user->step;
365 /* Room::unlock_data($sem); */
366 ignore_user_abort(FALSE);
371 /* this part I suppose is read only on $room structure */
372 if ($cur_step == -1) {
373 log_rd2("PRE-NEWSTAT: ".$user->stat);
375 if ($user->stat == 'room') {
376 log_rd("roomma ".$user->step);
379 if ($G_with_splash &&
380 ($$CO_splashdate < $curtime - $G_splash_interval ||
381 $$CO_splashdate > $curtime)) {
382 $is_super = $user->flags & USER_FLAG_TY_SUPER;
383 $ret .= show_notify_ex(str_replace("\n", " ", $G_splash_content[$G_lang]),
384 ($is_super ? 0 : $G_splash_timeout),
385 $mlang_indrd[($is_super ? 'btn_btotabsup' : 'btn_backtotab')][$G_lang],
386 $G_splash_w, $G_splash_h, true,
387 ($is_super ? 0 : $G_splash_timeout));
388 $ret .= sprintf('|createCookie("CO_splashdate%d", %d, 24*365, cookiepath);', $G_splash_idx, $curtime);
390 $ret .= $room->show_room($user->step, $user);
392 // TODO uncomment and test
393 /* NOTE the sets went common */
394 $new_stat = $user->stat;
395 $new_subst = $user->subst;
396 $new_step = $user->step;
403 else if ($user->stat == 'table') {
405 return (page_sync($user->sess, "briskin5/index.php", $user->table, $user->table_token));
407 log_rd2("NEWSTAT: ".$user->stat);
408 } /* if ($cur_step == -1) { */
410 ignore_user_abort(TRUE);
411 /* $sem = Room::lock_data(FALSE); */
412 $S_load_stat['rU_heavy']++;
413 /* if (($user = User::load_data($proxy_step['i'], $sess)) == FALSE) { */
414 /* Room::unlock_data($sem); */
415 /* ignore_user_abort(FALSE); */
416 /* return (blocking_error(TRUE)); */
419 if ($cur_step < $user->step) {
421 if ($cur_step + COMM_N < $user->step) {
422 if (($cur_stat != $user->stat)) {
423 $to_stat = $user->stat;
424 /* Room::unlock_data($sem); */
425 ignore_user_abort(FALSE);
427 return (page_sync($user->sess, ($to_stat == "table" ? "briskin5/index.php" : "index.php"), $user->table, $user->table_token));
429 log_rd2("lost history, refresh from scratch");
433 for ($i = $cur_step ; $i < $user->step ; $i++) {
435 log_rd2("ADDED TO THE STREAM: ".$user->comm[$ii]);
436 $ret .= $user->comm[$ii];
438 $new_stat = $user->stat;
439 $new_subst = $user->subst;
440 $new_step = $user->step;
443 log_rd2($user->step, 'index_rd.php: after ret set');
445 if ($user->the_end == TRUE) {
446 /* Room::unlock_data($sem); */
448 /* Switch to exclusive locking */
449 /* $sem = Room::lock_data(TRUE); */
453 $S_load_stat['wR_the_end']++;
454 /* if (($room = Room::load_data()) == FALSE) { */
455 /* Room::unlock_data($sem); */
456 /* ignore_user_abort(FALSE); */
457 /* return (blocking_error(TRUE)); */
460 /* if (($user = $room->get_user($sess, $idx)) == FALSE) { */
461 /* Room::unlock_data($sem); */
462 /* ignore_user_abort(FALSE); */
463 /* return (blocking_error(TRUE)); */
466 log_rd2("LOGOUT BYE BYE!!");
467 log_auth($user->sess, "Explicit logout.");
469 if ($user->the_end == TRUE) {
472 if ($user->subst == 'sitdown') {
473 log_load("ROOM WAKEUP");
474 $room->room_wakeup($user);
476 else if ($user->subst == 'standup')
477 $room->room_outstandup($user);
479 log_rd2("LOGOUT FROM WHAT ???");
481 /* Room::save_data($room); */
482 } /* if ($user->the_end == TRUE) { ... */
483 } /* if ($user->the_end == TRUE) { ... */
484 } /* if ($cur_step < $user->step) { */
486 /* Room::unlock_data($sem); */
487 ignore_user_abort(FALSE);
488 } /* else of if ($cur_step == -1) { */
504 function index_rd_ifra_init(&$room, &$user, &$header_out, &$body, $get, $post, $cookie)
506 GLOBAL $G_four_rnd_string;
510 $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);
512 $header_out['Cache-Control'] = 'no-cache, must-revalidate'; // HTTP/1.1
513 $header_out['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT'; // Date in the past
514 $header_out['Content-type'] = 'text/html; charset="utf-8"';
516 log_load("index_rd_ifra_init.php");
518 if (($from = gpcs_var('from', $get, $post, $cookie)) === FALSE)
520 if (($stat = gpcs_var('stat', $get, $post, $cookie)) === FALSE)
522 if (($subst = gpcs_var('subst', $get, $post, $cookie)) === FALSE)
524 if (($step = gpcs_var('step', $get, $post, $cookie)) === FALSE)
527 $user->rd_data_set($curtime, $stat, $subst, $step, $from);
529 $body .= sprintf("<html>
531 <script type=\"text/javascript\" src=\"commons.js\"></script>
532 <script type=\"text/javascript\" src=\"xynt-http-streaming-ifra.js\"></script>
533 <script type=\"text/javascript\">
534 var http_streaming = \"ready\";");
536 $body .= sprintf("last_clean = %d;\n", $st);
539 window.onload = function () { if (http_streaming != \"ready\") { http_streaming.reload(); } };
543 $body .= sprintf("<!-- \n%s -->\n", $G_four_rnd_string);
548 function index_rd_ifra_main(&$room, &$user, &$body)
550 GLOBAL $is_page_streaming;
552 $is_page_streaming = FALSE;
553 log_rd2("FROM OUTSIDE - STAT: ".$user->rd_stat." SUBST: ".$user->rd_subst." STEP: ".$user->rd_step." FROM: ".$user->rd_from. "IS_PAGE:" . $is_page_streaming);
557 // for ($i = 0, $script_step = 0 ; time() < $endtime ; $i++) {
558 // log_rd("PRE MAIN ".$step);;
560 $pre_main = gettimeofday(TRUE);
562 $old_stat = $user->rd_stat;
563 $old_subst = $user->rd_subst;
564 $old_step = $user->rd_step;
565 if (($ret = maincheck($room, $user, $old_stat, $old_subst, $old_step, $user->rd_stat, $user->rd_subst, $user->rd_step)) != FALSE) {
569 // log_rd2(sprintf("\nSESS: [%s]\nOLD_STAT: [%s] OLD_SUBST: [%s] OLD_STEP: [%s] \nSTAT: [%s] SUBST: [%s] STEP: [%s] \nCOMM: [%s]\n", $sess, $old_stat, $old_subst, $old_step, $stat, $subst, $step, $ret));
573 $body .= sprintf("<script id='hs%d' type='text/javascript'><!--
576 </script>", $user->rd_scristp++, escpush($ret) );
578 // log_send("IS_PAGE: ".($is_page_streaming == TRUE ? "TRUE" : "FALSE")." ENDTIME: [".$endtime."] ".$ret);
580 log_rd2(0, 'index_rd.php: after mop_flush (begin: '.sprintf("%f", $pre_main).')');
581 if ($is_page_streaming)
584 /* $old_stat = $stat; */
585 /* $old_subst = $subst; */
586 /* $old_step = $step; */
587 // log_rd("POST MAIN ".$step);;
589 /* if (($i % 10) == 0 && 1 == 0) { // TODO: reenable push(null); */
590 /* if ($no_data == TRUE) { */
591 /* // log_rd2("TIME: ".time()); */
592 /* printf("<script id='hs%d' type='text/javascript'><!-- */
595 /* alert(\"de che\"); */
596 /* </script>", $script_step++); */
597 /* // mop_flush(); */
598 /* log_crit("flush"); */
600 /* $no_data = TRUE; */
607 /* foreach ($S_load_stat as $key => $value) { */
608 /* $s .= sprintf("%s: %d - ", $key, $value); */
609 /* if (substr($key, 0, 1) == "w") */
611 /* else if (substr($key, 0, 1) == "r") */
614 /* $s = sprintf("index_rd.php stats: R: %d W: %d - %s", $tr, $tw, $s); */
620 function index_rd_ifra_keepalive(&$user)
622 return (sprintf("<script id='hs%d' type='text/javascript'><!--
625 </script>", $user->rd_scristp++));