Файл: fo/new.php
Строк: 69
<?php
require '../sid.php';
require '../config.php';
$link = connect_db();
if (!empty($_SESSION['us'])) {
list($user, $id, $ps) = check_login($link);
whorm(0, 'fo');
}
include '../head.php';
include '../navigator.php';
echo $div_title . 'Зона обмена' . $div_end . '
' . $div_left . $div_menu . '
<img src="../ico/up.gif" alt=""/> <a href="index.php?'.$ref.'">Зона обмена</a>
' . $block . $load . '
<a href="search.php?'.$ref.'">Поиск</a><br/>
<a href="pop.php?'.$ref.'">Популярные</a> |
<b>Новые</b>
' . $div_end;
$select = mysql_result(mysql_query("SELECT COUNT(*) FROM `fo_files` WHERE `moder` = '0'"), 0);
$num_fil = (!empty($_SESSION['us'])) ? $user['onp_files'] : 10;
if (isset($_GET['del'])) {
if ($user['level'] != 1 && $user['level'] != 4 && $user['level'] != 5) {
header('Location: index.php?' . $ref);
die();
}
$del = my_int($_GET['del']);
$sql = mysql_query("SELECT * FROM `fo_files` WHERE `id` = '$del' LIMIT 1");
if (mysql_num_rows($sql) != FALSE) {
$info = mysql_fetch_assoc($sql);
// удаление файла
mysql_query("DELETE FROM `fo_files` WHERE `id` = '$del' LIMIT 1");
// удаление рейтинга
mysql_query("DELETE FROM `rating_files` WHERE `uid` = '$del'");
// удаление комментов
mysql_query("DELETE FROM `fo_komm` WHERE `uid` = '$del'");
$game = end(explode('.', $info['url']));
// если удаляется игра
if ($game[1] == 'jar') {
// то удаляем файлы к ней
if (file_exists($game[0] . '.jad')) unlink($game[0] . '.jad');
} elseif ($game[1] == 'jad') {
if (file_exists($game[0] . '.jar')) unlink($game[0] . '.jar');
}
// если удаляется тема
if ($game[1] == 'nth') {
// то удаляем скрины к ней
if (file_exists($game[0] . '.nth.gif')) unlink($game[0] . '.nth.gif');
} elseif ($game[1] == 'thm') {
if (file_exists($game[0] . '.thm.gif')) unlink($game[0] . '.thm.gif');
}
if (file_exists($info['url'])) unlink($info['url']);
header('Location: new.php?' . $ref);
} else {
header('Location: new.php?' . $ref);
}
}
$n = new navigator($select, $num_fil, '?');
if ($select != FALSE) {
$i = 0;
$view = mysql_query("SELECT * FROM `fo_files` WHERE `moder` = '0' ORDER BY `id` DESC {$n->limit}");
while($a = mysql_fetch_assoc($view)) {
##############################
$ex = pathinfo($a['url']);
$ext = strtolower($ex['extension']);
if ($ext == '3gp') $format = '<img src="img/3gp.gif" alt="*"/>';
elseif ($ext == 'avi') $format = '<img src="img/avi.gif" alt="*"/>';
elseif ($ext == 'gif') $format = '<img src="img/gif.gif" alt="*"/>';
elseif ($ext == 'jpg') $format = '<img src="img/jpg.gif" alt="*"/>';
elseif ($ext == 'mp3') $format = '<img src="img/mp3.gif" alt="*"/>';
elseif ($ext == 'zip') $format = '<img src="img/zip.gif" alt="*"/>';
elseif ($ext == 'jar') $format = '<img src="img/jar.gif" alt="*"/> ';
else $format = '<img src="img/unknown.gif" alt="*"/>';
##############################
if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png' || $ext == 'bmp' || $ext == 'jpeg' || $ext == 'ico' || $ext == 'iso' || $ext == 'imy' || $ext == 'wbmp') $prev = '<img src="../resize.php?img=fo/'.$a['url'].'&width=40&height=0&i=0" alt="*"/>';
elseif ($ext == 'avi' || $ext == '3gp' || $ext == 'mp4' || $ext == 'mpeg' && extension_loaded('ffmpeg')) {
$prev = '<img src="ffmpeg.php?fid='.$a['url'].'" width="40" height="40" alt="preview"/>';
}
elseif ($ext == 'nth' || $ext == 'thm') {
$prev = '<img src="theme.php?i='.$a['id'].'" width="40" height="40" alt=""/>';
} else {
$prev = '';
}
$inf = (!empty($a['info'])) ? $a['info'] : 'Без описания';
if ($user['level'] == 1 || $user['level'] == 4 || $user['level'] == 5) {
$dl = '<a href="new.php?&del='.$a['id'].'"><img src="../ico/delete.gif" alt=""/></a> ';
}
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $dl . $prev . '<br/>' . $format . ' <a href="info.php?i='.$a['id'].'">' . $a['title'] . '</a><br/>' . $inf . $div_end;
}
echo $n->navi();
} else {
echo 'Новых файлов нет.<br/>';
}
echo $div_end;
include '../foot.php';
?>