View file forum/clear.php

File size: 2.85Kb
<?
include_once "../SYSTEM/include/functions.php";
include_once "../SYSTEM/include/mysql.php";
include_once "../SYSTEM/include/param.php";
include_once "../SYSTEM/include/ban.php";
include_once "../SYSTEM/include/sess.php";
include_once "../SYSTEM/include/ban_2.php";
include_once "../SYSTEM/include/theme.php";
$title='Очистка форума';
$mesto='Очищает форум';
head();
if (!isset($user) || $user['level']<3)
{
header("Location: index.php?".SID."&");
exit;
}

echo "<div class=\"h\"><b>Удалить темы</b></div><hr />\n";

if ($mail_in_new>0)echo "<div class=\"privat\"><img src=\"../SYSTEM/themes/$them/img/mail0.gif\" alt=\"\" /> <a href=\"../mail.php?act=in\">Приват</a> [$mail_in_new]</div><hr />\n";


if (isset($_GET['act']) && $_GET['act']=='clear' && isset($_POST['write']) && isset($_POST['write2']) && isset($_POST['read']) && isset($_POST['read2']))
{
$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;

$timeclear2=0;
if ($_POST['read2']=='sut')$timeclear2=$time-intval($_POST['read'])*60*60*24;
if ($_POST['read2']=='mes')$timeclear2=$time-intval($_POST['read'])*60*60*24*30;

$q = mysql_query("SELECT * FROM `$mysql[pref]forum_t` WHERE `time_last` < '$timeclear1' OR `time_read` < '$timeclear2';");

$del_th=0;
while ($thema = mysql_fetch_array($q))
{

mysql_query("DELETE FROM `$mysql[pref]forum_t` WHERE `id` = '$thema[id]';");
mysql_query("DELETE FROM `$mysql[pref]forum_p` WHERE `id_t` = '$thema[id]';");
$del_th++;
}
mysql_query("OPTIMIZE TABLE `$mysql[pref]forum_p` , `$mysql[pref]forum_t`;");
echo "Удалено $del_th тем<br />";
}




echo "<form method=\"post\" action=\"clear.php?act=clear\">\n";
echo "Будут удалены темы, в которых не писали<br />\n";
echo "<input name=\"write\" class=\"form\" value=\"12\" type=\"text\" /><br />\n";
echo "<select class=\"form\" name=\"write2\">\n";
echo "<option value=\"\">       </option>\n";
echo "<option value=\"mes\">Месяцев</option>\n";
echo "<option value=\"sut\">Суток</option>\n";
echo "</select><br />\n";

echo "Будут удалены темы, которые не читали<br />\n";
echo "<input name=\"read\" class=\"form\" value=\"12\" type=\"text\" /><br />\n";
echo "<select class=\"form\" name=\"read2\">\n";
echo "<option value=\"\">       </option>\n";
echo "<option value=\"mes\">Месяцев</option>\n";
echo "<option value=\"sut\">Суток</option>\n";
echo "</select><br />\n";


echo "<input value=\"Очистка\" class=\"form\" type=\"submit\" />\n";
echo "</form>\n";
echo "<br />\n";



echo "<a href=\"index.php\">Вернуться</a>\n";
echo "<br /><a href=\"../index.php\">На главную</a><br />\n";

foot();
?>