move curl-de-sac stuff optionally included
[brisk.git] / web / Obj / brisk.phh
index 9b596a0..3af8a15 100644 (file)
@@ -2,7 +2,7 @@
 /*
  *  brisk - brisk.phh
  *
- *  Copyright (C) 2006-2013 Matteo Nastasi
+ *  Copyright (C) 2006-2014 Matteo Nastasi
  *                          mailto: nastasi@alternativeoutput.it
  *                                  matteo.nastasi@milug.org
  *                          web: http://www.alternativeoutput.it
@@ -79,6 +79,7 @@ define('DBG_LMOP', 0x0800);
 define('DBG_TRAC', 0x1000);
 define('DBG_SHME', 0x2000);
 define('DBG_ENGI', 0x4000);
+define('DBG_CDS',  0x8000);
 // NOTE: BRISK DEBUG must be a numerical constant, not the result of operations on symbols
 define('BRISK_DEBUG', 0x0800);
 
@@ -108,8 +109,8 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi',
                                            'en' => 'EN<br>The signalling message of the table<br>will be deactivated for %d second%s.<br><br>'),
                       'alarpass' => array( 'it' => '<br>La password digitata non &egrave; corretta.<br><br>',
                                            'en' => '<br>The entered password is not correct.<br><br>'),
-                      'alarret'  => array( 'it' => '"Alarm \\"<b>%s</b>\\" inviato a <b>%s</b>."',
-                                           'en' => '"Alarm \\"<b>%s</b>\\" sent to <b>%s</b>."'),
+                      'alarret'  => array( 'it' => 'Alarm \\"<b>%s</b>\\" inviato a <b>%s</b>.',
+                                           'en' => 'Alarm \\"<b>%s</b>\\" sent to <b>%s</b>.'),
                       'authmust' => array( 'it' => '<b>Per autenticare qualcuno devi a tua volta essere autenticato e certificato.</b>',
                                            'en' => '<b>To authenticate someone you have to be authenticated and certified.</b>'), // on your turn
                       'mesgmust' => array( 'it' => '<b>Per inviare un messaggio devi essere autenticato.</b>',
@@ -151,12 +152,12 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi',
 $G_lng = langtolng($G_lang);
 
 $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "4.14.3";
+$G_brisk_version = "4.14.5";
 
 /* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: nuovo sistema di registrazione degli utenti, aggiunto reinvio dell\' email di verifica, ban con classi di IP',
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: nuovo sistema di registrazione degli utenti, aggiunto reinvio dell\' email di verifica, ban con classi di IP, nuovi colori, nuovo sistema bi banner laterali per gli eventi',
                                        'Se vuoi iscriverti alla <a target="_blank" href="mailto:ml-briscola+subscribe@milug.org">Mailing List</a>, cliccala!' ),
-                       'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: new users subscription system.',
+                       'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: new users subscription system, refactored sidebanner system.',
                                        'If you want to subscribe our <a target="_blank" href="ml-briscola+subscribe@milug.org">Mailing List</a>, click it!' ) );
 
 $G_room_help = array( 'it' => '
@@ -1000,10 +1001,13 @@ class Brisk
 
     var $delay_mgr;
 
+    var $cds;
+
     public static $sess_cur;
 
     function Brisk()
     {
+        $this->cds = NULL;
     }
 
     // constructor
@@ -1013,7 +1017,7 @@ class Brisk
                 fprintf(STDERR, "ROOM FROM FILE\n");
                 rename($crystal_filename, $crystal_filename.".old");
 
-                $brisk->reload($ban_list, $black_list);
+                $brisk->reload(TRUE, $ban_list, $black_list);
 
                 return($brisk);
             }
@@ -1030,11 +1034,6 @@ class Brisk
         $thiz->ban_list = NULL;
         $thiz->black_list = NULL;
 
-        fprintf(STDERR, "PRE IPCLASS_UPDATE (%d, %d)\n", count($ban_list), count($black_list));
-        $thiz->ipclass_update('ban_list', $ban_list);
-        $thiz->ipclass_update('black_list', $black_list);
-        fprintf(STDERR, "POST IPCLASS_UPDATE %d %d\n", count($thiz->ban_list), count($thiz->black_list));
-
         for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
             $thiz->user[$i] = User::create($thiz, $i, "", "");
         }
@@ -1049,6 +1048,8 @@ class Brisk
 
         static::$sess_cur = FALSE;
 
+        $thiz->reload(TRUE, $ban_list, $black_list);
+
         return ($thiz);
     }
 
@@ -1073,15 +1074,22 @@ class Brisk
         }
     }
 
-    function reload($ban_list, $black_list)
+    function reload($is_first, $ban_list, $black_list)
     {
         fprintf(STDERR, "RELOAD STUFF (%d)(%d)\n", count($ban_list), count($black_list));
 
+        if (defined('CURL_DE_SAC_VERS')) {
+            if (brisk_cds_reload($this) == FALSE) {
+                exit(12);
+            }
+        }
         $this->ipclass_update("ban_list", $ban_list);
         $this->ipclass_update("black_list", $black_list);
 
-        $this->banned_kickoff();
-        $this->garbage_manager(TRUE);
+        if (!$is_first) {
+            $this->banned_kickoff();
+            $this->garbage_manager(TRUE);
+        }
     }
 
     function banned_kickoff()
@@ -2255,6 +2263,9 @@ class Brisk
       }
 
       $idx = $ghost;
+      if (defined('CURL_DE_SAC_VERS')) {
+          brisk_cds_execute($this, $real_idx, $sess, $ip, $authenticate);
+      }
       return ($this->user[$ghost]);
     }
     else if ($idx != -1 && $i == MAX_PLAYERS) {
@@ -2354,6 +2365,9 @@ class Brisk
       log_main(sprintf("TROVATO LIBERO A [%d] sess [%s] name [%s] count [%d] name [%s] code [%s]", $idx, $sess, $name_new, count($this->user),$this->user[$real_idx]->name, $this->user[$real_idx]->code));
 
       $ret = $this->user[$real_idx];
+      if (defined('CURL_DE_SAC_VERS')) {
+          brisk_cds_execute($this, $real_idx, $sess, $ip, $authenticate);
+      }
       return ($ret);
     }
 
@@ -2707,6 +2721,33 @@ function log_mop($step, $log)
 }
 
 
+function log_cds($log)
+{
+    GLOBAL $PHP_SELF;
+
+    if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_CDS) == 0)
+        return;
+
+    $sess = Brisk::sess_cur_get();
+    if (isset($sess) == FALSE)
+        $ssess = "XXXX";
+    else
+        $ssess = $sess;
+
+    if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_CDS) == 0)
+        return;
+
+    if ((BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_TRAC)
+        $btrace = btrace_line(debug_backtrace());
+    else
+        $btrace = "";
+    if (($fp = @fopen(LEGAL_PATH."/cds.log", 'a')) != FALSE) {
+        fwrite($fp, sprintf("CDS: [%f] [%s] [%s]\n", gettimeofday(TRUE), $log, $btrace));
+        fclose($fp);
+    }
+}
+
+
 function log_only2($log)
 {
     GLOBAL $PHP_SELF;