Файл: c.php
Строк: 139
<?php
//error_reporting(2047|2048);
error_reporting(0);
ini_set('session.auto_start', 'Off');
ini_set('session.use_cookies', 'Off');
ini_set('session.gc_maxlifetime', '600');
ini_set('session.use_trans_sid', '0');
ini_set('url_rewriter.tags', '0');
include 'config.php';
class_exists('config') or die('Error load config class');
$config = new config(0, 0, 1);
if(isset($_GET['id'])) $id = intval($_GET['id']);
else $id = intval($_SERVER['QUERY_STRING']);
if($id < 1){
header('Location: index.php');
exit();
}
if(!isset($_GET['s'])){
session_start();
$sid = session_id();
$_SESSION['cid'] = $id;
echo '
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">
<head><meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/>
<link rel="shortcut icon" href="/favicon.ico" />
<meta name="yandex-verification" content="7e87ea897bf77e7e" />
<meta name="copyright" content="Hasma.Ru" />
<Meta name="author" Content="RON">
<Meta name="Reply-to" Content="zimaron@mail.ru">
<Meta name="description" Content="Банерская сеть ! Раскрути свой проект">
<Meta name="keywords" Content="Раскрутка интернет проектов"><link rel="stylesheet" type="text/css" href="/styles/style.css"/>
<title>'.$title.'</title><meta http-equiv="refresh" content="2; url=/c.php?id='.$id.'&s='.$sid.'" title="Выполняется переход"><meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/></head><body>
Подождите, пожалуйста...</div><a href="/c.php?id='.$id.'&s='.$sid.'">Выполняется переход !</a><br/>Подождите .....<br/>
<center><img src="/images/per.gif" alt=""></a></center></br>
</body></html>
';
exit();
}
$sid = trim($_GET['s']);
session_id($sid);
session_start();
session_destroy();
if($_SESSION['cid'] != $id){
header('Location: index.php');
exit();
}
$mysql = mysql_connect($config->mysql['host'], $config->mysql['user'], $config->mysql['pass']) or die();
mysql_select_db($config->mysql['db'], $mysql) or die();
$q = mysql_query("SELECT `is1`, `ic1`, `status` FROM `users` WHERE `id` = '$id';", $mysql);
$q = mysql_fetch_array($q) or $q['status'] = 1;
if($q['status'] == 1 || $q['status'] == 2){
header('Location: index.php');
mysql_close($mysql);
exit();
}
if(!isset($_COOKIE['c'.$id])){
setcookie('c'.$id, '1', @mktime('23', '59', '59')); }
if(isset($_SERVER['REMOTE_ADDR'])) $ip = addslashes($_SERVER['REMOTE_ADDR']); else $ip = '127.0.0.1';
if(isset($_SERVER['HTTP_USER_AGENT'])) $ua = addslashes($_SERVER['HTTP_USER_AGENT']); else $ua = '';
$ctr = round($q['ic1']/$q['is1'], 3);
$credit = $config->conf['credit']['ic'];
if(isset($_COOKIE['c'.$id])) $credit = 0;
elseif($q['is1'] <= $q['ic1']) $credit = 0;
elseif(stripos(' '.$ua, 'opera')) $credit = 0;
elseif(stripos(' '.$ua, 'mozilla')) $credit = 0;
elseif(stripos(' '.$ua, 'windows')) $credit = 0;
elseif(stripos(' '.$ua, 'compatible')) $credit = 0;
elseif($ctr >= 0.7) $credit += 2;
elseif($ctr >= 0.5) $credit += 1;
if($credit > 0){
$q = mysql_query("SELECT COUNT(`id`) FROM `clicks` WHERE `id` = '$id' && `ip` = '$ip' && `ua` = '$ua' && `status` = '2';", $mysql);
$q = mysql_fetch_array($q);
if($q['0'] > 0) $credit = 0;
else{
$q = mysql_query("SELECT COUNT(`id`) FROM `clicks` WHERE `id` = '$id' && `ip` = '$ip' && `time` >= '".(time()-10)."' && `status` = '2';", $mysql);
$q = mysql_fetch_array($q);
if($q['0'] >= 5){
$credit = 0;
$deny = file($config->root.'/deny.txt');
if(!in_array($id.':'.$ip."rn", $deny)){
$fo = fopen($config->root.'/deny.txt', 'a+');
fputs($fo, $id.':'.$ip."rn"); fclose($fo);
$subj = 'Накрутка кликов графического баннера! ['.$id.']';
$subj = convert_cyr_string($subj, 'w', 'k');
$subj = base64_encode($subj);
$subj = '=?koi8-r?B?'.$subj.'?=';
$head = 'From: '.$config->site.' <'.$config->mail.'>'."n".
'Reply-To: <'.$config->mail.'>'."n".
'Content-Type: text/plain; charset=windows-1251'."n".
'MIME-Version: 1.0';
$mess = 'Возможно накрутка кликов графического баннера:'."rn".
' ID: '.$id."rn".
' IP: '.$ip."rn";
mail($config->mail, $subj, $mess, $head);
}
}
}
}
$q = mysql_query("SELECT `ud` FROM `clicks` WHERE `id` = '$id' && `ip` = `ip` && `ua` = '$ua' && `status` = '1' ORDER BY `time` DESC LIMIT 0, 1;", $mysql);
$q = mysql_fetch_array($q);
if(!$q){
header('Location: index.php');
mysql_query("INSERT INTO `clicks` VALUES('$id', '0', '$ip', '$ua', '".time()."', '2');", $mysql);
mysql_close($mysql);
exit();
}
if($credit > 0){
mysql_query("UPDATE `users` SET `ic1` = `ic1`+1, `ic3` = `ic3`+1, `credit` = `credit`+$credit WHERE `id` = '$id';", $mysql); }
if($q['ud'] < 1){
header('Location: index.php');
mysql_query("INSERT INTO `clicks` VALUES('$id', '0', '$ip', '$ua', '".time()."', '2');", $mysql);
mysql_close($mysql);
exit();
}
$bd = $q['ud'];
$q = mysql_query("SELECT `ud` FROM `banners` WHERE `id` = '$bd';", $mysql);
$q = mysql_fetch_array($q);
if(!$q){
header('Location: index.php');
mysql_query("INSERT INTO `clicks` VALUES('$id', '0', '$ip', '$ua', '".time()."', '2');", $mysql);
mysql_close($mysql);
exit();
}
$ud = $q['ud'];
$q = mysql_query("SELECT `site` FROM `users` WHERE `id` = '$ud';", $mysql);
$q = mysql_fetch_array($q);
if(!$q){
header('Location: index.php');
mysql_query("INSERT INTO `clicks` VALUES('$id', '0', '$ip', '$ua', '".time()."', '2');", $mysql);
mysql_close($mysql);
exit();
}
mysql_query("INSERT INTO `clicks` VALUES('$id', '$ud', '$ip', '$ua', '".time()."', '2');", $mysql);
mysql_query("UPDATE `banners` SET `c1` = `c1`+1, `c3` = `c3`+1 WHERE `id` = '$bd';", $mysql);
mysql_query("UPDATE `users` SET `mc1` = `mc1`+1, `mc3` = `mc3`+1, `credit` = `credit`-".$config->conf['credit']['mc']." WHERE `id` = '$ud';", $mysql);
mysql_close($mysql);
header('Location: http://'.$q['site']);
?>