source IP address stored into log v4.5.2
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 3 Jan 2013 08:17:01 +0000 (09:17 +0100)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 3 Jan 2013 08:17:01 +0000 (09:17 +0100)
TODO.txt
web/Obj/brisk.phh
web/Obj/user.phh
web/briskin5/Obj/briskin5.phh
web/briskin5/index_wr.php
web/index.php
web/index_wr.php

index c475eff..5941766 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -4,12 +4,11 @@
   MAJOR |
  -------+
    - BUG: some connection to the named socket fails
-   - log_legal address fix
 
 
   MINOR |
  -------+
-   - try to be more antivirus-friendly
+   WIP - try to be more antivirus-friendly
    - packetize and automatize php-ancillary and apache module
    - into the room local step remains -1
    - DISABLED_TO_FIX: DNS access (perform blocking dns requests, must be fixed)
@@ -17,6 +16,7 @@
 
   DONE |
  ------+
+   DONE - log_legal address fix
    DONE - manage too fast reload in xynt-streaming
    DONE - add xhr as transport layer and manage different streams better
    TEST - BUG: pari + 72 non fa 4x ma attualmente fa 3x, da correggere
index 675ef33..9d3f6b6 100644 (file)
@@ -140,10 +140,10 @@ $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.5.1";
+$G_brisk_version = "4.5.2";
 
 /* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: nuova visualizzazione dello stato della connessione dati.',
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: nuova visualizzazione dello stato della connessione dati, indirizzo IP sorgente memorizzato correttamente nei log.',
                                        '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>: usage of reader/writer locking instead of generic exclusive locking.',
                                        'If you want to subscribe our <a target="_blank" href="ml-briscola+subscribe@milug.org">Mailing List</a>, click it!' ) );
@@ -788,7 +788,7 @@ class Room
                             $user_cur->bantime    = $bri_user->bantime;
                         }
                         
-                        log_legal($curtime, 'xxx', $user_cur, "STAT:DESTROY_GAME", $plist);
+                        log_legal($curtime, $user_cur->ip, $user_cur, "STAT:DESTROY_GAME", $plist);
                         
                         $this->room_join_wakeup($user_cur, FALSE, 0); 
                         $table_cur->table_token = "";
@@ -825,7 +825,7 @@ class Room
                     for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
                         $plist .= '|'.$this->user[$table_cur->player[$i]]->sess;
                     }
-                    log_legal($curtime, 'xxx', $user_cur, "STAT:DESTROY_GAME(RECOVERY)", $plist);
+                    log_legal($curtime, $user_cur->ip, $user_cur, "STAT:DESTROY_GAME(RECOVERY)", $plist);
                     
                     $this->room_join_wakeup($user_cur, TRUE, -2); 
                     $table_cur->table_token = "";
@@ -1522,7 +1522,7 @@ class Room
         $to_room = $to_user;
       }
 
-      log_legal($curtime, 'xxx', $user, 
+      log_legal($curtime, $user->ip, $user,
                ($user->stat == 'room' ? 'room' : 'table '.$user->table),$msg);
       
       $user->chat_lst = "$msg";
@@ -2623,8 +2623,8 @@ function log_shme($log)
 
 
 
-// function log_legal($curtime, $sess, $name, $where, $mesg) 
-function log_legal($curtime, $addr, $user, $where, $mesg) 
+// function log_legal($curtime, $sess, $name, $where, $mesg)
+function log_legal($curtime, $addr, $user, $where, $mesg)
 {
 
   if (($fp = @fopen(LEGAL_PATH."/legal.log", 'a')) != FALSE) {
index 4beaa5f..b6efbcd 100644 (file)
@@ -465,7 +465,7 @@ class User {
 
   function reset() {
     $curtime = time();
-    log_legal($curtime, 'xxx', $this, "STAT:LOGOUT", '');
+    log_legal($curtime, $this->ip, $this, "STAT:LOGOUT", '');
 
     $tmp_sess = $this->sess;
     $this->sess = "";
index 89445ce..1d11f36 100644 (file)
@@ -1109,7 +1109,7 @@ class Bin5 {
                                                                      $dt, $user->flags, xcape($user->name), xcape($user_mesg));
                 $user_cur->step_inc();
             }
-            log_legal($curtime, 'xxx', $user, ($user->stat == 'room' ? 'room' : 'table '.$user->table_orig),$user_mesg);
+            log_legal($curtime, $user->ip, $user, ($user->stat == 'room' ? 'room' : 'table '.$user->table_orig),$user_mesg);
         }
     }
 
index be76b58..4c816fd 100644 (file)
@@ -495,7 +495,7 @@ function bin5_index_wr_main(&$bri, $remote_addr, $get, $post, $cookie)
                         for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
                             $plist .= '|'.xcapelt($ucodes[$i]);
                         }
-                        log_legal($curtime, 'xxx', $user, "STAT:BRISKIN5:FINISH_GAME", $plist);
+                        log_legal($curtime, $user->ip, $user, "STAT:BRISKIN5:FINISH_GAME", $plist);
                         if ($user->table_orig < TABLES_AUTH_N) {
                             require_once("../Obj/dbase_".$G_dbasetype.".phh");
                             
index b0096e0..e3cb7c2 100644 (file)
@@ -283,14 +283,21 @@ function index_main(&$room, $transp_type, &$header_out, $addr, $get, $post, $coo
           
           $room->garbage_manager(TRUE);
           /* try login */
-          if (($user = $room->add_user(&$sess, &$idx, $name, $pass_private, $addr, $cookie)) != FALSE) {
+          $ipv4addr_arr = explode(':' , $addr);
+          if (isset($ipv4addr_arr[3])) {
+              $ipv4addr = $ipv4addr_arr[3];
+          }
+          else {
+              $ipv4addr = $addr;
+          }
+          if (($user = $room->add_user(&$sess, &$idx, $name, $pass_private, $ipv4addr, $cookie)) != FALSE) {
               $ACTION = "room";
               if ($idx < 0) {
                   $idx = -$idx - 1;
                   $is_login = TRUE;
               }
               
-              log_legal($curtime, $addr, $user, "STAT:LOGIN", '');
+              log_legal($curtime, $ipv4addr, $user, "STAT:LOGIN", '');
               
               // recovery lost game
               if ($user->stat == "table") {
index 56e2579..14c7f79 100644 (file)
@@ -600,7 +600,7 @@ function index_wr_main(&$room, $remote_addr, $get, $post, $cookie)
                     for ($i = 0 ; $i < $table->player_n ; $i++) {
                         $plist .= '|'.$room->user[$table->player[$i]]->sess;
                     }
-                    log_legal($curtime, 'xxx', $user, "STAT:CREATE_GAME", $plist);
+                    log_legal($curtime, $user->ip, $user, "STAT:CREATE_GAME", $plist);
                     
                     log_wr("pre new Bin5");
                     if (($bri = new Bin5($room, $table_idx, $table_token, $get, $post, $cookie)) == FALSE)