<?
/*
Автор скрипта: Mstivoj
Сайт поддержки: http://4i4i.ru
Запрещено распространять скрипт в любом виде и под любым предлогом !
*/
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/adm_check.php';
include_once '../sys/inc/user.php';
user_access('adm_accesses',null,'index.php?'.SID);
adm_check();

$act = isset($_GET['act']) ? trim($_GET['act']) : '';
switch ($act) {
/////////////////////////////////////////////////////////////////////
case 'mail':

$set['title']='Очистка Почты';
include_once '../sys/inc/thead.php';
title();
aut();

if (isset($_POST['write']) && isset($_POST['write2']))
{
$timeclear1=0;

if ($_POST['write2']=='sut')$timeclear1=$time-intval($_POST['write'])*60*60*24;
if ($_POST['write2']=='mes')$timeclear1=$time-intval($_POST['write'])*60*60*24*30;

$q = mysql_query("SELECT * FROM `mail` WHERE `time` < '$timeclear1'",$db);

$del_th=0;

while ($post = mysql_fetch_assoc($q))
{
mysql_query("DELETE FROM `mail` WHERE `id` = '$post[id]'",$db);
$del_th++;
}

mysql_query("OPTIMIZE TABLE `mail`",$db);
msg ("Удалено $del_th сообщений");
}


$count=mysql_result(mysql_query("SELECT COUNT(*) FROM `mail`"),0);
echo '<div class="foot"><div style="text-align: center;">Всего сообщений: '.$count.'</div></div>';

echo "<div class='main_menu'><form method='post'>\n";
echo "Будут удалены сообщения написанные ... тому назад<br />\n";
echo "<input name=\"write\" value=\"31\" type=\"text\" size='3' />\n";
echo "<select name=\"write2\">\n";
echo "<option value=\"sut\">Суток</option>\n";
echo "<option value=\"mes\">Месяцев</option>\n";
echo "</select><br />\n";
echo "<input value=\"Очистить\" type=\"submit\" /><br />\n";
echo "</form></div>\n";

echo "<div class='foot'>\n";
echo "&laquo; <a href='del.php'>отмена</a>\n";
echo "</div>\n";
  
break;
//////////////////////////////////////////////////////////////////// 
case 'tape':

$set['title']='Очистка Ленты';
include_once '../sys/inc/thead.php';
title();
aut();

if (isset($_POST['write']) && isset($_POST['write2']))
{
$timeclear1=0;

if ($_POST['write2']=='sut')$timeclear1=$time-intval($_POST['write'])*60*60*24;
if ($_POST['write2']=='mes')$timeclear1=$time-intval($_POST['write'])*60*60*24*30;

$q = mysql_query("SELECT * FROM `tape` WHERE `time` < '$timeclear1'",$db);

$del_th=0;

while ($post = mysql_fetch_assoc($q))
{
mysql_query("DELETE FROM `tape` WHERE `id` = '$post[id]'",$db);
$del_th++;
}

mysql_query("OPTIMIZE TABLE `tape`",$db);
msg ("Удалено $del_th уведомлений");
}


$count=mysql_result(mysql_query("SELECT COUNT(*) FROM `tape`"),0);
echo '<div class="foot"><div style="text-align: center;">Всего уведомлений: '.$count.'</div></div>';

echo "<div class='main_menu'><form method='post'>\n";
echo "Будут удалены уведомления, написанные ... тому назад<br />\n";
echo "<input name=\"write\" value=\"7\" type=\"text\" size='3' />\n";
echo "<select name=\"write2\">\n";
echo "<option value=\"sut\">Суток</option>\n";
echo "<option value=\"mes\">Месяцев</option>\n";
echo "</select><br />\n";
echo "<input value=\"Очистить\" type=\"submit\" /><br />\n";
echo "</form></div>\n";

echo "<div class='foot'>\n";
echo "&laquo; <a href='del.php'>отмена</a>\n";
echo "</div>\n";
  
break;
/////////////////////////////////////////////////////////////////////
case 'notification':

$set['title']='Очистка Журнала';
include_once '../sys/inc/thead.php';
title();
aut();

if (isset($_POST['write']) && isset($_POST['write2']))
{
$timeclear1=0;

if ($_POST['write2']=='sut')$timeclear1=$time-intval($_POST['write'])*60*60*24;
if ($_POST['write2']=='mes')$timeclear1=$time-intval($_POST['write'])*60*60*24*30;

$q = mysql_query("SELECT * FROM `notification` WHERE `time` < '$timeclear1'",$db);

$del_th=0;

while ($post = mysql_fetch_assoc($q))
{
mysql_query("DELETE FROM `notification` WHERE `id` = '$post[id]'",$db);
$del_th++;
}

mysql_query("OPTIMIZE TABLE `notification`",$db);
msg ("Удалено $del_th уведомлений");
}


$count=mysql_result(mysql_query("SELECT COUNT(*) FROM `notification`"),0);
echo '<div class="foot"><div style="text-align: center;">Всего уведомлений: '.$count.'</div></div>';

echo "<div class='main_menu'><form method='post'>\n";
echo "Будут удалены уведомления, написанные ... тому назад<br />\n";
echo "<input name=\"write\" value=\"7\" type=\"text\" size='3' />\n";
echo "<select name=\"write2\">\n";
echo "<option value=\"sut\">Суток</option>\n";
echo "<option value=\"mes\">Месяцев</option>\n";
echo "</select><br />\n";
echo "<input value=\"Очистить\" type=\"submit\" /><br />\n";
echo "</form></div>\n";

echo "<div class='foot'>\n";
echo "&laquo; <a href='del.php'>отмена</a>\n";
echo "</div>\n";
  
break;
/////////////////////////////////////////////////////////////////////
case 'discussions':

$set['title']='Очистка Обсуждений';
include_once '../sys/inc/thead.php';
title();
aut();

if (isset($_POST['write']) && isset($_POST['write2']))
{
$timeclear1=0;

if ($_POST['write2']=='sut')$timeclear1=$time-intval($_POST['write'])*60*60*24;
if ($_POST['write2']=='mes')$timeclear1=$time-intval($_POST['write'])*60*60*24*30;

$q = mysql_query("SELECT * FROM `discussions` WHERE `time` < '$timeclear1'",$db);

$del_th=0;

while ($post = mysql_fetch_assoc($q))
{
mysql_query("DELETE FROM `discussions` WHERE `id` = '$post[id]'",$db);
$del_th++;
}

mysql_query("OPTIMIZE TABLE `discussions`",$db);
msg ("Удалено $del_th уведомлений");
}


$count=mysql_result(mysql_query("SELECT COUNT(*) FROM `discussions`"),0);
echo '<div class="foot"><div style="text-align: center;">Всего уведомлений: '.$count.'</div></div>';

echo "<div class='main_menu'><form method='post'>\n";
echo "Будут удалены уведомления, написанные ... тому назад<br />\n";
echo "<input name=\"write\" value=\"7\" type=\"text\" size='3' />\n";
echo "<select name=\"write2\">\n";
echo "<option value=\"sut\">Суток</option>\n";
echo "<option value=\"mes\">Месяцев</option>\n";
echo "</select><br />\n";
echo "<input value=\"Очистить\" type=\"submit\" /><br />\n";
echo "</form></div>\n";

echo "<div class='foot'>\n";
echo "&laquo; <a href='del.php'>отмена</a>\n";
echo "</div>\n";
  
break;
/////////////////////////////////////////////////////////////////////
case 'user_log':

$set['title']='Очистка Истории Входов';
include_once '../sys/inc/thead.php';
title();
aut();

if (isset($_POST['write']) && isset($_POST['write2']))
{
$timeclear1=0;

if ($_POST['write2']=='sut')$timeclear1=$time-intval($_POST['write'])*60*60*24;
if ($_POST['write2']=='mes')$timeclear1=$time-intval($_POST['write'])*60*60*24*30;

$q = mysql_query("SELECT * FROM `user_log` WHERE `time` < '$timeclear1'",$db);

$del_th=0;

while ($post = mysql_fetch_assoc($q))
{
mysql_query("DELETE FROM `user_log` WHERE `id` = '$post[id]'",$db);
$del_th++;
}

mysql_query("OPTIMIZE TABLE `user_log`",$db);
msg ("Удалено $del_th входов");
}


$count=mysql_result(mysql_query("SELECT COUNT(*) FROM `user_log`"),0);
echo '<div class="foot"><div style="text-align: center;">Всего входов: '.$count.'</div></div>';

echo "<div class='main_menu'><form method='post'>\n";
echo "Будут удалены входы сделанные ... тому назад<br />\n";
echo "<input name=\"write\" value=\"7\" type=\"text\" size='3' />\n";
echo "<select name=\"write2\">\n";
echo "<option value=\"sut\">Суток</option>\n";
echo "<option value=\"mes\">Месяцев</option>\n";
echo "</select><br />\n";
echo "<input value=\"Очистить\" type=\"submit\" /><br />\n";
echo "</form></div>\n";

echo "<div class='foot'>\n";
echo "&laquo; <a href='del.php'>отмена</a>\n";
echo "</div>\n";
  
break;
/////////////////////////////////////////////////////////////////////

default;
    
//////////////////////////////////////////////////////////////////////
    
    
$set['title']='Очистка уведомлений';
include_once '../sys/inc/thead.php';
title();
aut();


echo "<div class='main_menu'>\n";
echo "<img src='/style/icons/delete.gif' alt='' class=''/>\n";
echo" <a href='?act=mail'>Очистка Почты</a>";
echo "</div>\n";


echo "<div class='main_menu'>\n";
echo "<img src='/style/icons/delete.gif' alt='' class=''/>\n";
echo" <a href='?act=tape'>Очистка Ленты</a>";
echo "</div>\n";


echo "<div class='main_menu'>\n";
echo "<img src='/style/icons/delete.gif' alt='' class=''/>\n";
echo" <a href='?act=notification'>Очистка Журнала</a>";
echo "</div>\n";


echo "<div class='main_menu'>\n";
echo "<img src='/style/icons/delete.gif' alt='' class=''/>\n";
echo" <a href='?act=discussions'>Очистка Обсуждений</a>";
echo "</div>\n";


echo "<div class='main_menu'>\n";
echo "<img src='/style/icons/delete.gif' alt='' class=''/>\n";
echo" <a href='?act=user_log'>Очистка Историй входов</a>";
echo "</div>\n";

echo "<div class='foot'>\n";
echo "&laquo; <a href='/adm_panel/'>В админку</a>\n";
echo "</div>\n";
    
}

include_once '../sys/inc/tfoot.php';
?>