Файл: t.php
Строк: 93
<?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['tid'] = $id;
header('Content-Type: text/vnd.wap.wml');
echo '<?xml version="1.0" encoding="utf-8"?>'.
'<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd">'.
'<wml>'.
'<card id="click" ontimer="t.php?id='.$id.'&s='.$sid.'" title="Loading">'.
'<timer value="10"/>'.
'<p align="left">'.
'<small>'.
'<a href="t.php?id='.$id.'&s='.$sid.'">Loading</a><br/><br/>'.
'© '.$config->site.
'</small>'.
'</p>'.
'</card>'.
'</wml>';
exit();
}
$sid = trim($_GET['s']);
session_id($sid);
session_start();
session_destroy();
if($_SESSION['tid'] != $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 `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['t'.$id])){
setcookie('t'.$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 = '';
$credit = $config->conf['credit']['it'];
if(isset($_COOKIE['t'.$id])) $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;
if($credit > 0){
$q = mysql_query("SELECT COUNT(`id`) FROM `clicks` WHERE `id` = '$id' && `ip` = '$ip' && `ua` = '$ua' && `status` = '3';", $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` = '3';", $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);
}
}
}
}
if($credit > 0){
mysql_query("UPDATE `users` SET `it1` = `it1`+1, `it3` = `it3`+1, `credit` = `credit`+$credit WHERE `id` = '$id';", $mysql); }
$ud = array();
$q = mysql_query("SELECT `id` FROM `users` WHERE `id` != '$id' && `credit` > '0' && `active` = '1' && `active_text` = '1' && `status` > '2';", $mysql);
while($d = mysql_fetch_array($q)) $ud[] = $d['id'];
$count = count($ud);
if($count < 1){
header('Location: index.php');
mysql_query("INSERT INTO `clicks` VALUES('$id', '0', '$ip', '$ua', '".time()."', '3');", $mysql);
mysql_close($mysql);
exit();
}
$ud = $ud[mt_rand(0, $count-1)];
$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()."', '3');", $mysql);
mysql_close($mysql);
exit();
}
mysql_query("INSERT INTO `clicks` VALUES('$id', '$ud', '$ip', '$ua', '".time()."', '3');", $mysql);
mysql_query("UPDATE `users` SET `mt1` = `mt1`+1, `mt3` = `mt3`+1, `credit` = `credit`-".$config->conf['credit']['mt']." WHERE `id` = '$ud';", $mysql);
mysql_close($mysql);
header('Location: http://'.$q['site']);
?>