Файл: core/adminka/users.php
Строк: 695
<?
require_once ("../../core/cuctema/core.php");
$temp_set=$set;
require_once ("../../core/cuctema/adm_check.php");
user_access('adm_log_read',null,'index.php?'.SID);
adm_check();
$set['title']='Админ-панель / Защита';
require_once ("../../core/cuctema/head.php");
aut();
err();
if (user_access('adm_show_adm')){
$act = (isset($_GET['act'])) ? $_GET['act'] : NULL;
switch ($act){
default:
$usearch=NULL;
echo "<div class='d2'>n";
echo "<form method="post" action='/adminka/users/?go'>";
echo "<input type="text" name="usearch" style='width: 87%; margin: 0px; padding: 4px 0px; vertical-align: middle;line-height: 100%;border: 1px solid #ccc;' value='".$usearch."' />n";
echo "<input type="submit" value="Искать" />";
echo "</form></div>n";
$sort='id';
$por='DESC';
if (isset($_GET['ASC']))$por='ASC'; // прямой порядок
if (isset($_GET['DESC']))$por='DESC'; // обратный порядок
if (isset($_GET['sort']))
{
switch ($_GET['sort']) {
case 'balls':$sort='balls'; // баллы
break;
case 'level':$sort='level'; // уровень
break;
case 'rating':$sort='rating'; // рейтинг
break;
case 'pol':$sort='pol'; // пол
break;
case 'id':$sort='id'; // ID
break;
}
}
$usearch=NULL;
if (isset($_SESSION['usearch']))$usearch=$_SESSION['usearch'];
if (isset($_POST['usearch']))$usearch=$_POST['usearch'];
if ($usearch==NULL)
unset($_SESSION['usearch']);
else
$_SESSION['usearch']=$usearch;
$usearch=preg_replace('/( ){1,}/','',$usearch);
if (isset($_GET['go']) && $usearch!=NULL)
{
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `nick` like '%".mysql_escape_string($usearch)."%' OR `id` = '".intval($usearch)."'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)
{
echo "<div class='hide'>Нет результатов</div>";
}
$num =0;
$q=mysql_query("SELECT * FROM `user` WHERE `nick` like '%".mysql_escape_string($usearch)."%' OR `id` = '".intval($usearch)."' ORDER BY `$sort` $por LIMIT $start, $set[p_str]");
while ($ank = mysql_fetch_array($q))
{
if($num==1){
echo "<div class='main123'>n";
$num=0;
}else{
echo "<div class='menu123'>n";
$num=1;}
echo "<table><tr><td>";
avatar($ank['id'],0,0,1);
echo "</td>n";
echo "<td>";
echo "<a href='/id".$ank['id']."'>".$ank['nick']."</a>".online($ank['id'])."<br/>";
if ($ank['pol']==1)
echo "Пол: <span class="menu">Муж</span>n";
else
echo "Пол: <span class="menu">Жен</span>n";
echo "<br/>n";
if ($ank['ank_d_r']!=NULL && $ank['ank_m_r']!=NULL && $ank['ank_g_r']!=NULL){
$ank['ank_age']=date("Y")-$ank['ank_g_r'];
if (date("n")<$ank['ank_m_r'])$ank['ank_age']=$ank['ank_age']-1;
elseif (date("n")==$ank['ank_m_r']&& date("j")<$ank['ank_d_r'])$ank['ank_age']=$ank['ank_age']-1;
echo "Возраст: <span class="menu">$ank[ank_age] лет</span>n";
echo "<br/>n";
}
if ($ank['ank_city']!=NULL)echo "Откуда: <span class="menu">$ank[ank_city]</span><br />n";
else
echo "Откуда: неизвестно<br />n";
if ($sort=='rating')
echo "<span class="ank_n">Рейтинг:</span> <span class="ank_d">$ank[rating]</span><br />n";
if ($sort=='balls')
echo "<span class="ank_n">Рейтинг:</span> <span class="ank_d">$ank[balls]</span><br />n";
if ($sort=='pol')
echo "<span class="ank_n">Пол:</span> <span class="ank_d">".(($ank['pol']==1)?'Мужской':'Женский')."</span>n";
echo "</td></tr></table></div>";
}
if ($k_page>1)str("?go&",$k_page,$page); // Вывод страниц
}else{
echo "<a href='?act=users'><div class='main123 main1234 display'><img src='картинка'/> Весь список пользователей</div></a>n";
echo "<a href='?act=admin'><div class='main123 main1234 display'><img src='картинка'/> Администрация 7emka</div></a>n";
echo "<a href='/adminka/log/'><div class='main123 main1234 display'><img src='картинка'/> Что делает администрация</div></a>n";
echo "<a href='/adminka/ip/'><div class='main123 main1234 display'><img src='картинка'/> Забанены по IP</div></a>n";
echo "<a href='?act=ban'><div class='main123 main1234 display'><img src='картинка'/> Забанены за нарушение</div></a>n";
echo "<a href='?act=online'><div class='main123 main1234 display'><img src='картинка'/> Онлайнер</div></a>n";
echo "<a href='?act=delete'><div class='main123 main1234 display'><img src='картинка'/> Удаление пользователях не посещающих сайт</div></a>n";
echo "<a href='?act=accesses'><div class='main123 main1234 display'><img src='картинка'/> Права доступа</div></a>n";
echo "<a href='?act=nevedimki'><div class='main123 main1234 display'><img src='картинка'/> Пользователи неведимки</div></a>n";
echo "<a href='?act=ban_ip'><div class='main123 main1234 display'><img src='картинка'/> Запретить доступ ip адресу</div></a>n";
echo "<a href='?act=resurs'><div class='main123 main1234 display'><img src='картинка'/> Постороние ресурсы</div></a>n";
}
break;
case 'users':
$sort='id';
$por='DESC';
if (isset($_GET['ASC']))$por='ASC'; // прямой порядок
if (isset($_GET['DESC']))$por='DESC'; // обратный порядок
if (isset($_GET['sort']))
{
switch ($_GET['sort']) {
case 'balls':$sort='balls'; // баллы
break;
case 'rating':$sort='rating'; // рейтинг
break;
case 'id':$sort='id'; // ID
break;
}
}
$sql_sort="`id` $por";
if(isset($_GET['sort'])){
if($_GET['sort']=='balls'){
$sql_sort="`balls` $por";
$sort='balls';
// баллы
}
else if($_GET['sort']=='rating'){
$sql_sort="`rating` $por";
$sort='rating';
// рейтинг
}
else if($_GET['sort']=='id'){
$sql_sort="`id` $por";
$sort='id';
// ID
}
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$usearch=NULL;
echo "<div class='d2'>n";
echo "<form method="post" action='/adminka/users/?go'>";
echo "<input type="text" name="usearch" style='width: 87%; margin: 0px; padding: 4px 0px; vertical-align: middle;line-height: 100%;border: 1px solid #ccc;' value="$usearch" />n";
echo "<input type="submit" value="Искать" />";
echo "</form></div>n";
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_query("SELECT * FROM `user` ORDER BY $sql_sort LIMIT $start, $set[p_str]");
$num = 0;
while ($ank = mysql_fetch_assoc($q)){
$ank=get_user($ank['id']);
$seg = time();
$uge = $seg-$ank['date_reg'];
if($num==1){
echo "<div class='main123 '>n";
$num=0;
}else{
echo "<div class='menu123 '>n";
$num=1;}
echo "<table><tr><td>";
avatar($ank['id'],0,0,1);
echo "</td>n";
echo "<td>";
echo "<a href='/mysite/?name=".$ank['nick']."'>".$ank['nick']."</a>".online($ank['id'])."<br/>";
if ($set['set_show_icon']==1)
echo "<br/>";
if ($ank['group_access']>1)echo "<span style='color:darkgreen'>$ank[group_name]</span><br />n";
if ($ank['id']==300){echo "<span style='color:darkgreen'>Модератор файлов</span><br />n";}
if(isset($ank['us_help']) and $ank['us_help']==1){
echo "<span style='color:darkgreen'>Онлайн помощник</span><br />n";
}
if ($sort=='id')
echo "<span class="ank_n">Посл. посещение:</span> <span class="ank_d">".vremja($ank['date_last'])."</span><br />n";
echo "<span class="ank_n">Уже с нами:</span> <span class="ank_d">".makestime($uge)."</span><br />n";
if (user_access('user_prof_edit') && $user['level']>$ank['level']){
echo "<a href='/adminka/edit_user/?id=$ank[id]'>Редактировать профиль</a><br />n";
}
echo "</td></tr></table></div>";
}
echo "</table>n";
break;
case 'admin':
$k_post=mysql_result(mysql_query("SELECT COUNT(`user`.`id`) FROM `user` LEFT JOIN `user_group` ON `user`.`group_access` = `user_group`.`id` WHERE `user_group`.`level` != 0 AND `user_group`.`level` IS NOT NULL"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>n";
if ($k_post==0)
{
echo "<div class='hide'>Нет результатов</div>";
}
$q=mysql_query("SELECT `user`.`id` FROM `user` LEFT JOIN `user_group` ON `user`.`group_access` = `user_group`.`id` WHERE `user_group`.`level` != 0 AND `user_group`.`level` IS NOT NULL ORDER BY `user_group`.`level` DESC LIMIT $start, $set[p_str]");
while ($ank = mysql_fetch_assoc($q))
{
$ank=get_user($ank['id']);
echo " <div class='d1'>n";
if (user_access('adm_log_read') && $ank['level']!=0 && ($ank['id']==$user['id'] || $ank['level']<$user['level']))
echo "<a href='/adminka/log/?id=$ank[id]'>$ank[nick]</a> ($ank[group_name])".online($ank['id'])."n";
else
echo "<a href='/id$ank[id]'>$ank[nick]</a> ($ank[group_name])".online($ank['id'])."n";
echo " </div>n";
echo " <div class='d2'>n";
echo "<span class="ank_n">Пол:</span> <span class="ank_d">".(($ank['pol']==1)?'Мужской':'Женский')."</span><br />n";
$adm_log_c_all=mysql_result(mysql_query("SELECT COUNT(*) FROM `admin_log` WHERE `id_user` = '$ank[id]'"), 0);
$mes=mktime(0, 0, 0, date('m')-1); // время месяц назад
$adm_log_c_mes=mysql_result(mysql_query("SELECT COUNT(*) FROM `admin_log` WHERE `id_user` = '$ank[id]' AND `time` > '$mes'"), 0);
echo "<span class='ank_n'>Вся активность:</span> <span class='ank_d'>$adm_log_c_all</span><br />n";
echo "<span class='ank_n'>Активность за месяц:</span> <span class='ank_d'>$adm_log_c_mes</span><br />n";
echo "<span class="ank_n">Посл. посещение:</span> <span class="ank_d">".vremja($ank['date_last'])."</span><br />n";
if (isset($user) && ($user['level']>$ank['level'] || $user['level']==4))
{
echo "<a href='/adminka/edit_user/?id=$ank[id]'>Редактировать профиль</a>n";
}
echo " </div>n";
}
echo "</table>n";
if ($k_page>1)str("?",$k_page,$page); // Вывод страниц
if (user_access('adm_panel_show')){
echo "<div class='d1'>n";
echo "«<a href='/adminka/'>В админку</a><br />n";
echo "</div>n";
}
break;
case 'ban':
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `time` > '$time'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_query("SELECT * FROM `ban` WHERE `time` > '$time' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
if ($k_post==0)
{
echo "<div class='hide'>Нет забаненых</div>";
}
while ($ban = mysql_fetch_assoc($q))
{
echo "<div class='d2'>n";
$ank=get_user($ban['id_user']);
echo "<a href='/id$ank[id]'>$ank[nick]</a>".online($ank['id'])."n";
$user_ban=get_user($ban['id_ban']);
echo "<br><span class="ank_n">Забанен до ".vremja($ban['time']).":</span><br />n";
echo "<span class="ank_d">".output_text($ban['prich'])."</span>n($user_ban[nick])</div>n";
if ((isset($access['ban_set']) || isset($access['ban_unset'])) && ($ank['level']<$user['level'] || $user['level']==4))
echo "<a href='/adm_panel/ban.php?id=$ank[id]'>Подробно</a><br />n";
}
if ($k_page>1)str("?",$k_page,$page); // Вывод страниц
if (user_access('adm_panel_show')){
echo '<a href="/adminka/"><div class="d1"><img src="/adm_panel/img/exit.png" > Назад</div></a>';
}
break;
case 'delete':
if (isset($_POST['write']) && isset($_POST['write2']))
{
$timeclear1=0;
if ($_POST['write2']=='sut')$timeclear1=$time-intval($_POST['write'])*60*60*24;
elseif ($_POST['write2']=='mes')$timeclear1=$time-intval($_POST['write'])*60*60*24*30;
else $err[]='Не выбран период';
$q = mysql_query("SELECT * FROM `user` WHERE `date_last` < '$timeclear1'",$db);
$del_th=0;
while ($post = mysql_fetch_assoc($q))
{
$ank['id']=&$post['id'];
mysql_query("DELETE FROM `user` WHERE `id` = '$ank[id]' LIMIT 1");
mysql_query("DELETE FROM `chat_post` WHERE `id_user` = '$ank[id]'");
$q5=mysql_query("SELECT * FROM `forum_t` WHERE `id_user` = '$ank[id]'");
while ($post5 = mysql_fetch_assoc($q5))
{
mysql_query("DELETE FROM `forum_p` WHERE `id_them` = '$post5[id]'");
}
mysql_query("DELETE FROM `forum_t` WHERE `id_user` = '$ank[id]'");
mysql_query("DELETE FROM `forum_p` WHERE `id_user` = '$ank[id]'");
mysql_query("DELETE FROM `forum_zakl` WHERE `id_user` = '$ank[id]'");
mysql_query("DELETE FROM `guest` WHERE `id_user` = '$ank[id]'");
mysql_query("DELETE FROM `loads_komm` WHERE `id_user` = '$ank[id]'");
mysql_query("DELETE FROM `news_komm` WHERE `id_user` = '$ank[id]'");
$opdirbase=@opendir(H.'/core/cuctema/set/user_del');
while ($filebase=@readdir($opdirbase))
if (eregi('.php$',$filebase))
include_once(H.'/core/cuctema/set/user_del/'.$filebase);
$q5=mysql_query("SELECT * FROM `obmennik_files` WHERE `id_user` = '$ank[id]'");
while ($post5 = mysql_fetch_assoc($q5))
{
unlink(H.'sys/obmen/files/'.$post5['id'].'.dat');
}
mysql_query("DELETE FROM `obmennik_files` WHERE `id_user` = '$ank[id]'");
mysql_query("DELETE FROM `users_konts` WHERE `id_user` = '$ank[id]' OR `id_kont` = '$ank[id]'");
mysql_query("DELETE FROM `mail` WHERE `id_user` = '$ank[id]' OR `id_kont` = '$ank[id]'");
mysql_query("DELETE FROM `user_voice` WHERE `id_user` = '$ank[id]' OR `id_kont` = '$ank[id]'");
mysql_query("DELETE FROM `user_collision` WHERE `id_user` = '$ank[id]' OR `id_user2` = '$ank[id]'");
mysql_query("DELETE FROM `votes_user` WHERE `u_id` = '$ank[id]'");
$del_th++;
}
mysql_query("OPTIMIZE TABLE `user`",$db);
msg ("Удалено $del_th пользователей");
}
err();
echo "<form method="post" class='foot' action="?act=delete">n";
echo "<div class='d2'>Будут удалены пользователи, не посещавшие сайт</div><div class='d2'>n";
echo "<input name="write" value="6" type="text" size='3' />n";
echo "<select name="write2">n";
echo "<option value="">--------------</option>n";
echo "<option value="mes">Месяцев</option>n";
echo "<option value="sut">Суток</option>n";
echo "</select><br /><br/>n";
echo "<input value="Удалить" type="submit" />n";
echo "<a href="?">Отмена</a><br />n";
echo "</form></div>n";
if (user_access('adm_panel_show')){
echo "<div class='d1'>n";
echo "«<a href='/adminka/'>В админку</a><br />n";
echo "</div>n";
}
break;
case 'online':
if(isset($_POST['on'])){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '".intval($_POST['id'])."'"),0)!=1)
$err='ID '.$_POST['id'].' не существует';
else
{
mysql_query("UPDATE `user` SET `us_online` = '1' WHERE `id` = '".intval($_POST['id'])."' LIMIT 1");
admin_log('Пользователи','Онлайн',"Включен онлайн для '[url=/info.php?id=".intval($_POST['id'])."]ID: ".intval($_POST['id'])."[/url]'");
msg('Онлайн успешно включен');
}
}
elseif(isset($_POST['off']))
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '".intval($_POST['id'])."'"),0)!=1)
$err='ID '.$_POST['id'].' не существует';
else
{
mysql_query("UPDATE `user` SET `us_online` = '0' WHERE `id` = '".intval($_POST['id'])."' LIMIT 1");
admin_log('Пользователи','Онлайн',"Выключен онлайн для '[url=/info.php?id=".intval($_POST['id'])."]ID: ".intval($_POST['id'])."[/url]'");
msg('Онлайн успешно выключен');
}
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `us_online` = '1'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)
{
echo "<div class='hide'>n";
echo "Нет юзеровn";
echo "</div>n";
}
$q = mysql_query("SELECT * FROM `user` WHERE `us_online` = '1' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while ($ank = mysql_fetch_assoc($q))
{
echo "<div class='d2'>n";
echo "<a href='/id$ank[id]'>$ank[nick]</a>".online($ank['id'])."n";
echo " </div>n";
if ($set['set_show_icon']==1)echo "<div class='d1' colspan='2'>n";
else
echo " <div class='d1'>n";
if ($ank['group_access']>1)echo "Должность <span class='status'>$user[group_name]</span><br />n";
echo "<span class="ank_n">Регистрация:</span> <span class="ank_d">".vremja($ank['date_reg'])."</span><br />n";
if ($ank['show_url']==1)
{
if (otkuda($ank['url']))echo "<span class="ank_n">URL:</span> <span class="ank_d"><a href='$ank[url]'>".otkuda($ank['url'])."</a></span><br />n";
}
echo "</div>n";
}
if ($k_page>1)str("?",$k_page,$page);
echo "<form method="post" action="?act=online" class='d2'>n";
echo "ID юзера:<br />n<input name="id" type="text" />n";
echo "<input value="Включить онлайн" name='on' type="submit" />n";
echo "<input value="Выключить онлайн" name='off' type="submit" />n";
echo "</form>n";
if(user_access('adm_panel_show')){
echo "<div class='d1'>n";
echo "«<a href='/adminka/'>В админку</a><br />n";
echo "</div>n";
}
break;
case 'accesses':
if (isset($_GET['id_group']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user_group` WHERE `id` = '".intval($_GET['id_group'])."'"), 0))
{
$group=mysql_fetch_assoc(mysql_query("SELECT * FROM `user_group` WHERE `id` = '".intval($_GET['id_group'])."'"));
$set['title']=output_text('Группа "'.$group['name'].'" - привилегии'); // заголовок страницы
require_once ("../../core/cuctema/head.php");
if (isset($_POST['accesses']))
{
mysql_query("DELETE FROM `user_group_access` WHERE `id_group` = '$group[id]'");
$q=mysql_query("SELECT * FROM `all_accesses`");
while ($post = mysql_fetch_assoc($q))
{
$type=$post['type'];
if (isset($_POST[$type]) && $_POST[$type]==1)
mysql_query("INSERT INTO `user_group_access` (`id_group`, `id_access`) VALUES ('$group[id]', '$post[type]')");
}
msg('Привилегии успешно изменены');
}
echo "<form method='post' action='/adminka/users/?act=accesses&id_group=$group[id]&$passgen' >n";
$q=mysql_query("SELECT * FROM `all_accesses` ORDER BY `name` ASC");
while ($post = mysql_fetch_assoc($q))
{
echo "<label>";
echo "<div class='d2'><input type='checkbox'".(mysql_result(mysql_query("SELECT COUNT(*) FROM `user_group_access` WHERE `id_group` = '$group[id]' AND `id_access` = '$post[type]' LIMIT 1"),0)==1?" checked='checked'":null)." name='$post[type]' value='1' />";
echo $post['name'];
echo "</label></div>n";
}
echo "<div class='d2'><input value='Применить' name='accesses' type='submit' /></div>";
echo "</form>n";
echo '<div class="d2"><a href="?act=accesses"><img src="/adm_panel/img/exit.png" > Группы</div></a>';
echo '<div class="d2"><a href="/ad/"><img src="/adm_panel/img/exit.png" > Админка</div></a>';
require_once ("../../core/cuctema/foot.php");
}
$set['title']='Группы пользователей'; // заголовок страницы
require_once ("../../core/cuctema/head.php");
$accesses=mysql_query("SELECT * FROM `user_group` ORDER BY `id` ASC");
while ($res = mysql_fetch_assoc($accesses))
{
echo "<div class='d2'><a href='?act=accesses&id_group=$res[id]'>$res[name] (L$res[level], ".mysql_result(mysql_query("SELECT COUNT(*) FROM `user_group_access` WHERE `id_group` = '$res[id]'"),0).")</a></div>n";
}
if (user_access('adm_panel_show')){
echo '<a href="/adminka/"><div class="d1"><img src="/adm_panel/img/exit.png" > Назад</div></a>';
}
break;
case 'nevedimki':
//echo "<table class='post'>n";
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `myguests_n`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)
{
echo " <div class='hide'>n";
echo "Услугу еще не кто не активировал!<br />n";
echo " </div>n";
}
$q=mysql_query("SELECT * FROM `myguests_n` ORDER BY id DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_array($q)) {
$ank=get_user($post['uid']);
echo " <div class='d2'>n";
echo "Пользователь: n";
echo "".online($ank['id'])." <a href='/id".$ank['id']."'>".$ank['nick']."</span></a><br />n";
echo "Услуга активна до: ".vremja($post['time'])."<br />n";
echo " </div>n";
}
//echo "</table>n";
if ($k_page>1)str("?",$k_page,$page);
echo "<div class='d1'>n";
echo "<a href='/adm_panel/'>В админку</a><br />n";
echo "</div>n";
break;
case 'ban_ip':
$opsos=NULL;
err();
if (isset($_POST['min']) && isset($_POST['max']) && isset($_POST['opsos']))
{
if (!preg_match("#^([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})$#",$_POST['min']))$err='Неверный формат IP';
if (!preg_match("#^([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})$#",$_POST['max']))$err='Неверный формат IP';
if ($_POST['opsos']==NULL)$err='Введите название оператора';
$min=ip2long($_POST['min']);
$max=ip2long($_POST['max']);
$opsos=my_esc(stripcslashes(htmlspecialchars($_POST['opsos'])));
mysql_query("INSERT INTO `opsos` (`min`, `max`, `opsos`) values('$min', '$max', '$opsos')",$db);
msg ('Диапазон успешно добавлен');
}
if (isset($_GET['delmin']) && isset($_GET['delmax']) &&
mysql_result(mysql_query("SELECT COUNT(*) FROM `opsos` WHERE `min` = '".$_GET['delmin']."' AND `max` = '".$_GET['delmax']."' LIMIT 1",$db), 0)!=0)
{
mysql_query("DELETE FROM `opsos` WHERE `min` = '".$_GET['delmin']."' AND `max` = '".$_GET['delmax']."' LIMIT 1");
mysql_query("OPTIMIZE TABLE `opsos`");
msg('Диапазон успешно удален');
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `opsos`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)
{
echo "<div class='hide'>Нет операторов</div>";
}
$q=mysql_query("SELECT * FROM `opsos` ORDER BY `opsos` ASC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
echo "<div class='d2'>";
echo long2ip($post['min']).' - '.long2ip($post['max']);
echo "</div>";
echo "<div class='d2'>";
echo "$post[opsos]<br />n";
echo "<a href="?act=ban_ip&page=$page&delmin=$post[min]&delmax=$post[max]">Удалить</a><br />n";
echo "</div>";
}
if ($k_page>1)str('?',$k_page,$page); // Вывод страниц
echo "<form method="post" action='?act=ban_ip'>n";
echo "<div class='d2'>Начальный IP адрес:<br />n<input name="min" size="16" value="" type="text" /></div>n";
echo "<div class='d2'>Завершающий IP:<br />n<input name='max' size='16' value='' type='text' /></div>n";
echo "<div class='d2'>Оператор:<br />n<input name='opsos' size='16' value='".$opsos."' type='text' /></div>n";
echo "<div class='d2'><input value="Добавить" type="submit" /></div>n";
echo "</form>n";
if (user_access('adm_panel_show')){
echo "<div class='d1'>n";
echo "«<a href='/adminka/'>В админку</a><br />n";
echo "</div>n";
}
break;
case 'resurs':
$k_post=mysql_result(mysql_query("SELECT COUNT(distinct(`url`)) FROM `user_ref`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)
{
echo "<div class='hide'>n";
echo "Нет постороних ресуров";
echo "</div>n";
}
$q=mysql_query("SELECT COUNT(`url`) AS `count`, MAX(`time`) AS `time`, `url` FROM `user_ref` GROUP BY `url` ORDER BY `count` DESC LIMIT $start, $set[p_str]");
while ($ref = mysql_fetch_assoc($q))
{
echo "<div class='d1'>n";
echo "URL: <a target='_blank' href='/go.php?go=".base64_encode("http://$ref[url]")."'>".htmlentities($ref['url'])."</a><br />n";
echo "</div>n";
echo "<div class='d2'>n";
echo "Переходов: $ref[count]<br />n";
echo "Последний: ".vremja($ref['time'])."<br />n";
echo "</div>n";
}
if ($k_page>1)str("?",$k_page,$page); // Вывод страниц
if (user_access('adm_panel_show'))echo "<div class='d1'>n";
echo "«<a href='/adminka/'>В админку</a><br />n";
echo "</div>n";
break;
case 'ctatuctuka':
for ($i=0;$i<24;$i++)
{
$hit=mysql_result(mysql_query("SELECT COUNT(*) FROM `visit_today` WHERE `time` >= '".mktime($i,0,0)."' AND `time` < '".mktime($i+1,0,0)."'"),0);
$host=mysql_result(mysql_query("SELECT COUNT(DISTINCT `ip`) FROM `visit_today` WHERE `time` >= '".mktime($i,0,0)."' AND `time` < '".mktime($i+1,0,0)."'"),0);
$user_reg=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_reg` >= '".mktime($i,0,0)."' AND `date_reg` < '".mktime($i+1,0,0)."'"),0);
$forum_them=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` WHERE `time_create` >= '".mktime($i,0,0)."' AND `time_create` < '".mktime($i+1,0,0)."'"),0);
$forum_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `time` >= '".mktime($i,0,0)."' AND `time` < '".mktime($i+1,0,0)."'"),0);
$stat[]=array('hit'=>$hit,'host'=>$host,'time'=>mktime($i,0,0),'for_th'=>$forum_them,'for_p'=>$forum_post,'user'=>$user_reg);
}
echo "<div class ='d1'>";
echo "Текущие сутки:<br />n";
echo "</div>";
echo "<div class ='d2'>";
echo "<table border='1'>";
echo "<tr>n";
echo "<td><b>Час</b></td>n";
echo "<td><b>Хиты</b></td>n";
echo "<td><b>Хосты</b></td>n";
echo "<td><b>Рег.</b></td>n";
echo "<td><b>Форум-темы</b></td>n";
echo "<td><b>Форум-посты</b></td>n";
echo "</tr>n";
for ($i=0;$i<sizeof($stat);$i++)
{
if ($time<$stat[$i]['time'])continue;
echo "<tr>n";
echo "<td>".date('H',$stat[$i]['time']+$user['set_timesdvig']*60*60)."</td>n";
echo "<td>".$stat[$i]['hit']."</td>n";
echo "<td>".$stat[$i]['host']."</td>n";
echo "<td>".$stat[$i]['user']."</td>n";
echo "<td>".$stat[$i]['for_th']."</td>n";
echo "<td>".$stat[$i]['for_p']."</td>n";
echo "</tr>n";
}
echo "</table><br />n";
unset($stat);
echo "</div>";
echo "<div class ='d1'>";
echo "Последний месяц:<br />n";
echo "</div>";
echo "<div class ='d2'>";
$k_day=mysql_result(mysql_query("SELECT COUNT(*) FROM `visit_everyday`"),0);
$q=mysql_query("SELECT * FROM `visit_everyday` ORDER BY `time` ASC LIMIT ".max($k_day-30,0).", 30");
while ($result=mysql_fetch_assoc($q)) {
$day_st=mktime(0, 0, 0, date('n', $result['time']), date('j', $result['time']));
$day_fn=mktime(0, 0, 0, date('n', $result['time']), date('j', $result['time'])+1);
$user_reg=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_reg` >= '$day_st' AND `date_reg` < '$day_fn'"),0);
$forum_them=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` WHERE `time_create` >= '$day_st' AND `time_create` < '$day_fn'"),0);
$forum_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `time` >= '$day_st' AND `time` < '$day_fn'"),0);
$stat[]=array('host'=>($result['host_ip_ua']<$result['host']*2?$result['host_ip_ua']:$result['host']),'hit'=>$result['hit'],'time'=>$result['time'],'for_th'=>$forum_them,'for_p'=>$forum_post,'user'=>$user_reg);
}
echo "<table border='1'>";
echo "<tr>n";
echo "<td><b>Дата</b></td>n";
echo "<td><b>Хиты</b></td>n";
echo "<td><b>Хосты</b></td>n";
echo "<td><b>Рег.</b></td>n";
echo "<td><b>Форум-темы</b></td>n";
echo "<td><b>Форум-посты</b></td>n";
echo "</tr>n";
for ($i=0;$i<sizeof($stat);$i++)
{
echo "<tr>n";
echo "<td>".date('d.m.Y',$stat[$i]['time'])."</td>n";
echo "<td>".$stat[$i]['hit']."</td>n";
echo "<td>".$stat[$i]['host']."</td>n";
echo "<td>".$stat[$i]['user']."</td>n";
echo "<td>".$stat[$i]['for_th']."</td>n";
echo "<td>".$stat[$i]['for_p']."</td>n";
echo "</tr>n";
}
echo "</table><br />n";
echo "</div>";
if (user_access('adm_panel_show')){
echo "<a href='/adminka/'><div class='main123 main1234 display'><img src='картинка'/> Админка</div></a>n";
}
break;
}
}
require_once ("../../core/cuctema/foot.php");
?>