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')"
+++ /dev/null
-; 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
-
--- /dev/null
+; 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
$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++;
}
<FilesMatch "\.php$">
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.
+<IfModule mod_php.c>
+php_value default_charset "UTF-8"
php_flag mbstring.encoding_translation On
-php_value mbstring.func_overload "7"
+</IfModule>
</FilesMatch>
ExpiresActive On
ExpiresByType image/jpg "access plus 4 days"
-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.
+<IfModule mod_authz_core.c>
+ Require all denied
+</IfModule>
+<IfModule !mod_authz_core.c>
+ Order Deny,Allow
+ Deny from All
+</IfModule>
*
*/
-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);
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;
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;
// 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 {
}
- function save_data($chals)
+ static function save_data($chals)
{
$shm = FALSE;
$oldmod = $chals->mod;
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' ),
$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++;
}
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);
class Vect {
- function Vect($a)
+ /* php8: declared, dynamic properties are deprecated since 8.2 */
+ public $el;
+
+ function __construct($a)
{
$this->el = $a;
}
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);
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);
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();
}
class Client_prefs {
- var $listen;
- var $supp_comp;
+ public $listen;
+ public $supp_comp;
- function Client_prefs()
+ function __construct()
{
}
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;
class GhostSess
{
- var $gs;
+ public $gs;
- function GhostSess()
+ function __construct()
{
$this->gs = array();
}
{
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;
}
}
}
- 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];
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])) {
// 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];
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);
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;
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;
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;
*
*/
-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");
/* 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);
*
*/
-require_once("${G_base}Obj/dbase_base.phh");
+require_once("{$G_base}Obj/dbase_base.phh");
$escsql_from = array( "\\", "'" );
$escsql_to = array( "\\\\", "''" );
class DBConn
{
static $dbcnnx = FALSE;
- var $db = FALSE;
+ public $db = FALSE;
- function DBConn()
+ function __construct()
{
$this->db = DBConn::$dbcnnx;
}
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;
}
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)
$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;
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);
return(FALSE);
}
- $ret = pg_numrows($sere_pg);
+ $ret = pg_num_rows($sere_pg);
if ($ret === FALSE) {
return(FALSE);
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);
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);
}
}
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);
/* 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) {
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);
}
$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);
}
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);
}
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__));
}
$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);
}
// 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);
}
$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 ?
$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);
}
$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);
}
$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
$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);
}
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;
}
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)
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;
}
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)
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)
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);
$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
$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;
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");
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;
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;
// 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;
}
- function save_data($hban)
+ static function save_data($hban)
{
$shm = FALSE;
$oldmod = $hban->mod;
}
- 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) {
- 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);
*/
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);
}
class IPClass {
- var $ipcl;
+ public $ipcl;
- function IPClass()
+ function __construct()
{
$this->ipcl = NULL;
}
*
*/
-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'];
class ProviderProxy
{
- var $pp;
+ public $pp;
- function ProviderProxy()
+ function __construct()
{
$this->pp = NULL;
}
}
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();
}
}
class Cookies {
- var $cookies;
+ public $cookies;
- function Cookies()
+ function __construct()
{
$this->cookies = array();
}
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()
{
}
$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();
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',
class Transport_template {
- function Transport_template() {
+ function __construct() {
}
// return string value is appended to the content of the returned page
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;
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;
}
class Transport_xhr {
+ /* php8: declared, dynamic properties are deprecated since 8.2 */
+ public $type;
- function Transport_xhr() {
+ function __construct() {
$this->type = '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';
}
}
class Transport_htmlfile extends Transport_iframe {
- function Transport_htmlfile() {
+ function __construct() {
$this->type = 'htmlfile';
}
}
class Transport {
- function Transport()
+ function __construct()
{
}
* Suite 330, Boston, MA 02111-1307, USA.
*/
-require_once("${G_base}Obj/transports.phh");
+require_once("{$G_base}Obj/transports.phh");
// User flags
);
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.
// 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") {
$type = "soft";
$preface = sprintf("<div class='doc_alert'>%s</div>",
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
<?php
class ZLibStream {
- var $s;
- var $head;
- var $type;
- var $filter;
+ public $s;
+ public $head;
+ public $type;
+ public $filter;
- function ZLibStream($type)
+ function __construct($type)
{
$this->type = $type;
$this->s = array( FALSE, FALSE );
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);
* 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);
*/
$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 *;",
/* 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]<br>\n", eschtml($pts->logins[$i]), eschtml($usr_sql));
save_rej($pts->logins[$i]);
continue;
<FilesMatch "\.php$">
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.
+<IfModule mod_php.c>
+php_value default_charset "UTF-8"
php_flag mbstring.encoding_translation On
-php_value mbstring.func_overload "7"
+</IfModule>
</FilesMatch>
ExpiresActive On
ExpiresByType image/jpg "access plus 4 days"
-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.
+<IfModule mod_authz_core.c>
+ Require all denied
+</IfModule>
+<IfModule !mod_authz_core.c>
+ Order Deny,Allow
+ Deny from All
+</IfModule>
}
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
} // 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()
{
}
/* CREATE() NOT USED
function create($idx)
{
- if (($thiz =& new Bin5_table()) == FALSE)
+ if (($thiz = new Bin5_table()) == FALSE)
return (FALSE);
$thiz->create($idx);
/* CLONE() NOT USED
function myclone(&$from)
{
- if (($thiz =& new Bin5_table()) == FALSE)
+ if (($thiz = new Bin5_table()) == FALSE)
return (FALSE);
parent::copy($from);
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);
//
// 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;
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;
parent::copy($from);
}
- function copy(&$from)
+ /* php8: "&" dropped, User::copy() takes $from by value (see spawn above). */
+ function copy($from)
{
$this->parentcopy($from);
/* CLONE NOT USED
function myclone(&$from)
{
- if (($thiz =& new User()) == FALSE)
+ if (($thiz = new User()) == FALSE)
return (FALSE);
$thiz->copy($from);
}
*/
- 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);
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 {
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)
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");
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();
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);
/* 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);
}
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;
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);
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;
$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);
{
GLOBAL $G_dbasetype;
- $fun_name = "placing_time_${G_dbasetype}";
+ $fun_name = "placing_time_{$G_dbasetype}";
return ($fun_name());
}
$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 ("");
// MLANG
$ret = sprintf("<table class='placing'><tr><th>Pos.</th><th>Utente</th><th>Score</th><th>(Punti/Partite)</th>");
- 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 = "";
{
GLOBAL $G_dbasetype;
- $fun_name = "placing_show_${G_dbasetype}";
+ $fun_name = "placing_show_{$G_dbasetype}";
return ($fun_name($user, $ty, $subty));
}
);
abstract class Rules {
- var $table;
- var $id;
+ public $table;
+ public $id;
abstract function engine(&$bri, $curtime, $action, $user);
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");
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");
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
//
// 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;
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;
}
}
exit;
}
- $fun_name = "main_${G_dbasetype}";
+ $fun_name = "main_{$G_dbasetype}";
if ($ret = $fun_name($from, $to))
echo "Success.<br>\n";
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");
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);
$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;
}
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);
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);
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;
$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++) {
exit;
}
- $fun_name = "main_${G_dbasetype}";
+ $fun_name = "main_{$G_dbasetype}";
$ctime = time();
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 <b>(Beta)</b>'),
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.'|';
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) {
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");
-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.
+<IfModule mod_authz_core.c>
+ Require all denied
+</IfModule>
+<IfModule !mod_authz_core.c>
+ Order Deny,Allow
+ Deny from All
+</IfModule>
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);
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");
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.<br>",
$id, $usr_n);
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.<br>",
$id, $usr_n);
log_crit("stat-day: select from tournaments failed");
break;
}
- $usr_n = pg_numrows($usr_pg);
+ $usr_n = pg_num_rows($usr_pg);
$tab_lines = "<tr><th></th><th>User</th><th>Guar</th><th>Date</th></tr>";
for ($i = 0 ; $i < $usr_n ; $i++) {
$usr_obj = pg_fetch_object($usr_pg, $i);
$status .= "2<br>";
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.<br>",
$id, $mai_n);
log_crit("stat-day: select from tournaments failed");
break;
}
- $usr_n = pg_numrows($usr_pg);
+ $usr_n = pg_num_rows($usr_pg);
$tab_lines = "<tr><th></th><th>User</th><th>Guar</th><th>Date</th></tr>";
for ($i = 0 ; $i < $usr_n ; $i++) {
$usr_obj = pg_fetch_object($usr_pg, $i);
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) {
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.<br>",
$id, $usr_n);
break;
}
- $usr_n = pg_numrows($usr_pg);
+ $usr_n = pg_num_rows($usr_pg);
$tab_lines = "<tr><th></th><th>User</th><th>EMail</th><th>Guar</th><th>Apprendice</th><th>Date</th></tr>";
for ($i = 0 ; $i < $usr_n ; $i++) {
$usr_obj = pg_fetch_object($usr_pg, $i);
window.onload = function() {
xstm = new xynt_streaming(window, "<?php echo "$f_trans";?>", <?php
- echo ($f_port == NULL ? "${trans_ports[$f_trans]}" : "$f_port" );?>, <?php echo "$f_fback";?>, console, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=<?php echo "$f_test";?>', function(com){eval(com);});
+ echo ($f_port == NULL ? "{$trans_ports[$f_trans]}" : "$f_port" );?>, <?php echo "$f_fback";?>, console, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=<?php echo "$f_test";?>', function(com){eval(com);});
xstm.hbit_set(heartbit);
xstm.start();
}
window.onload = function() {
xstm = new xynt_streaming(window, "<?php echo "$f_trans";?>", <?php
- echo ($f_port == NULL ? "${trans_ports[$f_trans]}" : "$f_port" );?>, <?php echo "$f_fback";?>, console, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=<?php echo "$f_test";?>', function(com){eval(com);});
+ echo ($f_port == NULL ? "{$trans_ports[$f_trans]}" : "$f_port" );?>, <?php echo "$f_fback";?>, console, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=<?php echo "$f_test";?>', function(com){eval(com);});
xstm.hbit_set(heartbit);
xstm.start();
}
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");
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");
$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)
{
}
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) {
}
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);