<?php
/*
- NTLCMS v 18.1 19.08.2017 г
- Автор скрипта Александр (NTL)
- Скрипт клик клуба v 18.1
- Оф.сайт http://clicks24.ru
- Контакты ntl-jt@mail.ru
- Все права принадлежат разработчику
- Вы не имеете право вносить изменения в код скрипта
- Данный скрипт запрещено распространять
*/
define('NTLCMS', 1);
$module = 'checktask';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
include ('../system/head.php');
################################################################################
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
################################################################################
echo '<div class="title"><center>Проверка выполнения</center></div>';
################################################################################
if (isset($_POST['pay_here']) && is_numeric($_POST['pay_here'])){
$payed = isset($_GET['pay_here']) ? filter_int($_GET['pay_here']) : '0';
$rows = DB :: run() -> query("select (`id_job`) from `jobs_use` where `pay` = '0' and `id` = '$payed'") -> fetch(PDO::FETCH_OBJ);
$task = DB :: run() -> querySingle("select count(`id_job`) from `jobs_use` where `pay` = '0' and `id` = '$payed'");
$payed2 = $rows -> id_job;
if ($task > 0){
$row = DB :: run() -> query("select * from `jobs` where `id` = '$payed2' and `user` = '$ulogin' and `accept` = '1' limit 1") -> fetch(PDO::FETCH_OBJ);
$summa = $row -> pay;
if ($summa < $_USER['balans']){
$tasks = DB :: run() -> querySingle("select count(`id_job`) from `jobs_use` where `pay` = '0' and `id` = '$payed'");
if ($tasks > 0){
$user = DB :: run() -> query("select (`user`) from `jobs_use` where `pay` = '0' and `id_job` = '$payed2' limit 1") -> fetch(PDO::FETCH_OBJ);
$to = $user -> user;
$per = DB :: run() -> querySingle("select count(`period`) from `jobs` where `pay` = '0' and `id` = '$payed2' limit 1");
DB :: run() -> query("update `users` set `balans` = `balans` - '".$summa."' where `login` = '$ulogin'");
DB :: run() -> query("update `users` set `balans` = `balans` + '".$summa."' where `login` = '$to'");
DB :: run() -> query("insert into `notice` (`to`, `date`, `status`, `tema`, `text`) values (?, ?, ?, ?, ?)", array($to, TIME, 1, 'Задания юзеров', 'Выполненное вами задание [url='.URL.'/showtask'.$payed.']№ '.$payed.'[/url] оплачено рекламодателем!'));
DB :: run() -> query("update `jobs_use` set `pay` = '1' where `id` = '$payed'");
if ($per == 0){
//DB :: run() -> query("update `jobs` set `done` = '1' where `id` = '$payed2'");
}
echo '<div class="post"><center>'.image('success.png','16|16').' Заявка успешно принята!</center></div>';
}
} else echo '<div class="post"><center>'.image('fail.png','16|16').' У вас недостаточно средств для оплаты!</center></div>';
}
}
else
if (isset($_POST['del_here']) && is_numeric($_POST['del_here'])){
$payed = isset($_GET['del_here']) ? filter_int($_GET['del_here']) : '0';
$payed2 = DB :: run() -> query("select (`id_job`) from `jobs_use` where `pay` = '0' and `id` = '$payed'") -> fetch(PDO::FETCH_OBJ);
$task = DB :: run() -> querySingle("select (`id_job`) from `jobs_use` where `pay` = '0' and `id` = '$payed'");
if ($task > 0){
$taskes = DB :: run() -> querySingle("select (`pay`) from `jobs` where `id` = '$payed' and `user` = '$ulogin' and `accept` = '1' limit 1");
if ($taskes > 0){
$sum = DB :: run() -> query("select (`pay`) from `jobs` where `id` = '$payed' and `user` = '$ulogin' and `accept` = '1' limit 1") -> fetch(PDO::FETCH_OBJ);
DB :: run() -> query("update `jobs_use` set `pay` = '2' where `id` = '$payed'");
echo '<div class="post"><center>'.image('success.png','16|16').' Заявка успешно отменена!</center></div>';
}
}
}
$sql = DB :: run() -> query("select * from `jobs_category`");
while ($data = $sql -> fetch(PDO::FETCH_OBJ)){
$names[$data -> id] = $data -> name;
}
$sql = DB :: run() -> query("select * from `jobs` where `user` = '$ulogin'");
$task = DB :: run() -> querySingle("select count(`id`) from `jobs_use` where `author` = '$ulogin' and `pay` = '0' and `id_job` = '$payed'");
if ($task == 0){
echo '<div class="post"><center>'.image('fail.png','16|16').' Задания на проверку отсутствуют!</center></div>';
}
while ($sdata = $sql -> fetch()){
$sdatas[] = $sdata;
}
for ($i = 0; $i < count($sdatas); $i++){
$wname = $sdatas[$i]['id'];
$sql = DB :: run() -> query("select * from `jobs_use` where `pay` = '0' and `id_job` = '$wname' limit 10");
while($data = $sql -> fetch(PDO::FETCH_OBJ)){
echo '<div class="menu">';
echo '#'.$sdatas[$i]['id'].'. <b>'.$sdatas[$i]['name'].'</b> (Оплата '.$sdatas[$i]['pay'].' WMR)<br/>';
echo '<b>Сообщение:</b> '.$data -> message;
echo '<br/><b>Категория:</b> '.$names[$sdatas[$i]['category']];
echo '<form action="'.URL.'/paycheck'.((int) $data -> id).'" method="post">
<input type="hidden" name="pay_here" value="'.$data -> id.'" />
<input type="submit" value="Оплатить задание"/></form>
<form action="'.URL.'/delcheck'.((int) $data -> id).'" method="post">
<input type="hidden" name="del_here" value="'.$data -> id.'" />
<input type="submit" value="Отменить задание"/></form>';
echo '</div>';
}
}
echo '<div class="block">'.image('home.png','18|18').' <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/tasks">Задания юзеров</a></div>';
include ('../system/foot.php');
?>