Файл: modules/magaz/admin.php
Строк: 232
<?
if(isset($user) && $user['level'] > 6) {
$locate = 'in_magaz';
switch ($_GET['mod']) {
default:
$title = 'Админ-панель Магазин';
require_once(SYS.'/view/header.php');
$tpl->div('title', 'Админ-панель Магазин');
$mt = $db->query("SELECT * FROM `magaz_tovar` WHERE `pod` = '0'")->rowCount();
$mr = $db->query("SELECT * FROM `magaz_tovar` WHERE `pod` = '2'")->rowCount();
$delete = $db->query("SELECT * FROM `magaz_tovar` WHERE `pod` = '3'")->rowCount();
$op = $db->query("SELECT * FROM `operation` WHERE `pod` = '0'")->rowCount();
$tpl->div('menu',img('money_safe.png') .'<a href="/magaz/admin?mod=act">Активация товаров</a> '.($mt > 0 ? '[+'.$mt.']':NULL).'<br/>');
$tpl->div('menu',img('money_safe.png') .'<a href="/magaz/admin?mod=tovar">Модерация измененных товаров</a> '.($mr > 0 ? '[+'.$mr.']':NULL).'<br/>');
$tpl->div('menu',img('money_safe.png') .'<a href="/magaz/admin?mod=del">Модерация удаления товаров</a> '.($delete > 0 ? '[+'.$delete.']':NULL).'<br/>');
$tpl->div('menu',img('6.png') .'<a href="/magaz/admin?mod=wmr">Подтверждение ввода/вывода средств</a> '.($op > 0 ? '[+'.$op.']':NULL).'<br/>');
$tpl->div('block',img('shop.png') .'<a href="/magaz/">Магазин</a><br/>'. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
break;
case 'act':
$title = 'Активация товаров';
require_once(SYS.'/view/header.php');
$tpl->div('title', 'Активация товаров');
if (isset($_GET['pod']) && $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '".abs(intval($_GET['pod']))."'")->rowCount() !=0) {
$db->query("UPDATE `magaz_tovar` SET `pod` = '1' WHERE `id` = '".abs(intval($_GET['pod']))."'");
$fid = $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '". abs(intval($_GET['pod'])) ."'")->fetch();
$db->query("INSERT INTO `notify` SET `user_id` = '". $fid['user'] ."', `from_id` ='". $user['id'] ."', `request_id` = '". $fid['id'] ."', `type` = 'magaz_act', `read` = '0', `time` = '". time() ."'");
echo $tpl->div('menu', '<center>Товар успешно активирован</center>');
}
if (isset($_GET['del']) && $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '".abs(intval($_GET['del']))."'")->rowCount() !=0) {
$fid = $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '". abs(intval($_GET['del'])) ."'")->fetch();
unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['file']);
if ($file['src_1'] != NULL) unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['src_1']);
if ($file['src_2'] != NULL) unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['src_2']);
if ($file['src_3'] != NULL) unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['src_3']);
$db->query("DELETE FROM `magaz_tovar` WHERE `id` = '". $fid['id'] ."'");
$db->query("DELETE FROM `magaz_s` WHERE `uid` = '". $fid['id'] ."'");
$db->query("DELETE FROM `magaz_k` WHERE `uid` = '". $fid['id'] ."'");
$db->query("INSERT INTO `notify` SET `user_id` = '". $fid['user'] ."', `from_id` ='". $user['id'] ."', `request_id` = '". $fid['id'] ."', `type` = 'magaz_del', `read` = '0', `time` = '". time() ."'");
echo $tpl->div('menu', '<center>Товар успешно удален</center>');
}
$magaz_t = $db->query("SELECT * FROM `magaz_tovar` WHERE `pod` = '0'")->rowCount();
$pages = new Paginator($magaz_t, $ames);
if($magaz_t == 0) {
echo $tpl->div('menu', '<center>Нет товаров</center>');
}
else {
$magaz_tt = $db->query("SELECT * FROM `magaz_tovar` WHERE `pod` = '0' ORDER BY `id` LIMIT $start, $ames");
while($magaz_t = $magaz_tt->fetch()) {
echo '<div class="menu">';
if (!empty($magaz_t['src_1'])) { echo '<img src="/files/magaz/'. $magaz_t['path'] .'/'.$magaz_t['src_1'].'" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
else if (empty($magaz_t['src_2'])) { echo '<img src="/files/magaz/'. $magaz_t['path'] .'/'.$magaz_t['src_2'].'" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
else if (empty($magaz_t['src_3'])) { echo '<img src="/files/magaz/'. $magaz_t['path'] .'/'.$magaz_t['src_3'].'" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
else { echo '<img src="/template/icons/no.png" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
echo 'Название: <a href="/magaz/file/'. $magaz_t['id'] .'/">'. $magaz_t['name'] .'</a><br/>Описание: '. rez_text($magaz_t['text']) .'<br/>Цена: <font color="green">'. $magaz_t['wmr'] .'руб.</font><br/><a href="/magaz/admin?mod=act&pod='. $magaz_t['id'] .'/">Активировать</a> | <a href="/magaz/admin?mod=act&del='. $magaz_t['id'] .'/">Удалить</a></div>';
}
$pages->view('/magaz/admin?mod=act&');
}
$tpl->div('block',img('admin.png') .'<a href="/magaz/admin">Админ-панель</a><br/>'. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
break;
case 'tovar':
$title = 'Модерация измененных товаров';
require_once(SYS.'/view/header.php');
$tpl->div('title', 'Модерация измененных товаров');
if (isset($_GET['pod']) && $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '".abs(intval($_GET['pod']))."'")->rowCount() !=0) {
$db->query("UPDATE `magaz_tovar` SET `pod` = '1' WHERE `id` = '".abs(intval($_GET['pod']))."'");
$fid = $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '". abs(intval($_GET['pod'])) ."'")->fetch();
$db->query("INSERT INTO `notify` SET `user_id` = '". $fid['user'] ."', `from_id` ='". $user['id'] ."', `request_id` = '". $fid['id'] ."', `type` = 'magaz_act', `read` = '0', `time` = '". time() ."'");
echo $tpl->div('menu', '<center>Товар успешно активирован</center>');
}
if (isset($_GET['del']) && $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '".abs(intval($_GET['del']))."'")->rowCount() !=0) {
$fid = $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '". abs(intval($_GET['del'])) ."'")->fetch();
unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['file']);
if ($file['src_1'] != NULL) unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['src_1']);
if ($file['src_2'] != NULL) unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['src_2']);
if ($file['src_3'] != NULL) unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['src_3']);
$db->query("DELETE FROM `magaz_tovar` WHERE `id` = '". $fid['id'] ."'");
$db->query("DELETE FROM `magaz_s` WHERE `uid` = '". $fid['id'] ."'");
$db->query("DELETE FROM `magaz_k` WHERE `uid` = '". $fid['id'] ."'");
$db->query("INSERT INTO `notify` SET `user_id` = '". $fid['user'] ."', `from_id` ='". $user['id'] ."', `request_id` = '". $fid['id'] ."', `type` = 'magaz_del', `read` = '0', `time` = '". time() ."'");
echo $tpl->div('menu', '<center>Товар успешно удален</center>');
}
$magaz_t = $db->query("SELECT * FROM `magaz_tovar` WHERE `pod` = '2'")->rowCount();
$pages = new Paginator($magaz_t, $ames);
if($magaz_t == 0) {
echo $tpl->div('menu', '<center>Нет товаров</center>');
}
else {
$magaz_tt = $db->query("SELECT * FROM `magaz_tovar` WHERE `pod` = '2' ORDER BY `id` LIMIT $start, $ames");
while($magaz_t = $magaz_tt->fetch()) {
echo '<div class="menu">';
if (!empty($magaz_t['src_1'])) { echo '<img src="/files/magaz/'. $magaz_t['path'] .'/'.$magaz_t['src_1'].'" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
else if (empty($magaz_t['src_2'])) { echo '<img src="/files/magaz/'. $magaz_t['path'] .'/'.$magaz_t['src_2'].'" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
else if (empty($magaz_t['src_3'])) { echo '<img src="/files/magaz/'. $magaz_t['path'] .'/'.$magaz_t['src_3'].'" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
else { echo '<img src="/template/icons/no.png" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
echo 'Название: <a href="/magaz/file/'. $magaz_t['id'] .'/">'. $magaz_t['name'] .'</a><br/>Описание: '. rez_text($magaz_t['text']) .'<br/>Цена: <font color="green">'. $magaz_t['wmr'] .'руб.</font><br/><a href="/magaz/admin?mod=tovar&pod='. $magaz_t['id'] .'/">Активировать</a> | <a href="/magaz/admin?mod=tovar&del='. $magaz_t['id'] .'/">Удалить</a></div>';
}
$pages->view('/magaz/admin?mod=tovar&');
}
$tpl->div('block',img('admin.png') .'<a href="/magaz/admin">Админ-панель</a><br/>'. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
break;
case 'del':
$title = 'Модерация измененных товаров';
require_once(SYS.'/view/header.php');
$tpl->div('title', 'Модерация измененных товаров');
if (isset($_GET['pod']) && $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '".abs(intval($_GET['pod']))."'")->rowCount() !=0) {
$db->query("UPDATE `magaz_tovar` SET `pod` = '1' WHERE `id` = '".abs(intval($_GET['pod']))."'");
$fid = $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '". abs(intval($_GET['pod'])) ."'")->fetch();
$db->query("INSERT INTO `notify` SET `user_id` = '". $fid['user'] ."', `from_id` ='". $user['id'] ."', `request_id` = '". $fid['id'] ."', `type` = 'magaz_del_no', `read` = '0', `time` = '". time() ."'");
echo $tpl->div('menu', '<center>Товар возвращен назад</center>');
}
if (isset($_GET['del']) && $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '".abs(intval($_GET['del']))."'")->rowCount() !=0) {
$fid = $db->query("SELECT * FROM `magaz_tovar` WHERE `id` = '". abs(intval($_GET['del'])) ."'")->fetch();
unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['file']);
if ($file['src_1'] != NULL) unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['src_1']);
if ($file['src_2'] != NULL) unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['src_2']);
if ($file['src_3'] != NULL) unlink(ROOT .'/files/magaz/'.$fid['path'].'/'.$fid['src_3']);
$db->query("DELETE FROM `magaz_tovar` WHERE `id` = '". $fid['id'] ."'");
$db->query("DELETE FROM `magaz_s` WHERE `uid` = '". $fid['id'] ."'");
$db->query("DELETE FROM `magaz_k` WHERE `uid` = '". $fid['id'] ."'");
$db->query("INSERT INTO `notify` SET `user_id` = '". $fid['user'] ."', `from_id` ='". $user['id'] ."', `request_id` = '". $fid['id'] ."', `type` = 'magaz_del', `read` = '0', `time` = '". time() ."'");
echo $tpl->div('menu', '<center>Товар успешно удален</center>');
}
$magaz_t = $db->query("SELECT * FROM `magaz_tovar` WHERE `pod` = '3'")->rowCount();
$pages = new Paginator($magaz_t, $ames);
if($magaz_t == 0) {
echo $tpl->div('menu', '<center>Нет товаров</center>');
}
else {
$magaz_tt = $db->query("SELECT * FROM `magaz_tovar` WHERE `pod` = '3' ORDER BY `id` LIMIT $start, $ames");
while($magaz_t = $magaz_tt->fetch()) {
echo '<div class="menu">';
if (!empty($magaz_t['src_1'])) { echo '<img src="/files/magaz/'. $magaz_t['path'] .'/'.$magaz_t['src_1'].'" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
else if (empty($magaz_t['src_2'])) { echo '<img src="/files/magaz/'. $magaz_t['path'] .'/'.$magaz_t['src_2'].'" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
else if (empty($magaz_t['src_3'])) { echo '<img src="/files/magaz/'. $magaz_t['path'] .'/'.$magaz_t['src_3'].'" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
else { echo '<img src="/template/icons/no.png" height="45" width="45" style="float:left;margin: 2px 8px 2px 2px;">';}
echo 'Название: <a href="/magaz/file/'. $magaz_t['id'] .'/">'. $magaz_t['name'] .'</a><br/>Описание: '. rez_text($magaz_t['text']) .'<br/>Цена: <font color="green">'. $magaz_t['wmr'] .'руб.</font><br/><a href="/magaz/admin?mod=del&pod='. $magaz_t['id'] .'/">Вернуть</a> | <a href="/magaz/admin?mod=del&del='. $magaz_t['id'] .'/">Удалить</a></div>';
}
$pages->view('/magaz/admin?mod=del&');
}
$tpl->div('block',img('admin.png') .'<a href="/magaz/admin">Админ-панель</a><br/>'. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
break;
case 'wmr':
$title = 'Ввод/вывод средств';
require_once(SYS.'/view/header.php');
$tpl->div('title', 'Ввод/вывод средств');
if (isset($_GET['pod']) && $db->query("SELECT * FROM `operation` WHERE `id` = '".abs(intval($_GET['pod']))."' AND `pod` = '0'")->rowCount() !=0) {
$db->query("UPDATE `operation` SET `pod` = '1' WHERE `id` = '".abs(intval($_GET['pod']))."'");
$operat = $db->query("SELECT * FROM `operation` WHERE `id` = '". abs(intval($_GET['pod'])) ."'")->fetch();
$uss = $db->query("SELECT * FROM `users` WHERE `id` = '". $operat['user'] ."'")->fetch();
if($operat['type'] == 1) {
$db->query("UPDATE `users` SET `wmr` = '". ($uss['wmr']+$operat['wmr']) ."' WHERE `id` = '".$uss['id']."'");
echo $tpl->div('menu', '<center>Средства зачислены</center>');
}
else if($operat['type'] == 2) {
echo $tpl->div('menu', 'Средства выведены');
}
$db->query("INSERT INTO `notify` SET `user_id` = '". $uss['id'] ."', `from_id` ='". $user['id'] ."', `request_id` = '1', `type` = 'magaz_wmr_ok', `read` = '0', `time` = '". time() ."'");
}
if (isset($_GET['del']) && $db->query("SELECT * FROM `operation` WHERE `id` = '".abs(intval($_GET['del']))."' AND `pod` = '0'")->rowCount() !=0) {
$db->query("UPDATE `operation` SET `pod` = '2' WHERE `id` = '".abs(intval($_GET['del']))."'");
$operat = $db->query("SELECT * FROM `operation` WHERE `id` = '". abs(intval($_GET['del'])) ."'")->fetch();
$uss = $db->query("SELECT * FROM `users` WHERE `id` = '". $operat['user'] ."'")->fetch();
if($operat['type'] == 2) {
$db->query("UPDATE `users` SET `wmr` = '". ($uss['wmr']+$operat['wmr']) ."' WHERE `id` = '".$uss['id']."'");
echo $tpl->div('menu', 'Средства возвращены на виртуальный счёт');
}
else if($operat['type'] == 1) {
echo $tpl->div('menu', '<center>Операция отклонена</center>');
}
$db->query("INSERT INTO `notify` SET `user_id` = '". $uss['id'] ."', `from_id` ='". $user['id'] ."', `request_id` = '1', `type` = 'magaz_wmr_no', `read` = '0', `time` = '". time() ."'");
}
$magaz_t = $db->query("SELECT * FROM `operation` WHERE `pod` = '0'")->rowCount();
$pages = new Paginator($magaz_t, $ames);
if($magaz_t == 0) {
echo $tpl->div('menu', '<center>Нет операция</center>');
}
else {
$magaz_tt = $db->query("SELECT * FROM `operation` WHERE `pod` = '0' ORDER BY `id` LIMIT $start, $ames");
while($magaz_t = $magaz_tt->fetch()) {
echo '<div class="menu">';
$us = $db->query("SELECT * FROM `users` WHERE `id` = '". $magaz_t['user'] ."'")->fetch();
echo ($magaz_t['type'] == 1 ? '<img src="/template/icons/plus1.png" style="float:left;margin: 2px 8px 2px 2px;">'.$us['nick'].' запросил пополнение, кошелек '.$us['wmr_cosh']:'<img src="/template/icons/minus.png" style="float:left;margin: 2px 8px 2px 2px;">'.$us['nick'].' выводит средства, кошелек '.$us['wmr_cosh']).'<br /> Сумма: <font color="green">'. $magaz_t['wmr'] .'руб.</font><br/><a href="/magaz/admin?mod=wmr&pod='. $magaz_t['id'] .'/">Подтвердить</a> | <a href="/magaz/admin?mod=wmr&del='. $magaz_t['id'] .'/">Отклонить</a></div>';
}
$pages->view('/magaz/admin?mod=wmr&');
}
$tpl->div('block',img('admin.png') .'<a href="/magaz/admin">Админ-панель</a><br/>'. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
break;
}
} else { go('/'); }
?>