From: Matteo Nastasi Date: Tue, 2 Jan 2018 13:46:40 +0000 (+0100) Subject: other changes and fixes from beta site X-Git-Tag: v5.6.0~22 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=48f50311b96f41a3cd22f2832a225ccd1cd2131a;p=brisk.git other changes and fixes from beta site --- diff --git a/web/briskin5/explain.php b/web/briskin5/explain.php index 2490ab6..1c15dd2 100644 --- a/web/briskin5/explain.php +++ b/web/briskin5/explain.php @@ -28,6 +28,12 @@ */ +foreach (array("HTTP_HOST", "DOCUMENT_ROOT") as $i) { + if (isset($_SERVER[$i])) { + $$i = $_SERVER[$i]; + } + } + $G_base = "../"; ini_set("max_execution_time", "240"); diff --git a/web/briskin5/stat-day.php b/web/briskin5/stat-day.php index 8d3dd3e..17c6e8c 100644 --- a/web/briskin5/stat-day.php +++ b/web/briskin5/stat-day.php @@ -38,6 +38,24 @@ curl -d "pazz=$BRISK_PASS" "http://$BRISK_SITE/briskin5/stat-day.php?from=$(date */ +foreach (array("HTTP_HOST", "DOCUMENT_ROOT") as $i) { + if (isset($_SERVER[$i])) { + $$i = $_SERVER[$i]; + } + } + +foreach (array("pazz") as $i) { + if (isset($_POST[$i])) { + $$i = $_POST[$i]; + } + } + +foreach (array("from", "to") as $i) { + if (isset($_GET[$i])) { + $$i = $_GET[$i]; + } + } + $G_base = "../"; // SYNC WITH bin5_tournaments table @@ -98,11 +116,11 @@ function main_pgsql($from, $to) $trn_obj = pg_fetch_object($trn_pg, $t); $tmt_sql = sprintf(" -SELECT m.code AS code, m.mazzo_next as minus_one_is_old - FROM %sbin5_matches AS m, %sbin5_games AS g, %sbin5_tournaments as t - WHERE t.code = m.tcode AND m.code = g.mcode - AND t.code = %d AND g.tstamp >= '%s' AND g.tstamp < '%s' - GROUP BY m.code, minus_one_is_old +SELECT m.code AS code, m.mazzo_next as minus_one_is_old + FROM %sbin5_matches AS m, %sbin5_games AS g, %sbin5_tournaments as t + WHERE t.code = m.tcode AND m.code = g.mcode + AND t.code = %d AND g.tstamp >= '%s' AND g.tstamp < '%s' + GROUP BY m.code, minus_one_is_old ORDER BY m.code, minus_one_is_old DESC;", $G_dbpfx, $G_dbpfx, $G_dbpfx, $trn_obj->code, $from, $to); @@ -250,7 +268,7 @@ SELECT p.pts AS pts if ($tmt_obj->minus_one_is_old != -1) { $rules_name = rules_id2name($trn_obj->code); fprintf($fpexp, "%s%s", $users[$gam_obj->mazzo]['login'], - xcape( ${rules_name}::game_description($gam_obj->act, 'plain', $gam_obj->mult, + xcape( $rules_name::game_description($gam_obj->act, 'plain', $gam_obj->mult, $gam_obj->asta_win, ($gam_obj->asta_win != -1 ? $users[$gam_obj->asta_win]['login'] : ""), diff --git a/web/spush/brisk-spush.phh b/web/spush/brisk-spush.phh index 6c4b5e3..0f22baa 100644 --- a/web/spush/brisk-spush.phh +++ b/web/spush/brisk-spush.phh @@ -160,11 +160,11 @@ class PendingPage { if ($this->kalive < $curtime) { printf("TRY FLUSH CLOSE 1\n"); - fclose($this->socket); + @fclose($this->socket); return TRUE; } - $wret = fwrite($this->socket, $this->msg, mb_strlen($this->msg, "ASCII")); + $wret = @fwrite($this->socket, $this->msg, mb_strlen($this->msg, "ASCII")); if ($wret == FALSE && $wret !== FALSE) { printf("TRY FLUSH PendingPage::try_flush: wret 0 but not FALSE [%d]\n", mb_strlen($this->msg, "ASCII")); } diff --git a/web/xynt-streaming.js b/web/xynt-streaming.js index a144f1c..13eeb7b 100644 --- a/web/xynt-streaming.js +++ b/web/xynt-streaming.js @@ -544,6 +544,8 @@ xynt_streaming.prototype = { win: null, transp_type: null, transp_port: 80, + transp_type_cur: null, + transp_port_cur: 80, transp_fback: 0, transp: null, console: null, @@ -633,15 +635,24 @@ xynt_streaming.prototype = { // DEFAULT TRANSPORT PROTOCOL HERE websocketsec, websocket if (this.transp_fback > 0) { - transp_type = "websocketsec"; - // transp_port = (this.transp_fback == 2 ? 443 : 8080); - transp_port = 443; + if (location.protocol == 'https:') { + transp_type = "websocketsec"; + transp_port = 443; + } + else { + transp_type = "websocket"; + transp_port = (this.transp_fback == 2 ? 80 : 8080); + } + } else { transp_type = this.transp_type; transp_port = this.transp_port; } + this.transp_type_cur = transp_type; + this.transp_port_cur = transp_port; + if (transp_type == "websocket" || transp_type == "websocketsec") { var end_proto, first_slash, newpage; @@ -902,6 +913,10 @@ xynt_streaming.prototype = { // alert("SINGLE: ["+singlecomm+"]"); // window.console.log("["+singlecomm+"]"); this.cmdproc(singlecomm); + if (this.transp_type_cur) { + this.transp_type = this.transp_type_cur; + this.transp_port = this.transp_port_cur; + } again = 1; } } while (again); diff --git a/web/xynt_test01_wss.php b/web/xynt_test01_wss.php new file mode 100644 index 0000000..4c1c43b --- /dev/null +++ b/web/xynt_test01_wss.php @@ -0,0 +1,344 @@ +il client aspetta 3 secondi, e poi da 10 a N ogni secondo, (status sempre verde).", + "Esegue un comando, manda loc_new a un valore irraggiungibile, stoppa il processore di comandi e poi dà un comando teoricamente irraggiungibile."); + + +// trim(mb_convert_case($split[0], MB_CASE_TITLE, 'UTF-8')) + +function headers_render($header, $len) +{ + $cookies = ""; + + if (isset($header['Cookies'])) { + $cookies = $header['Cookies']->render(); + unset($header['Cookies']); + } + if (isset($header['Location'])) { + header(sprintf("HTTP/1.1 302 OK\r\n%sLocation: %s", $cookies, $header['Location'])); + } + else if (isset($header['HTTP-Response'])) { + header(sprintf("HTTP/1.1 %s", $header['HTTP-Response'])); + foreach($header as $key => $value) { + if (strtolower($key) == "http-response") + continue; + header(sprintf("%s: %s", $key, $value)); + } + if ($len >= 0) { + header(sprintf("Content-Length: %ld", $len)); + } + } + else { + header("HTTP/1.1 200 OK\r\n"); + + if (!isset($header['Date'])) + header(sprintf("Date: %s", date(DATE_RFC822))); + if (!isset($header['Connection'])) + header("Connection: close"); + if (!isset($header['Content-Type'])) + header("Content-Type: text/html"); + foreach($header as $key => $value) { + header(sprintf("%s: %s", $key, $value)); + } + if ($len >= 0) { + header(sprintf("Content-Length: %d", $len)); + } + else { + header("Cache-Control: no-cache, must-revalidate"); + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + if (!isset($header['Content-Encoding'])) { + header("Content-Encoding: chunked"); + } + header("Transfer-Encoding: chunked"); + } + header($cookies); + } + + return (TRUE); +} + +$transs = array( "iframe", "websocket", "websocketsec", "xhr", "htmlfile" ); +$trans_ports = array( "iframe"=>80, "websocket"=>80, "websocketsec"=>443, "xhr"=>80, "htmlfile"=>80 ); +if (!isset($f_trans)) + $f_trans = $transs[0]; + +if (!isset($f_test)) + $f_test = 1; + +if (!isset($f_port)) + $f_port = NULL; + +if (!isset($f_fback)) + $f_fback = 0; + + +function mop_flush() +{ + for ($i = 0; $i < ob_get_level(); $i++) + ob_end_flush(); + ob_implicit_flush(1); + flush(); +} + +$escpush_from = array("\\", "\""); +$escpush_to = array("\\\\", "\\\""); +function escpush($s) +{ + GLOBAL $escpush_from, $escpush_to; + + return str_replace($escpush_from, $escpush_to, $s); +} + +function xcape($s) +{ + $from = array ( '\\', '@', '|' ); + $to = array ( '\\\\', '@', '¦' ); + + return (str_replace($from, $to, htmlentities($s,ENT_COMPAT,"UTF-8"))); +} + +if (isset($isstream) && $isstream == "true") { + require_once("Obj/transports.phh"); + + if (isset($transp) && $transp == "websocket") { + $trobj = new Transport_websocket(); + } + else if (isset($transp) && $transp == "websocketsec") { + $trobj = new Transport_websocket(TRUE); + } + else if (isset($transp) && $transp == "xhr") { + $trobj = new Transport_xhr(); + } + else if (isset($transp) && $transp == "htmlfile") { + $trobj = new Transport_htmlfile(); + } + else { + $trobj = new Transport_iframe(); + } + $headers_out = array(); + + $init_string = ""; + for ($i = 0 ; $i < 4096 ; $i++) { + if (($i % 128) == 0) + $init_string .= " "; + else + $init_string .= chr(mt_rand(65, 90)); + } + $headers_in = getallheaders(); + // error_log(print_r($headers_in, TRUE)); + $headers = array(); + foreach ($headers_in as $header_in => $value) { + $headers[mb_convert_case($header_in, MB_CASE_TITLE, 'UTF-8')] = $value; + } + $fp = fopen("/tmp/xynt.log", "a+"); + fprintf($fp, "here we are\n"); + fclose($fp); + + $body = $trobj->init("plain", $headers, $headers_out, $init_string, "", "0"); + + if ($body === FALSE) { + $fp = fopen("/tmp/xynt.log", "a+"); + fprintf($fp, "init failed\n"); + fclose($fp); + } + else { + $fp = fopen("/tmp/xynt.log", "a+"); + fprintf($fp, "after_init [%s] [%s]\n", $transp, print_r($headers_out, TRUE)); + fprintf($fp, "body [%s][%d]\n", $body, mb_strlen($body, "ASCII")); + fclose($fp); + } + + if (isset($transp) && ($transp == "websocket" || $transp == "websocketsec")) { + header_remove('Connection'); + header_remove('Content-Encoding'); + header_remove('Content-Type'); + header_remove('Date'); + header_remove('Keep-Alive'); + header_remove('Server'); + header_remove('Transfer-Encoding'); + header_remove('Vary'); + header_remove('X-Powered-By'); + + headers_render($headers_out, 100); + } + $lnz = 0; + + print($body); + $lnz += mb_strlen($body, "ASCII"); + mop_flush(); + + switch ($f_test) { + case 1: + // from 1 to 9 into the innerHTML and than close + for ($i = 1 ; $i < 10 ; $i++) { + $chunk = $trobj->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i)); + print($chunk); + mop_flush(); + sleep(1); + } + + break; + case 2: + // from 1 to 9 into the innerHTML and than close + for ($i = 1 ; $i < 10 ; $i++) { + $chunk = $trobj->chunk($i, sprintf("gst.st++; \$('container').innerHTML = gst.st;")); + print($chunk); + $lnz += mb_strlen($chunk, "ASCII"); + mop_flush(); + sleep(1); + } + break; + case 3: + // from 1 to 9 with 60 secs after 8, the client js api must restart stream after 12 secs + for ($i = 1 ; $i < 10 ; $i++) { + $chunk = $trobj->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i)); + print($chunk); + mop_flush(); + sleep(1); + if ($i == 8) + sleep(60); + } + break; + case 4: + // from 1 to 9 into the innerHTML and than close + for ($i = 1 ; $i < 10 ; $i++) { + if ($i != 5) { + $chunk = $trobj->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i)); + } + else { + $chunk = $trobj->chunk($i, sprintf("\$('container').innerHTML = '%d';|sleep(gst,3000);", $i)); + } + print($chunk); + mop_flush(); + sleep(1); + } + break; + case 5: + // from 1 to 9 into the innerHTML and than close + $cont = array('@BEGIN@', '@END@', '@BEGIN@ sleep(1); @END@'); + for ($i = 1 ; $i < 10 ; $i++) { + switch($i) { + case 6: + case 7: + case 8: + $chunk = $trobj->chunk($i, sprintf("\$('container').innerHTML = '%s';", xcape($cont[$i - 6]))); + break; + default: + $chunk = $trobj->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i)); + break; + } + print($chunk); + mop_flush(); + if ($i < 9) + sleep(1); + } + break; + case 6: + // from 1 to 9 into the innerHTML and than close + if ($step == 8) { + $chunk = $trobj->chunk(1, sprintf("gst.st++; \$('container').innerHTML = gst.st;")); + print($chunk); + // without this usleep the delay is doubled in iframe stream because + // no transp.xynt_streaming back-set is performed + usleep(250000); + mop_flush(); + } + else { + for ($i = 1 ; $i < 10 ; $i++) { + $chunk = $trobj->chunk($i, sprintf("gst.st++; \$('container').innerHTML = gst.st;")); + print($chunk); + mop_flush(); + if ($i < 9) + sleep(1); + } + } + break; + case 7: + $chunk = $trobj->chunk(1, sprintf("gst.st++; \$('container').innerHTML = 'prima';")); + print($chunk); + + $chunk = $trobj->chunk(2, sprintf("gst.st++; gst.st_loc_new++; xstm.stop();")); + print($chunk); + + $chunk = $trobj->chunk(3, sprintf("gst.st++; \$('container').innerHTML = 'dopo';")); + print($chunk); + + break; + } + + print($trobj->close()); + mop_flush(); + + exit; +} +?> + + +XYNT TEST01 + + + + + + + + + + +
+"); +for ($test = 1 ; $test <= count($desc) ; $test++) { + printf(""); + foreach ($transs as $trans) { + printf("Test %s %02d (port %d (fb %d))", $trans, $test, + ($f_port == NULL ? "" : sprintf("&f_port=%d", $f_port)), $f_fback, $trans, $test, + ($f_port == NULL ? $trans_ports[$trans] : $f_port ), $f_fback); + } + printf("\n"); +} +printf("STOP", count($transs)); +printf(""); +printf("
[%s]
Test: %d
", $f_trans, $f_test); +?> +
+
+Descrizione: +
+ +
+Status:
+ + +
+Counter: +BEGIN + +
+ +