]> mop.ddnsfree.com - git repositories - brisk.git/commitdiff
port to php 8.4 (debian 13)
authorMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 13 Sep 2026 10:30:35 +0000 (12:30 +0200)
committerMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 13 Sep 2026 10:30:35 +0000 (12:30 +0200)
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 <IfModule mod_php.c>
  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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014M1jiEq9cHdE5SE5j6vFuE

39 files changed:
INSTALL.sh
system/etc_php5_conf.d_mbstring.ini [deleted file]
system/etc_php8.4_conf.d_brisk.ini [new file with mode: 0644]
test/nonblocking.php
web/.htaccess
web/Obj/.htaccess
web/Obj/auth.phh
web/Obj/brisk.phh
web/Obj/dbase_base.phh
web/Obj/dbase_file.phh
web/Obj/dbase_pgsql.phh
web/Obj/hardban.phh
web/Obj/ipclass.phh
web/Obj/provider_proxy.phh
web/Obj/sac-a-push.phh
web/Obj/singlemsg.phh
web/Obj/transports.phh
web/Obj/user.phh
web/Obj/zlibstream.phh
web/admin.php
web/briskin5/.htaccess
web/briskin5/Obj/.htaccess
web/briskin5/Obj/briskin5.phh
web/briskin5/Obj/placing.phh
web/briskin5/Obj/rules_base.phh
web/briskin5/explain.php
web/briskin5/stat-day.php
web/briskin5/statadm.php
web/error.php
web/index_wr.php
web/mailmgr.php
web/spush/.htaccess
web/spush/brisk-spush.phh
web/usermgmt.php
web/xynt_test01.php
web/xynt_test01_wss.php
webtest/mailtest.php
webtest/singlemsg.php
webtest/test_db.php

index 05b76e6c478754e90bdc942c78c8b717d521abc1..7a441178ff1ca0a5491211d358f8e67a644dd91b 100755 (executable)
@@ -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 (file)
index dffe7d3..0000000
+++ /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 (file)
index 0000000..4905c1a
--- /dev/null
@@ -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
index 808551023fca63971941f18642ed25b36c2b6092..2aba83423e3a1471cb7f002cbf7826a4b444dee6 100755 (executable)
@@ -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++;
     }
index 0eb75915357fd44dc302bb04a271d9218e43d633..b016cecdaac18a83869bad9789edc60c91fb2411 100644 (file)
@@ -4,10 +4,16 @@ header append Cache-Control "public, last-modified, must-revalidate"
 <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"
index 481dad607e26f23030151b96154e7ce702ed37a1..04a77ee56d7c87f735d0e635051372beaddef1a5 100644 (file)
@@ -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.
+<IfModule mod_authz_core.c>
+    Require all denied
+</IfModule>
+<IfModule !mod_authz_core.c>
+    Order Deny,Allow
+    Deny from All
+</IfModule>
index 193bca63a551b1c54cad6a63416ff72a2e8d5fc4..d9b45287368d9835722f150a0396f2c968165810 100644 (file)
@@ -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;
index 8f9556517ceb26f460780b6794de68b542ddc7b8..52a2e41fdbf74a5f8126a66e739b8c7c5f863b42 100644 (file)
@@ -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);
index 66c998fe342c0fb999d2580dfd3706cc58d20f10..13052e8d65426c921809a802359775b5fb7157b9 100644 (file)
 
 
 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;
index 9461f1e99da381d267da84dfc4e06dcb5fc8d72b..eaf44a506cf05fae0427242512bb452f68170558 100644 (file)
    *
    */
 
-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);
index 1c9bea4d601540686967299f066af8e1e2333f44..8856c2754b29c3b2c854b12dfac0fd1bf530b2b6 100644 (file)
@@ -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");
index c59deb37d0b6d29ad639b7d70330a53641d80ee1..8b1c0ff6494e0ed44f5112cf1cbfc56e3d563d56 100644 (file)
@@ -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);
 
index 3a3d5888d6ce911bcaad41471e5f284c9ed2fca5..993991061cc7da44e78e42c22980bef63498333c 100644 (file)
  */
 
 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;
     }
index 57d98522f9c8b3352f1c4e0c14a9511b731dc97f..993ba3dc27ed1d9c92118108dd7d8ed86b41f8ec 100644 (file)
  *
  */
 
-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;
     }
index 1f9a70c2e953c0ebccd5dcbe86a0fdd1df6a12e1..801279ae2c8404f4607ab4b75a4f1af204727930 100644 (file)
@@ -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();
index 11c981af756e537ebded89b4ff05a67521a12b01..5ca935f8af9aa0d084d952a58edc226841d785ad 100644 (file)
@@ -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',
index ea592a8d7892dcae9b9bec4baa54f6a2b94b717b..3e028d6d128c1efb6e6d8d6ca35552e7a5b29720 100644 (file)
@@ -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</script>", $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()
     {
     }
 
index 32bb71ed547d48c3ebcb28a8dd563c67b0000b16..c98de14c49b444ee10bd93d8f3fa35c3c30327db 100644 (file)
@@ -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("<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
index 91ac7116be1092943d71f27f37aea7a6e294e067..9468370211de8739335cbca32e45cb3e3e953d72 100644 (file)
@@ -1,11 +1,11 @@
 <?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 );
index c3428e663353048111eda4bc3a5147a016bfbc74..c9f3a41148aae6338481ba7621356dc343d8e4c7 100644 (file)
@@ -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]<br>\n", eschtml($pts->logins[$i]), eschtml($usr_sql));
                         save_rej($pts->logins[$i]);
                         continue;
index 0eb75915357fd44dc302bb04a271d9218e43d633..b016cecdaac18a83869bad9789edc60c91fb2411 100644 (file)
@@ -4,10 +4,16 @@ header append Cache-Control "public, last-modified, must-revalidate"
 <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"
index 481dad607e26f23030151b96154e7ce702ed37a1..04a77ee56d7c87f735d0e635051372beaddef1a5 100644 (file)
@@ -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.
+<IfModule mod_authz_core.c>
+    Require all denied
+</IfModule>
+<IfModule !mod_authz_core.c>
+    Order Deny,Allow
+    Deny from All
+</IfModule>
index 7ce17b0540df6bc2d2d584964117835aca8d2bb5..c8bbd6f6276ddba47ed53ce658fac3bcb8a2ba0b 100644 (file)
@@ -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);
index ad69d50b8a8646ba8d4d4d76377c557a94c06f96..294efd0c94bce82e7425f36f0c1f9cc05e0c9c34 100644 (file)
@@ -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("<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 = "";
@@ -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));
 }
index 6f93892f5fe8361561c426bc674a5ab13f614ec7..026baa8dad9c7dfbaff5a83d319e01a7fd93fd15 100644 (file)
@@ -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);
 
index 1c15dd24325ed52d7cf4901fcc075bf7286c6ba1..80c04e73b815ac2d4b6890dfc04829b9717fcbba 100644 (file)
@@ -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");
 
index 7bc80e4223fc9addcdccbac90fe1fa98a8a3661d..65e46776c085105472f7721480518474c7a9ae0e 100644 (file)
@@ -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.<br>\n";
index 7e4284e63886efc6f7eae565940fefe2f70b7ac8..583bda4c28fbc45b32754702de44ec64b5a976d1 100644 (file)
@@ -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();
 
index 83751df47f6593788fa483fb0973c0bebc22e4af..b106d0a2be86a6789eb07af20f87b234a4491b7d 100644 (file)
@@ -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 <b>(Beta)</b>'),
index dd2d9db20043150470d3a79fda9510cde93a2923..efa5a79793bf827ffa8e4e7c1389b67e5cbd4901 100644 (file)
@@ -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) {
index e3a970c3c713d76cc91ffc3b2bcb279ed99bb7a5..5fd236e5458f830bd0ab0e7bbfb53d98fa66a45d 100644 (file)
@@ -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");
index 481dad607e26f23030151b96154e7ce702ed37a1..04a77ee56d7c87f735d0e635051372beaddef1a5 100644 (file)
@@ -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.
+<IfModule mod_authz_core.c>
+    Require all denied
+</IfModule>
+<IfModule !mod_authz_core.c>
+    Order Deny,Allow
+    Deny from All
+</IfModule>
index 77b842acb0b24a7ac061a6042f2672e7feff5f48..c4dca71f1f054265cd751340767d917cb67e644c 100644 (file)
@@ -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);
index 24948a135f3ead414c8ca09b2af43f7d57011109..5f26aa665dad03e021505c95732b1fadc5a0873f 100644 (file)
@@ -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.<br>",
                                           $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.<br>",
                                           $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 = "<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);
@@ -429,7 +429,7 @@ SELECT mail.*, usr.email AS email
                         $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);
@@ -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 = "<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);
@@ -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.<br>",
                                           $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 = "<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);
index 4c1c43bab19cfbb44071ae5bb3b2afee4a30f431..463614c0eb073c7ac6398fc3a464c22d0df315ed 100644 (file)
@@ -301,7 +301,7 @@ if (isset($isstream) && $isstream == "true") {
      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();
  }
index 4c1c43bab19cfbb44071ae5bb3b2afee4a30f431..463614c0eb073c7ac6398fc3a464c22d0df315ed 100644 (file)
@@ -301,7 +301,7 @@ if (isset($isstream) && $isstream == "true") {
      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();
  }
index 99dcac2bd930beee3fcbc8e2bde257d24b6fdab2..c57aebc7cde6fb3d816a7157ec67707f0239960e 100644 (file)
@@ -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");
index a6cd60afa949c08e90dc130a5b54ca0e34ea7e3d..011cf69155abf154f591b4030cfe0fa49a7b0bf0 100644 (file)
@@ -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");
 
 
index 21a77ad0206559def4bdcde0084146ed5fe78616..4cfb615a5b2430096285542dfb55dd7ef3162a20 100644 (file)
@@ -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);