Файл: index.php
Строк: 82
<?
#путь к скрипту на сервере (следуя из корня сайта)
$SPath = "scripts/sniffer_script";
###
/*Welcome to the Sniffer Script v 0.4 Source Code!*/
/*Copyright by SPG http://www.spg.arbse.net*/
/*Developed by s1ayer[SPG]*/
function redactdb ($DataBase, $C_ID)
{
function fnl ($FPath){
$handle_lock = fopen ($FPath, "r");
flock ($handle_lock, LOCK_EX);
return $handle_lock = fopen ($FPath, "r");
}
function cnu ($handle_lock) {
flock ($handle_lock, LOCK_UN);
fclose ($handle_lock);
}
function get_ip () {
if(getenv('HTTP_CLIENT_IP')) {$user_ip = getenv('HTTP_CLIENT_IP');}
elseif(getenv('HTTP_X_FORWARDED_FOR')){$user_ip = getenv('HTTP_X_FORWARDED_FOR');}
elseif(getenv('REMOTE_ADDR')) {$user_ip = getenv('REMOTE_ADDR');}
else{$user_ip='[empty]';}
return $user_ip;
}
$hl = fnl ($DataBase);
if (count(file($DataBase)) == 0)
{
if (empty($_SERVER['HTTP_REFERER']))
{
$_SERVER['HTTP_REFERER'] = "[direct]";
}
$user_ip = get_ip();
$fopen = fopen ($DataBase, "a+");
flock ($fopen, LOCK_EX);
fputs ($fopen, "$C_ID::$user_ip::".getenv("HTTP_USER_AGENT")."::".getenv("OS")."::0::".$_SERVER['HTTP_REFERER']."::".$_SERVER['REQUEST_URI']."rn");
flock ($fopen, LOCK_UN);
fclose ($fopen);
}
$file=file($DataBase);
for($i=0;$i<count($file);$i++)
{
list ($id_user, $ip_user, $browser_user, $winver_user, $shows_user, $refer_user, $request_user)=explode ("::", $file[$i]);
$user_ip = get_ip();
if($id_user==$C_ID or $ip_user == $user_ip)
{
if ($ip_user != $user_ip)
{
$ip_user.="|$user_ip";
}
$browser_user_array = explode ("|", $browser_user);
if ($browser_user != getenv("HTTP_USER_AGENT") and !in_array(getenv("HTTP_USER_AGENT"), $browser_user_array))
{
$browser_user.="|".getenv("HTTP_USER_AGENT");
}
if ($winver_user != getenv("OS"))
{
$winver_user.="|".getenv("OS");
}
$refer_user_array = explode ("|", $refer_user);
if (!empty($_SERVER['HTTP_REFERER']) and !in_array($_SERVER['HTTP_REFERER'], $refer_user_array))
{
$refer_user.="|".$_SERVER['HTTP_REFERER'];
}
else
{
if (empty($_SERVER['HTTP_REFERER']))
{$_SERVER['HTTP_REFERER'] = "[direct]";}
if (!in_array($_SERVER['HTTP_REFERER'], $refer_user_array))
{
$refer_user.="|[direct]";
}
}
$request_user = trim($request_user);
$request_user_array = explode ("|", $request_user);
if (!empty($_SERVER['REQUEST_URI']) and !in_array($_SERVER['REQUEST_URI'], $request_user_array))
{
$request_user = trim($request_user);
$request_user.="|".$_SERVER['REQUEST_URI'];
}
$file[$i]= str_replace($file[$i], "$id_user::$ip_user::$browser_user::$winver_user::".($shows_user+1)."::$refer_user::$request_userrn", $file[$i]);
break;
}
if ($i == count($file)-1)
{
if (empty($_SERVER['HTTP_REFERER']))
{
$_SERVER['HTTP_REFERER'] = "[direct]";
}
$file[$i].="$C_ID::$user_ip::".getenv("HTTP_USER_AGENT")."::".getenv("OS")."::1::".$_SERVER['HTTP_REFERER']."::".$_SERVER['REQUEST_URI']."rn";
}
}
$fp=fopen($DataBase,"w");
fputs($fp,implode("",$file));
fclose($fp);
cnu ($hl);
}
if (!isset($_COOKIE['user_id']) and !isset($sfid))
{
$uniq_id = uniqid("").rand(0, 9999);
setcookie ("user_id", $uniq_id, time()+31536000, "/");
if ($QUERY_STRING == "")
{
header ("Location: ".$_SERVER['REQUEST_URI']."?sfid=$uniq_id");
}
else
{
header ("Location: ".$_SERVER['REQUEST_URI']."&sfid=$uniq_id");
}
exit;
}
if (isset($_COOKIE['user_id']))
{
$session_failed = false;
}
else
{
$session_failed = true;
}
if ($session_failed == false)
{
redactdb ($_SERVER['DOCUMENT_ROOT']."/$SPath/base.dat", $_COOKIE['user_id']);
}
else
{
print "<!--Warning: This Browser doesn't support cookies-->rn";
}
?>