Файл: clik.online/admin.php
Строк: 1288
<?php
/**
* @author: Egor Smolyakov, 2012.
* @mod: Admin Ulty, 2015
* Абдусамад Дилмуродов http://profiwm.com/us3827
*/
defined('ROOT') or define('ROOT', str_replace('\', '/', realpath(dirname (__FILE__))));
require_once ROOT . '/system/init.php'; // инициализация ядра
if($user['admin'] == 0) redir(HOST.'/login/');
page_head('Админ-панель'); // название страницы
switch ($act) {
default:
echo '
<div class="menu"><b>Техническая поддержка</b></div>
<div class="menu">
<a href="'.HOST.'/admin/?act=tickets">Техническая поддержка</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `tickets`;").']';
if (DB :: run() -> querySingle("SELECT COUNT(*) FROM `tickets` WHERE `open` = '1' AND `new_reply` = '2';") > 0) echo ' <span style="color: red">Новые вопросы!</span>';
echo '<br /><a href="'.HOST.'/admin/?act=moder">Модерация сайтов</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `sites` WHERE `moderation` = '0' AND `active` != '2';").']<br />
</div>
<div class="menu"><b>Партнерская программа</b></div>
<div class="menu">
<a href="'.HOST.'/admin/?act=sites">Просмотр сайтов</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `sites` WHERE `moderation` = '1';").']<br />
<a href="'.HOST.'/admin/?act=stat">Смотреть статистику</a><br />
<a href="'.HOST.'/admin/logs/">Просмотр логов</a><br />
</div>
<div class="menu"><b>Операторы</b></div>
<div class="menu">
<a href="'.HOST.'/admin/?act=operators">Редактировать операторы</a><br />
</div>
<div class="menu"><b>Пользователи</b></div>
<div class="menu">
<a href="'.HOST.'/admin/?act=users">Управление пользователями</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `users`;").']<br />
<a href="'.HOST.'/admin/?act=banned">Блокировка пользователей</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `users` WHERE `banned` = '1';").']<br />
<a href="'.HOST.'/admin/?act=okout">Готовые к выплатам</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `users` WHERE `rub` >= ".$set['min_out'].";").']<br />
<a href="'.HOST.'/admin/?act=outrub">Запросили вывод</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `users` WHERE `out_check` = '1';").']<br />
<a href="'.HOST.'/admin/?act=referals">Просмотр рефералов</a><br />
<a href="'.HOST.'/admin/?act=mail">Просмотр почты</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `mail`;").']
</div>
<div class="menu"><b>Настройка</b></div>
<div class="menu">
<a href="'.HOST.'/admin/?act=setting">Общие настройки</a><br />
<a href="'.HOST.'/admin.php?act=teasers">Управление тизерами</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `teasers`;").']<br />
<a href="'.HOST.'/admin.php?act=banners">Управление баннерами</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `banners`;").']<br />
<a href="'.HOST.'/admin.php?act=ads">Управление текстовими рекламами</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `ads`;").']<br />
<a href="'.HOST.'/admin.php?act=links">Управление ссылками</a><br />
<a href="'.HOST.'/admin/?act=news">Управление новостями</a> ['.DB :: run() -> querySingle("SELECT COUNT(*) FROM `news`;").']<br />
<a href="'.HOST.'/forum/">Управление форумом</a><br />
<a href="'.HOST.'/admin/?act=pages">Управление страницами</a><br />
</div>';
$tcount = DB :: run() -> queryFetch("SELECT * FROM `counter` WHERE `type` = 'teasers';");
$bcount = DB :: run() -> queryFetch("SELECT * FROM `counter` WHERE `type` = 'banners';");
$acount = DB :: run() -> queryFetch("SELECT * FROM `counter` WHERE `type` = 'ads';");
$ccount = DB :: run() -> queryFetch("SELECT * FROM `counter` WHERE `type` = 'ClickUnder';");
echo "
<table width='100%'>
<tr align='center'><td class='title' colspan='4'><b>Статистика за сегодня</b></td></tr>
<tr align='center'>
<td class='aut'><b>Показатель</b></td>
<td class='aut'><b>Показов:</b></td><td class='aut'><b>Переходов:</b></td>
</tr>
<tr>
<td class='menu'><b>По тизерам</b></td><td class='menu'>".$tcount['pokaz']."</td><td class='menu'>".$tcount['click']."</td>
</tr><tr> <td class='menu'><b>По баннерам</b></td>
<td class='menu'>".$bcount['pokaz']."</td><td class='menu'>".$bcount['click']."</td></tr><tr>
<td class='menu'><b>По текс. рек.</b></td>
<td class='menu'>".$acount['pokaz']."</td>
<td class='menu'>".$acount['click']."</td>
<tr>
<td class='menu'><b>По ClickUnder</b></td>
<td class='menu'>-</td>
<td class='menu'>".$ccount['click']."</td>
<tr>
</tr>
</table>";
echo '<div class="menu"><hr></div>';
break;
// пользователи
case 'users':
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=users&',25);
$querypost = DB :: run() -> query("SELECT * FROM `users` ORDER BY `id` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `users`;");
if ($total > 0) {
echo '
<table border="1" class="menu" width="100%">
<tr>
<td><b>Логин</b></td>
<td><b>Статус</b></td>
<td><b>Заработал</b></td>
<td><b>Заработал всего</b></td>
<td><b>E-mail</b></td>
<td><b>IP</b></td>
<td><b>WMR</b></td>
<td><b>WMZ</b></td>
</tr>
';
while ($uz = $querypost -> fetch()) {
echo '<tr>';
echo '<td>'.$uz['login'].'</td><td>';
if($uz['banned'] == 1) echo '<span style="color: red">Забанен</span>'; else echo 'Активный';
echo '</td><td>'.$uz['rub'].' руб.</td><td>'.$uz['out_all'].' руб.</td><td>'.$uz['email'].'</td><td>'.$uz['ip'].'</td><td>R'.$uz['wmr'].'</td><td>Z'.$uz['wmz'].'</td><td><a href="'.HOST.'/admin/?act=user&id='.$uz['id'].'">Все данные</a></td>';
echo'</tr>';
}
echo '
</table>';
} else {
echo '<div class="menu">Пользователей нет.</div>';
}
echo $nav->navi($total,0);
break;
// статистика
case 'stat':
echo '
<div class="menu">
Кликов сегодня: <b>'.DB :: run() -> querySingle("SELECT count(*) FROM `click_db` WHERE `date` = '".date('d.m.Y')."';").'</b><br />
Заработано партнерами сегодня: <b>'.number_format(DB :: run() -> querySingle("SELECT SUM(`user_plus`) FROM `click_db` WHERE `date` = '".date('d.m.Y')."';"), 2).'</b> руб.<br />
Средняя цена клика сегодня:
<b>'.number_format(DB :: run() -> querySingle("SELECT SUM(`user_plus`) FROM `click_db` WHERE `date` = '".date('d.m.Y')."';")/DB :: run() -> querySingle("SELECT count(*) FROM `click_db` WHERE `date` = '".date('d.m.Y')."';"),3).'</b> руб.<br />
</div>
';
break;
// тех. поддержка
case 'tickets':
if (isset($_GET['open']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `tickets` WHERE `id`=? LIMIT 1;", array(intval($_GET['open']))) == 1) {
DB :: run() -> query ('UPDATE `tickets` SET `open` = "1" WHERE `id` = ?;', array(intval($_GET['open'])));
redir(HOST.'/admin/?act=tickets');
}
if (isset($_GET['close']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `tickets` WHERE `id`=? LIMIT 1;", array(intval($_GET['close']))) == 1) {
DB :: run() -> query ('UPDATE `tickets` SET `open` = "0" WHERE `id` = ?;', array(intval($_GET['close'])));
redir(HOST.'/admin/?act=tickets');
}
if (isset($_GET['view']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `tickets` WHERE `id`=?;", array(intval($_GET['view']))) == 1) {
$data = DB :: run() -> queryFetch("SELECT * FROM `tickets` WHERE `id`=?;", array(protect($_GET['view'])));
if($data['new_reply'] == 2) DB :: run() -> query("UPDATE `tickets` SET `new_reply` = '0' WHERE `id` = '".$data['id']."';");
if(!empty($_POST['message']))
{
$message = protect($_POST['message']);
DB :: run() -> query ('INSERT INTO `tickets_reply` SET `reply_login` = ?, `time` = ?, `text` = ?, `tid` = ?;',
array('1', TIME, $message, $data['id']));
DB :: run() -> query ('UPDATE `tickets` SET `new_reply` = "1" WHERE `id` = ?;',
array($data['id']));
echo '<div class="menu">Сообщение добавлено.</div>';
}
if (!empty($error)) {
echo '<div class="menu">'.$error.'</div>';
}
echo '<div class="title">
<b>Текст вопроса:</b><br />
'.nl2br($data['text_answer']).'<br />
<br />
<form action="'.HOST.'/admin/?act=tickets&view='.$data['id'].'" method="POST">
<hr>
Добавить сообщение:<br />
<textarea name="message" type="text" cols="30" rows="5"></textarea><br />
<input type="submit" value="Отправить" /><br />
</form></div>';
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=tickets&view='.$data['id'].'&',8);
$querypost = DB :: run() -> query("SELECT * FROM `tickets_reply` WHERE `tid` = '".$data['id']."' ORDER BY `id` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";;");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `tickets_reply` WHERE `tid` = '".$data['id']."';");
if ($total > 0) {
while ($quest = $querypost -> fetch()) {
echo '<div class="menu">';
if ($quest['reply_login'] == $user['login']) echo '<b>'.$quest['reply_login'].'</b>'; else echo '<b>Администратор</b>';
echo ' ['.view_date($quest['time']).']<br />
'.nl2br($quest['text']).'
</div>';
}
echo $nav->navi($total,0);
} else {
echo '<div class="menu">Вы не ответили на этот вопрос.</div>';
}
echo '<div class="title"><a href="'.HOST.'/admin/">Управление сайтом</a><br /><a href="'.HOST.'/">Личный кабинет</a></div>';
page_foot(); // низ сайта
}
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=tickets&',10);
$querypost = DB :: run() -> query("SELECT * FROM `tickets` ORDER BY `new_reply` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `tickets`;");
if ($total > 0) {
echo '
<table border="1" class="menu" width="100%">
<tr>
<td><b>Автор</b></td>
<td><b>Тема</b></td>
<td><b>Дата добавления</b></td>
<td><b>Действия</b></td>
</tr>
';
while ($ticket = $querypost -> fetch()) {
echo '<tr>';
echo '<td>'.$ticket['user_author'].'</td><td><a href="'.HOST.'/admin/?act=tickets&view='.$ticket['id'].'">'.$ticket['title'].'</a></td>';
echo'<td>'.view_date($ticket['time']).'</td><td>';
if($ticket['open'] == 1) echo '<a href="'.HOST.'/admin/?act=tickets&close='.$ticket['id'].'">Закрыть</a>'; else echo '<a href="'.HOST.'/admin/?act=tickets&open='.$ticket['id'].'">Открыть</a>';
echo'</td>';
if($ticket['new_reply'] == 2) echo '<td style="color:red">Новый вопрос!</td>';
echo'</tr>';
}
echo '
</table>';
} else {
echo '<div class="menu">Новых тикетов нет.</div>';
}
echo $nav->navi($total,0);
break;
case 'user':
if (isset($_GET['id'])) {
$queryread = DB :: run() -> query("SELECT * FROM `users` WHERE `id`=? LIMIT 1;", array(intval($_GET['id'])));
$data = $queryread -> fetch();
if ($data > 0) {
if(isset($_GET['logs'])) {
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=user&id='.$data['id'].'&logs&',$set['count_pages']);
$querypost = DB :: run() -> query("SELECT * FROM `logs_auth` WHERE `user_login` = '".$data['login']."' ORDER BY `id` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `logs_auth` WHERE `user_login` = '".$data['login']."';");
if ($total > 0) {
while ($log = $querypost -> fetch()) {
echo '<div class="menu">IP: <b>'.$log['ip'].'</b><br />
Браузер: <b>'.$log['browser'].'</b><br />
Дата входа: <b>'.view_date($log['time']).'</b>
</div>';
}
} else {
echo '<div class="menu">Не заходил.</div>';
}
echo $nav->navi($total,0);
echo '<div class="menu"><a href="'.HOST.'/admin/">Управление сайтом</a><br /><a href="'.HOST.'/">Личный кабинет</a></div>';
page_foot(); // низ сайта
}
echo '<div class="menu">
Логин: <b>'.$data['login'].'</b><br />
Дата регистрации: <b>'.view_date($data['reg_time']).'</b><br />
Посл. посещение: <b>'.view_date($data['last_time']).'</b><br />
IP: <b>'.$data['ip'].'</b><br />
Браузер: <b>'.$data['ua'].'</b><br />';
if($data['ref_id'] != 0) echo 'Привел на сайт: id '.$data['ref_id'].'<br />';
echo 'Рефералов: <b>'.$data['referals'].'</b><br />';
$querypost = DB :: run() -> query("SELECT * FROM `sites` WHERE `user_id` = '".$data['id']."' AND `moderation` = '1' ORDER BY `id`;");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `sites` WHERE `user_id` = '".$data['id']."' AND `moderation` = '1' ;");
if ($total > 0) {
while ($site = $querypost -> fetch()) {
echo '<a href="'.$site['link'].'">'.$site['link'].'</a> (<a href="'.HOST.'/admin/?act=sites&delete='.$site['id'].'">Удалить</a>)<br />';
}
}else{
echo 'Сайтов нет.';
}
echo '</div>';
echo '<div class="menu">';
echo '<a href="'.HOST.'/admin/?act=user&id='.$data['id'].'&logs">История авторизаций</a><br />';
//echo '<a href="'.HOST.'/admin/?act=user&id='.$data['id'].'&edit">Редактировать юзера</a><br />';
//echo '<a href="'.HOST.'/admin/?act=user&id='.$data['id'].'&del">Удалить юзера</a>';
echo '</div>';
echo '<div class="menu"><a href="'.HOST.'/admin/">Управление сайтом</a><br /><a href="'.HOST.'/">Личный кабинет</a></div>';
page_foot(); // низ сайта
echo '</div>';
} else {
page_head('Ошибка'); // название страницы
echo '<div class="menu">Пользователь не найден.</div>';
}
page_foot(); // низ сайта
}else{
redir (HOST.'/admin/');
}
break;
// модерация сайтов
case 'moder':
if (isset($_GET['no']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `sites` WHERE `id`=? LIMIT 1;", array(intval($_GET['no']))) == 1) {
DB :: run() -> query ('UPDATE `sites` SET `active` = "2" WHERE `id` = ?;', array(intval($_GET['no'])));
redir(HOST.'/admin/?act=moder');
}
if (isset($_GET['ok']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `sites` WHERE `id`=? LIMIT 1;", array(intval($_GET['ok']))) == 1) {
DB :: run() -> query ('UPDATE `sites` SET `moderation` = "1", `active` = "1" WHERE `id` = ?;', array(intval($_GET['ok'])));
redir(HOST.'/admin/?act=moder');
}
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=moder&',20);
$querypost = DB :: run() -> query("SELECT * FROM `sites` WHERE `moderation` = '0' AND `active` != '2' ORDER BY `id` LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `sites` WHERE `moderation` = '0' AND `active` != '2';");
if ($total > 0) {
echo '
<table border="1" class="menu" width="100%">
<tr>
<td><b>Владелец</b></td>
<td><b>Статус</b></td>
<td><b>Линк</b></td>
<td><b>Дата добавления</b></td>
</tr>
';
while ($site = $querypost -> fetch()) {
echo '
<tr><td>ID '.$site['user_id'].'</td><td><a href="'.$site['link'].'">'.$site['link'].'</a></td>';
if($s['active'] == 1) echo '<td style="color: green">Активный</td>'; if($s['active'] == 2) echo '<td style="color: red">заблокирован</td>'; if(!$s['active']) echo '<td style="color: blue">Не активный</td>';
echo'<td>'.view_date($site['time_add']).'</td><td><a href="'.HOST.'/admin/?act=moder&ok='.$site['id'].'">Одобрить</a></td><td><a href="'.HOST.'/admin/?act=moder&no='.$site['id'].'">Отказать</a></td></tr>';
}
echo '
</table>';
} else {
echo '<div class="menu">Новых сайтов нет.</div>';
}
echo $nav->navi($total,0);
break;
// логи переходов
case 'logs':
if(!empty($_GET['uid'])) {
$uid = " AND `user_id` = '".intval($_GET['uid'])."'";
$pageu = '&uid='.intval($_GET['uid']).'&';
}else{
$uid = '';
$pageu = '';
}
if(!empty($_GET['day'])) {
$sql = "`date` = '".protect($_GET['day'])."'";
$page = '?day='.protect($_GET['day']).'&';
} else {
$sql = "`date` = '".date('d.m.Y')."'";
$page = '?';
}
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/logs/'.$page.''.$pageu.'',40);
$querypost = DB :: run() -> query("SELECT * FROM `click_db` WHERE $sql $uid ORDER BY `time_click` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `click_db` WHERE $sql $uid;");
if ($total > 0) {
echo '<div class="menu">Статистика переходов</div>';
echo '
<table border="1" class="menu" width="100%">
<tr>
<td><b>UID</b></td>
<td><b>IP</b></td>
<td><b>Browser</b></td>
<td><b>Реферер</b></td>
<td><b>Оператор</b></td>
<td><b>Время перехода</b></td>
<td><b>Доход</b></td>
<td><b>Источник</b></td></tr>
';
while ($per = $querypost -> fetch()) {
echo '<tr><td>'.$per['user_id'].'</td><td>'.$per['ip'].'</td><td>'.$per['browser'].'</td><td>'.$per['referer'].'</td><td>'.$per['operator_name'].'</td><td>'.date('d.m.Y h:i:s', $per['time_click']).'</td><td>'.$per['user_plus'].' руб.</td><td>'.($per['type'] == 'teasers' ? 'Тизер' : '').($per['type'] == 'banners' ? 'Баннер' : '').($per['type'] == 'ads' ? 'Текстовая реклама' : '').($per['type'] == 'ClickUnder' ? 'ClickUnder' : '').'</td>';
if($per['s_click']==1) echo '<td style="color:red">САМОКЛИК</td>';
echo '</tr>';
}
echo '</table>';
} else {
echo '<div class="menu">Переходов нет.</div>';
}
echo '<div class="menu">Статистика за:<br />
<form action="'.HOST.'/admin/logs/" method="GET">
<input name="day" type="text" value="'.date('d.m.Y').'" size="9"/><br />
ID пользователя:<br />
<input name="uid" type="text" value="" size="9"/>
<br /><input type="submit" value="Смотреть" />
</form>
</div>';
echo $nav->navi($total,0);
break;
// промодерированые сайты
case 'sites':
if (isset($_GET['delete']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `sites` WHERE `id`=? LIMIT 1;", array(intval($_GET['delete']))) == 1) {
DB :: run() -> query ('DELETE FROM `sites` WHERE `id` = ?;', array(intval($_GET['delete'])));
redir(HOST.'/admin/?act=sites');
}
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=sites&',20);
$querypost = DB :: run() -> query("SELECT * FROM `sites` WHERE `moderation` = '1' ORDER BY `id` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `sites` WHERE `moderation` = '1';");
if ($total > 0) {
echo '
<table border="1" class="menu" width="100%">
<tr>
<td><b>Владелец</b></td>
<td><b>Линк</b></td>
<td><b>Дата добавления</b></td>
</tr>
';
while ($site = $querypost -> fetch()) {
echo '
<tr><td>ID '.$site['user_id'].'</td><td><a href="'.$site['link'].'">'.$site['link'].'</a></td><td>'.view_date($site['time_add']).'</td><td><a href="'.HOST.'/admin/?act=sites&delete='.$site['id'].'">Удалить</a></td></tr>';
}
echo '
</table>';
} else {
echo '<div class="menu">Активных сайтов нет.</div>';
}
echo $nav->navi($total,0);
break;
// почта пользователей
case 'operators':
if (isset($_GET['delete']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `operators` WHERE `oper`=? LIMIT 1;", array(protect($_GET['delete']))) == 1) {
DB :: run() -> query ('DELETE FROM `operators` WHERE `oper` = ?;', array(protect($_GET['delete'])));
redir(HOST.'/admin/?act=operators');
}
//
if (isset($_GET['edit']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `operators` WHERE `oper`=? AND `rusname` = ?;", array(protect($_GET['edit']), protect($_GET['country']))) == 1) {
$page = DB :: run() -> queryFetch("SELECT * FROM `operators` WHERE `oper`=? AND `rusname` = ?;", array(protect($_GET['edit']), protect($_GET['country'])));
if(!empty($_POST)) {
$oper = protect($_POST['oper']);
$rusname = protect($_POST['rusname']);
$socr = protect($_POST['socr']);
$cena_rub = protect($_POST['cena_rub']);
DB :: run() -> query ("UPDATE `operators` SET `cena_rub` = ?,`socr` = ?, `rusname` = ?,`oper` = ? WHERE `oper` = ? AND `rusname` = ?;", array($cena_rub, $socr, $rusname, $oper, $page['oper'], protect($_GET['country'])) );
echo '<div class="menu">'.'Изменено.'.'</div>';
}
echo '<div class="menu">'.'
<form action="'.HOST.'/admin/?act=operators&edit='.$page['oper'].'&country='.$page['rusname'].'" method="POST">
Цена за 1000 переходов (руб):<br />
<input type="text" name="cena_rub" value="'.$page['cena_rub'].'"/><br />
Название оператора:<br />
<input type="text" name="rusname" value="'.$page['rusname'].'"/><br />
Страна:<br />
<input type="text" name="oper" value="'.$page['oper'].'"/><br />
Сокращение страны:<br />
<input type="text" name="socr" value="'.$page['socr'].'"/><br />
<input type="submit" value="Изменить" /><br />
</form>
'.'</div>';
echo '<div class="menu"><a href="'.HOST.'/admin/">Управление сайтом</a><br /><a href="'.HOST.'/">Личный кабинет</a></div>';
page_foot(); // низ сайта
}
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=operators&',20);
$querypost = DB :: run() -> query("SELECT * FROM `operators` ORDER BY `id_oper` LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `operators`;");
if ($total > 0) {
echo '
<table border="1" class="menu" width="100%">
<tr>
<td><b>Оператор</b></td>
<td><b>Цена</b></td>
</tr>
';
while ($op = $querypost -> fetch()) {
echo '
<tr><td>'.$op['oper'].' ('.$op['rusname'].')</td><td>'.$op['cena_rub'].'</td><td><a href="'.HOST.'/admin/?act=operators&edit='.$op['oper'].'&country='.$op['rusname'].'">Редактировать</a></td><td><a href="'.HOST.'/admin/?act=operators&delete='.$op['oper'].'&country='.$op['rusname'].'">Удалить</a></td></tr>';
}
echo '
</table>';
echo '<div class="menu">Чтобы обновить базу обращайтесь к автору скрипта - <b>iNeeXT'y</b>.</div>';
} else {
echo '<div class="menu">База пустая.</div>';
}
echo $nav->navi($total,0);
break;
// блокировка пользователей
case 'banned':
if (isset($_POST['submit'])) {
if (isset($_POST['uzz']) and $_POST['uzz'] and is_array($_POST['uzz'])) {
$iTotal = count($_POST['uzz']);
$aMess = null; $i = null;
foreach ($_POST['uzz'] as $key) { ++$i;
DB :: run() -> query("UPDATE `users` SET `banned` = '0' WHERE `id` = '".$key."'");
}
} else {
echo '<div class="menu">Не выбранны пользователи.</div>';
}
}
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=banned&',$set['count_pages']);
$querypost = DB :: run() -> query("SELECT * FROM `users` WHERE `banned` = '1' ORDER BY `id` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `users` WHERE `banned` = '1';");
if ($total > 0) {
echo '<form action="'.HOST.'/admin/?act=banned" method="post">';
while ($uz = $querypost -> fetch()) {
echo '<div class="menu"><input type="checkbox" name="uzz[]" value="'.$uz['id'].'">
'.$uz['login'].'
</div>';
}
echo '<div class="menu">
<input name="submit" type="submit" value="Разблокировать">
</form>
</div>
';
} else {
echo '<div class="menu">Список пуст.</div>';
}
if(!empty($_POST['login']) && !empty($_POST['message']))
{
$message = protect($_POST['message']);
$queryread = DB :: run() -> query("SELECT * FROM `users` WHERE `login`=? LIMIT 1;", array(protect($_POST['login'])));
$data = $queryread -> fetch();
if ($data > 0) {
$login = $data['login'];
if($login == $user['login']) {
echo '<div class="menu">Администратора блокировать нельзя!</div>';
}
else {
// отсылаем письмо
$subject = 'Вы заблокированы!';
$regmail = "Здравствуйте ".$login."<br />rnВы заблокированы в нашей партнерской программе. Причина:rn'".$message."'";
$adds = "From: <$set[reg_mail]>n";
$adds .= "X-sender: <$set[reg_mail]>n";
$adds .= "Content-Type: text/html; charset=utf-8n";
$subject = '=?utf-8?B?' . base64_encode($subject) . '?=';
@mail($data['email'],$subject,$regmail,$adds);
DB :: run() -> query("UPDATE `users` SET `banned` = '1' WHERE `id` = '".$data['id']."';");
echo '<div class="menu">Пользователь заблокирован!</div>';
}
}else{
echo '<div class="menu">Пользователь не найден.</div>';
}
}
echo '<div class="menu">
<form action="'.HOST.'/admin/?act=banned" method="post">
Логин:<br />
<input type="text" name="login" /><br />
Причина бана:<br />
<textarea type="text" cols="20" rows="5" name="message"></textarea><br />
<input type="submit" value="Заблокировать">
</form>
</div>
';
echo $nav->navi($total,0);
break;
// готоые к выплатам
case 'okout':
if (isset($_POST['submit'])) {
if (isset($_POST['uzz']) and $_POST['uzz'] and is_array($_POST['uzz'])) {
$iTotal = count($_POST['uzz']);
$aMess = null; $i = null;
foreach ($_POST['uzz'] as $key) { ++$i;
DB :: run() -> query("UPDATE `users` SET `out_check` = '0', `rub` = '0', `out_all` = `out_all` + '".trim($_POST['money'.$key.''])."' WHERE `id` = '".$key."'");
}
} else {
echo '<div class="menu">Не выбранны пользователи.</div>';
}
}
$querypost = DB :: run() -> query("SELECT * FROM `users` WHERE `rub` >= ".$set['min_out']." AND `banned` = '0' ORDER BY `rub` DESC;");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `users` WHERE `rub` >= ".$set['min_out']." AND `banned` = '0';");
if ($total > 0) {
echo '<form action="'.HOST.'/admin/?act=okout" method="post">';
while ($uz = $querypost -> fetch()) {
echo '<div class="menu"><input type="checkbox" name="uzz[]" value="'.$uz['id'].'"> <input type="hidden" name="money'.$uz['id'].'" value="'.$uz['rub'].'" >
<a href="'.HOST.'/admin/?act=user&id='.$uz['id'].'"><b>'.$uz['login'].'</b></a> (<a href="'.HOST.'/admin/?act=logs&uid='.$uz['id'].'">Логи</a>/<a href="'.HOST.'/admin/?act=user&id='.$uz['id'].'">Сайты</a>)<br />
'; if($uz['out_type']) echo '<b>Z'.$uz['wmz'].'</b> сумма на счету <b>'.number_format(($uz['rub']*$set['dollar_curs'])).'</b> USD'; else echo '<b>R'.$uz['wmr'].'</b> сумма на счету <b>'.number_format($uz['rub']).'</b> руб. [<a href="wmk:payto?Purse=R'.$uz['wmr'].'&Amount='.number_format($uz['rub']).'&Desc=Выплаты clik.online партнеру ID:'.$uz['id'].'&Id='.$uz['id'].'">Оплатить</a>]';
echo '</div>';
}
echo '<div class="menu">
<input name="submit" type="submit" value="Выплачено">
</form></div>
';
} else {
echo '<div class="menu">Пока нет готовых к выплатам.</div>';
}
break;
// запросившие вывод средств
case 'outrub':
if (isset($_POST['submit'])) {
if (isset($_POST['uzz']) and $_POST['uzz'] and is_array($_POST['uzz'])) {
$iTotal = count($_POST['uzz']);
$aMess = null; $i = null;
foreach ($_POST['uzz'] as $key) { ++$i;
DB :: run() -> query("UPDATE `users` SET `out_check` = '0', `rub` = '0', `out_all` = `out_all` + '".trim($_POST['money'.$key.''])."', `out_time` = '".time()."' WHERE `id` = '".$key."'");
}
} else {
echo '<div class="menu">Не выбранны пользователи.</div>';
}
}
$querypost = DB :: run() -> query("SELECT * FROM `users` WHERE `out_check` = '1' AND `banned` = '0' ORDER BY `rub` DESC;");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `users` WHERE `out_check` = '1' AND `banned` = '0';");
if ($total > 0) {
echo '<form action="'.HOST.'/admin/?act=outrub" method="post">';
while ($uz = $querypost -> fetch()) {
echo '<div class="menu"><input type="checkbox" name="uzz[]" value="'.$uz['id'].'"> <input type="hidden" name="money'.$uz['id'].'" value="'.$uz['rub'].'" >
Запросил выплату <a href="'.HOST.'/admin/?act=user&id='.$uz['id'].'"><b>'.$uz['login'].'</b></a> (<a href="'.HOST.'/admin/?act=logs&uid='.$uz['id'].'">логи</a>/<a href="'.HOST.'/admin/?act=user&id='.$uz['id'].'">сайты</a>)<br />
'; if($uz['out_type']) echo '<b>Z'.$uz['wmz'].'</b> на вывод <b>'.number_format(($uz['rub']*$set['dollar_curs'])).'</b> USD'; else echo '<b>R'.$uz['wmr'].'</b> на вывод <b>'.number_format($uz['rub']).'</b> руб. [<a href="wmk:payto?Purse=R'.$uz['wmr'].'&Amount='.number_format($uz['rub']).'&Desc=Выплаты clik.online партнеру ID:'.$uz['id'].'&Id='.$uz['id'].'">Оплатить</a>]';
echo '</div>';
}
echo '<div class="menu">
<input name="submit" type="submit" value="Выплачено">
</form></div>
';
} else {
echo '<div class="menu">Запросивших вывод нет.</div>';
}
break;
// рефералы
case 'referals':
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=referals&',$set['count_pages']);
$querypost = DB :: run() -> query("SELECT * FROM `referals` ORDER BY `rub_zar` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `referals`;");
if ($total > 0) {
while ($ref = $querypost -> fetch()) {
echo '<div class="menu">
<b>ID:'.$ref['user_id'].'</b> заработал на реферале '.$ref['ref'].' <b>'.number_format($ref['rub_zar'], 2).'</b> руб.
</div>';
}
} else {
echo '<div class="menu">Рефералов нет.</div>';
}
echo $nav->navi($total,0);
break;
// почта пользователей
case 'mail':
if(isset($_GET['clear'])) {
DB :: run() -> query("TRUNCATE TABLE `mail`");
DB :: run() -> query("OPTIMIZE TABLE `mail`");
echo '
<div class="menu">Почта очищена!</div>
';
}
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=mail&',$set['count_pages']);
$querypost = DB :: run() -> query("SELECT * FROM `mail` ORDER BY `id` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `mail`;");
if ($total > 0) {
while ($data = $querypost -> fetch()) {
echo '<div class="menu">'.'';
echo '<b>'.$data['user_send'].'</b> > <b>'.$data['user_to'].'</b> ['.view_date($data['time_send']).']<br />
'.nl2br($data['message']).'';
echo '
';
echo '</div>';
}
echo '
<div class="menu">
<a href="'.HOST.'/admin/?act=mail&clear">Очистить почту</a>
</div>
';
} else {
echo '<div class="menu">Писем нет.</div>';
}
echo $nav->navi($total,0);
break;
case 'pages':
if (isset($_GET['delete']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `pages` WHERE `name`=? LIMIT 1;", array(protect($_GET['delete']))) == 1) {
DB :: run() -> query ('DELETE FROM `pages` WHERE `name` = ?;', array(protect($_GET['delete'])));
redir(HOST.'/admin/?act=pages');
}
//
if (isset($_GET['edit']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `pages` WHERE `name`=? LIMIT 1;", array(protect($_GET['edit']))) == 1) {
$page = DB :: run() -> queryFetch("SELECT * FROM `pages` WHERE `name`=? LIMIT 1;", array(protect($_GET['edit'])));
if(!empty($_POST)) {
$name = protect($_POST['name']);
$text = protect($_POST['text']);
$title = protect($_POST['title']);
DB :: run() -> query ("UPDATE `pages` SET `name` = ?,`title` = ?, `text` = ? WHERE `name` = ?;", array($name, $title, $text, $page['name']) );
echo '<div class="menu">'.'Изменено.'.'</div>';
}
echo '<div class="menu">'.'
<form action="'.HOST.'/admin/?act=pages&edit='.$page['name'].'" method="POST">
Адрес страницы ('.HOST.'/page/<b>адрес</b>/): <br />
<input type="text" name="name" value="'.$page['name'].'"/><br />
Название статьи: <br />
<input type="text" name="title" value="'.$page['title'].'"/><br />
Текст: <br />
<textarea type="text" name="text">'.$page['text'].'</textarea><br />
<input type="submit" value="Изменить" /><br />
</form>
'.'</div>';
echo '<div class="menu"><a href="'.HOST.'/admin/">Управление сайтом</a><br /><a href="'.HOST.'/">Личный кабинет</a></div>';
page_foot(); // низ сайта
}
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=pages&',$set['count_pages']);
$querypost = DB :: run() -> query("SELECT * FROM `pages` ORDER BY `name` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `pages`;");
if ($total > 0) {
while ($data = $querypost -> fetch()) {
echo '<div class="menu">'.'';
echo '<b>'.$data['title'].'</b> <a href="'.HOST.'/admin/?act=pages&delete='.$data['name'].'">Удалить</a> / <a href="'.HOST.'/admin/?act=pages&edit='.$data['name'].'">Редактировать</a>';
echo '
';
echo '</div>';
}
} else {
echo '<div class="menu">Страниц нет.</div>';
}
echo $nav->navi($total,0);
if(!empty($_POST)) {
$name = protect($_POST['name']);
$text = protect($_POST['text']);
$title = protect($_POST['title']);
DB :: run() -> query ("INSERT INTO `pages` SET `name` = ?, `title` = ?, `text` = ?;", array($name,$title, $text) );
echo '<div class="menu">'.'Добавлено.'.'</div>';
}
if (!empty($error)) {
echo '<div class="menu">'.$error.'</div>';
}
echo '<div class="menu">'.'
<form action="'.HOST.'/admin/?act=pages" method="POST">
Адрес страницы ('.HOST.'/page/<b>адрес</b>/): <br />
<input type="text" name="name" /><br />
Название статьи: <br />
<input type="text" name="title" /><br />
Содержание: <br />
<textarea type="text" name="text"></textarea><br />
<input type="submit" value="Отправить" /><br />
</form>
'.'</div>';
break;
// новости
case 'news':
if (isset($_GET['delete']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `news` WHERE `id`=? LIMIT 1;", array(intval($_GET['delete']))) == 1) {
DB :: run() -> query ('DELETE FROM `news` WHERE `id` = ?;', array(intval($_GET['delete'])));
redir(HOST.'/admin/?act=news');
}
//
if (isset($_GET['edit']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `news` WHERE `id`=? LIMIT 1;", array(intval($_GET['edit']))) == 1) {
$page = DB :: run() -> queryFetch("SELECT * FROM `news` WHERE `id`=? LIMIT 1;", array(intval($_GET['edit'])));
if(!empty($_POST)) {
$text = protect($_POST['text']);
$title = protect($_POST['title']);
DB :: run() -> query ("UPDATE `news` SET `title` = ?, `text_news` = ? WHERE `id` = ?;", array($title, $text, $page['id']) );
echo '<div class="menu">'.'Изменено.'.'</div>';
}
echo '<div class="menu">'.'
<form action="'.HOST.'/admin/?act=news&edit='.$page['id'].'" method="POST">
Название статьи: <br />
<input type="text" name="title" value="'.$page['title'].'"/><br />
Текст: <br />
<textarea type="text" name="text">'.$page['text_news'].'</textarea><br />
<input type="submit" value="Изменить" /><br />
</form>
'.'</div>';
echo '<div class="menu"><a href="'.HOST.'/admin/">Управление сайтом</a><br /><a href="'.HOST.'/">Личный кабинет</a></div>';
page_foot(); // низ сайта
}
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=pages&',$set['count_pages']);
$querypost = DB :: run() -> query("SELECT * FROM `news` ORDER BY `id` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `news`;");
if ($total > 0) {
while ($data = $querypost -> fetch()) {
echo '<div class="menu">'.'';
echo '<b>'.$data['title'].'</b> <a href="'.HOST.'/admin/?act=news&delete='.$data['id'].'">Удалить</a> / <a href="'.HOST.'/admin/?act=news&edit='.$data['id'].'">Редактировать</a>';
echo '
';
echo '</div>';
}
} else {
echo '<div class="menu">Новостей нет.</div>';
}
echo $nav->navi($total,0);
if(!empty($_POST)) {
$text = protect($_POST['text']);
$title = protect($_POST['title']);
if (isset($_POST['mail'])) // Расслылка новостей на майл
{
$query = DB:: run() -> query("SELECT `email` FROM `users` WHERE `send_news` = '1' AND `email` <> ''");
// отсылаем письмо
$subject = 'Новости партнерской программы';
$regmail = "Новость - <b>".$title."</b><br />rn ".nl2br($text)."";
$adds = "From: <$set[reg_mail]>n";
$adds .= "X-sender: <$set[reg_mail]>n";
$adds .= "Content-Type: text/html; charset=utf-8n";
while ($to = $query-> fetch())
{
$subject = '=?utf-8?B?' . base64_encode($subject) . '?=';
@mail($to['email'],$subject,$regmail,$adds);
}
}
DB :: run() -> query ("INSERT INTO `news` SET `time` = ?, `title` = ?, `text_news` = ?;", array(TIME,$title, $text) );
echo '<div class="menu">'.'Добавлено.'.'</div>';
}
if (!empty($error)) {
echo '<div class="menu">'.$error.'</div>';
}
echo '<div class="menu">'.'
<form action="'.HOST.'/admin/?act=news" method="POST">
Заголовок новости: <br />
<input type="text" name="title" /><br />
Текст новости: <br />
<textarea type="text" name="text"></textarea><br />
<input type="checkbox" name="mail" value="1"/> Рассылка<br />
<input type="submit" value="Отправить" /><br />
</form>
'.'</div>';
break;
case 'setting':
if(!empty($_POST)) {
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'title_index'",
array(protect($_POST['title_index'])));
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'reg_mail'",
array(protect($_POST['reg_mail'])));
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'anti_flood'",
array(protect($_POST['anti_flood'])));
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'count_pages'",
array(protect($_POST['count_pages'])));
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'min_out'",
array(protect($_POST['min_out'])));
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'ref_prc'",
array(protect($_POST['ref_prc'])));
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'max_sizefile'",
array(protect($_POST['max_sizefile'])));
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'dollar_curs'",
array(protect($_POST['dollar_curs'])));
echo '<div class="menu">'.'Данные успешно обновлены.'.'</div>';
echo '<div class="menu"><a href="'.HOST.'/admin/">Управление сайтом</a><br /><a href="'.HOST.'/">Личный кабинет</a></div>';
page_foot(); // низ сайта
}
if (!empty($error)) {
echo '<div class="menu">'.$error.'</div>';
}
echo '<div class="menu">'.'
<form action="'.HOST.'/admin/?act=setting" method="POST">
Заголовок сайта: <br />
<input type="text" name="title_index" value="'.$set['title_index'].'" /><br />
Мыло системы: <br />
<input type="text" name="reg_mail" value="'.$set['reg_mail'].'" /><br />
Курс доллара: <br />
<input type="text" name="dollar_curs" value="'.$set['dollar_curs'].'" /><br />
Антифлуд (в секундах): <br />
<input type="text" name="anti_flood" value="'.$set['anti_flood'].'" /><br />
К-во записей на страницу: <br />
<input type="text" name="count_pages" value="'.$set['count_pages'].'" /><br />
Минималка для вывода: <br />
<input type="text" name="min_out" value="'.$set['min_out'].'" /><br />
Процент для рефералов: <br />
<input type="text" name="ref_prc" value="'.$set['ref_prc'].'" /><br />
Максимальный размер файла для выигрузки (в килобайтах): <br />
<input type="text" name="max_sizefile" value="'.$set['max_sizefile'].'" /><br />
<input type="submit" value="Сохранить" /><br />
</form>
'.'</div>';
break;
case 'links':
if(!empty($_POST)) {
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'link_om'",
array(protect($_POST['link_om'])));
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'link_bws'",
array(protect($_POST['link_bws'])));
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'link_comp'",
array(protect($_POST['link_comp'])));
DB :: run() -> query ("UPDATE `settings` SET `value` = ? WHERE `id` = 'link_other'",
array(protect($_POST['link_other'])));
echo '<div class="menu">'.'Данные успешно обновлены.'.'</div>';
echo '<div class="menu"><a href="'.HOST.'/admin/">Управление сайтом</a><br /><a href="'.HOST.'/">Личный кабинет</a></div>';
page_foot(); // низ сайта
}
if (!empty($error)) {
echo '<div class="menu">'.$error.'</div>';
}
echo '<div class="menu">'.'
<form action="'.HOST.'/admin/?act=links" method="POST">
Opera Mini: <br />
<input type="text" name="link_om" value="'.$set['link_om'].'" /><br />
Мобильные: <br />
<input type="text" name="link_bws" value="'.$set['link_bws'].'" /><br />
Компьютеры: <br />
<input type="text" name="link_comp" value="'.$set['link_comp'].'" /><br />
Другие: <br />
<input type="text" name="link_other" value="'.$set['link_other'].'" /><br />
<input type="submit" value="Сохранить" /><br />
</form>
'.'</div>';
break;
// форум
case 'forum':
if (isset($_GET['delmessage']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `forum_messages` WHERE `id`=? LIMIT 1;", array(intval($_GET['delmessage']))) == 1) {
$message = DB :: run() -> queryFetch('select * from `forum_messages` where `id` = ?;',array(intval($_GET['delmessage'])));
$category = DB :: run() -> queryFetch('select * from `forum_themes` where `id` = ?;',array($message['theme_id']));
DB :: run() -> query ("UPDATE `forum_category` SET `count_messages` = `count_messages` - 1 WHERE `id` = ?;", array($category['cat_id']));
DB :: run() -> query('DELETE FROM `forum_messages` WHERE `id` = "'.$message['id'].'";');
@unlink(ROOT.'/misc/forumfiles/'.$message['filename']);
redir(HOST.'/forum/?act=theme&id='.$message['theme_id']);
}
if (isset($_GET['delete']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `forum_category` WHERE `id`=? LIMIT 1;", array(intval($_GET['delete']))) == 1) {
// удаляем темы
$forum_themes = DB :: run() -> query('select * from `forum_themes` where `cat_id` = ?;',array(intval($_GET['delete'])));
while ($theme = $forum_themes -> fetch()) {
// удаляем сообщения
$forum_messages = DB :: run() -> query('select * from `forum_messages` where `theme_id` = ?;',array($theme['id']));
while ($message = $forum_messages -> fetch()) {
DB :: run() -> query ('DELETE FROM `forum_messages` WHERE `id` = ?;', array($message['id']));
@unlink(ROOT.'/misc/forumfiles/'.$message['filename']);
}
DB :: run() -> query ('DELETE FROM `forum_themes` WHERE `id` = ?;', array($theme['id']));
}
DB :: run() -> query ('DELETE FROM `forum_category` WHERE `id` = ?;', array(intval($_GET['delete'])));
redir(HOST.'/forum/');
}
// редактируем форум
if (isset($_GET['edit']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `forum_category` WHERE `id`=? LIMIT 1;", array(intval($_GET['edit']))) == 1) {
$forum = DB :: run() -> queryFetch("SELECT * FROM `forum_category` WHERE `id`=? LIMIT 1;", array(intval($_GET['edit'])));
if(!empty($_POST['name'])) {
$name = protect($_POST['name']);
$desc = protect($_POST['desc']);
$oe = floatval($_POST['out']);
DB :: run() -> query ("UPDATE `forum_category` SET `title` = ?, `description` = ?, `open_theme` = ? WHERE `id` = ?;", array($name, $desc, $oe, $forum['id']) );
echo '<div class="menu">Раздел успешно отредактирован.</div>';
}
echo '<div class="menu">
<form action="'.HOST.'/admin/?act=forum&edit='.$forum['id'].'" method="POST">
Название раздела:<br />
<input type="text" name="name" value="'.$forum['title'].'"/><br />
Описание раздела:<br />
<textarea name="desc" type="text">'.$forum['description'].'</textarea><br />
Создание тем запрещено:<br />
<input type="radio" value="0" name="out" checked="check"/> Нет<br />
<input type="radio" value="1" name="out"/> Да<br />
<input type="submit" value="Сохранить" /><br />
</form>
</div>';
}
// редактируем тему
if (isset($_GET['edit_theme']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `forum_themes` WHERE `id`=? LIMIT 1;", array(intval($_GET['edit_theme']))) == 1) {
$theme = DB :: run() -> queryFetch("SELECT * FROM `forum_themes` WHERE `id`=? LIMIT 1;", array(intval($_GET['edit_theme'])));
if(!empty($_POST['title'])) {
$title = protect($_POST['title']);
$top = floatval($_POST['top']);
$close = floatval($_POST['close']);
DB :: run() -> query ("UPDATE `forum_themes` SET `title` = ?, `top` = ?, `close` = ? WHERE `id` = ?;", array($title, $top, $close, $theme['id']) );
echo '<div class="menu">Тема успешно отредактирована.</div>';
}
echo '<div class="menu">
<form action="'.HOST.'/admin/?act=forum&edit_theme='.$theme['id'].'" method="POST">
Заголовок темы:<br />
<input type="text" name="title" value="'.$theme['title'].'"/><br />
Закрыть тему:<br />
<input type="radio" value="0" name="close" checked="check"/> Нет<br />
<input type="radio" value="1" name="close"/> Да<br />
Вывести наверх:<br />
<input type="radio" value="0" name="top" checked="check"/> Нет<br />
<input type="radio" value="1" name="top"/> Да<br />
<input type="submit" value="Редактировать" /><br />
</form></div>';
}
// переносим тему
if (isset($_GET['themeto']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `forum_themes` WHERE `id`=? LIMIT 1;", array(intval($_GET['themeto']))) == 1) {
$theme = DB :: run() -> queryFetch("SELECT * FROM `forum_themes` WHERE `id`=? LIMIT 1;", array(intval($_GET['themeto'])));
if(!empty($_POST['cat_id'])) {
$cat_id = floatval($_POST['cat_id']);
$count_messages = DB :: run() -> querySingle("SELECT COUNT(*) FROM `forum_messages` WHERE `theme_id`=? LIMIT 1;", array($theme['id']));
DB :: run() -> query ("UPDATE `forum_category` SET `count_themes`=`count_themes`-1,`count_messages` = `count_messages` - '".$count_messages."' WHERE `id` = ?;", array($theme['cat_id']));
DB :: run() -> query ("UPDATE `forum_category` SET `count_themes`=`count_themes`+1,`count_messages` = `count_messages` + '".$count_messages."' WHERE `id` = ?;", array($cat_id));
DB :: run() -> query ("UPDATE `forum_themes` SET `cat_id` = ? WHERE `id` = ?;", array($cat_id, intval($_GET['themeto'])));
echo '<div class="menu">Тема перенесена.</div>';
}
echo '<div class="menu">
<form action="'.HOST.'/admin/?act=forum&themeto='.intval($_GET['themeto']).'" method="POST">
Перенести в раздел:<br />
<select name="cat_id">';
$lists = DB :: run() -> query("SELECT * FROM `forum_category`");
while ($cat = $lists -> fetch()) {
echo '<option value="'.$cat['id'].'">'.$cat['title'].'</option>';
}
echo'</select><br />
<input type="submit" value="Сохранить" /><br />
</form>
</div>';
}
// удаляем тему
if (isset($_GET['deltheme']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `forum_themes` WHERE `id`=? LIMIT 1;", array(intval($_GET['deltheme']))) == 1) {
$theme = DB :: run() -> queryFetch("SELECT * FROM `forum_themes` WHERE `id`=? LIMIT 1;", array(intval($_GET['deltheme'])));
$count_messages = DB :: run() -> querySingle("SELECT COUNT(*) FROM `forum_messages` WHERE `theme_id`=? LIMIT 1;", array($theme['id']));
DB :: run() -> query ("UPDATE `forum_category` SET `count_themes`=`count_themes`-1,`count_messages` = `count_messages` - '".$count_messages."' WHERE `id` = ?;", array($theme['cat_id']));
// удаляем сообщения
$forum_messages = DB :: run() -> query('select * from `forum_messages` where `theme_id` = ?;',array($theme['id']));
while ($message = $forum_messages -> fetch()) {
DB :: run() -> query ('DELETE FROM `forum_messages` WHERE `id` = ?;', array($message['id']));
@unlink(ROOT.'/misc/forumfiles/'.$message['filename']);
}
DB :: run() -> query ("DELETE FROM `forum_themes` WHERE `id` = ?;", array($theme['id']));
echo '<div class="menu">Тема удалена.</div>';
}
break;
CASE 'teasers':
if ($_GET['add']) {
if (isset($_POST['submit'])) {
function getext($filename) {
return end(explode(".", $filename));
}
$current_ext = getext(basename($_FILES['file']['name']));
$allowed_ext = explode(', ', 'jpeg, jpg, gif, png, bmp');
if (!in_array($current_ext, $allowed_ext)) {
print('Файлы формата '.$current_ext.' запрещены');
break;
}
if (empty($_FILES['file']['name'])) {
print('Не выбран файл.');
break;
}
$file = 'teaser_'.time();
copy($_FILES['file']['tmp_name'], './teasers/images/'.$file.'.'.$current_ext);
$title = isset($_POST['title']) ? trim($_POST['title']) : '';
$title = mb_substr($title, 0, 200);
$text = isset($_POST['text']) ? trim($_POST['text']) : '';
$text = mb_substr($text, 0, 500);
$adult = isset($_POST['adult']) ? trim($_POST['adult']) : '0';
DB :: run() -> query ('INSERT INTO `teasers` SET `title` = ?, `text` = ?, `img` = ?, `adult` = ?;',
array($title, $text, $file.'.'.$current_ext, $adult));
echo '<div class="menu"><p>Тизер добавлень</p></div>';
} else {
echo '<form enctype="multipart/form-data" method="post" action="/admin.php?act=teasers&add=ok">' .
'<div class="menu"><p><h3>Выберите картинку (jpg, jpeg, png, gif)</h3>' .
'<input type="file" name="file" value="" /></p>' .
'<p><h3>Название</h3>' .
'<p><input type="text" name="title" value="" /></p>' .
'<p><h3>Текст</h3>' .
'<textarea name="text" rows="4"></textarea><br />' .
'<input type="checkbox" value="1" name="adult" />XXX 18+' .
'<input type="hidden" name="MAX_FILE_SIZE" value="565" />' .
'<p><input type="submit" name="submit" value="Добавить" /></p>' .
'</div></form>';
}
} elseif (isset($_GET['delete']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `teasers` WHERE `id`=? LIMIT 1;", array(intval($_GET['delete']))) == 1) {
// удаляем тизер
$query = DB :: run() -> query('select * from `teasers` where `id` = ?;',array($_GET['delete']));
while ($del = $query -> fetch()) {
@unlink(ROOT.'/teasers/images/'.$del['img']);
}
DB :: run() -> query ('DELETE FROM `teasers` WHERE `id` = ?;', array($_GET['delete']));
echo '<div class="menu">Тизер удалена.</div>';
} elseif (isset($_GET['edit']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `teasers` WHERE `id`=? LIMIT 1;", array(intval($_GET['edit']))) == 1) {
$edit = DB :: run() -> queryFetch("SELECT * FROM `teasers` WHERE `id`=? LIMIT 1;", array(intval($_GET['edit'])));
if (isset($_POST['submit'])) {
$title = isset($_POST['title']) ? trim($_POST['title']) : '';
$title = mb_substr($title, 0, 200);
$text = isset($_POST['text']) ? trim($_POST['text']) : '';
$text = mb_substr($text, 0, 500);
$adult = isset($_POST['adult']) ? trim($_POST['adult']) : '0';
DB :: run() -> query ('UPDATE `teasers` SET `title` = ?, `text` = ?, `adult` = ? WHERE `id` = '.$_GET['edit'].';',
array($title, $text, $adult));
echo '<div class="menu"><p>Тизер изменень</p></div>';
} else {
echo '<form method="post" action="/admin.php?act=teasers&edit='.$_GET['edit'].'">' .
'<p><h3>Название</h3>' .
'<p><input type="text" name="title" value="'.$edit['title'].'" /></p>' .
'<p><h3>Текст</h3>' .
'<textarea name="text" rows="4">'.$edit['text'].'</textarea><br />' .
'<input type="checkbox" value="1" name="adult"'.($edit['adult'] == '1' ? ' checked="checked"' : '').' />XXX 18+' .
'<input type="submit" name="submit" value="Изменить" /></p>' .
'</div></form>';
}
} else {
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=teasers&',$set['count_pages']);
echo '<link rel="stylesheet" type="text/css" href="'.HOST.'/teasers/style.css">';
$querypost = DB :: run() -> query("SELECT * FROM `teasers` ORDER BY `id` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `teasers`;");
if ($total > 0) {
while ($data = $querypost -> fetch()) {
//echo '<div class="menu">'.'';
echo '<table cellspacing="0" cellpadding="0" border="0" class="ads" width="300px"><tr><td style="text-align: center;"><img src="/teasers/images/'.$data['img'].'" width="80" height="80" class="img" alt="*"></td><td><b>'.$data['title'].'</b><br />'.$data['text'].'<br /><a href="'.HOST.'/admin/?act=teasers&delete='.$data['id'].'">Удалить</a> / <a href="'.HOST.'/admin/?act=teasers&edit='.$data['id'].'">Редактировать</a></td></tr></table>';
echo '
';
//echo '</div>';
}
} else {
echo '<div class="menu">Тизеров нет.</div>';
}
echo $nav->navi($total,0);
}
echo '<div class="menu"><a href="/admin.php?act=teasers&add=ok">Добавить тизер</a><br /><a href="/admin.php?act=teasers">Тизери</a></div>';
break;
CASE 'banners':
if ($_GET['add']) {
if (isset($_POST['submit'])) {
function getext($filename) {
return end(explode(".", $filename));
}
$current_ext = getext(basename($_FILES['file']['name']));
$allowed_ext = explode(', ', 'jpeg, jpg, gif, png, bmp');
if (!in_array($current_ext, $allowed_ext)) {
print('Файлы формата '.$current_ext.' запрещены');
break;
}
if (empty($_FILES['file']['name'])) {
print('Не выбран файл.');
break;
}
$file = 'teaser_'.time();
copy($_FILES['file']['tmp_name'], './banners/images/'.$file.'.'.$current_ext);
$adult = isset($_POST['adult']) ? intval($_POST['adult']) : '0';
DB :: run() -> query ('INSERT INTO `banners` SET `adult` = ?, `img` = ?;', array($adult, $file.'.'.$current_ext));
echo '<div class="menu"><p>Баннер добавлен</p></div>';
} else {
echo '<form enctype="multipart/form-data" method="post" action="/admin.php?act=banners&add=ok">' .
'<div class="menu"><p><h3>Выберите картинку (jpg, jpeg, png, gif) (150x60)</h3>' .
'<input type="file" name="file" value="" /></p>' .
'<input type="checkbox" value="1" name="adult" />XXX 18+' .
'<input type="hidden" name="MAX_FILE_SIZE" value="565" />' .
'<p><input type="submit" name="submit" value="Добавить" /></p>' .
'</div></form>';
}
} elseif (isset($_GET['delete']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `banners` WHERE `id`=? LIMIT 1;", array(intval($_GET['delete']))) == 1) {
// удаляем тизер
$query = DB :: run() -> query('select * from `banners` where `id` = ?;',array($_GET['delete']));
while ($del = $query -> fetch()) {
@unlink(ROOT.'/banners/images/'.$del['img']);
}
DB :: run() -> query ('DELETE FROM `banners` WHERE `id` = ?;', array($_GET['delete']));
echo '<div class="menu">Баннер удалена.</div>';
} else {
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=banners&',$set['count_pages']);
$querypost = DB :: run() -> query("SELECT * FROM `banners` ORDER BY `id` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `banners`;");
if ($total > 0) {
while ($data = $querypost -> fetch()) {
echo '<div class="menu">'.'';
echo '<img src="/banners/images/'.$data['img'].'" width="150" height="60" alt="*"><a href="'.HOST.'/admin/?act=banners&delete='.$data['id'].'">Удалить</a>';
echo '
';
echo '</div>';
}
} else {
echo '<div class="menu">Баннеров нет.</div>';
}
echo $nav->navi($total,0);
}
echo '<div class="menu"><a href="/admin.php?act=banners&add=ok">Добавить баннер</a><br /><a href="/admin.php?act=banners">Баннери</a></div>';
break;
CASE 'ads':
if ($_GET['add']) {
if (isset($_POST['submit'])) {
$adult = isset($_POST['adult']) ? intval($_POST['adult']) : '0';
$text = isset($_POST['text']) ? trim($_POST['text']) : '';
$text = mb_substr($text, 0, 50);
DB :: run() -> query ('INSERT INTO `ads` SET `adult` = ?, `text` = ?;',
array($adult, $text));
echo '<div class="menu"><p>Текстовая реклама добавленa</p></div>';
} else {
echo '<form method="post" action="/admin.php?act=ads&add=ok">' .
'<p><h3>Текст</h3>' .
'<p><input type="text" name="text" value="" /></p>' .
'<input type="checkbox" value="1" name="adult" />XXX 18+' .
'<p><input type="submit" name="submit" value="Добавить" /></p>' .
'</div></form>';
}
} elseif (isset($_GET['delete']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `ads` WHERE `id`=? LIMIT 1;", array(intval($_GET['delete']))) == 1) {
DB :: run() -> query ('DELETE FROM `ads` WHERE `id` = ?;', array($_GET['delete']));
echo '<div class="menu">Текстовая реклама удалена.</div>';
} elseif (isset($_GET['edit']) && DB :: run() -> querySingle("SELECT COUNT(*) FROM `ads` WHERE `id`=? LIMIT 1;", array(intval($_GET['edit']))) == 1) {
$edit = DB :: run() -> queryFetch("SELECT * FROM `ads` WHERE `id`=? LIMIT 1;", array(intval($_GET['edit'])));
if (isset($_POST['submit'])) {
$adult = isset($_POST['adult']) ? intval($_POST['adult']) : '0';
$text = isset($_POST['text']) ? trim($_POST['text']) : '';
$text = mb_substr($text, 0, 50);
DB :: run() -> query ('UPDATE `ads` SET `adult` = ?, `text` = ? WHERE `id` = '.$_GET['edit'].';',
array($adult, $text));
echo '<div class="menu"><p>Ткстовая реклама измененa</p></div>';
} else {
echo '<form method="post" action="/admin.php?act=ads&edit='.$_GET['edit'].'">' .
'<p><h3>Текст</h3>' .
'<p><input type="text" name="text" value="'.$edit['text'].'" /></p>' .
'<input type="checkbox" value="1" name="adult"'.($edit['adult'] == '1' ? ' checked="checked"' : '').' />XXX 18+' .
'<input type="submit" name="submit" value="Изменить" /></p>' .
'</div></form>';
}
} else {
include_once ROOT . '/system/inc/classes/Navigator.class.php'; // класс навигации
$nav = new Navigator(HOST.'/admin/?act=ads&',$set['count_pages']);
$querypost = DB :: run() -> query("SELECT * FROM `ads` ORDER BY `id` DESC LIMIT ".$nav->start().", ".$nav->pnumber.";");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `ads`;");
if ($total > 0) {
while ($data = $querypost -> fetch()) {
echo '<div class="menu">'.'';
echo ''.$data['text'].'<br /><a href="'.HOST.'/admin/?act=ads&delete='.$data['id'].'">Удалить</a> / <a href="'.HOST.'/admin/?act=ads&edit='.$data['id'].'">Редактировать</a>';
echo '
';
echo '</div>';
}
} else {
echo '<div class="menu">Текстовые рекламы нет.</div>';
}
echo $nav->navi($total,0);
}
echo '<div class="menu"><a href="/admin.php?act=ads&add=ok">Добавить Текстовая реклама</a><br /><a href="/admin.php?act=ads">Текстовые рекламы</a></div>';
break;
}
echo '<div class="menu"><a href="'.HOST.'/admin/">Управление сайтом</a><br /><a href="'.HOST.'/">Личный кабинет</a><br/> </div>';
page_foot();
?>