From: Matteo Nastasi Date: Sun, 13 Sep 2026 10:30:35 +0000 (+0200) Subject: port to php 8.4 (debian 13) X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=4e90dc8ae4eb25bd07be1656cbff6ee92ddb7e87;p=brisk.git port to php 8.4 (debian 13) The code was written for php 5. Minimal changes to make it run cleanly on 8.4, with no restructuring. Fatal errors - split() -> explode() (removed in 7.0), 5 places - "$x =& new Class()" -> "= new" (removed in 7.0), 7 places - 41 php4 style constructors -> __construct(). A non obvious case: Bin5_user defined "function User() {}", which on php5 was its constructor because it overrode the slot inherited from User; that one was renamed too. - 15 static calls to non static methods (Challenges::load_data(), Hardbans::add(), Table::create(), ...): E_STRICT on php5, Error since 8.0. "static" added to the 8 declarations, none of them uses $this. - 5 overrides with incompatible signatures (spawn, copy, load_step, unproxy_step, page_sync): E_STRICT on php5, fatal since 8.0. The useless "&" on objects were dropped and the parameters of three methods reordered, with the two call sites adjusted. - dbase_pgsql.phh: pg_result_status($res) was called in the branch where $res is FALSE. Since 8.0 results are \PgSql\Result objects and no longer resources, so it is not a warning any more but a fatal TypeError - and in the connection recovery path, of all places. Replaced with pg_last_error(). - dbase_pgsql.phh: "${rules_name}::game_description(...)" was a variable variable whose name came from an undefined constant; on php5 it degraded to a string with a notice and resolved to $rules_name by accident, on php8 it is a fatal Error. - dbase_file.phh: define() with an unquoted constant name, same mechanism. - usermgmt.php: "break" outside any loop. On php5 it was a runtime fatal, since 7.0 it is a compile time one: the file did not load any more. Deprecations - 245 "var $prop" -> public - 29 occurrences of "${var}" inside strings -> "{$var}" (8.2) - 29 dynamic properties declared (8.2). User declared $brisk but the code always uses $room: renamed, nobody reads $user->brisk. - 53 pg_numrows() -> pg_num_rows(): the alias is deprecated in 8.4 - strftime() -> date(), shmop_close() -> unset() - room_join_wakeup(): removed a default followed by a mandatory parameter mbstring.func_overload It was set to 7 in the .htaccess files and was removed in 8.0. All 62 call sites of strlen/substr/strpos were examined: they are either pure ASCII or deliberately byte oriented, and moving to php8 fixes them, given that the websocket frame parsing in transports.phh and the fwrite accounting in sac-a-push.phh would have been wrong under overload. No change needed: where character semantics were required the author already used explicit mb_*. The only exception is index_wr.php, where mail() is no longer remapped onto mb_send_mail(): mb_encode_mimeheader() was added on the subject and on the user name, which otherwise ended up as raw UTF-8 in the headers. Configuration (debian 13) - .htaccess: func_overload removed, internal_encoding/http_input replaced by default_charset; the php_value block now sits inside because with PHP-FPM apache would answer 500 - the three .htaccess that protect the sources used the apache 2.2 syntax (Order/Deny), which needs mod_access_compat: now "Require all denied" with a fallback - system/etc_php5_conf.d_mbstring.ini -> etc_php8.4_conf.d_brisk.ini - INSTALL.sh: "php5 -l" -> "php -l" Checked: php -l clean on 64 files; the whole include chain of the daemon loads with E_ALL without warnings or deprecations; the tests in test/ pass. Not yet verified against a database: dbase_pgsql.phh was only checked statically. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_014M1jiEq9cHdE5SE5j6vFuE --- diff --git a/INSTALL.sh b/INSTALL.sh index 05b76e6..7a44117 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -99,7 +99,7 @@ if [ "$1" = "chk" ]; then IFS=' ' for i in $(find -name '*.pho' -o -name '*.phh' -o -name '*.php'); do - php5 -l $i + php -l $i done taggit="$(git describe --tags | sed 's/^v//g')" diff --git a/system/etc_php5_conf.d_mbstring.ini b/system/etc_php5_conf.d_mbstring.ini deleted file mode 100644 index dffe7d3..0000000 --- a/system/etc_php5_conf.d_mbstring.ini +++ /dev/null @@ -1,7 +0,0 @@ -; Set mbstring defaults to UTF-8 -mbstring.language=UTF-8 -mbstring.internal_encoding=UTF-8 -mbstring.http_input=auto -mbstring.http_output=UTF-8 -mbstring.detect_order=auto - diff --git a/system/etc_php8.4_conf.d_brisk.ini b/system/etc_php8.4_conf.d_brisk.ini new file mode 100644 index 0000000..4905c1a --- /dev/null +++ b/system/etc_php8.4_conf.d_brisk.ini @@ -0,0 +1,20 @@ +; Brisk - required PHP settings (php 8.4 / debian 13) +; To be installed both in /etc/php/8.4/cli/conf.d/ (brisk-spush daemon) +; and in /etc/php/8.4/apache2/conf.d/ or fpm/conf.d/ (web pages). + +; UTF-8 everywhere. Replaces mbstring.internal_encoding / +; mbstring.http_input / mbstring.http_output, all deprecated. +default_charset=UTF-8 + +mbstring.language=UTF-8 +mbstring.detect_order=auto + +; NOTE: mbstring.func_overload was removed in php 8.0. +; It used to be set to 7 in the .htaccess of web/ and web/briskin5/. + +; The pages served by apache print their html with echo/printf: a warning or +; a deprecation notice ends up inside the response. Off is mandatory. +; (The brisk-spush daemon instead writes to the socket and uses stdout as its +; log, so there such messages are only noise in the log.) +display_errors=Off +log_errors=On diff --git a/test/nonblocking.php b/test/nonblocking.php index 8085510..2aba834 100755 --- a/test/nonblocking.php +++ b/test/nonblocking.php @@ -43,7 +43,7 @@ function cmd_deserialize($cmd) $a = explode('&', $cmd); $i = 0; while ($i < count($a)) { - $b = split('=', $a[$i]); + $b = explode('=', $a[$i]); $ret[urldecode($b[0])] = urldecode($b[1]); $i++; } diff --git a/web/.htaccess b/web/.htaccess index 0eb7591..b016cec 100644 --- a/web/.htaccess +++ b/web/.htaccess @@ -4,10 +4,16 @@ header append Cache-Control "public, last-modified, must-revalidate" header append Pragma "no-cache" header append Expires "-1" -php_value mbstring.http_input "auto" -php_value mbstring.internal_encoding "UTF-8" +# php 8.4: mbstring.func_overload was REMOVED (it used to be 7 = +# mail+string+regex). strlen/substr/strpos are back to byte semantics: the +# places that need character semantics now call mb_* explicitly in the source. +# mbstring.internal_encoding/http_input are deprecated: default_charset is used +# instead. php_value/php_flag only work with mod_php; with PHP-FPM Apache +# answers 500, hence the block is conditional. + +php_value default_charset "UTF-8" php_flag mbstring.encoding_translation On -php_value mbstring.func_overload "7" + ExpiresActive On ExpiresByType image/jpg "access plus 4 days" diff --git a/web/Obj/.htaccess b/web/Obj/.htaccess index 481dad6..04a77ee 100644 --- a/web/Obj/.htaccess +++ b/web/Obj/.htaccess @@ -1,3 +1,10 @@ -Order Deny,Allow -Deny from All - +# apache 2.4 (debian 13). The old 2.2 syntax "Order Deny,Allow / Deny from All" +# needs mod_access_compat, which is not guaranteed: the native one is used here, +# with a fallback. + + Require all denied + + + Order Deny,Allow + Deny from All + diff --git a/web/Obj/auth.phh b/web/Obj/auth.phh index 193bca6..d9b4528 100644 --- a/web/Obj/auth.phh +++ b/web/Obj/auth.phh @@ -22,7 +22,7 @@ * */ -require_once("${G_base}Obj/dbase_${G_dbasetype}.phh"); +require_once("{$G_base}Obj/dbase_{$G_dbasetype}.phh"); define('CHAL_SHM_DIMS_MIN', 16384); define('CHAL_SHM_DIMS_MAX', 65536); @@ -32,12 +32,12 @@ define('CHAL_GARBAGE_TIMEOUT', 5); class Challenge { - var $login; - var $token; - var $ip; - var $tstamp; + public $login; + public $token; + public $ip; + public $tstamp; - function Challenge($login, $token, $ip, $tstamp) + function __construct($login, $token, $ip, $tstamp) { $this->login = $login; $this->token = $token; @@ -49,15 +49,15 @@ class Challenge { class Challenges { static $delta_t; - var $item; - var $item_n; - var $mod; - var $shm_sz; + public $item; + public $item_n; + public $mod; + public $shm_sz; - var $garbage_timeout; + public $garbage_timeout; - function Challenges() + function __construct() { $this->item = array(); $this->item_n = 0; @@ -155,14 +155,14 @@ class Challenges { // Static functions static function create() { - $chal =& new Challenges(); + $chal = new Challenges(); $chal->mod = TRUE; return $chal; } - function load_data() + static function load_data() { GLOBAL $sess; do { @@ -207,7 +207,7 @@ class Challenges { } - function save_data($chals) + static function save_data($chals) { $shm = FALSE; $oldmod = $chals->mod; diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 8f95565..52a2e41 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -92,7 +92,7 @@ define('DEBUGGING', "no-debugging"); define('BSK_BUSTING', "dev"); require_once("$DOCUMENT_ROOT/Etc/".BRISK_CONF); -require_once("${G_base}Obj/ipclass.phh"); +require_once("{$G_base}Obj/ipclass.phh"); $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi', 'en' => 'back standing' ), @@ -441,7 +441,7 @@ function cmd_deserialize($cmd) $a = explode('&', $cmd); $i = 0; while ($i < count($a)) { - $b = split('=', $a[$i]); + $b = explode('=', $a[$i]); $ret[urldecode($b[0])] = urldecode($b[1]); $i++; } @@ -459,8 +459,8 @@ function versions_cmp($v1, $v2) if ($v1 == $v2) return 0; - $v1_ar = split('\.', $v1); - $v2_ar = split('\.', $v2); + $v1_ar = explode('.', $v1); + $v2_ar = explode('.', $v2); $v2_ct = count($v2_ar); @@ -619,7 +619,10 @@ function xcapemesg($s) class Vect { - function Vect($a) + /* php8: declared, dynamic properties are deprecated since 8.2 */ + public $el; + + function __construct($a) { $this->el = $a; } @@ -642,26 +645,26 @@ define('TABLE_AUTH_TY_CERT', 3); class Table { - var $idx; - var $player; - var $player_n; + public $idx; + public $player; + public $player_n; - var $auth_type; // required authorization to sit down + public $auth_type; // required authorization to sit down - var $wag_own; - var $wag_com; - var $wag_tout; + public $wag_own; + public $wag_com; + public $wag_tout; - var $table_token; - var $table_start; // information field + public $table_token; + public $table_start; // information field - var $wakeup_time; + public $wakeup_time; - function Table() + function __construct() { } - function create($idx) + static function create($idx) { if (($thiz = new Table()) == FALSE) return (FALSE); @@ -723,7 +726,9 @@ class Table { return ($thiz); } - function spawn($from) + /* static like Bin5_table::spawn(), which overrides it: php does not let an + override change the staticness of the parent method. */ + static function spawn($from) { if (($thiz = new Table()) == FALSE) return (FALSE); @@ -862,11 +867,13 @@ class Table { class Delay_Manager { - var $delta; - var $lastckeck; - var $triglevel; + public $delta; + public $lastckeck; + public $triglevel; + /* php8: declared, dynamic properties are deprecated since 8.2 */ + public $lastcheck; - function Delay_Manager($triglevel) + function __construct($triglevel) { $this->triglevel = $triglevel; $this->delta = array(); @@ -910,10 +917,10 @@ class Delay_Manager } class Client_prefs { - var $listen; - var $supp_comp; + public $listen; + public $supp_comp; - function Client_prefs() + function __construct() { } @@ -1010,11 +1017,11 @@ define('GHOST_SESS_REAS_PROX', 6); // proxy access class GhostSessEl { - var $time; - var $sess; - var $reas; + public $time; + public $sess; + public $reas; - function GhostSessEl($time, $sess, $reas) + function __construct($time, $sess, $reas) { $this->time = $time + GHOST_SESS_TOUT; $this->sess = $sess; @@ -1024,9 +1031,9 @@ class GhostSessEl class GhostSess { - var $gs; + public $gs; - function GhostSess() + function __construct() { $this->gs = array(); } @@ -1072,26 +1079,26 @@ class Brisk { static $delta_t; - var $crystal_filename; - var $user; - var $table; - var $match; - var $comm; // commands for many people - var $step; // current step of the comm array - var $garbage_timeout; - var $shm_sz; + public $crystal_filename; + public $user; + public $table; + public $match; + public $comm; // commands for many people + public $step; // current step of the comm array + public $garbage_timeout; + public $shm_sz; - var $ban_list; // ban list (authized allowed) - var $black_list; // black list (anti-dos, noone allowed) - var $cloud_smasher; // list of cloud ip ranges to be rejected - var $ghost_sess; - var $delay_mgr; + public $ban_list; // ban list (authized allowed) + public $black_list; // black list (anti-dos, noone allowed) + public $cloud_smasher; // list of cloud ip ranges to be rejected + public $ghost_sess; + public $delay_mgr; - var $cds; + public $cds; public static $sess_cur; - function Brisk() + function __construct() { $this->cds = NULL; } @@ -1552,7 +1559,7 @@ class Brisk } } - function room_join_wakeup($user, $update_lacc = FALSE, $trans_delta) + function room_join_wakeup($user, $update_lacc, $trans_delta) { $table_idx = $user->table; $table = $this->table[$table_idx]; @@ -2324,7 +2331,7 @@ class Brisk if ($to_tabl) { // FIXME BRISK4: include for each kind of table - require_once("${G_base}briskin5/Obj/briskin5.phh"); + require_once("{$G_base}briskin5/Obj/briskin5.phh"); // Before all align times with table timeout for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) { if (isset($this->match[$table_idx])) { @@ -2506,7 +2513,7 @@ class Brisk // If user at the table we need to update the table data too $table_idx = $ghost_user->table; if ($ghost_user->stat == "table" && $this->table[$table_idx]->player_n == PLAYERS_N) { - require_once("${G_base}briskin5/Obj/briskin5.phh"); + require_once("{$G_base}briskin5/Obj/briskin5.phh"); if (isset($this->match[$table_idx])) { $bin5 = $this->match[$table_idx]; @@ -3447,7 +3454,7 @@ function sharedmem_sz($tok) return (-1); } $shm_sz = shmop_size($shm_id); - shmop_close($shm_id); + unset($shm_id); // php8: shmop_close() deprecata, il segmento si libera col refcount // log_main("shm_sz: ".$shm_sz." SHM_DIMS: ".SHM_DIMS); return ($shm_sz); diff --git a/web/Obj/dbase_base.phh b/web/Obj/dbase_base.phh index 66c998f..13052e8 100644 --- a/web/Obj/dbase_base.phh +++ b/web/Obj/dbase_base.phh @@ -24,20 +24,20 @@ class LoginDBItem { - var $code; - var $login; - var $pass; - var $email; - var $type; - var $last_dona; - var $supp_comp; - var $tos_vers; - var $disa_reas; - var $guar_code; - var $match_cnt; - var $game_cnt; - - function LoginDBItem($code, $login, $pass, $email, $type, $last_dona, $supp_comp, $tos_vers, + public $code; + public $login; + public $pass; + public $email; + public $type; + public $last_dona; + public $supp_comp; + public $tos_vers; + public $disa_reas; + public $guar_code; + public $match_cnt; + public $game_cnt; + + function __construct($code, $login, $pass, $email, $type, $last_dona, $supp_comp, $tos_vers, $disa_reas, $guar_code, $match_cnt, $game_cnt) { $this->code = $code; @@ -147,16 +147,16 @@ class LoginDBItem { define('MAIL_TYP_CHECK', 1); class MailDBItem { - var $code; - var $ucode; - var $type; - var $tstamp; - var $subj; - var $body_txt; - var $body_htm; - var $hash; + public $code; + public $ucode; + public $type; + public $tstamp; + public $subj; + public $body_txt; + public $body_htm; + public $hash; - function MailDBItem($code, $ucode, $type, $tstamp, $subj, $body_txt, $body_htm, $hash=NULL) + function __construct($code, $ucode, $type, $tstamp, $subj, $body_txt, $body_htm, $hash=NULL) { $this->code = $code; $this->ucode = $ucode; @@ -187,15 +187,18 @@ define('USERSNET_DEF_SKILL', 2); define('USERSNET_DEF_TRUST', 2); class UsersNetItem { - var $owner; - var $target; - var $friend; - var $skill; - var $trust; - - var $from_db; - - function UsersNetItem($owner, $target, $friend, $skill, $trust, + public $owner; + public $target; + public $friend; + public $skill; + public $trust; + + public $from_db; + /* php8: declared, dynamic properties are deprecated since 8.2 */ + public $widefriend; + public $narrowfriend; + + function __construct($owner, $target, $friend, $skill, $trust, $widefriend, $narrowfriend, $from_db) { $this->owner = $owner; diff --git a/web/Obj/dbase_file.phh b/web/Obj/dbase_file.phh index 9461f1e..eaf44a5 100644 --- a/web/Obj/dbase_file.phh +++ b/web/Obj/dbase_file.phh @@ -22,16 +22,19 @@ * */ -require_once("${G_base}Obj/dbase_base.phh"); +require_once("{$G_base}Obj/dbase_base.phh"); -define(BRISK_AUTH_CONF, "brisk_auth.conf.pho"); +/* php8: the constant name was an unquoted bareword. On php5/7 it was + evaluated as an undefined constant, degraded to a string with a warning, + and the define ended up working; on php8 it is a fatal Error. */ +define('BRISK_AUTH_CONF', "brisk_auth.conf.pho"); class BriskDB { - var $item; - var $item_n; + public $item; + public $item_n; - function BriskDB() + function __construct() { log_main("BriskDB create:start"); @@ -147,7 +150,7 @@ class BriskDB { /* if it exists check for a valid challenge */ if (($a_sem = Challenges::lock_data(TRUE)) != FALSE) { - if (($chals = &Challenges::load_data()) != FALSE) { + if (($chals = Challenges::load_data()) != FALSE) { for ($e = 0 ; $e < $chals->item_n ; $e++) { log_main("challenge[".$i."]: ".$chals->item[$e]->login); diff --git a/web/Obj/dbase_pgsql.phh b/web/Obj/dbase_pgsql.phh index 1c9bea4..8856c27 100644 --- a/web/Obj/dbase_pgsql.phh +++ b/web/Obj/dbase_pgsql.phh @@ -22,7 +22,7 @@ * */ -require_once("${G_base}Obj/dbase_base.phh"); +require_once("{$G_base}Obj/dbase_base.phh"); $escsql_from = array( "\\", "'" ); $escsql_to = array( "\\\\", "''" ); @@ -37,9 +37,9 @@ function escsql($s) class DBConn { static $dbcnnx = FALSE; - var $db = FALSE; + public $db = FALSE; - function DBConn() + function __construct() { $this->db = DBConn::$dbcnnx; } @@ -83,11 +83,11 @@ class DBConn class BriskDB { - var $dbconn; - var $item; - var $item_n; + public $dbconn; + public $item; + public $item_n; - function BriskDB($dbconn) + function __construct($dbconn) { $this->dbconn = $dbconn; } @@ -118,7 +118,11 @@ class BriskDB return FALSE; if (($res = @pg_query($this->dbconn->db(), $sql)) == FALSE) { - error_log('pg_result_status: ' . pg_result_status($res)); + /* php8: $res is FALSE here. Since 8.0 results are \PgSql\Result objects + and no longer resources, so pg_result_status(FALSE) is not a + warning any more but a fatal TypeError. The real error can be + read from the connection with pg_last_error() anyway. */ + error_log('pg_query failed: ' . pg_last_error($this->dbconn->db())); error_log('pg_connection_status: ' . pg_connection_status($this->dbconn->db())); // try to recover the connection if (($this->dbconn = DBConn::recover()) == FALSE) @@ -148,7 +152,7 @@ class BriskDB $user_sql = sprintf("SELECT * FROM %susers WHERE login = '%s'", $G_dbpfx, escsql($login)); if (($user_pg = $this->query($user_sql)) != FALSE) - if (pg_numrows($user_pg) == 1) + if (pg_num_rows($user_pg) == 1) return TRUE; return FALSE; @@ -161,7 +165,7 @@ class BriskDB if (($user_pg = $this->query($user_sql)) == FALSE) { return FALSE; } - if (pg_numrows($user_pg) != 1) + if (pg_num_rows($user_pg) != 1) return FALSE; $user_obj = pg_fetch_object($user_pg, 0); @@ -216,7 +220,7 @@ class BriskDB return(FALSE); } - $ret = pg_numrows($sere_pg); + $ret = pg_num_rows($sere_pg); if ($ret === FALSE) { return(FALSE); @@ -260,7 +264,7 @@ class BriskDB if (($mail_pg = $this->query($mail_sql)) == FALSE) { return FALSE; } - if (pg_numrows($mail_pg) != 1) + if (pg_num_rows($mail_pg) != 1) return FALSE; $mail_obj = pg_fetch_object($mail_pg, 0); @@ -281,7 +285,7 @@ class BriskDB fprintf(STDERR, "QUERY [%s]_ FALSE", $user_sql); return (3); } - if (pg_numrows($user_pg) == 1) { + if (pg_num_rows($user_pg) == 1) { return ($i + 1); } } @@ -296,7 +300,7 @@ class BriskDB if (($user_pg = $this->query($user_sql)) == FALSE) { return FALSE; } - if (pg_numrows($user_pg) != 1) + if (pg_num_rows($user_pg) != 1) return FALSE; $user_obj = pg_fetch_object($user_pg, 0); @@ -411,7 +415,7 @@ class BriskDB /* if it exists check for a valid challenge */ if (($a_sem = Challenges::lock_data(TRUE)) != FALSE) { - if (($chals = &Challenges::load_data()) != FALSE) { + if (($chals = Challenges::load_data()) != FALSE) { for ($e = 0 ; $e < $chals->item_n ; $e++) { log_main("challenge[".$e."]: ".$chals->item[$e]->login); if (strcmp($login, $chals->item[$e]->login) == 0) { @@ -531,7 +535,7 @@ class BriskDB log_crit(sprintf("%s::%s: pg_query usr_sql failed [%s]", __CLASS__, __FUNCTION__, $usr_sql)); return (FALSE); } - $usr_n = pg_numrows($usr_pg); + $usr_n = pg_num_rows($usr_pg); if ($usr_n != BIN5_PLAYERS_N) { log_crit(sprintf("%s::%s: wrong number of players [%s] %d", __CLASS__, __FUNCTION__, $usr_sql, $usr_n)); return (FALSE); @@ -565,7 +569,7 @@ class BriskDB } $num_sql = sprintf("SELECT count(*) AS points_n FROM %sbin5_games WHERE mcode = %d;", $G_dbpfx, $match_code); - if (($num_pg = $this->query($num_sql)) == FALSE || pg_numrows($num_pg) != 1) { + if (($num_pg = $this->query($num_sql)) == FALSE || pg_num_rows($num_pg) != 1) { log_crit(sprintf("%s::%s: get games number fails", __CLASS__, __FUNCTION__)); return (FALSE); } @@ -582,7 +586,7 @@ class BriskDB ORDER BY o.pos;", $G_dbpfx, $G_dbpfx, $G_dbpfx, $G_dbpfx, $match_code); if (($tot_pg = pg_query($this->dbconn->db(), $tot_sql)) == FALSE - || pg_numrows($tot_pg) != BIN5_PLAYERS_N) { + || pg_num_rows($tot_pg) != BIN5_PLAYERS_N) { log_crit(sprintf("%s::%s: get games totals fails", __CLASS__, __FUNCTION__)); return(FALSE); } @@ -604,7 +608,7 @@ class BriskDB log_crit(sprintf("%s::%s: get points fails", __CLASS__, __FUNCTION__)); return (FALSE); } - $pts_n = pg_numrows($pts_pg); + $pts_n = pg_num_rows($pts_pg); if ($pts_n > $table->points_n) { // inconsistent scenario number of points great than number of games log_crit(sprintf("%s::%s: number of points great than number of games", __CLASS__, __FUNCTION__)); @@ -622,7 +626,7 @@ class BriskDB } $gam_sql = sprintf("SELECT * FROM %sbin5_games WHERE mcode = %d ORDER BY tstamp DESC LIMIT 1;", $G_dbpfx, $match_code); - if (($gam_pg = $this->query($gam_sql)) == FALSE || pg_numrows($gam_pg) != 1) { + if (($gam_pg = $this->query($gam_sql)) == FALSE || pg_num_rows($gam_pg) != 1) { log_crit(sprintf("%s::%s: get last game fails", __CLASS__, __FUNCTION__)); return (FALSE); } @@ -631,7 +635,7 @@ class BriskDB // update matches with new ttok and table idx $mtc_sql = sprintf("UPDATE %sbin5_matches SET (ttok, tidx) = ('%s', %d) WHERE code = %d RETURNING *;", $G_dbpfx, $sql_ttok, $tidx, $match_code); - if (($mtc_pg = $this->query($mtc_sql)) == FALSE || pg_numrows($mtc_pg) != 1) { + if (($mtc_pg = $this->query($mtc_sql)) == FALSE || pg_num_rows($mtc_pg) != 1) { log_crit(sprintf("%s::%s: update matches table failed", __CLASS__, __FUNCTION__)); return (FALSE); } @@ -642,7 +646,13 @@ class BriskDB $table->rules = new $rules_name($table); unset($old_rules); - $table->old_reason = ${rules_name}::game_description($gam_obj->act, 'html', $gam_obj->mult, + /* php8: this used to be ${rules_name}, a variable variable whose name came + from the undefined constant rules_name. On php5 the constant degraded + to the string "rules_name" with a notice, and the whole thing + resolved to $rules_name by accident; on php8 an undefined constant is + a fatal Error. The variable is now used directly, as on the line + above. */ + $table->old_reason = $rules_name::game_description($gam_obj->act, 'html', $gam_obj->mult, $gam_obj->asta_win, ($gam_obj->asta_win != -1 ? $users[$gam_obj->asta_win]['login'] : ""), $gam_obj->friend, ($gam_obj->friend != -1 ? @@ -660,7 +670,7 @@ class BriskDB $ord_sql = sprintf("SELECT ucode FROM %sbin5_table_orders WHERE mcode = %d ORDER BY pos ASC;", $G_dbpfx, $match_code); - if (($ord_pg = $this->query($ord_sql)) == FALSE || pg_numrows($ord_pg) != $exp_num) { + if (($ord_pg = $this->query($ord_sql)) == FALSE || pg_num_rows($ord_pg) != $exp_num) { log_crit(sprintf("%s: fails for id or users number", __FUNCTION__)); return (FALSE); } @@ -675,7 +685,7 @@ class BriskDB $mtdt_sql = sprintf("SELECT * FROM %sbin5_matches WHERE code = %d;", $G_dbpfx, $match_code); - if (($mtdt_pg = $this->query($mtdt_sql)) == FALSE || pg_numrows($mtdt_pg) != 1) { + if (($mtdt_pg = $this->query($mtdt_sql)) == FALSE || pg_num_rows($mtdt_pg) != 1) { log_crit(sprintf("%s: fails retrieve match_data values [%d]", __FUNCTION__, $match_code)); return (FALSE); } @@ -716,7 +726,7 @@ class BriskDB $codes_where = ""; $mtc_sql = sprintf("UPDATE %sbin5_matches SET (mazzo_next, mult_next) = (%d, %d) WHERE ttok = '%s' RETURNING *;", $G_dbpfx, $table->mazzo, $table->mult, $sql_ttok); - if (($mtc_pg = $this->query($mtc_sql)) == FALSE || pg_numrows($mtc_pg) != 1) { + if (($mtc_pg = $this->query($mtc_sql)) == FALSE || pg_num_rows($mtc_pg) != 1) { // match not exists, insert it // , BIN5_TOURNAMENT_NO_DRAW @@ -843,7 +853,7 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) $mai_sql = sprintf("SELECT * FROM %smails WHERE code = %d AND type = %d AND hash = '%s';", $G_dbpfx, $code, $type, escsql($hash)); - if (($mai_pg = $this->query($mai_sql)) == FALSE || pg_numrows($mai_pg) != 1) { + if (($mai_pg = $this->query($mai_sql)) == FALSE || pg_num_rows($mai_pg) != 1) { // check failed return (FALSE); } @@ -885,7 +895,7 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) return ($widefriend); } - for ($i = 0 ; $i < pg_numrows($wfri_pg) ; $i++) { + for ($i = 0 ; $i < pg_num_rows($wfri_pg) ; $i++) { $wfri_obj = pg_fetch_object($wfri_pg, $i); $widefriend[usersnet_friend_getlabel(intval($wfri_obj->friend))] = $wfri_obj->count; } @@ -905,7 +915,7 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) return ($wideskill); } - if (pg_numrows($wskl_pg) > 0) { + if (pg_num_rows($wskl_pg) > 0) { $wskl_obj = pg_fetch_object($wskl_pg, 0); // TODO: UNCOMMENT IF THE NETWORK WORKS VERY WELL // if ($wskl_obj->count >= 3) @@ -926,7 +936,7 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) return $narrowfriend; } - for ($i = 0 ; $i < pg_numrows($nfri_pg) ; $i++) { + for ($i = 0 ; $i < pg_num_rows($nfri_pg) ; $i++) { $nfri_obj = pg_fetch_object($nfri_pg, $i); $narrowfriend[usersnet_friend_getlabel(intval($nfri_obj->friend))] = $nfri_obj->count; } @@ -945,7 +955,7 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) return ($narrowskill); } - if (pg_numrows($nskl_pg) > 0) { + if (pg_num_rows($nskl_pg) > 0) { $nskl_obj = pg_fetch_object($nskl_pg, 0); // TODO: UNCOMMENT IF THE NETWORK WORKS VERY WELL // if ($nskl_obj->count >= 3) @@ -966,7 +976,7 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) return ($partyskill); } - if (pg_numrows($pskl_pg) > 0) { + if (pg_num_rows($pskl_pg) > 0) { $pskl_obj = pg_fetch_object($pskl_pg, 0); // TODO: UNCOMMENT IF THE NETWORK WORKS VERY WELL // if ($wskl_obj->count >= 3) @@ -985,7 +995,7 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) if (($net_pg = $this->query($net_sql)) == FALSE) return FALSE; - if (pg_numrows($net_pg) != 1) + if (pg_num_rows($net_pg) != 1) return FALSE; $net_obj = pg_fetch_object($net_pg, 0); @@ -1044,7 +1054,7 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) $friend, $json->skill, $json->trust, $G_dbpfx, $owner_id, escsql(strtolower($json->login))); - if (($net_pg = $this->query($net_sql)) == FALSE || pg_numrows($net_pg) == 0) { + if (($net_pg = $this->query($net_sql)) == FALSE || pg_num_rows($net_pg) == 0) { $net_sql = sprintf(" INSERT INTO %susersnet SELECT %d AS owner, us.code as target, %d as friend, %d as skill, %d as trust @@ -1057,14 +1067,14 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) $ret = 2; break; } - if (pg_numrows($net_pg) != 1) { - log_wr(sprintf('insert numrow failed [%s] [%d]', $net_sql, pg_numrows($net_pg))); + if (pg_num_rows($net_pg) != 1) { + log_wr(sprintf('insert numrow failed [%s] [%d]', $net_sql, pg_num_rows($net_pg))); $ret = 3; break; } } else { - if (pg_numrows($net_pg) != 1) { + if (pg_num_rows($net_pg) != 1) { log_wr('update numrow failed'); $ret = 4; break; @@ -1084,10 +1094,10 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) class LoginDBOld { - var $item; - var $item_n; + public $item; + public $item_n; - function LoginDBOld($filename) + function __construct($filename) { GLOBAL $DOCUMENT_ROOT; log_main("LoginDBOld create:start"); diff --git a/web/Obj/hardban.phh b/web/Obj/hardban.phh index c59deb3..8b1c0ff 100644 --- a/web/Obj/hardban.phh +++ b/web/Obj/hardban.phh @@ -29,12 +29,12 @@ define('HBAN_VALID_TIME', 15); define('HBAN_GARBAGE_TIMEOUT', 5); class Hardban { - var $login; - var $ip; - var $session; - var $timeout; + public $login; + public $ip; + public $session; + public $timeout; - function Hardban($login, $ip, $session, $timeout) + function __construct($login, $ip, $session, $timeout) { $this->login = $login; $this->ip = $ip; @@ -46,15 +46,15 @@ class Hardban { class Hardbans { static $delta_t; - var $item; - var $item_n; - var $mod; - var $shm_sz; + public $item; + public $item_n; + public $mod; + public $shm_sz; - var $garbage_timeout; + public $garbage_timeout; - function Hardbans() + function __construct() { $this->item = array(); $this->item_n = 0; @@ -147,14 +147,14 @@ class Hardbans { // Static functions static function create() { - $chal =& new Hardbans(); + $chal = new Hardbans(); $chal->mod = TRUE; return $chal; } - function load_data() + static function load_data() { GLOBAL $sess; @@ -201,7 +201,7 @@ class Hardbans { } - function save_data($hban) + static function save_data($hban) { $shm = FALSE; $oldmod = $hban->mod; @@ -260,13 +260,13 @@ class Hardbans { } - function check($login, $ip, $session) + static function check($login, $ip, $session) { $bantime = -1; /* if it exists check for a valid challenge */ if (($a_sem = Hardbans::lock_data(TRUE)) != FALSE) { - if (($hban = &Hardbans::load_data()) != FALSE) { + if (($hban = Hardbans::load_data()) != FALSE) { for ($e = 0 ; $e < $hban->item_n ; $e++) { if ($login != FALSE) { if (strcasecmp($login, $hban->item[$e]->login) == 0 || $hban->item[$e]->session == $session) { @@ -294,13 +294,13 @@ class Hardbans { - function add($login, $ip, $session, $timeout) + static function add($login, $ip, $session, $timeout) { $found = FALSE; /* if it exists check for a valid challenge */ if (($a_sem = Hardbans::lock_data(TRUE)) != FALSE) { - if (($hban = &Hardbans::load_data()) != FALSE) { + if (($hban = Hardbans::load_data()) != FALSE) { $hban->add_item($login, $ip, $session, $timeout); diff --git a/web/Obj/ipclass.phh b/web/Obj/ipclass.phh index 3a3d588..9939910 100644 --- a/web/Obj/ipclass.phh +++ b/web/Obj/ipclass.phh @@ -23,13 +23,13 @@ */ class IPClassItem { - var $addr; - var $mask; + public $addr; + public $mask; - function IPClassItem($ipset) + function __construct($ipset) { //split - $elem = split("/", $ipset, 2); + $elem = explode("/", $ipset, 2); $addr = $elem[0]; if (!isset($elem[1])) { fprintf(STDERR, "ORIG: %s\n", $ipset); @@ -60,9 +60,9 @@ class IPClassItem { } class IPClass { - var $ipcl; + public $ipcl; - function IPClass() + function __construct() { $this->ipcl = NULL; } diff --git a/web/Obj/provider_proxy.phh b/web/Obj/provider_proxy.phh index 57d9852..993ba3d 100644 --- a/web/Obj/provider_proxy.phh +++ b/web/Obj/provider_proxy.phh @@ -22,15 +22,15 @@ * */ -require_once("${G_base}Obj/ipclass.phh"); +require_once("{$G_base}Obj/ipclass.phh"); class ProviderProxyItem { - var $name; - var $headitem; - var $ipclass; + public $name; + public $headitem; + public $ipclass; - function ProviderProxyItem($pp_name, $pp_descr) + function __construct($pp_name, $pp_descr) { $this->name = $pp_name; $this->headitem = $pp_descr['headitem']; @@ -41,9 +41,9 @@ class ProviderProxyItem class ProviderProxy { - var $pp; + public $pp; - function ProviderProxy() + function __construct() { $this->pp = NULL; } diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index 1f9a70c..801279a 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -319,10 +319,10 @@ function get_encoding($header) } class Cookie { - var $attr; + public $attr; // Set-Cookie: reg_fb_gate=deleted; Expires=Thu, 01-Jan-1970 00:00:01 GMT; Path=/; Domain=.foo.com; HttpOnly // string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] ) - function Cookie() + function __construct() { $this->attr = array(); } @@ -388,9 +388,9 @@ class Cookie { } class Cookies { - var $cookies; + public $cookies; - function Cookies() + function __construct() { $this->cookies = array(); } @@ -423,33 +423,33 @@ class Sac_a_push { static $cnt_master = NULL; static $cnt_slave = NULL; - var $provider_proxy; // list of provider/browser that offer proxy service + public $provider_proxy; // list of provider/browser that offer proxy service - var $file_socket_pfx; - var $unix_socket_pfx; - var $direct_socket; // socket where read direct commands - var $socks; - var $s2u; // user associated with input socket - var $s2p; // pending page associated with input socket - var $s2c; // ws sockets in closing phase - var $pending_pages; - var $is_daemon; + public $file_socket_pfx; + public $unix_socket_pfx; + public $direct_socket; // socket where read direct commands + public $socks; + public $s2u; // user associated with input socket + public $s2p; // pending page associated with input socket + public $s2c; // ws sockets in closing phase + public $pending_pages; + public $is_daemon; - var $list_web; - var $list_cmd; - var $in; + public $list_web; + public $list_cmd; + public $in; - var $debug; - var $blocking_mode; + public $debug; + public $blocking_mode; - var $app; + public $app; - var $curtime; + public $curtime; - var $rndstr; - var $main_loop; + public $rndstr; + public $main_loop; - function Sac_a_push() + function __construct() { } @@ -487,7 +487,7 @@ class Sac_a_push { $thiz->file_socket_pfx = $sockname_pfx; $thiz->unix_socket_pfx = "unix://$sockname_pfx"; - $thiz->direct_socket = "unix://${sockname_pfx}_admin.sock"; + $thiz->direct_socket = "unix://{$sockname_pfx}_admin.sock"; $thiz->debug = $debug; $thiz->list_web = array(); $thiz->socks = array(); diff --git a/web/Obj/singlemsg.phh b/web/Obj/singlemsg.phh index 11c981a..5ca935f 100644 --- a/web/Obj/singlemsg.phh +++ b/web/Obj/singlemsg.phh @@ -27,7 +27,7 @@ $G_base = ""; require_once("Obj/brisk.phh"); require_once("Obj/user.phh"); require_once("Obj/auth.phh"); -require_once("Obj/dbase_${G_dbasetype}.phh"); +require_once("Obj/dbase_{$G_dbasetype}.phh"); $mlang_singlemsg = array( 'headline' => array('it' => 'briscola chiamata in salsa ajax', diff --git a/web/Obj/transports.phh b/web/Obj/transports.phh index ea592a8..3e028d6 100644 --- a/web/Obj/transports.phh +++ b/web/Obj/transports.phh @@ -61,7 +61,7 @@ class Transport_template { - function Transport_template() { + function __construct() { } // return string value is appended to the content of the returned page @@ -98,7 +98,12 @@ class Transport_template { define("TRANSP_WS_CLOSE_TOUT", 5); class Transport_websocket_postclose { - function Transport_websocket_postclose($transp_ws, $sock, $curtime) { + /* php8: declared, dynamic properties are deprecated since 8.2 */ + public $transp_ws; + public $sock; + public $start; + + function __construct($transp_ws, $sock, $curtime) { printf("POSTCLOSE: Creation\n"); $this->transp_ws = $transp_ws; $this->sock = $sock; @@ -130,7 +135,21 @@ class Transport_websocket_postclose { class Transport_websocket { protected $magicGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; - function Transport_websocket($secure = FALSE) { + /* php8: declared, dynamic properties are deprecated since 8.2. + $partialBuffer and $requestedResource are assigned later on + (in dataframe and handshake respectively), not in the constructor. */ + public $type; + public $headerOriginRequired; + public $headerSecWebSocketProtocolRequired; + public $headerSecWebSocketExtensionsRequired; + public $sendingContinuous; + public $handlingPartialPacket; + public $partialMessage; + public $hasSentClose; + public $partialBuffer; + public $requestedResource; + + function __construct($secure = FALSE) { $this->type = ($secure == FALSE ? "websocket" : "websocketsec"); $this->headerOriginRequired = false; $this->headerSecWebSocketProtocolRequired = false; @@ -532,8 +551,10 @@ class Transport_websocket { } class Transport_xhr { + /* php8: declared, dynamic properties are deprecated since 8.2 */ + public $type; - function Transport_xhr() { + function __construct() { $this->type = 'xhr'; } @@ -578,8 +599,11 @@ class Transport_xhr { } class Transport_iframe { + /* php8: declared, dynamic properties are deprecated since 8.2. + Transport_htmlfile inherits it too, and sets it to 'htmlfile'. */ + public $type; - function Transport_iframe() { + function __construct() { $this->type = 'iframe'; } @@ -663,7 +687,7 @@ push(\"%s\");\n// -->\n", $step, escpush($cont) ); } class Transport_htmlfile extends Transport_iframe { - function Transport_htmlfile() { + function __construct() { $this->type = 'htmlfile'; } @@ -674,7 +698,7 @@ class Transport_htmlfile extends Transport_iframe { } class Transport { - function Transport() + function __construct() { } diff --git a/web/Obj/user.phh b/web/Obj/user.phh index 32bb71e..c98de14 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -21,7 +21,7 @@ * Suite 330, Boston, MA 02111-1307, USA. */ -require_once("${G_base}Obj/transports.phh"); +require_once("{$G_base}Obj/transports.phh"); // User flags @@ -106,40 +106,44 @@ $mlang_user = array( ); class User { - var $brisk; // reference to the room where the user is registered - var $idx; // index in the room users array when you are in game - var $idx_orig; // index in the room table users array when you aren't in game - var $code; // authentication code - var $name; // name of the user - var $sess; // session of the user - var $ip; // ip of the user - var $lacc; // last access (for the cleanup) - var $laccwr; // last access (for the cleanup) - var $bantime; // timeout to temporary ban - var $stat; // status (outdoor, room, table, game, ...) - var $subst; // substatus for each status - var $step; // step of the current status - var $trans_step; // step to enable transition between pages (disable == -1) - var $cl_step; // current step returned by client - var $ping_req; // ping is already requested ? - - var $pend_async; // number of async check that must be returned - - var $rd_socket; // socket handle of push stream - var $rd_endtime; // end time for push stream - var $rd_stat; // actual status of push stream - var $rd_subst; // actual substatus of push stream - var $rd_step; // actual step of push stream - var $rd_from; // referer - var $rd_scristp; // current script step (for each session) - var $rd_kalive; // if no message are sent after RD_KEEPALIVE_TOUT secs we send a keepalive from server - var $rd_cache; // place where store failed fwrite data - var $rd_toflush; // bool to inform about unfflushed socket - var $rd_zls; // zlibstream object handle if compressed stream, else FALSE - var $rd_transp; // class that define stream encapsulation type (iframe, xhr, ...) - var $rd_is_chunked; // is the transport chunked or not ? - - var $comm; // commands array + /* php8: the declaration said "$brisk" but the code always writes and reads + "$room" (create(), briskin5, and so on), so $room was a dynamic property, + deprecated since 8.2. Renamed: nobody reads $user->brisk, every "->brisk" + in the project is on a Bin5 object. */ + public $room; // reference to the room where the user is registered + public $idx; // index in the room users array when you are in game + public $idx_orig; // index in the room table users array when you aren't in game + public $code; // authentication code + public $name; // name of the user + public $sess; // session of the user + public $ip; // ip of the user + public $lacc; // last access (for the cleanup) + public $laccwr; // last access (for the cleanup) + public $bantime; // timeout to temporary ban + public $stat; // status (outdoor, room, table, game, ...) + public $subst; // substatus for each status + public $step; // step of the current status + public $trans_step; // step to enable transition between pages (disable == -1) + public $cl_step; // current step returned by client + public $ping_req; // ping is already requested ? + + public $pend_async; // number of async check that must be returned + + public $rd_socket; // socket handle of push stream + public $rd_endtime; // end time for push stream + public $rd_stat; // actual status of push stream + public $rd_subst; // actual substatus of push stream + public $rd_step; // actual step of push stream + public $rd_from; // referer + public $rd_scristp; // current script step (for each session) + public $rd_kalive; // if no message are sent after RD_KEEPALIVE_TOUT secs we send a keepalive from server + public $rd_cache; // place where store failed fwrite data + public $rd_toflush; // bool to inform about unfflushed socket + public $rd_zls; // zlibstream object handle if compressed stream, else FALSE + public $rd_transp; // class that define stream encapsulation type (iframe, xhr, ...) + public $rd_is_chunked; // is the transport chunked or not ? + + public $comm; // commands array // var $asta_card; // // var $asta_pnt; // // var $handpt; // Total card points at the beginning of the current hand. @@ -147,24 +151,33 @@ class User { // FIXME: the table_orig field must be removed after table field verify of index management (in spawned table // it is allways ZERO - var $table; // id of the current table when you are in game - var $table_orig; // id of the current table when you aren't in game - var $table_pos; // idx on the table - var $table_token;// token that identify a game on a table - var $flags; // Bitfield with: AUTHENTICATE: 0x02 - var $rec; // field with user db record or FALSE - var $the_end; // Flag to change the end of the session - - var $chat_lst; // Last chat line - var $chattime; // Array of chat times - var $chat_cur; // Current chat line number - var $chat_ban; // Time for ban chat - var $chat_dlt; // Delta t for ban - var $shm_sz; + public $table; // id of the current table when you are in game + public $table_orig; // id of the current table when you aren't in game + public $table_pos; // idx on the table + public $table_token;// token that identify a game on a table + public $flags; // Bitfield with: AUTHENTICATE: 0x02 + public $rec; // field with user db record or FALSE + public $the_end; // Flag to change the end of the session + + public $chat_lst; // Last chat line + public $chattime; // Array of chat times + public $chat_cur; // Current chat line number + public $chat_ban; // Time for ban chat + public $chat_dlt; // Delta t for ban + public $shm_sz; + + /* php8: declared, dynamic properties are deprecated since 8.2. + asta_card, asta_pnt, handpt and exitislock belong to Bin5_user (which + redeclares them) but are already set here by User::create(). */ + public $td_toflush; + public $asta_card; + public $asta_pnt; + public $handpt; + public $exitislock; const BASE = ""; // basepath for absolute web references - function User() { + function __construct() { } static function create(&$brisk, $idx, $name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") { @@ -692,7 +705,7 @@ class User { $type = "soft"; $preface = sprintf("
%s
", sprintf($mlang_user['toc_date_dscl'][$G_lang], - strftime("%e/%m/%Y", $G_tos_dthard))); + date("j/m/Y", $G_tos_dthard))); } else { // call notify hard diff --git a/web/Obj/zlibstream.phh b/web/Obj/zlibstream.phh index 91ac711..9468370 100644 --- a/web/Obj/zlibstream.phh +++ b/web/Obj/zlibstream.phh @@ -1,11 +1,11 @@ type = $type; $this->s = array( FALSE, FALSE ); diff --git a/web/admin.php b/web/admin.php index c3428e6..c9f3a41 100644 --- a/web/admin.php +++ b/web/admin.php @@ -31,20 +31,22 @@ ini_set("max_execution_time", "300"); class ImpPoints { - var $time; - var $tsess; - var $user_sess; - var $isauth; - var $username; - var $useraddr; - var $where; - var $ttok; - var $tidx; - var $nplayers; - var $logins; - var $pts; - - function ImpPoints($s) + public $time; + public $tsess; + public $user_sess; + public $isauth; + public $username; + public $useraddr; + public $where; + public $ttok; + public $tidx; + public $nplayers; + public $logins; + public $pts; + /* php8: declared, dynamic properties are deprecated since 8.2 */ + public $usess; + + function __construct($s) { $arr = explode('|', $s); @@ -151,7 +153,7 @@ function main() * matches management */ $mtc_sql = sprintf("SELECT * FROM %sbin5_matches WHERE ttok = '%s';", $G_dbpfx, escsql($pts->ttok)); - if (($mtc_pg = pg_query($dbconn->db(), $mtc_sql)) == FALSE || pg_numrows($mtc_pg) != 1) { + if (($mtc_pg = pg_query($dbconn->db(), $mtc_sql)) == FALSE || pg_num_rows($mtc_pg) != 1) { // match not exists, insert it $mtc_sql = sprintf("INSERT INTO %sbin5_matches (ttok, tidx) VALUES ('%s', %d) RETURNING *;", $G_dbpfx, escsql($pts->ttok), $pts->tidx); @@ -172,7 +174,7 @@ function main() */ $gam_sql = sprintf("SELECT * FROM %sbin5_games WHERE mcode = %d and tstamp = to_timestamp(%d);", $G_dbpfx, $mtc_obj->code, $pts->time); - if (($gam_pg = pg_query($dbconn->db(), $gam_sql)) == FALSE || pg_numrows($gam_pg) != 1) { + if (($gam_pg = pg_query($dbconn->db(), $gam_sql)) == FALSE || pg_num_rows($gam_pg) != 1) { // match not exists, insert it $gam_sql = sprintf("INSERT INTO %sbin5_games (mcode, tstamp) VALUES (%d, to_timestamp(%d)) RETURNING *;", @@ -195,7 +197,7 @@ function main() /* get the login associated code */ $usr_sql = sprintf("SELECT * FROM %susers WHERE login = '%s';", $G_dbpfx, escsql($pts->logins[$i])); - if (($usr_pg = pg_query($dbconn->db(), $usr_sql)) == FALSE || pg_numrows($usr_pg) != 1) { + if (($usr_pg = pg_query($dbconn->db(), $usr_sql)) == FALSE || pg_num_rows($usr_pg) != 1) { $cont .= sprintf("User [%s] not found [%s]
\n", eschtml($pts->logins[$i]), eschtml($usr_sql)); save_rej($pts->logins[$i]); continue; diff --git a/web/briskin5/.htaccess b/web/briskin5/.htaccess index 0eb7591..b016cec 100644 --- a/web/briskin5/.htaccess +++ b/web/briskin5/.htaccess @@ -4,10 +4,16 @@ header append Cache-Control "public, last-modified, must-revalidate" header append Pragma "no-cache" header append Expires "-1" -php_value mbstring.http_input "auto" -php_value mbstring.internal_encoding "UTF-8" +# php 8.4: mbstring.func_overload was REMOVED (it used to be 7 = +# mail+string+regex). strlen/substr/strpos are back to byte semantics: the +# places that need character semantics now call mb_* explicitly in the source. +# mbstring.internal_encoding/http_input are deprecated: default_charset is used +# instead. php_value/php_flag only work with mod_php; with PHP-FPM Apache +# answers 500, hence the block is conditional. + +php_value default_charset "UTF-8" php_flag mbstring.encoding_translation On -php_value mbstring.func_overload "7" + ExpiresActive On ExpiresByType image/jpg "access plus 4 days" diff --git a/web/briskin5/Obj/.htaccess b/web/briskin5/Obj/.htaccess index 481dad6..04a77ee 100644 --- a/web/briskin5/Obj/.htaccess +++ b/web/briskin5/Obj/.htaccess @@ -1,3 +1,10 @@ -Order Deny,Allow -Deny from All - +# apache 2.4 (debian 13). The old 2.2 syntax "Order Deny,Allow / Deny from All" +# needs mod_access_compat, which is not guaranteed: the native one is used here, +# with a fallback. + + Require all denied + + + Order Deny,Allow + Deny from All + diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 7ce17b0..c8bbd6f 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -131,14 +131,15 @@ function dom_select_deck($cur_sel) } class Card { - var $value; /* 0 - 39 card value */ - var $stat; /* 'bunch', 'hand', 'table', 'take' */ - var $owner; /* (table position 0-4) */ - // var $pos; /* Pos in hand. */ - var $x; /* When played the X position on the table of the owner. */ - var $y; /* When played the Y position on the table of the owner. */ - - function Card($value, $stat, $owner) + public $value; /* 0 - 39 card value */ + public $stat; /* 'bunch', 'hand', 'table', 'take' */ + public $owner; /* (table position 0-4) */ + public $pos; /* Pos in hand. */ // php8: riattivata, setpos() la scrive + // and dynamic properties are deprecated since 8.2 + public $x; /* When played the X position on the table of the owner. */ + public $y; /* When played the Y position on the table of the owner. */ + + function __construct($value, $stat, $owner) { $this->value = $value; $this->stat = $stat; // Card stat @@ -171,41 +172,41 @@ class Card { } // end class Card class Bin5_table extends Table { - var $card; // il mazzo di carte - var $mazzo; // chi e' di mazzo - var $gstart; // first player of the current game - var $turn; // turn in the game (absolute, not modularized) - - var $asta_pla; // array(); TRUE: in auction, FALSE: out of the auction - var $asta_pla_n; // number of players in auction - var $asta_card; // current card for auction - var $asta_pnt; // current point for auction - - var $mult; - var $points; // points array - var $points_n; // number of row of points - var $total; - - var $asta_win; // the caller idx position at table - var $briscola; - var $tourn_pts; // points in the caller hand - var $friend; // the callee idx position at table - - var $match_id; // the id of the match on the database (-1 == just not saved) - - var $old_act; // last action that trigs the end of the game - var $old_mazzo; - var $old_reason; - var $old_asta_pnt; - var $old_mult; - var $old_pnt; // points made by caller and callee - var $old_asta_win; // the old caller idx position at table - var $old_friend; // the old callee idx position at table - - var $old_tourn_pts; // the old tournment computed points in the hand of caller - var $rules; - - function Bin5_table() + public $card; // il mazzo di carte + public $mazzo; // chi e' di mazzo + public $gstart; // first player of the current game + public $turn; // turn in the game (absolute, not modularized) + + public $asta_pla; // array(); TRUE: in auction, FALSE: out of the auction + public $asta_pla_n; // number of players in auction + public $asta_card; // current card for auction + public $asta_pnt; // current point for auction + + public $mult; + public $points; // points array + public $points_n; // number of row of points + public $total; + + public $asta_win; // the caller idx position at table + public $briscola; + public $tourn_pts; // points in the caller hand + public $friend; // the callee idx position at table + + public $match_id; // the id of the match on the database (-1 == just not saved) + + public $old_act; // last action that trigs the end of the game + public $old_mazzo; + public $old_reason; + public $old_asta_pnt; + public $old_mult; + public $old_pnt; // points made by caller and callee + public $old_asta_win; // the old caller idx position at table + public $old_friend; // the old callee idx position at table + + public $old_tourn_pts; // the old tournment computed points in the hand of caller + public $rules; + + function __construct() { } @@ -213,7 +214,7 @@ class Bin5_table extends Table { /* CREATE() NOT USED function create($idx) { - if (($thiz =& new Bin5_table()) == FALSE) + if (($thiz = new Bin5_table()) == FALSE) return (FALSE); $thiz->create($idx); @@ -252,7 +253,7 @@ class Bin5_table extends Table { /* CLONE() NOT USED function myclone(&$from) { - if (($thiz =& new Bin5_table()) == FALSE) + if (($thiz = new Bin5_table()) == FALSE) return (FALSE); parent::copy($from); @@ -297,10 +298,14 @@ class Bin5_table extends Table { parent::copy($from); } - function spawn(&$from) + /* php8: the "&" was dropped because Table::spawn() takes $from by value and + an override cannot change by-reference passing (fatal). Here $from is + only read, and objects have been handles since php5, so the reference + was a php4 leftover with no effect. */ + static function spawn($from) { GLOBAL $G_lang; - if (($thiz =& new Bin5_table()) == FALSE) + if (($thiz = new Bin5_table()) == FALSE) return (FALSE); $thiz->parentcopy($from); @@ -339,7 +344,7 @@ class Bin5_table extends Table { // // for ($i = 0 ; $i < (BIN5_CARD_HAND * BIN5_PLAYERS_N) ; $i++) { // // for ($i = 0 ; $i < (BIN5_CARD_HAND * BIN5_PLAYERS_N) ; $i++) { - // $ret[$i] =& new Card($i, 'bunch', 'no_owner'); + // $ret[$i] = new Card($i, 'bunch', 'no_owner'); // } // // $oret = &$ret; @@ -770,25 +775,25 @@ define('BIN5_USER_CONTINUE_INIT', -1); define('BIN5_USER_RULES_INIT', -1); class Bin5_user extends User { - var $asta_card; // - var $asta_pnt; // - var $handpt; // Total card points at the beginning of the current hand. - var $exitislock; // Player can exit from the table ? - var $privflags; // Flags for briskin5 only + public $asta_card; // + public $asta_pnt; // + public $handpt; // Total card points at the beginning of the current hand. + public $exitislock; // Player can exit from the table ? + public $privflags; // Flags for briskin5 only - var $continue; // Id of the match that the user would continue - var $rules; // Id of rules required by user + public $continue; // Id of the match that the user would continue + public $rules; // Id of rules required by user - var $asta_tourn_pts; // array with tournment points for each suit + public $asta_tourn_pts; // array with tournment points for each suit const BASE = "../"; - function User() { + function __construct() { } /* CREATE NOT USED function create($name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") { - if (($thiz =& new User()) == FALSE) + if (($thiz = new User()) == FALSE) return (FALSE); $thiz->asta_card = -2; @@ -808,7 +813,8 @@ class Bin5_user extends User { parent::copy($from); } - function copy(&$from) + /* php8: "&" dropped, User::copy() takes $from by value (see spawn above). */ + function copy($from) { $this->parentcopy($from); @@ -824,7 +830,7 @@ class Bin5_user extends User { /* CLONE NOT USED function myclone(&$from) { - if (($thiz =& new User()) == FALSE) + if (($thiz = new User()) == FALSE) return (FALSE); $thiz->copy($from); @@ -833,7 +839,13 @@ class Bin5_user extends User { } */ - static function spawn($from, &$bri, $table, $table_pos, $get, $post, $cookie) + /* php8: signature reordered. User::spawn($from, $table, $table_pos) is the + parent, and an override may neither add mandatory parameters nor change + by-reference passing: it was a fatal. The three parent parameters now + come first and in the same order, the extra ones last with a default. + In practice they are all mandatory: the only caller + (Bin5::__construct) always passes them all. */ + static function spawn($from, $table, $table_pos, $bri = NULL, $get = NULL, $post = NULL, $cookie = NULL) { if (($thiz = new Bin5_user()) == FALSE) return (FALSE); @@ -884,7 +896,11 @@ class Bin5_user extends User { return (TRUE); } - static function load_step($tab_id, $sess) + /* php8: $sess moved first, as in User::load_step($sess); an override cannot + add mandatory parameters. $tab_id stays necessary in practice (it goes + into the path of the state file). + NOTE: this method has no callers, neither here nor in the base class. */ + static function load_step($sess, $tab_id = -1) { $fp = FALSE; do { @@ -934,7 +950,9 @@ class Bin5_user extends User { return (FALSE); } - static function unproxy_step($tab_id, $sess) + /* php8: $sess first, as in User::unproxy_step($sess), $tab_id last with a + default. In practice $tab_id is mandatory: the only caller passes it. */ + static function unproxy_step($sess, $tab_id = -1) { log_rd2("UNPROXY: ".BIN5_PROXY_PATH."/table".$tab_id."/".$sess.".step"); if (file_exists(BIN5_PROXY_PATH."/table".$tab_id) == FALSE) @@ -979,7 +997,11 @@ class Bin5_user extends User { return (sprintf(($is_unrecoverable ? 'xstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");')); } - protected function page_sync($sess, $page) + /* php8: signature aligned with User::page_sync(): an override must accept at + least every parameter of the parent. $table_idx and $table_token are not + needed by this version, but the callers already pass both of them + (user.phh:742,756 and briskin5.phh:1078). */ + protected function page_sync($sess, $page, $table_idx = -1, $table_token = "") { log_rd2("PAGE_SYNC"); // printf("xXx BIN5_USER::PAGE_SYNC\n"); @@ -1115,24 +1137,24 @@ class Bin5_user extends User { class Bin5 { static $delta_t = array(); - var $brisk;// room object reference + public $brisk;// room object reference - var $user; - var $table; - var $comm; // commands for many people - var $step; // current step of the comm array - var $garbage_timeout; - var $shm_sz; + public $user; + public $table; + public $comm; // commands for many people + public $step; // current step of the comm array + public $garbage_timeout; + public $shm_sz; - var $table_idx; - var $table_token; + public $table_idx; + public $table_token; - var $the_end; - var $tok; + public $the_end; + public $tok; - var $delay_mgr; + public $delay_mgr; - function Bin5($brisk, $table_idx, $table_token, $get, $post, $cookie) { + function __construct($brisk, $table_idx, $table_token, $get, $post, $cookie) { $this->user = array(); $this->table = array(); @@ -1150,7 +1172,10 @@ class Bin5 { for ($i = 0 ; $i < $table->player_n ; $i++) { $user[$table->player[$i]]->table_token = $table_token; - $this->user[$i] = Bin5_user::spawn($user[$table->player[$i]], $this, $table_idx, $i, $get, $post, $cookie); + /* php8: argument order adjusted to the new Bin5_user::spawn() signature: + $from, $table, $table_pos first as in the parent, then $bri and + the rest. */ + $this->user[$i] = Bin5_user::spawn($user[$table->player[$i]], $table_idx, $i, $this, $get, $post, $cookie); } $this->table[0] = Bin5_table::spawn($table); @@ -1247,7 +1272,7 @@ class Bin5 { /* se gli altri utenti non erano d'accordo questo utente viene bannato */ $remcalc = $this->table[0]->exitlock_calc($this->user, $user_cur->table_pos); if ($remcalc < 3) { - require_once("${G_base}Obj/hardban.phh"); + require_once("{$G_base}Obj/hardban.phh"); Hardbans::add(($user_cur->is_auth() ? $user_cur->name : FALSE), $user_cur->ip, $user_cur->sess, $user_cur->laccwr + BAN_TIME); } @@ -1281,7 +1306,8 @@ class Bin5 { log_main("DESTROY2 BRISKIN5 DATA [".$this->table_idx."]"); for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) { $this->user[$i]->destroy_data($this->table_idx); - Bin5_user::unproxy_step($this->table_idx, $this->user[$i]->sess); + /* php8: argomenti invertiti, vedi la nuova firma di unproxy_step(). */ + Bin5_user::unproxy_step($this->user[$i]->sess, $this->table_idx); } if (($tok = @ftok(FTOK_PATH."/bin5/table".$this->table_idx."/table", "B")) == -1) break; @@ -1570,7 +1596,7 @@ function locshm_exists($tok) return (FALSE); } else { - shmop_close($id); + unset($id); // php8: shmop_close() deprecata, il segmento si libera col refcount log_main($tok." SHM exists"); return (TRUE); diff --git a/web/briskin5/Obj/placing.phh b/web/briskin5/Obj/placing.phh index ad69d50..294efd0 100644 --- a/web/briskin5/Obj/placing.phh +++ b/web/briskin5/Obj/placing.phh @@ -47,11 +47,11 @@ define('WEE_MAX_GAMES', 35); class Ptsgam { - var $username; - var $pts; - var $gam; + public $username; + public $pts; + public $gam; - function Ptsgam($username = "", $pts = 0, $gam = 0) + function __construct($username = "", $pts = 0, $gam = 0) { $this->username = $username; $this->pts = $pts; @@ -160,7 +160,7 @@ function placing_time_pgsql() $mti_sql = sprintf("SELECT CAST(EXTRACT(EPOCH FROM mtime) AS INTEGER) as mtime FROM %sbin5_places_mtime WHERE code = 0;", $G_dbpfx); - if (($mti_pg = pg_query($bdb->dbconn->db(), $mti_sql)) == FALSE || pg_numrows($mti_pg) == 0) { + if (($mti_pg = pg_query($bdb->dbconn->db(), $mti_sql)) == FALSE || pg_num_rows($mti_pg) == 0) { // no point found, abort log_crit("placing: get placing mtime failed [$mti_sql]"); return (FALSE); @@ -175,7 +175,7 @@ function placing_time() { GLOBAL $G_dbasetype; - $fun_name = "placing_time_${G_dbasetype}"; + $fun_name = "placing_time_{$G_dbasetype}"; return ($fun_name()); } @@ -278,7 +278,7 @@ function placing_show_pgsql($user, $ty, $subty) $G_dbpfx, ($ty * 2) + $subty, TOP_NUM); } - if (($pla_pg = pg_query($bdb->dbconn->db(), $pla_sql)) == FALSE || pg_numrows($pla_pg) == 0) { + if (($pla_pg = pg_query($bdb->dbconn->db(), $pla_sql)) == FALSE || pg_num_rows($pla_pg) == 0) { // no point found, abort log_crit("placing: get placing list failed [$pla_sql]"); return (""); @@ -287,7 +287,7 @@ function placing_show_pgsql($user, $ty, $subty) // MLANG $ret = sprintf(""); - for ($i = 0 ; $i < pg_numrows($pla_pg) ; $i++) { + for ($i = 0 ; $i < pg_num_rows($pla_pg) ; $i++) { $pla_obj = pg_fetch_object($pla_pg,$i); $ein = ""; @@ -317,7 +317,7 @@ function placing_show($user, $ty, $subty) { GLOBAL $G_dbasetype; - $fun_name = "placing_show_${G_dbasetype}"; + $fun_name = "placing_show_{$G_dbasetype}"; return ($fun_name($user, $ty, $subty)); } diff --git a/web/briskin5/Obj/rules_base.phh b/web/briskin5/Obj/rules_base.phh index 6f93892..026baa8 100644 --- a/web/briskin5/Obj/rules_base.phh +++ b/web/briskin5/Obj/rules_base.phh @@ -72,8 +72,8 @@ $mlang_bin5_rules = array( ); abstract class Rules { - var $table; - var $id; + public $table; + public $id; abstract function engine(&$bri, $curtime, $action, $user); diff --git a/web/briskin5/explain.php b/web/briskin5/explain.php index 1c15dd2..80c04e7 100644 --- a/web/briskin5/explain.php +++ b/web/briskin5/explain.php @@ -41,7 +41,7 @@ ini_set("max_execution_time", "240"); require_once("../Obj/brisk.phh"); require_once("../Obj/user.phh"); require_once("../Obj/auth.phh"); -require_once("../Obj/dbase_${G_dbasetype}.phh"); +require_once("../Obj/dbase_{$G_dbasetype}.phh"); require_once("Obj/briskin5.phh"); require_once("Obj/placing.phh"); diff --git a/web/briskin5/stat-day.php b/web/briskin5/stat-day.php index 7bc80e4..65e4677 100644 --- a/web/briskin5/stat-day.php +++ b/web/briskin5/stat-day.php @@ -70,7 +70,7 @@ ini_set("max_execution_time", "240"); require_once("../Obj/brisk.phh"); require_once("../Obj/user.phh"); require_once("../Obj/auth.phh"); -require_once("../Obj/dbase_${G_dbasetype}.phh"); +require_once("../Obj/dbase_{$G_dbasetype}.phh"); require_once("Obj/briskin5.phh"); require_once("Obj/placing.phh"); @@ -107,7 +107,7 @@ function main_pgsql($from, $to) break; } - $trn_n = pg_numrows($trn_pg); + $trn_n = pg_num_rows($trn_pg); printf("Number of tournaments: %d\n", $trn_n); // loop on tournaments @@ -133,7 +133,7 @@ SELECT m.code AS code, m.ttype AS ttype, m.mazzo_next AS minus_one_is_old // // store matches before clean them // - $tmt_n = pg_numrows($tmt_pg); + $tmt_n = pg_num_rows($tmt_pg); // get matches if ($tmt_n == 0) continue; @@ -188,11 +188,11 @@ SELECT p.pts AS pts break; } if ($u == 0) { - $num_games = pg_numrows($pts_pg[$u]); + $num_games = pg_num_rows($pts_pg[$u]); } else { - if ($num_games != pg_numrows($pts_pg[$u])) { - log_crit("stat-day: num_games != pg_numrows"); + if ($num_games != pg_num_rows($pts_pg[$u])) { + log_crit("stat-day: num_games != pg_num_rows"); break; } } @@ -342,7 +342,7 @@ function main() exit; } - $fun_name = "main_${G_dbasetype}"; + $fun_name = "main_{$G_dbasetype}"; if ($ret = $fun_name($from, $to)) echo "Success.
\n"; diff --git a/web/briskin5/statadm.php b/web/briskin5/statadm.php index 7e4284e..583bda4 100644 --- a/web/briskin5/statadm.php +++ b/web/briskin5/statadm.php @@ -53,7 +53,7 @@ ini_set("max_execution_time", "240"); require_once("../Obj/brisk.phh"); require_once("../Obj/user.phh"); require_once("../Obj/auth.phh"); -require_once("../Obj/dbase_${G_dbasetype}.phh"); +require_once("../Obj/dbase_{$G_dbasetype}.phh"); require_once("Obj/briskin5.phh"); require_once("Obj/placing.phh"); @@ -99,7 +99,7 @@ function main_pgsql($curtime) break; } - $tmt_n = pg_numrows($tmt_pg); + $tmt_n = pg_num_rows($tmt_pg); // get matches for ($m = 0 ; $m < $tmt_n ; $m++) { $tmt_obj = pg_fetch_object($tmt_pg, $m); @@ -107,7 +107,7 @@ function main_pgsql($curtime) $mtc_sql = sprintf("SELECT * from %sbin5_matches WHERE code = %d", $G_dbpfx, $tmt_obj->code); - if (($mtc_pg = pg_query($bdb->dbconn->db(), $mtc_sql)) == FALSE || pg_numrows($mtc_pg) != 1) { + if (($mtc_pg = pg_query($bdb->dbconn->db(), $mtc_sql)) == FALSE || pg_num_rows($mtc_pg) != 1) { log_crit("statadm: matches row select failed"); break; } @@ -128,7 +128,7 @@ function main_pgsql($curtime) break; } - $gam_n = pg_numrows($gam_pg); + $gam_n = pg_num_rows($gam_pg); for ($g = 0 ; $g < $gam_n ; $g++) { $gam_obj = pg_fetch_object($gam_pg, $g); @@ -141,7 +141,7 @@ function main_pgsql($curtime) log_crit("statadm: points row select [$pts_sql] failed"); break; } - $pts_n = pg_numrows($pts_pg); + $pts_n = pg_num_rows($pts_pg); for ($p = 0 ; $p < $pts_n ; $p++) { $pts_obj = pg_fetch_object($pts_pg, $p); @@ -204,7 +204,7 @@ function main_pgsql($curtime) break; } - for ($i = 0 ; $i < pg_numrows($pla_pg) ; $i++) { + for ($i = 0 ; $i < pg_num_rows($pla_pg) ; $i++) { $pla_obj = pg_fetch_object($pla_pg,$i); if ($pla_obj->games < $ming[$dtime]) continue; @@ -231,8 +231,8 @@ function main_pgsql($curtime) $old_gam[$subty] = $pla_obj->games; $old_score[$subty] = $pla_obj->score; - } // for ($i = 0 ; $i < pg_numrows($pla_pg) ; $i++) { - if ($i < pg_numrows($pla_pg)) { + } // for ($i = 0 ; $i < pg_num_rows($pla_pg) ; $i++) { + if ($i < pg_num_rows($pla_pg)) { break; } } // for ($dtime = 0 ; $dtime < count($limi) ; $dtime++) { @@ -271,7 +271,7 @@ function main() exit; } - $fun_name = "main_${G_dbasetype}"; + $fun_name = "main_{$G_dbasetype}"; $ctime = time(); diff --git a/web/error.php b/web/error.php index 83751df..b106d0a 100644 --- a/web/error.php +++ b/web/error.php @@ -27,7 +27,7 @@ $G_base = ""; require_once("Obj/brisk.phh"); require_once("Obj/user.phh"); require_once("Obj/auth.phh"); -require_once("Obj/dbase_${G_dbasetype}.phh"); +require_once("Obj/dbase_{$G_dbasetype}.phh"); $mlang_error = array( 'headline' => array('it' => 'briscola chiamata in salsa ajax', 'en' => 'declaration briscola in ajax sauce (Beta)'), diff --git a/web/index_wr.php b/web/index_wr.php index dd2d9db..efa5a79 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -175,7 +175,7 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) if (($a_sem = Challenges::lock_data(TRUE)) != FALSE) { log_main("chal lock data success"); - if (($chals = &Challenges::load_data()) != FALSE) { + if (($chals = Challenges::load_data()) != FALSE) { $token = uniqid(""); // echo '2|'.$argz[1].'|'.$token.'|'.$remote_addr.'|'.$curtime.'|'; @@ -550,7 +550,16 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) if (($ema = $bdb->getmail($user->name)) != FALSE) { // mail("nastasi", - mail("brisk@alternativeoutput.it", urldecode($cli_subj), urldecode($cli_mesg), sprintf("From: %s <%s>", $user->name, $ema)); + /* php8: mbstring.func_overload was removed, so mail() is no + longer remapped onto mb_send_mail(): the subject and + the user name have to be encoded by hand, otherwise + they end up as raw UTF-8 in the headers (forbidden by + RFC 5322). */ + mail("brisk@alternativeoutput.it", + mb_encode_mimeheader(urldecode($cli_subj), "UTF-8"), + urldecode($cli_mesg), + sprintf("From: %s <%s>\r\nContent-Type: text/plain; charset=UTF-8", + mb_encode_mimeheader($user->name, "UTF-8"), $ema)); } if (($fp = @fopen(LEGAL_PATH."/messages.txt", 'a')) != FALSE) { diff --git a/web/mailmgr.php b/web/mailmgr.php index e3a970c..5fd236e 100644 --- a/web/mailmgr.php +++ b/web/mailmgr.php @@ -42,7 +42,7 @@ ini_set("max_execution_time", "240"); require_once($G_base."Obj/brisk.phh"); require_once($G_base."Obj/user.phh"); require_once($G_base."Obj/auth.phh"); -require_once($G_base."Obj/dbase_${G_dbasetype}.phh"); +require_once($G_base."Obj/dbase_{$G_dbasetype}.phh"); require_once($G_base."Obj/singlemsg.phh"); require_once($G_base."spush/brisk-spush.phh"); diff --git a/web/spush/.htaccess b/web/spush/.htaccess index 481dad6..04a77ee 100644 --- a/web/spush/.htaccess +++ b/web/spush/.htaccess @@ -1,3 +1,10 @@ -Order Deny,Allow -Deny from All - +# apache 2.4 (debian 13). The old 2.2 syntax "Order Deny,Allow / Deny from All" +# needs mod_access_compat, which is not guaranteed: the native one is used here, +# with a fallback. + + Require all denied + + + Order Deny,Allow + Deny from All + diff --git a/web/spush/brisk-spush.phh b/web/spush/brisk-spush.phh index 77b842a..c4dca71 100644 --- a/web/spush/brisk-spush.phh +++ b/web/spush/brisk-spush.phh @@ -33,25 +33,25 @@ define('PENDINGPAGE_WAITDATA', 1); define('PENDINGPAGE_FLUSH', 2); class PendingPage { - var $socket; // socket handler of page stream - var $status; // status can be 0: waiting for data, 1: flush phase - - var $kalive; // if no message are sent after RD_KEEPALIVE_TOUT secs we send a keepalive from server - var $msg; // place where store failed fwrite data - var $msg_sz; // size of content - - var $method; // method used to request the page - var $header; // array of header fields - var $get; // array of get args - var $post; // array of post args - var $cookie; // array of cookie args - var $path; // requested path - var $addr; // source address - var $contsz; // expected content size - var $rest; // number of missing bytes - var $cont; // content of unfinished POST - - function PendingPage($socket, $curtime, $kalive) + public $socket; // socket handler of page stream + public $status; // status can be 0: waiting for data, 1: flush phase + + public $kalive; // if no message are sent after RD_KEEPALIVE_TOUT secs we send a keepalive from server + public $msg; // place where store failed fwrite data + public $msg_sz; // size of content + + public $method; // method used to request the page + public $header; // array of header fields + public $get; // array of get args + public $post; // array of post args + public $cookie; // array of cookie args + public $path; // requested path + public $addr; // source address + public $contsz; // expected content size + public $rest; // number of missing bytes + public $cont; // content of unfinished POST + + function __construct($socket, $curtime, $kalive) { $this->socket = $socket; // fprintf(STDERR, "SOCKET ADD: %s\n", $this->socket); diff --git a/web/usermgmt.php b/web/usermgmt.php index 24948a1..5f26aa6 100644 --- a/web/usermgmt.php +++ b/web/usermgmt.php @@ -72,7 +72,7 @@ require_once($G_base."Obj/user.phh"); require_once($G_base."Obj/auth.phh"); require_once($G_base."Obj/mail.phh"); require_once($G_base."Obj/dbase_base.phh"); -require_once($G_base."Obj/dbase_${G_dbasetype}.phh"); +require_once($G_base."Obj/dbase_{$G_dbasetype}.phh"); require_once($G_base."briskin5/Obj/briskin5.phh"); require_once($G_base."briskin5/Obj/placing.phh"); require_once($G_base."spush/brisk-spush.phh"); @@ -195,7 +195,7 @@ SELECT usr.*, guar.login AS guar_login log_crit("stat-day: select from tournaments failed"); break; } - $usr_n = pg_numrows($usr_pg); + $usr_n = pg_num_rows($usr_pg); if ($usr_n != 1) { $status .= sprintf("Inconsistency for code %d, returned %d records, skipped.
", $id, $usr_n); @@ -293,7 +293,7 @@ SELECT usr.*, guar.login AS guar_login log_crit("stat-day: select from tournaments failed"); break; } - $usr_n = pg_numrows($usr_pg); + $usr_n = pg_num_rows($usr_pg); if ($usr_n != 1) { $status .= sprintf("Inconsistency for code %d, returned %d records, skipped.
", $id, $usr_n); @@ -352,7 +352,7 @@ SELECT usr.*, guar.login AS guar_login log_crit("stat-day: select from tournaments failed"); break; } - $usr_n = pg_numrows($usr_pg); + $usr_n = pg_num_rows($usr_pg); $tab_lines = ""; for ($i = 0 ; $i < $usr_n ; $i++) { $usr_obj = pg_fetch_object($usr_pg, $i); @@ -429,7 +429,7 @@ SELECT mail.*, usr.email AS email $status .= "2
"; break; } - $mai_n = pg_numrows($mai_pg); + $mai_n = pg_num_rows($mai_pg); if ($mai_n != 1) { $status .= sprintf("Inconsistency for code %d, returned %d records, skipped.
", $id, $mai_n); @@ -472,7 +472,7 @@ SELECT usr.*, guar.login AS guar_login log_crit("stat-day: select from tournaments failed"); break; } - $usr_n = pg_numrows($usr_pg); + $usr_n = pg_num_rows($usr_pg); $tab_lines = ""; for ($i = 0 ; $i < $usr_n ; $i++) { $usr_obj = pg_fetch_object($usr_pg, $i); @@ -522,7 +522,12 @@ SELECT usr.*, guar.login AS guar_login if ($action == "accept") { if (($bdb = BriskDB::create()) == FALSE) { log_crit("stat-day: database connection failed"); - break; + /* php8: there used to be a "break" outside any loop or switch here. + On php5 it was a runtime fatal (the script died if the db did + not answer); since php7 it is a compile time fatal, so the + whole of usermgmt.php was not even loaded any more. + The block ends with exit anyway (see the foreach below). */ + exit; } foreach($_POST as $key => $value) { @@ -618,7 +623,7 @@ SELECT usr.*, guar.login AS guar_login log_crit("stat-day: select from tournaments failed"); break; } - $usr_n = pg_numrows($usr_pg); + $usr_n = pg_num_rows($usr_pg); if ($usr_n != 1) { $status .= sprintf("Inconsistency for code %d, returned %d records, skipped.
", $id, $usr_n); @@ -708,7 +713,7 @@ SELECT usr.*, guar.login AS guar_login break; } - $usr_n = pg_numrows($usr_pg); + $usr_n = pg_num_rows($usr_pg); $tab_lines = ""; for ($i = 0 ; $i < $usr_n ; $i++) { $usr_obj = pg_fetch_object($usr_pg, $i); diff --git a/web/xynt_test01.php b/web/xynt_test01.php index 4c1c43b..463614c 100644 --- a/web/xynt_test01.php +++ b/web/xynt_test01.php @@ -301,7 +301,7 @@ if (isset($isstream) && $isstream == "true") { window.onload = function() { xstm = new xynt_streaming(window, "", , , console, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=', function(com){eval(com);}); + echo ($f_port == NULL ? "{$trans_ports[$f_trans]}" : "$f_port" );?>, , console, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=', function(com){eval(com);}); xstm.hbit_set(heartbit); xstm.start(); } diff --git a/web/xynt_test01_wss.php b/web/xynt_test01_wss.php index 4c1c43b..463614c 100644 --- a/web/xynt_test01_wss.php +++ b/web/xynt_test01_wss.php @@ -301,7 +301,7 @@ if (isset($isstream) && $isstream == "true") { window.onload = function() { xstm = new xynt_streaming(window, "", , , console, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=', function(com){eval(com);}); + echo ($f_port == NULL ? "{$trans_ports[$f_trans]}" : "$f_port" );?>, , console, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=', function(com){eval(com);}); xstm.hbit_set(heartbit); xstm.start(); } diff --git a/webtest/mailtest.php b/webtest/mailtest.php index 99dcac2..c57aebc 100644 --- a/webtest/mailtest.php +++ b/webtest/mailtest.php @@ -11,7 +11,7 @@ require_once($G_base."Obj/user.phh"); require_once($G_base."Obj/auth.phh"); require_once($G_base."Obj/mail.phh"); require_once($G_base."Obj/dbase_base.phh"); -require_once($G_base."Obj/dbase_${G_dbasetype}.phh"); +require_once($G_base."Obj/dbase_{$G_dbasetype}.phh"); require_once($G_base."briskin5/Obj/briskin5.phh"); require_once($G_base."briskin5/Obj/placing.phh"); require_once($G_base."spush/brisk-spush.phh"); diff --git a/webtest/singlemsg.php b/webtest/singlemsg.php index a6cd60a..011cf69 100644 --- a/webtest/singlemsg.php +++ b/webtest/singlemsg.php @@ -27,7 +27,7 @@ $G_base = ""; require_once("Obj/brisk.phh"); require_once("Obj/user.phh"); require_once("Obj/auth.phh"); -require_once("Obj/dbase_${G_dbasetype}.phh"); +require_once("Obj/dbase_{$G_dbasetype}.phh"); require_once("Obj/singlemsg.phh"); diff --git a/webtest/test_db.php b/webtest/test_db.php index 21a77ad..4cfb615 100644 --- a/webtest/test_db.php +++ b/webtest/test_db.php @@ -25,7 +25,7 @@ $G_base = "./"; require_once($G_base."Obj/brisk.phh"); -require_once($G_base."Obj/dbase_${G_dbasetype}.phh"); +require_once($G_base."Obj/dbase_{$G_dbasetype}.phh"); function succ($s) { @@ -97,7 +97,7 @@ function main() { } succ($cmp_que); - for ($r = 0 ; $r < pg_numrows($cmp_pg) ; $r++) { + for ($r = 0 ; $r < pg_num_rows($cmp_pg) ; $r++) { $cmp_obj = pg_fetch_object($cmp_pg, $r); if ($ip_obj->ip & $msk != $cmp) { @@ -118,7 +118,7 @@ function main() { } succ("SELECT * FROM test_ip"); - for ($r = 0 ; $r < pg_numrows($ip_pg) ; $r++) { + for ($r = 0 ; $r < pg_num_rows($ip_pg) ; $r++) { $ip_obj = pg_fetch_object($ip_pg, $r); $v = int2ip($ip_obj->ip);
Pos.UtenteScore(Punti/Partite)
UserGuarDate
UserGuarDate
UserEMailGuarApprendiceDate