<?
require'../config.php';
$align='left';
$title='Удаление неактивных юзеров';
aut();
head();
who_add(0,'enter');
$act=htmlspecialchars(trim($_GET['act']));
switch ($act){
default:
echo '<a href="dell.php?act=fullign">Чистка Полного Игнора</a><br/>';
echo '<a href="dell.php?act=drop">Удалить неактивных юзеров за 2 месяца</a><br/>';
break;

############################################################################
// А вот и само удаление неактивных
case 'drop':
echo "<a href='dell.php?act=yes'>Да</a> | <a href='enter.php'>Нет</a></br>";
break;
case 'yes':
$del=time()-2629800;
$user_query = mysql_query("SELECT * FROM `users` WHERE `onl`<'$del'");
while ($user_q = mysql_fetch_assoc($user_query)){
$u=intval($user_q[id]);
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/photos/photo_'.$u.'.jpeg');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/photos/photo_'.$u.'.jpg');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/photos/photo_'.$u.'.png');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/photos/photo_'.$u.'.gif');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/audio/audio_'.$u.'.mp3');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/audio/audio_'.$u.'.wav');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/video/video_'.$u.'.3gp');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/video/video_'.$u.'.avi');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/video/video_'.$u.'.mp4');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/album/album_'.$u.'.gif');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/album/album_'.$u.'.jpg');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/album/album_'.$u.'.jpeg');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/album/album_'.$u.'.bmp');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/album/album_'.$u.'.png');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/groups/logo/'.$u.'.gif');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/groups/logo/'.$u.'.jpg');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/groups/logo/'.$u.'.jpeg');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/groups/logo/'.$u.'.png');
@unlink($_SERVER['DOCUMENT_ROOT'].'/files/groups/logo/'.$u.'.bmp');

mysql_query("DELETE FROM `friends` WHERE (`user_id`='$u') OR (`fr_id`='$u')");
mysql_query("DELETE FROM `ignor` WHERE (`user_id`='$u') OR (`ig_id`='$u')");
mysql_query("DELETE FROM `privat` WHERE (`user_id`='$u') OR (`to_id`='$u')");
mysql_query("DELETE FROM `oko` WHERE (`user_id`='$u') OR (`to_id`='$u')");
mysql_query("DELETE FROM `gifts` WHERE (`user_id`='$u') OR (`to_id`='$u')");
mysql_query("DELETE FROM `akcyi` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `audio` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `audio_komm` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `bannlist` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `diaries` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `diaskomm` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `diaskomm1` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `diaskomm2` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `foto_add` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `foto_albom` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `foto_komm` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `fo_files` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `fo_komm` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `gb` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `group_chat` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `group_news` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `group_newskom` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `group_users` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `komm_photo` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `konkurs` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `message` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `nar` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `news` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `newskom` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `objavs` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `opinions` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `perevod` WHERE `user_id`='$u'");
$fo = mysql_query("SELECT * FROM `fo_files` WHERE `user_id`='$u'");
while($file = mysql_fetch_assoc($fo)){
@unlink($file['path']);
mysql_query("DELETE FROM `fo_files` WHERE `id`='".abs((int)$file['id'])."'");
}
mysql_query("DELETE FROM `questions` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `video` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `video_komm` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `vklads` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `vote_photo` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `vote_us` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `vstr` WHERE `user_id`='$u'");
mysql_query("DELETE FROM `viktorina_users` WHERE `user`='$u'");
mysql_query("DELETE FROM `voices` WHERE `id_user`='$u'");
mysql_query("DELETE FROM `users` WHERE `id`='$u' LIMIT 1");
mysql_query("OPTIMIZE TABLE `users`");
}
echo 'Выполнено успешно!</br>';
break;


############################################################################
//Типо полный игнор
case 'fullign':
$r = mysql_query ("SELECT * from users WHERE whos = '2' ");
$a = mysql_fetch_array($r);
while ($a !== false){
$id = $a['id'];
mysql_query("UPDATE users set whos = '0' WHERE id = '".$id."'");
$a = mysql_fetch_array($r);
}
echo 'Полный Игнор снят со всех пользователей!<br/>';
break;

############################################################################
}
echo gb.'<a href="'.H.'enter">Прихожая</a><br/>'.div;
info_compress();
echo 'Время:'.$debag->endTimer().' сек<br />'.div;
foot();
?>