From 3834934333bc49c745beaf1e373986d308b66255 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 3 Jan 2013 09:17:01 +0100 Subject: [PATCH] source IP address stored into log --- TODO.txt | 4 ++-- web/Obj/brisk.phh | 14 +++++++------- web/Obj/user.phh | 2 +- web/briskin5/Obj/briskin5.phh | 2 +- web/briskin5/index_wr.php | 2 +- web/index.php | 11 +++++++++-- web/index_wr.php | 2 +- 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/TODO.txt b/TODO.txt index c475eff..5941766 100644 --- 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 diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 675ef33..9d3f6b6 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -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.'), NOVITA\': nuova visualizzazione dello stato della connessione dati.', +$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': nuova visualizzazione dello stato della connessione dati, indirizzo IP sorgente memorizzato correttamente nei log.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ), 'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NEWS: usage of reader/writer locking instead of generic exclusive locking.', 'If you want to subscribe our Mailing List, 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) { diff --git a/web/Obj/user.phh b/web/Obj/user.phh index 4beaa5f..b6efbcd 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -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 = ""; diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 89445ce..1d11f36 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -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); } } diff --git a/web/briskin5/index_wr.php b/web/briskin5/index_wr.php index be76b58..4c816fd 100644 --- a/web/briskin5/index_wr.php +++ b/web/briskin5/index_wr.php @@ -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"); diff --git a/web/index.php b/web/index.php index b0096e0..e3cb7c2 100644 --- a/web/index.php +++ b/web/index.php @@ -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") { diff --git a/web/index_wr.php b/web/index_wr.php index 56e2579..14c7f79 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -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) -- 2.17.1