<?php
function getip() {
if(getenv("HTTP_CLIENT_IP")) {
$ip = getenv("HTTP_CLIENT_IP");
} elseif(getenv("HTTP_X_FORWARDED_FOR")) {
$ip = getenv("HTTP_X_FORWARDED_FOR");
} else {
$ip = getenv("REMOTE_ADDR");
}
return $ip;
}
include "../cfg.php";
$id = intval($_GET['id']);
$sid = intval($_GET['sid']);
$get_user_info = mysql_query("SELECT id, url, user_id FROM webmasters WHERE id = ".$id." LIMIT 1");
$row = mysql_fetch_array($get_user_info);
$urlwm = $row['url'];
$wm_id = $row['user_id'];
$ip = getip(); // Переменная с IP
$brauzer = substr($_SERVER["HTTP_USER_AGENT"],0,50); // Браузер
$get_popup = mysql_query("SELECT id, url, clx FROM strike WHERE id = ".$sid." LIMIT 1");
$row = mysql_fetch_array($get_popup);
$sid = $row['id'];
$url = $row['url'];
$clx = $row['clx'];
$time = time() - $cfgTime;
$cfgPouseClick = time() - 300;
$count_click = mysql_num_rows(mysql_query("SELECT id FROM log_strike WHERE (ip = '".$ip."' AND date > ".$time.") OR (brouser = '".$brauzer."' AND date > ".$cfgPouseClick.")"));
if($count_click || $clx <= 0) {
print "<html><head><script language=\"javascript\">top.location.href=\"".$url."\";</script></head></html>";
} else {
$one_porcent = $cfgStrike / 100;
$admin_percent = sprintf("%01.4f", $one_porcent * $cfgHeaderPerc);
$wm_percent = $cfgStrike - $admin_percent;
mysql_query("UPDATE users SET balance=balance+".$wm_percent." WHERE id=".$wm_id." LIMIT 1");
mysql_query("UPDATE strike SET clx=clx-1, count=count+1 WHERE id=".$sid." LIMIT 1");
mysql_query("UPDATE webmasters SET clx_today=clx_today+1, m_today=m_today+".$wm_percent." WHERE id=".$id." LIMIT 1");
mysql_query("INSERT INTO log_strike (date, ip, idw, ids, price, url, brouser, fromurl) VALUES (".time().", '".$ip."', ".$id.", ".$sid.", ".$cfgStrike.", '".$urlwm."', '".$brauzer."', '".$_SERVER['HTTP_REFERER']."')");
// МЕСТО ГДЕ МОЖНО ПИСАТЬ СТАТИСТИКУ АДМИНУ
$date = date("d.m.Y");
mysql_query("UPDATE logs SET strike = strike + ".$admin_percent." WHERE date = '".$date."' LIMIT 1");
print "<html><head><script language=\"javascript\">top.location.href=\"".$url."\";</script></head></html>";
}
} else {
print "<html><head><script language=\"javascript\">top.location.href=\"".$cfgSiteUrl."\";</script></head></html>";
}
?>