<?php
if(!defined('FastCore')){echo ('Выявлена попытка взлома!');exit();}
class Task_model
{
var $data;
var $count;
var $db = NULL;
/*******************настройки************/
public $set = array(
"chtime" => "48", // Максимальное время проверки (часов)
"maxusertask" => "15", // Максимальное количество одновременных выполнений одним пользователем
"per" => "20", // Комиссия системы в процентах (%)
"price_up" => "1", // Стоимость поднятия в рублях (руб.)
"min_price" => 0.5, // МИнимальная оплата исполнителю (руб. Десятичный разделитель точка)
);
/**************************************/
public $status = array(
'1' => 'Начато',
'2' => 'Отправленно на проверку',
'3' => 'Доработка',
'4' => 'Выполнено',
'5' => 'Просрочено',
'6' => 'Отказ',
'7' => 'Заблокировано',
);
private function con(){
$conn = new \mysqli(dbHost, dbUser, dbPass, dbName);
// unset($conf);
if (empty($conn) || $conn->connect_error) {
die('Сервер временно недоступен');
}
$conn->set_charset("utf8");
return $conn;
}
// $user = $GLOBALS['db']->query('SELECT * FROM db_users WHERE id = ? LIMIT 1',$uid)->fetchArray();
// $users = $GLOBALS['db']->query('SELECT * FROM db_users WHERE login = ? LIMIT 1',array($login))->fetchArray();
function __construct(){
# Подключаем класс базы из фк #
$this->db = new db(dbHost, dbUser, dbPass, dbName);
$this->data = array();
$this->func = new func;
$this->count = 0;
// $this->set = getConf('mod_task');
if(!isset($this->set['min_price']))
$this->set['min_price'] = 0.01;
}
/* Начало проверки IP*/
public function Activation($uid) {
$user = $this->db->query('SELECT * FROM db_users WHERE id = ? LIMIT 1',$uid)->fetchArray();
$ipGet = $this->func->ipGet();
$ipUse = $this->func->ipValid($ipGet);
$uuips = $this->db->query('SELECT * FROM `db_uips` WHERE `id` = ?',array($uid))->fetchArray();
if($user['check_status'] == 1) {
if ($uuips['ip'] != $ipUse) {
$this->db->query('UPDATE `db_users` SET `check_code` = ? WHERE `id` = ?', 0,$uid);
return header ('Location: /user/activecode');
}
}
}
/* конец проверки IP*/
/******************************************/
public function Gets($f = array(), $startRowIndex=0, $maximumRows=FALSE,$desc = NULL)
{
$conn = $this->con();
$ret = new Task_model;
$lim = $maximumRows ? 'LIMIT '.(int)$startRowIndex.', '.(int)$maximumRows : 'LIMIT 300';
if(empty($desc)){
if(!empty($f['adm']))
$desc = "IF(t.Approved = 0, 1, 999), t.`Id` DESC";
else
$desc = 't.`Sort` DESC,t.`Id` DESC';
}
elseif($desc == 'rand')
$desc = 'RAND()';
elseif($desc == 'Sort')
$desc = 't.Sort DESC';
else
{
$desc = $conn->real_escape_string($desc);
$ar = explode(' ', trim($desc));
$preix = ($ar[0] == 'st4' || $ar[0] == 'RatPlus') ? '' : 't.';
if (isset($ar[1]))
$desc = $preix.'`'.$ar[0].'`';
else
$desc = $preix.'`'.$ar[0].'` DESC';
}
$where = '';
$select = '';
$join = '';
if(!empty($f)){
$w = array();
//OnliFav Login Url
if(isset($f['Url'])){
$s = $conn->real_escape_string($f['Url']);
array_push($w, "t.`Url` LIKE '%{$s}%'");
}
if(isset($f['Login'])){
$users = $GLOBALS['db']->query('SELECT * FROM db_users WHERE login = ? LIMIT 1',array($f['Login']))->fetchArray();
$f['UserId'] = $users['id'];
unset($users);
if(empty($f['UserId']))
return $ret;
}
if(isset($f['Id']))
array_push($w, "t.Id = ".(int)$f['Id']);
if(isset($f['AutoChek']))
array_push($w, "t.AutoChek = 1");
if(!empty($f['PriceOt']))
array_push($w, "t.Amount >= ".(float)$f['PriceOt']);
if(isset($f['UserId']))
array_push($w, "t.UserId = ".(int)$f['UserId']);
if(isset($f['Active']))
array_push($w, "t.Active = ".(int)$f['Active']);
if(isset($f['Approved']))
array_push($w, "t.Approved = ".(int)$f['Approved']);
if(isset($f['CatId']))
array_push($w, "t.CatId = ".(int)$f['CatId']);
if(isset($f['r']))
$select .= ', SUM( IF(turm.Status = 2,1,0) ) as st2 ';
if(!empty($f['ActiveOk'])){
$per = $this->set['per']/100;
$time = time();
$join .= "LEFT JOIN `mod_task_user` as tu on(t.Id = tu.TaskId AND (
tu.UserId = {$GLOBALS['uid']} AND tu.Status <> 5
AND
(
t.`Povtor` = 0 OR
(
({$time} < (tu.EndDate + (t.`Povtor` * 360))) OR tu.Status = 7
)
OR
(tu.Status < 4 AND tu.Status = 7)
)
) )";
array_push($w, "t.Active > 0 AND Approved > 0 AND t.`Balans` >= (t.`Amount` + (t.`Amount` * {$per})) AND u.ban = 0");
array_push($w, "tu.Id IS NULL AND blok.UserId IS NULL ");
/*********черный список******************/
$join .= "LEFT JOIN `mod_task_ut_black` as lb on(t.UserId = lb.UserIdBlack AND lb.UserId = {$GLOBALS['uid']})";
array_push($w, "lb.UserIdBlack IS NULL");
/*********заблокированные задания*******/
$join .= "LEFT JOIN `mod_task_ut_taskblock` as tb on(t.Id = tb.TaskId AND tb.UserId = {$GLOBALS['uid']})";
array_push($w, "tb.TaskId IS NULL");
/*****************************************/
}
/****************Избранное*************************/
if(isset($f['Fav']) && $GLOBALS['uid'] > 0){
$select .= ', IF(lw.UserId IS NULL,0,1) as Fav';
$join .= "LEFT JOIN `mod_task_ut_white` as lw on(lw.UserIdWhite = t.UserId AND lw.UserId = {$GLOBALS['uid']})";
if(!empty($f['OnliFav']))
array_push($w, "lw.UserId IS NOT NULL");
}
if(isset($f['s'])){
$s = $conn->real_escape_string($f['s']);
array_push($w, "(t.`Url` LIKE '%{$s}%' OR t.`Title` LIKE '%{$s}%')");
}
/****************************************************/
if(!empty($w)){
$where = ' WHERE ' .implode(' AND ', $w);
unset($w);
}
}
$q = "SELECT t.*,
SUM( IF(turm.Rat = '1',1,0) ) as RatPlus,
SUM( IF(turm.Rat = '-1',1,0) ) as RatMinus,
SUM( IF((turm.Status < 4),1,0) ) as st1,
SUM( IF(turm.Status = 4,1,0) ) as st4,
cat.`Title` as CatTitle,
IF(blok.UserId IS NULL, 0, 1) as Blok,
u.`login` as Login
{$select}
FROM `mod_task` as t
LEFT JOIN `db_users` as u on(u.id = t.UserId)
LEFT JOIN `mod_task_user` as turm on(t.Id = turm.TaskId)
LEFT JOIN `mod_task_cat` as cat on(cat.Id = t.CatId)
LEFT JOIN mod_task_user_block as blok on(t.UserId = blok.UserId)
{$join}
{$where}
GROUP BY t.Id
ORDER BY {$desc} {$lim}
";
//die($q);
$query = $conn->query($q);
if (!empty($query) && $query->num_rows)
{
$ret->data = $this->convertList($query);
if($maximumRows){
$query2 = $conn->query("SELECT COUNT(t.Id) FROM `mod_task` as t
LEFT JOIN `db_users` as u on(u.id = t.UserId)
LEFT JOIN `mod_task_cat` as cat on(cat.Id = t.CatId)
LEFT JOIN mod_task_user_block as blok on(t.UserId = blok.UserId)
{$join}
{$where}");
if(!empty($query2) && $query2->num_rows){
$ret->count = (int)$query2->fetch_array()[0];
$query2->close();
}
}
}
$conn->close();
return $ret;
}
public function GetByID($id,$UserId = NULL,$ActiveOk = NULL)
{
$conn = $this->con();
$ret = NULL;
$w = 't.Id = '.(int)$id;
$jn = '';
if(!empty($UserId))
$w .= " AND t.UserId = ".(int)$UserId;
if(!empty($ActiveOk)){
$per = $this->set['per']/100;
$time = time();
$w .= " AND t.Active > 0 AND Approved > 0 AND t.`Balans` >= (t.`Amount` + (t.`Amount` * {$per})) AND u.ban = 0";
$jn .= "LEFT JOIN `mod_task_user` as tu on(t.Id = tu.TaskId AND (
tu.UserId = {$GLOBALS['uid']} AND tu.Status <> 5
AND
(
t.`Povtor` = 0 OR
(
({$time} < (tu.EndDate + (t.`Povtor` * 360))) OR tu.Status = 7
)
OR
(tu.Status < 4 AND tu.Status = 7)
)
) )";
$w .= " AND tu.Id IS NULL";
}
$q = "SELECT t.*, u.login as Login,
SUM( IF(turm.Rat = 1,1,0) ) as RatPlus,
SUM( IF(turm.Rat = -1,1,0) ) as RatMinus,
SUM( IF(turm.Status = 4,1,0) ) as st4,
cat.Title as CatTitle
FROM `mod_task` as t
LEFT JOIN `db_users` as u on(u.id = t.UserId)
LEFT JOIN mod_task_cat as cat on(cat.Id = t.CatId)
LEFT JOIN mod_task_user as turm on(t.Id = turm.TaskId)
$jn
WHERE {$w}
GROUP BY t.Id
LIMIT 1";
//die($q);
$query = $conn->query($q);
if (!empty($query) && $query->num_rows)
$ret = $this->convert($query);
$conn->close();
return $ret;
}
public function GetByID_s($id,$UserId = NULL)
{
$conn = $this->con();
$ret = NULL;
$w = 'Id = '.(int)$id;
$jn = '';
if(!empty($UserId))
$w .= " AND UserId = ".(int)$UserId;
$q = "SELECT * FROM `mod_task` WHERE {$w} LIMIT 1";
//die($q);
$query = $conn->query($q);
if (!empty($query) && $query->num_rows)
$ret = $this->convert($query);
$conn->close();
return $ret;
}
public function ChDel($id,$UserId)
{
$conn = $this->con();
$ret = NULL;
$id = (int)$id;
$UserId = (int)$UserId;
$q = "SELECT t.*, IF(tu.Status IS NOT NULL, 1,0) as ch FROM `mod_task` as t
LEFT JOIN mod_task_user as tu on(t.Id = tu.TaskId AND tu.Status < 4)
WHERE t.Id = {$id} AND t.UserId = {$UserId} LIMIT 1";
$query = $conn->query($q);
if (!empty($query) && $query->num_rows){
$ret = $this->convert($query);
}
$conn->close();
return $ret;
}
/*****************ins/up***********************/
public function Update($dat, $adm = FALSE)
{
$ret = FALSE;
if(!$adm && !$GLOBALS['uid'])
return FALSE;
//var_dump($dat);die();
$data = array();
$id = 0;
if (isset($dat['Id'])) {
$id=(int)$dat['Id'];
}
else
return FALSE;
if(isset($dat['Url'])){
$data['Url'] = $this->mav_htmltotext(trim($dat['Url']));
if(!preg_match('~^(?:https?:)?//.*~ius', $data['Url']))
$data['Url'] = 'http://'.ltrim($data['Url'], '/');
}
if(isset($dat['Title']))
$data['Title'] = $this->mav_htmltotext(trim($dat['Title']));
if(isset($dat['Body']))
$data['Body'] = $this->mav_htmltotext(trim($dat['Body']));
if(isset($dat['UserId']))
$data['UserId'] = (int)$dat['UserId'];
if(isset($dat['Approved']))
$data['Approved'] = (int)$dat['Approved'];
if(isset($dat['ApprovedComm']))
$data['ApprovedComm'] = $this->mav_htmltotext(trim($dat['ApprovedComm']));
if(isset($dat['Active']))
$data['Active'] = (int)$dat['Active'];
if(isset($dat['Pol']))
$data['Pol'] = (int)$dat['Pol'];
if(isset($dat['Vozr_min']))
$data['Vozr_min'] = (int)$dat['Vozr_min'];
if(isset($dat['Vozr_max']))
$data['Vozr_max'] = (int)$dat['Vozr_max'];
if(isset($dat['AddDate']))
$data['AddDate'] = (int)$dat['AddDate'];
if(isset($dat['Refer']))
$data['Refer'] = (int)$dat['Refer'];
if(isset($dat['AutoChek'],$dat['AutoChekText'])){
$data['AutoChek'] = (int)$dat['AutoChek'];
if($data['AutoChek'] > 0){
$data['AutoChekText'] = preg_replace('~[\s\t\r\n]~ius', ' ', mb_strtolower(trim($dat['AutoChekText'])));
$data['AutoChekText'] = preg_replace('~[^0-9a-zа-я\*\!\?]~ius', '',$data['AutoChekText']);
if(empty($data['AutoChekText']))
$data['AutoChek'] = 0;
}
}
if(isset($dat['Amount'])){
$data['Amount'] = $this->mav_float($dat['Amount'], 2);
if($data['Amount'] < $this->set['min_price'])
$data['Amount'] = $this->set['min_price'];
}
if(isset($dat['Balans']) && $dat['Balans'] >= 0){
$data['Balans'] = $this->mav_float($dat['Balans']);
}
if(isset($dat['Sort']))
$data['Sort'] = (int)$dat['Sort'];
if(isset($dat['Otvet']))
$data['Otvet'] = $this->mav_htmltotext(trim($dat['Otvet']));
if(isset($dat['Srok']))
$data['Srok'] = (int)$dat['Srok'];
if(isset($dat['Povtor']))
$data['Povtor'] = (int)$dat['Povtor'];
if(isset($dat['CatId']))
$data['CatId'] = (int)$dat['CatId'];
$where_ins = ($adm) ? $id : array('Id' => $id, 'UserId' => $GLOBALS['uid']);
if(!empty($data))
$ret = $this->b_update('mod_task',$data,$where_ins);
return $ret;
}
public function Insert($dat)
{
if(empty($dat['Url']) || empty($dat['Title']) || empty($dat['UserId']) || empty($dat['Amount']))
return FALSE;
$data = array();
if(isset($dat['Url'])){
$data['Url'] = $this->mav_htmltotext(trim($dat['Url']));
if(!preg_match('~^(?:https?:)?//.*~ius', $data['Url']))
$data['Url'] = 'http://'.ltrim($data['Url'], '/');
else
$data['Url'] = $dat['Url'];
}
if(isset($dat['Title']))
$data['Title'] = $this->mav_htmltotext(trim($dat['Title']));
if(isset($dat['Body']))
$data['Body'] = $this->mav_htmltotext(trim($dat['Body']));
if(isset($dat['UserId']))
$data['UserId'] = (int)$dat['UserId'];
if(isset($dat['Pol']))
$data['Pol'] = (int)$dat['Pol'];
if(isset($dat['Vozr_min']))
$data['Vozr_min'] = (int)$dat['Vozr_min'];
if(isset($dat['Vozr_max']))
$data['Vozr_max'] = (int)$dat['Vozr_max'];
$data['Refer'] = isset($dat['Refer']) ? (int)$dat['Refer'] : 0;
$data['Approved'] = isset($dat['Approved']) ? (int)$dat['Approved'] : 0;
$data['Active'] = isset($dat['Active']) ? (int)$dat['Active'] : 1;
$data['Sort'] = $data['AddDate'] = time();
$data['Amount'] = $this->mav_float($dat['Amount'], 2);
if($data['Amount'] < $this->set['min_price'])
$data['Amount'] = $this->set['min_price'];
$data['CatId'] = (int)$dat['CatId'];
if(isset($dat['AutoChek'],$dat['AutoChekText'])){
$data['AutoChek'] = (int)$dat['AutoChek'];
if($data['AutoChek'] > 0){
$data['AutoChekText'] = preg_replace('~[\s\t\r\n]~ius', ' ', mb_strtolower(trim($dat['AutoChekText'])));
$data['AutoChekText'] = preg_replace('~[^0-9a-zа-я\*\!\?]~ius', '',$data['AutoChekText']);
if(empty($data['AutoChekText']))
$data['AutoChek'] = 0;
}
}
if(isset($dat['Balans']) && $dat['Balans'] >= 0)
$data['Balans'] = $this->mav_float($dat['Balans']);
if(isset($dat['Otvet']))
$data['Otvet'] = $this->mav_htmltotext(trim($dat['Otvet']));
if(isset($dat['Srok']))
$data['Srok'] = (int)$dat['Srok'];
if(isset($dat['Povtor']))
$data['Povtor'] = (int)$dat['Povtor'];
//var_dump($data); die();
$id = $this->b_insert('mod_task',$data,0);
return $id;
}
public function Delete($id,$adm = FALSE)
{
$conn = $this->con();
$id=(int)$id;
if($adm)
$q = "DELETE FROM `mod_task` WHERE `Id` = {$id}";
else{
if(!$GLOBALS['uid'])
return FALSE;
$q = "DELETE FROM `mod_task` WHERE `Id` = {$id} AND `UserId` = {$GLOBALS['uid']}";
}
$conn->query($q);
$ret = $conn->affected_rows;
$conn->close();
return $ret;
}
/*****************Дополнительные методы*********/
public function BlackList($UserId){
if(!$GLOBALS['uid'])
return FALSE;
$conn = $this->con();
$UserId = (int)$UserId;
$query = $conn->query("SELECT * FROM `mod_task_ut_black` WHERE UserId = {$GLOBALS['uid']} AND `UserIdBlack` = {$UserId} LIMIT 1");
if (!empty($query) && $query->num_rows){
$row = $query->fetch_assoc();
$conn->query("DELETE FROM `mod_task_ut_black` WHERE UserId = {$GLOBALS['uid']} AND `UserIdBlack` = {$UserId}");
}
else
$conn->query("INSERT INTO `mod_task_ut_black`(`UserId`, `UserIdBlack`) VALUES ({$GLOBALS['uid']},{$UserId})");
$ret = $conn->affected_rows;
$conn->close();
return $ret;
}
public function WhiteList($UserId){
if(!$GLOBALS['uid'])
return FALSE;
$conn = $this->con();
$UserId = (int)$UserId;
$query = $conn->query("SELECT * FROM `mod_task_ut_white` WHERE UserId = {$GLOBALS['uid']} AND `UserIdWhite` = {$UserId} LIMIT 1");
if (!empty($query) && $query->num_rows){
$row = $query->fetch_assoc();
$conn->query("DELETE FROM `mod_task_ut_white` WHERE UserId = {$GLOBALS['uid']} AND `UserIdWhite` = {$UserId}");
}
else
$conn->query("INSERT INTO `mod_task_ut_white`(`UserId`, `UserIdWhite`) VALUES ({$GLOBALS['uid']},{$UserId})");
$ret = $conn->affected_rows;
$conn->close();
return $ret;
}
public function BlockTask($TaskId){
if(!$GLOBALS['uid'])
return FALSE;
$conn = $this->con();
$TaskId = (int)$TaskId;
$query = $conn->query("SELECT * FROM `mod_task_ut_taskblock` WHERE UserId = {$GLOBALS['uid']} AND `TaskId` = {$TaskId} LIMIT 1");
if (!empty($query) && $query->num_rows){
$row = $query->fetch_assoc();
$conn->query("DELETE FROM `mod_task_ut_taskblock` WHERE UserId = {$GLOBALS['uid']} AND `TaskId` = {$TaskId}");
}
else
$conn->query("INSERT INTO `mod_task_ut_taskblock`(`UserId`, `TaskId`) VALUES ({$GLOBALS['uid']},{$TaskId})");
$ret = $conn->affected_rows;
$conn->close();
return $ret;
}
public function GetsWhiteList($f = array(), $startRowIndex=0, $maximumRows=FALSE){
$ret = new Task_model;
if(!$GLOBALS['uid'])
return $ret;
$conn = $this->con();
$lim = $maximumRows ? 'LIMIT '.(int)$startRowIndex.', '.(int)$maximumRows : 'LIMIT 300';
$where = '';
if(!empty($f)){
$w = '';
if(isset($f['Login']))
array_push($w, "u.Login = '".$conn->real_escape_string($f['Login'])."'");
if(!empty($w)){
$where = ' AND ' .implode(' AND ', $w);
unset($w);
}
}
$q = "SELECT u.login as Login,u.id as Id FROM `db_users` as u LEFT JOIN `mod_task_ut_white` as l ON(u.id = l.UserIdWhite AND l.UserId = {$GLOBALS['uid']}) where l.UserId IS NOT NULL {$where} GROUP BY u.id";
$query = $conn->query($q);
if (!empty($query) && $query->num_rows)
{
$ret->data = $this->convertList($query);
if($maximumRows){
$query2 = $conn->query("SELECT COUNT(*) FROM `db_users` as u LEFT JOIN `mod_task_ut_white` as l ON(u.id = l.UserIdWhite AND l.UserId = {$GLOBALS['uid']}) where l.UserId IS NOT NULL {$where} GROUP BY u.id");
if(!empty($query2) && $query2->num_rows){
$ret->count = (int)$query2->fetch_array()[0];
$query2->close();
}
}
}
$conn->close();
return $ret;
}
public function GetsBlackList($f = array(), $startRowIndex=0, $maximumRows=FALSE){
$ret = new Task_model;
if(!$GLOBALS['uid'])
return $ret;
$conn = $this->con();
$lim = $maximumRows ? 'LIMIT '.(int)$startRowIndex.', '.(int)$maximumRows : 'LIMIT 300';
$where = '';
if(!empty($f)){
$w = '';
if(isset($f['Login']))
array_push($w, "u.Login = '".$conn->real_escape_string($f['Login'])."'");
if(!empty($w)){
$where = ' AND ' .implode(' AND ', $w);
unset($w);
}
}
$q = "SELECT u.login as Login,u.id as Id FROM `db_users` as u LEFT JOIN `mod_task_ut_black` as l ON(u.id = l.UserIdBlack AND l.UserId = {$GLOBALS['uid']}) where l.UserId IS NOT NULL {$where} GROUP BY u.id";
$query = $conn->query($q);
if (!empty($query) && $query->num_rows)
{
$ret->data = $this->convertList($query);
if($maximumRows){
$query2 = $conn->query("SELECT COUNT(*) FROM `db_users` as u LEFT JOIN `mod_task_ut_black` as l ON(u.id = l.UserIdBlack AND l.UserId = {$GLOBALS['uid']}) where l.UserId IS NOT NULL {$where} GROUP BY u.id");
if(!empty($query2) && $query2->num_rows){
$ret->count = (int)$query2->fetch_array()[0];
$query2->close();
}
}
}
$conn->close();
return $ret;
}
public function GetsBlockTask(){}
private function convert(&$query)
{
$row = $query->fetch_assoc();
if(empty($row)){
$query->close();
return NULL;
}
else
{
$query->close();
if(isset($row['Amount']))
$row['AmountPer'] = $row['Amount'] + $row['Amount']*($this->set['per'] / 100);
return $row;
}
}
private function convertList(&$query)
{
$ret = array();
while($row = $query->fetch_assoc()){
if(isset($row['Amount']))
$row['AmountPer'] = $row['Amount'] + $row['Amount']*($this->set['per'] / 100);
array_push($ret, $row);
}
$query->close();
return $ret;
}
/***************Blok*******************************/
public function ChBlok(){
$ret = FALSE;
$conn = $this->con();
$query = $conn->query("SELECT * FROM `mod_task_user_block` WHERE `UserId` = {$GLOBALS['uid']} LIMIT 1");
if (!empty($query) && $query->num_rows > 0){
$ret = TRUE;
$query->close();
}
$conn->close();
return $ret;
}
public function ChBlokComm(){
$conn = $this->con();
$ret = FALSE;
$query = $conn->query("SELECT * FROM `mod_task_user_block` WHERE `UserId` = {$GLOBALS['uid']} LIMIT 1");
if (!empty($query) && $query->num_rows > 0){
$ret['Blok'] = TRUE;
$row = $query->fetch_assoc();
$ret['Comm'] = $row['Comm'];
$query->close();
}
$conn->close();
return $ret;
}
public function InsertUBlok($id,$Comm = ''){
return $this->b_insert('mod_task_user_block',array('UserId' => (int)$id,'Comm' => $Comm));
}
public function DeletUBlok($id){
$conn = $this->con();
$ret = $conn->query("DELETE FROM `mod_task_user_block` WHERE `UserId` = {$id}");
$conn->close();
return $ret;
}
public function GetsUBlok($f = array(), $startRowIndex=0, $maximumRows=FALSE,$desc = NULL)
{
$conn = $this->con();
$ret = new Task_model;
$where = '';
$select = '';
$join = '';
$lim = $maximumRows ? 'LIMIT '.(int)$startRowIndex.', '.(int)$maximumRows : 'LIMIT 300';
if(empty($desc))
$desc = 't.`UserId` DESC';
else
{
$desc = $conn->real_escape_string($desc);
$ar = explode(' ', trim($desc));
if (isset($ar[1]))
$desc = 't.`'.$ar[0].'` DESC';
else
$desc = 't.`'.$ar[0].'`';
}
if(!empty($f)){
$w = array();
if(isset($f['UserId']))
array_push($w, "t.UserId = ".(int)$f['UserId']);
/****************************************************/
if(!empty($w)){
$where = ' WHERE ' .implode(' AND ', $w);
unset($w);
}
}
$q = "SELECT
t.*,u.login
FROM `mod_task_user_block` as t
LEFT JOIN db_users as u ON(u.id = t.UserId)
{$where} ORDER BY {$desc} {$lim}";
//die($q);
$query = $conn->query($q);
if (!empty($query) && $query->num_rows)
{
$ret->data = $this->convertList($query);
if($maximumRows){
$query2 = $conn->query("SELECT COUNT(*) FROM `mod_task_user_block` as r {$where}");
if(!empty($query2) && $query2->num_rows){
$ret->count = (int)$query2->fetch_array()[0];
$query2->close();
}
}
}
$conn->close();
return $ret;
}
/***************Cats*******************************/
/*function GetCatByID(){
$ret = array();
$query = $conn->query("SELECT * FROM `mod_task_cat`");
if (!empty($query))
{
while($row = $query->fetch_assoc()){
$id = $row['Id'];
unset($row['Id']);
$ret[$id] = $row;
}
}
return $ret;
}*/
function GetsCat(){
$conn = $this->con();
$ret = array();
$query = $conn->query("SELECT * FROM `mod_task_cat`");
if (!empty($query))
{
while($row = $query->fetch_assoc()){
$id = $row['Id'];
unset($row['Id']);
$ret[$id] = $row;
}
}
$conn->close();
return $ret;
}
function InsertCat($dat){
$ret = FALSE;
$data = array();
if(isset($dat['Title']))
$data['Title'] = $this->mav_htmltotext(trim($dat['Title']));
else
return $ret;
if(isset($dat['Body']))
$data['Body'] = $this->mav_htmltotext(trim($dat['Body']));
$ret = $this->b_insert('mod_task_cat',$data);
return $ret;
}
function UpdateCat($dat){
if(empty($dat['Id']))
return FALSE;
$ret = FALSE;
$data = array();
if(isset($dat['Title']))
$data['Title'] = $this->mav_htmltotext(trim($dat['Title']));
if(isset($dat['Body']))
$data['Body'] = $this->mav_htmltotext(trim($dat['Body']));
if(!empty($data))
$ret = $this->b_update('mod_task_cat',$data,$dat['Id']);
return $ret;
}
function DeletCat($id){
$conn = $this->con();
$id=(int)$id;
$ret = $conn->query("DELETE FROM `mod_task_cat` WHERE `Id` = ".(int)$id);
$conn->close();
return $ret;
}
/*******************************User********************************************************/
public function GetsU($f = array(), $startRowIndex=0, $maximumRows=FALSE,$desc = NULL)
{
$conn = $this->con();
$ret = new Task_model;
$lim = $maximumRows ? 'LIMIT '.(int)$startRowIndex.', '.(int)$maximumRows : 'LIMIT 300';
if(empty($desc)){
$desc = 't.`Id` DESC';
}
elseif($desc == 'rand')
$desc = 'RAND()';
elseif($desc == 'Status')
$desc = 't.`Status`, t.`EndDate`';
else
{
$desc = $conn->real_escape_string($desc);
$ar = explode(' ', trim($desc));
if (isset($ar[1]))
$desc = 't.`'.$ar[0].'` DESC';
else
$desc = 't.`'.$ar[0].'`';
}
$where = '';
$select = '';
$join = '';
if(!empty($f)){
$w = array();
if(isset($f['Id']))
array_push($w, "t.Id = ".(int)$f['Id']);
if(isset($f['UserId']))
array_push($w, "t.UserId = ".(int)$f['UserId']);
if(isset($f['TaskId']))
array_push($w, "t.TaskId = ".(int)$f['TaskId']);
if(isset($f['Status']))
array_push($w, "t.Status = ".(int)$f['Status']);
if(isset($f['s'])){
$s = $conn->real_escape_string($f['s']);
array_push($w, "(t.`Url` LIKE '%{$s}%' OR t.`Title` LIKE '%{$s}%')");
}
/****************Избранное*************************/
if(isset($f['Fav'])){
$select .= ', IF(lw.UserId IS NULL,0,1) as Fav';
$join .= "LEFT JOIN `mod_task_ut_white` as lw on(lw.UserIdWhite = task.UserId AND lw.UserId = t.UserId)";
}
/****************ЧС*************************/
if(isset($f['BlackList'])){
$select .= ', IF(lb.UserId IS NULL,0,1) as BlackList';
$join .= "LEFT JOIN `mod_task_ut_black` as lb on(lb.UserIdBlack = task.UserId AND lb.UserId = t.UserId)";
}
/****************************************************/
if(!empty($w)){
$where = ' WHERE ' .implode(' AND ', $w);
unset($w);
}
}
///Здесь усерИд заданиста в исполнители
$q = "SELECT ti.*, t.*, t.Id, IF(blok.UserId IS NULL, 0, 1) as Blok, u.login, taskuser.login as TaskUserLogin {$select}
FROM `mod_task_user` as t
LEFT JOIN `mod_task_user_item` as ti ON(ti.Id = t.Id)
LEFT JOIN db_users as u on(u.id = t.UserId)
LEFT JOIN mod_task_user_block as blok on(t.UserId = blok.UserId)
LEFT JOIN mod_task as task on(task.Id = t.TaskId)
LEFT JOIN db_users as taskuser on(taskuser.id = t.TaskUserId)
{$join}
{$where} ORDER BY {$desc} {$lim}";
$query = $conn->query($q);
//die($q);
if (!empty($query) && $query->num_rows)
{
$ret->data = $this->convertList($query);
if($maximumRows){
$query2 = $conn->query("SELECT COUNT(t.Id) FROM `mod_task_user` as t LEFT JOIN `db_users` as u on(u.id = t.UserId) {$where}");
if(!empty($query2) && $query2->num_rows){
$ret->count = (int)$query2->fetch_array()[0];
$query2->close();
}
}
}
$conn->close();
return $ret;
}
public function GetByIDU($id, $UserId = FALSE)
{
$conn = $this->con();
$ret = NULL;
$w = 't.Id = '.(int)$id;
$jn = '';
if(!empty($UserId))
$w .= " AND t.UserId = ".(int)$UserId;
$q = "SELECT
ti.*, t.*, t.Id, ti.Id as IId, u.login as Login,
cat.Title as CatTitle, taskuser.login as TaskUserLogin
FROM `mod_task_user` as t
LEFT JOIN `mod_task_user_item` as ti ON(ti.Id = t.Id)
LEFT JOIN db_users as u on(u.id = t.UserId)
LEFT JOIN mod_task_cat as cat on(cat.Id = ti.CatId)
LEFT JOIN db_users as taskuser on(taskuser.id = t.TaskUserId)
WHERE {$w} LIMIT 1
";
//die($q);
$query = $conn->query($q);
if (!empty($query) && $query->num_rows)
$ret = $this->convert($query);
$conn->close();
return $ret;
}
public function GetByIDU_r($id)
{
$conn = $this->con();
$ret = NULL;
$w = 'tu.Id = '.(int)$id;
$q = "SELECT tu.*, t.Balans as TaskBalans FROM `mod_task_user` as tu
LEFT JOIN mod_task as t on(t.Id = tu.TaskId)
WHERE {$w} LIMIT 1
";
$query = $conn->query($q);
if (!empty($query) && $query->num_rows)
$ret = $this->convert($query);
$conn->close();
return $ret;
}
function chCount(){
$conn = $this->con();
$ret = 0;
$query = $conn->query("SELECT count(*) FROM `mod_task_user` WHERE `UserId` = {$GLOBALS['uid']} AND `Status` < 4");
if (!empty($query) && $query->num_rows > 0){
$ret = (int)$query->fetch_array()[0];
$query->close();
}
$conn->close();
return $ret;
}
function MyTek(){
$ret = array(
'tek' => array(),
'wait' => 0,
);
if(!$GLOBALS['uid'])
return $ret;
$conn = $this->con();
$q = "SELECT tu.*,ti.Dorabotka FROM `mod_task_user` as tu
LEFT JOIN `mod_task_user_item` as ti ON(ti.Id = tu.Id)
WHERE tu.`UserId` = {$GLOBALS['uid']} AND tu.`Status` < 4 ORDER BY tu.`EndDate` DESC LIMIT 50";
$query = $conn->query($q);
//die($q);
if (!empty($query) && $query->num_rows)
{
while($row = $query->fetch_assoc()){
$row['Status'] = (int)$row['Status'];
if($row['Status'] === 1 || $row['Status'] === 3){
if($row['Status'] === 1)
unset($row['Dorabotka']);
array_push($ret['tek'], $row);
}
else
$ret['wait']++;
}
}
$conn->close();
return $ret;
}
/*****************ins/up***********************/
public function UpdateU($dat, $adm = FALSE)
{
$ret = FALSE;
if(!$adm && !$GLOBALS['uid'])
return FALSE;
//var_dump($dat);die();
$data = array();
$data2 = array();
$id = 0;
if (isset($dat['Id'])) {
$id=(int)$dat['Id'];
}
else
return FALSE;
if(isset($dat['Url'])){
$data2['Url'] = $this->mav_htmltotext(trim($dat['Url']));
if(!preg_match('~^(?:https?:)?//.*~ius', $data2['Url']))
$data2['Url'] = 'http://'.ltrim($data2['Url'], '/');
}
if(isset($dat['Title']))
$data['Title'] = $this->mav_htmltotext(trim($dat['Title']));
if(isset($dat['Body']))
$data2['Body'] = $this->mav_htmltotext(trim($dat['Body']));
/*if(isset($dat['UserId']))
$data['UserId'] = (int)$dat['UserId'];*/
if(isset($dat['Status']))
$data['Status'] = (int)$dat['Status'];
if(isset($dat['OtchetDate']))
$data['OtchetDate'] = (int)$dat['OtchetDate'];
if(isset($dat['Otchet']))
$data2['Otchet'] = $this->mav_htmltotext(trim($dat['Otchet']));
if(isset($dat['Dorabotka']))
$data2['Dorabotka'] = $this->mav_htmltotext(trim($dat['Dorabotka']));
if(isset($dat['AddDate']))
$data['AddDate'] = (int)$dat['AddDate'];
if(isset($dat['EndDate']))
$data['EndDate'] = (int)$dat['EndDate'];
if(isset($dat['CatId']))
$data2['CatId'] = (int)$dat['CatId'];
if(isset($dat['Amount'])){
$data['Amount'] = $this->mav_float($dat['Amount'], 2);
if($data['Amount'] <= 0)
$data['Amount'] = 0.01;
}
if(isset($dat['Rat']))
$data['Rat'] = $dat['Rat'];
if(isset($dat['BlokMess']))
$data2['BlokMess'] = trim($dat['BlokMess']);
$where_ins = ($adm) ? $id : array('Id' => $id, 'UserId' => $GLOBALS['uid']);
if(!empty($data))
$ret = $this->b_update('mod_task_user',$data,$where_ins);
if(!empty($data2))
$ret = $this->b_update('mod_task_user_item',$data2,$id);
return $ret;
}
public function InsertU($dat)
{
if(empty($dat['Url']) || empty($dat['Title']) || empty($dat['UserId']) || empty($dat['TaskId']) || empty($dat['TaskUserId']))
return FALSE;
$data = array();
$data2 = array();
$data2['Url'] = $this->mav_htmltotext(trim($dat['Url']));
if(!preg_match('~^(?:https?:)?//.*~ius', $data2['Url']))
$data2['Url'] = 'http://'.ltrim($data2['Url'], '/');
$data['Title'] = $this->mav_htmltotext(trim($dat['Title']));
$data['UserId'] = (int)$dat['UserId'];
$data['Status'] = 1;
$data['TaskId'] = (int)$dat['TaskId'];
$data['TaskUserId'] = (int)$dat['TaskUserId'];
$data2['Otchet'] = '';
$data2['Dorabotka'] = '';
$data['AddDate'] = $data2['OkDate'] = time();
if(isset($dat['EndDate']))
$data['EndDate'] = (int)$dat['EndDate'];
if(isset($dat['Otvet']))
$data2['Otvet'] = $this->mav_htmltotext(trim($dat['Otvet']));
if(isset($dat['CatId']))
$data2['CatId'] = (int)$dat['CatId'];
if(isset($dat['Body']))
$data2['Body'] = $this->mav_htmltotext(trim($dat['Body']));
if(isset($dat['Amount'])){
$data['Amount'] = $this->mav_float($dat['Amount'], 2);
if($data['Amount'] <= 0)
$data['Amount'] = 0.01;
}
$data['AutoChek'] = isset($dat['AutoChek']) ? (int)$dat['AutoChek'] : 0;
if(!empty($data['AutoChek'])){
if(empty($dat['AutoChekText']))
$data['AutoChek'] = 0;
else
$data2['AutoChekText'] = $dat['AutoChekText'];
}
//var_dump($data); die();
$id = $this->b_insert('mod_task_user',$data,0);
if($id > 0){
$data2['Id'] = $id;
if(!$this->b_insert('mod_task_user_item',$data2)){
$this->DeleteU($id);
return FALSE;
}
}
return $id;
}
public function DeleteU($id,$adm = FALSE)
{
$conn = $this->con();
$id=(int)$id;
if($adm)
$q = "DELETE FROM `mod_task_user` WHERE `Id` = {$id}";
else{
if(!$GLOBALS['uid'])
return FALSE;
$q = "DELETE FROM `mod_task_user` WHERE `Id` = {$id} AND `UserId` = {$GLOBALS['uid']}";
}
$conn->query($q);
$ret = $conn->affected_rows;
if($ret){
$ret = $conn->query("DELETE FROM `mod_task_user_item` WHERE `Id` = {$id}");
}
$conn->close();
return $ret;
}
/********************************************/
public function mav_htmltotext($t, $amp = 0)
{
if($amp)
$t = str_replace("&", "&", $t);
$ar1 = array("\"","<",">","'","\\"); $ar2 = array(""","<",">","'","\");
$t = str_replace($ar1,$ar2,$t);
return $t;
}
public function mav_float($sum,$round = FALSE){
$sum = (float)$sum;
//if($sum < 0.0001)
// return FALSE;
$sum = trim($sum);
$sum = preg_replace('~[^0-9\.\,\-]~ius', '', $sum);
$sum = preg_replace('~,~ius', '.', $sum);
if($round !== FALSE)
$sum = round($sum, $round, PHP_ROUND_HALF_UP);
return $sum;
}
private function b_insert($table,$data,$ch = TRUE){
$conn = $this->con();
$k = array();
$v = array();
foreach ($data as $key => $val) {
$t = gettype($val);
if($t != "boolean" && $t != "integer" && $t != "double")
$val = "'".$conn->real_escape_string($val)."'";
elseif ($t == "double")
$val = str_replace(',', '.', $val);
array_push($k, '`'.$conn->real_escape_string(trim($key)).'`');
array_push($v, $val);
}
$sql = 'INSERT INTO `'.$conn->real_escape_string(trim($table)).'` ('.implode(',', $k).') VALUES ('.implode(',', $v).')';
$ret = 0;
//echo $sql.'<br/>';
//die($sql);
if($conn->query($sql))
$ret = !$conn->insert_id ? TRUE : $conn->insert_id;
$conn->close();
return $ret;
}
private function b_update($table,$data,$id,$ch = TRUE){
$conn = $this->con();
$k = array();
foreach ($data as $key => $val) {
$t = gettype($val);
if($t != "boolean" && $t != "integer" && $t != "double")
$val = "'".$conn->real_escape_string($val)."'";
elseif ($t == "double")
$val = str_replace(',', '.', $val);
$key = $conn->real_escape_string($key);
array_push($k, "`{$key}` = {$val}");
}
$w = '';
if(is_array($id)){
$t_ar = array();
foreach ($id as $key => $val) {
$t = gettype($val);
if($t != "boolean" && $t != "integer" && $t != "double")
$val = "'".$conn->real_escape_string($val)."'";
elseif ($t == "double")
$val = str_replace(',', '.', $val);
$key = $conn->real_escape_string($key);
array_push($t_ar, "`{$key}` = {$val}");
}
if(empty($t_ar))
return FALSE;
$w = implode(' AND ', $t_ar);
}
else
$w = '`Id` = '.(int)$id;
$sql = 'UPDATE `'.$conn->real_escape_string(trim($table)).'` SET '.implode(',', $k).' WHERE '.$w;
$ret = $conn->query($sql);
/*var_dump($mysqli->error);
die($sql);*/
$conn->close();
return ($ret > 0) ? TRUE : FALSE;
}
private function b_chek($table, $key, $val)
{
$conn = $this->con();
$ret = FALSE;
$t = gettype($val);
if($t != "boolean" && $t != "integer" && $t = "double")
$val = "'".$conn->real_escape_string($val)."'";
elseif ($t == "double")
$val = str_replace(',', '.', $val);
$key = $conn->real_escape_string($key);
$query = $conn->query("SELECT * FROM ".$conn->real_escape_string(trim($table))." WHERE `{$key}` = {$val} LIMIT 1");
if (!empty($query) && $query->num_rows > 0){
$ret = TRUE;
$query->close();
}
$conn->close();
return $ret;
}
public function views($f,$w){
if(!empty($_POST['aj']))
ob_end_clean();
extract($w);
include($f);
}
public function form_redirect_send($mess,$url = ''){
if(isset($_POST['aj']))
return $mess;
$_SESSION['form_redirect'] = $mess;
if(empty($url))
$url = $_SERVER['REQUEST_URI']; // $_SERVER['SERVER_NAME'].'/'.
$url = trim($url,'/');
header("HTTP/1.0 302");
if(strpos($url,'://') === FALSE){
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
header("Location: {$protocol}{$_SERVER['SERVER_NAME']}/{$url}");
}
else
header("Location: {$url}");
die();
}
public function form_mess($mess){
if(isset($_POST['aj'])) {
return $mess;
$_SESSION['form_redirect'] = $mess;
}
die();
}
public function form_redirect(){
if(empty($_SESSION['form_redirect']))
return '';
$ret = $_SESSION['form_redirect'];
unset($_SESSION['form_redirect']);
return $ret;
}
public function MoneyPlus($id,$sum){
return $GLOBALS['db']->query("UPDATE db_users SET money_p = money_p + '$sum' WHERE id = '$id'");
}
/*public function MoneyMinus($id,$sum){
$GLOBALS['db']->query('UPDATE db_users SET money_b = money_b - ? WHERE id = ?', $sum, $id);
}*/
public function TaskDone($sum,$id){
return $GLOBALS['db']->query('UPDATE db_users SET task_done = task_done + ? WHERE id = ?', $sum, $id);
}
public function RMoneyPlus($id,$sum){
return $GLOBALS['db']->query('UPDATE db_users SET money_b = money_b + ? WHERE id = ?', $sum, $id);
}
public function RMoneyMinus($id,$sum){
return $GLOBALS['db']->query('UPDATE db_users SET money_b = money_b - ? WHERE id = ?', $sum, $id);
}
public function getpager($startpag,$pagevis,$count,$action, $jsfunc = 'pager')
{
$ret = '';
if($count > $pagevis)
{
if($startpag > 0)
{
$rt = ($startpag/$pagevis);
$ret .= "<a onclick=\"{$jsfunc}({$rt}); return false;\" href=\"#\" title=\"Предыдущая\"><< Предыдущая</a>";
}
$tempi = array();
for($i=$startpag;$i>=0;$i=$i-$pagevis)
{
$tempi[$i] = $i;
if(count($tempi)>4)
break;
}
asort($tempi);
for($i=($startpag+$pagevis);$i<$count;$i=$i+$pagevis) {
$tempi[$i] = $i;
if(count($tempi)>9)
break;
}
foreach ($tempi as $key => $value)
{
$ii = ($key === 0) ? 1 : ($key/$pagevis)+1;
if($startpag == $key)
$ret .= "<span data-tpagspan=\"{$ii}\">{$ii}</span>";
else{
$ret .= "<a onclick=\"{$jsfunc}({$ii}); return false;\" href=\"#\" title=\"{$ii}\">{$ii}</a>";
}
}
if($startpag < $count-$pagevis)
{
$rt = ($startpag === 0) ? 2 : ($startpag/$pagevis)+1;
$ret .= "<a onclick=\"{$jsfunc}({$rt}); return false;\" href=\"#\" title=\"Следующая\">Следующая >></a>";
}
$ret = '<div class="pager">'.$ret.'</div>';
}
return $ret;
}
/*******************************cron********************************************************/
public function cron(){
$crond_ok = file_get_contents(F.'core/mav/task_cron');
$crond_ok = (int)$crond_ok;
$time = time();
$conn = $this->con();
/*****************Раз в сутки***************************/
if($crond_ok < ($time - 60*60*24)){
$sut = time() - 60*60*24;
$query = $conn->query("SELECT Id FROM `mod_task_user` WHERE EndDate < {$sut} AND Status = 5");
if (!empty($query) && $query->num_rows) {
while($row = $query->fetch_assoc()){
$this->DeleteU($row['Id'],TRUE);
}
}
/*********Удаление старых исполнителей****/
$conn->query("DELETE FROM `mod_task_user_item` WHERE `OkDate` < ".($time-60*60*24*30));
}
/************если время на провеку закончилось: одобрить и заплатить*****************/
$tm = $time - 60*60*$this->set['chtime'];
$q = "SELECT Id, `TaskId`, `UserId`, `Amount` FROM `mod_task_user` WHERE OtchetDate < {$tm} AND Status = 2 ";
$query = $conn->query($q);
if (!empty($query))
{
while($row = $query->fetch_assoc())
{
$ar = array(
'Id' => $row['Id'],
'Status' => 4,
);
if($this->UpdateU($ar,TRUE)){
$this->MoneyPlus($row['UserId'],$row['Amount']);
}
}
$query->close();
}
/**************************Если просрочил задание: Вернуть средства и установить просрочено**************/
/* $q = "SELECT `Id`, `TaskId`,`UserId`, `Amount` FROM `mod_task_user` WHERE EndDate < {$time} AND (Status = 1 OR Status = 3)";
$query = $conn->query($q);
if (!empty($query)){
if($query->num_rows > 0) {
while($row = $query->fetch_assoc()){
//if($conn->query("UPDATE `mod_task_user` SET `Status` = 5 WHERE `Id` = ".$row['Id'])){
$id_status = $row['Id'];
$id_task = $row['TaskId'];
$conn->query("UPDATE `mod_task_user` SET `Status` = 5 WHERE `Id` = '$id_status'", false, false);
$bal = $row['Amount']+$row['Amount']*($this->set['per'] / 100);
file_put_contents(F.'core/mav/task_log_cron', $row['Amount']." - UPDATE `mod_task` SET `Balans` = `Balans` + {$bal} WHERE `Id` = ".$id_task." Айди отчета юзера: ".$id_status." Юзера айди: ".$row['UserId']."\n\n", FILE_APPEND);
//file_put_contents(F.'core/mav/task_log_cron', var_dump($row). "\n\n", FILE_APPEND);
$conn->query("UPDATE `mod_task` SET `Balans` = `Balans` + {$bal} WHERE `Id` = '$id_task'", false, false);
$conn->close();
//}
}
}
}*/
$row = $this->db->query("SELECT `Id`, `TaskId`,`UserId`, `Amount` FROM `mod_task_user` WHERE EndDate < UNIX_TIMESTAMP() AND (Status = 1 OR Status = 3)");
if($row->numRows() > 0){
foreach($result = $row->fetchAll() as $result){
$id_status = $result['Id'];
$id_task = $result['TaskId'];
$this->db->query("UPDATE `mod_task_user` SET `Status` = '5' WHERE `Id` = '$id_status'", false, false);
$bal = $result['Amount']+$result['Amount']*($this->set['per'] / 100);
file_put_contents(F.'core/mav/task_log_cron', $result['Amount']." - UPDATE `mod_task` SET `Balans` = `Balans` + {$bal} WHERE `Id` = ".$id_task." Айди отчета юзера: ".$id_status." Юзера айди: ".$result['UserId']."\n\n", FILE_APPEND);
$this->db->query("UPDATE `mod_task` SET `Balans` = `Balans` + '$bal' WHERE `Id` = '$id_task'", false, false);
}
//$this->db->close();
}
/*********запись об успехе****************/
file_put_contents(F.'core/mav/task_cron', $time);
/*****************************************/
$conn->close();
return TRUE;
}
}