Re: IP tracking
Verfasst: 29.12.2009 22:09
was für einen phpbb Version verwendest du?
Code: Alles auswählen
<?php
/**
*
* @author Bierhasser http://www.phpbb.de/community/memberlist.php?mode=viewprofile&u=3383
* @package Ip-Tracking
* @version 1.0.0
* @copyright (c) Bierhasser 2009
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
if (!defined('IN_PHPBB'))
{
exit;
}
function track_ip ()
{
global $db, $user, $auth, $_SERVER, $phpbb_root_path, $phpEx;
$ip_conf = array();
if ( file_exists($phpbb_root_path.'includes/conf_ip_tracking.'.$phpEx) )
{
include($phpbb_root_path.'includes/conf_ip_tracking.'.$phpEx);
}
else
{
return;
}
if ( !isset($ip_conf['log_admin']) || !isset($ip_conf['log_user']) || !isset($ip_conf['log_guest']) || !isset($ip_conf['log_bot']))
{
return;
}
// Alte Logeinträge löschen?
if ( isset($ip_conf['log_last_rotate']) && isset($ip_conf['log_next_rotate']) )
{
$now = time();
if ( $now >= $ip_conf['log_next_rotate'] && (int)$ip_conf['log_rotate'] > 0 )
{
$sql = 'DELETE FROM ' . IP_TRACK_TABLE . ' WHERE ip_time <= \''.$db->sql_escape($ip_conf['log_last_rotate']).'\'';
$db->sql_query($sql);
$sql = 'SELECT ip_time FROM ' . IP_TRACK_TABLE . ' ORDER BY ip_time ASC';
$result = $db->sql_query_limit($sql, 1);
$db->sql_return_on_error(false);
if ((bool) $result === false)
{
$ip_first_entry = time();
}
else
{
$ip_first_entry = $db->sql_fetchfield('ip_time');
$db->sql_freeresult($result);
}
$ip_conf['first_entry'] = $ip_first_entry;
$ip_conf['log_last_rotate'] = time();
$ip_conf['log_next_rotate'] = $ip_conf['log_last_rotate'] + (86400 * $ip_conf['log_rotate']);
$ip_conf = safe_ip_conf($ip_conf);
}
}
$usertype = ( $auth->acl_get('a_') ) ? 3 : $user->data['user_type'];
$usertype = ( $user->data['is_bot'] ) ? 4 : $usertype;
if ( !$ip_conf['log_admin'] && $usertype == 3 )
{
return;
}
if ( !$ip_conf['log_user'] && $usertype == 0 )
{
return;
}
if ( !$ip_conf['log_bot'] && $usertype == 4 )
{
return;
}
if ( !$ip_conf['log_guest'] && $usertype == 2 )
{
return;
}
$browser = $user->browser;
if (strlen($browser) > 255)
{
$browser = substr($browser, 0, 255);
}
$referer = ( isset($_SERVER["HTTP_REFERER"]) ) ? $_SERVER["HTTP_REFERER"] : '';
$ip_data = array(
'ip_ip' => $user->ip,
'ip_time' => time(),
'ip_location' => $db->sql_escape($_SERVER["REQUEST_URI"]),
'ip_referer' => $db->sql_escape($referer),
'ip_username' => $user->data['username'],
'ip_user_id' => $user->data['user_id'],
'ip_user_type' => $usertype,
'ip_browser' => $db->sql_escape($browser)
);
$db->sql_query('INSERT INTO ' . IP_TRACK_TABLE . ' ' . $db->sql_build_array('INSERT', $ip_data));
}
function safe_ip_conf($new = '' )
{
// array?
if ( !is_array($new) )
{
return FALSE;
}
// ist im array überhaupt ein wert?
if ( count($new) < 1 )
{
return false;
}
$tmp_conf = array();
//neue Werte $ip_conf zuweisen
foreach( $new as $k => $v )
{
if ( strlen($k) > 0 )
{
$v = preg_replace( "/'/", "\\'" , $v );
$v = preg_replace( "/\r|\n/", "" , $v );
$tmp_conf[ $k ] = $v;
}
}
global $phpbb_root_path, $phpEx;
ksort($tmp_conf);
$file_string = '<?php
/**
*
* @author Bierhasser http://www.phpbb.de/community/memberlist.php?mode=viewprofile&u=3383
* @package Ip-Tracking
* @version 1.0.0
* @copyright (c) Bierhasser 2009
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/';
foreach( $tmp_conf as $k => $v )
{
$v = ( is_numeric($v) ) ? (int)$v : "'$v'";
$file_string .= "\n" . '$ip_conf[\'' . $k . '\'] = ' . $v . ';';
}
$file_string .= "\n?>";
// schreibe neue conf_
if ( $fh = @fopen($phpbb_root_path.'includes/conf_ip_tracking.'.$phpEx, 'w' ) )
{
fwrite($fh, $file_string, strlen($file_string) );
fclose($fh);
#phpbb_chmod($phpbb_root_path.'includes/conf_ip_tracking.'.$phpEx, CHMOD_WRITE);
}
return $tmp_conf;
}
?>
Code: Alles auswählen
DELETE FROM phpbb_config WHERE config_name = 'ip_tracking'
Code: Alles auswählen
DROP TABLE `phpbb_ip_tracking`
Da heute erst der 25.1. ist und die logs grade gelöscht wurden, ist alles in Ordnung.John Doe hat geschrieben:Heute am 26.01. waren keine logs gelöscht.
Es sind alle logs vom 16.01. bis 26.01 da.
Code: Alles auswählen
if ($user->data['user_type'] != USER_FOUNDER)
{
$template->assign_var('T_TEMPLATE_PATH', $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template');
trigger_error($user->lang['NEED_FOUNDER'], E_USER_ERROR);
}