Файл: test.otwap.aux.su/redirect.php
Строк: 20
<?
require("lib/config.php");
require("lib/functions.php");
if (isset($_GET[id])) {
$ref_url = $_SERVER['HTTP_REFERER'];
$ref_url = ereg_replace('http://','',$ref_url);
$ref_url = substr($ref_url,0,strpos($ref_url,'/'));
$ip = IPDetect();
$query = "SELECT s.id_user, s.clickwmz, s.url, u.balance FROM sites s, user u WHERE s.id = $_GET[id] AND s.id_user = u.id";
$set = select($query);
$row = mysql_fetch_row($set);
$id_from = $row[0];
$cash_from = $row[1];
$url = $row[2];
$balance = $row[3];
$query = "SELECT s.id_user, s.url FROM sites s WHERE s.id = $_GET[from]";
$set = select($query);
$row = mysql_fetch_row($set);
$id_to = $row[0];
$from_url = $row[1];
preg_match("/^(http://)?([^/]+)/i",$from_url, $matches);
$host = $matches[2];
// preg_match("/[^./]+.[^./]+$/", $host, $matches);
$from_url = $host; //$matches[0];
$cash_to = $cash_from*0.60;
$query = "SELECT u.id FROM user u WHERE u.spid = $id_to";
$set = select($query);
$row = mysql_fetch_row($set);
$query = "SELECT COUNT(*) FROM `history_referal` WHERE `ip` = '$ip' AND `to` = '$_GET[from]' AND `from` = '$_GET[id]' AND `date` > SUBDATE(NOW(), INTERVAL 15 HOUR)";
$set = select($query);
$cont = mysql_fetch_row($set);
if (($cont[0] == 0) AND ($balance >= 0.1) AND ($ref_url == $from_url)) {
if ($row[0] > 0) {
$sponsor = $row[0];
$cash_referal = $cash_from*0.02;
updata("UPDATE `user` SET `balance` = `balance` + $cash_referal WHERE `id` = $sponsor");
}
updata("UPDATE `user` SET `balance` = `balance` - $cash_from WHERE `id` = $id_from");
updata("UPDATE `user` SET `balance` = `balance` + $cash_to WHERE `id` = $id_to");
insert("INSERT INTO `history_referal` VALUES('', '$id_to', '$cash_to', '$_GET[from]', '$id_from', '$cash_from', '$_GET[id]', '$sponcor', '$cash_referal', '$ip', NOW())");
}
} else {
$url = BASE_URL;
}
header("Location: $url");
?>