Файл: fo/pop.php
Строк: 62
<?php
require '../system/sid.php';
require '../system/config.php';
if (!empty($_SESSION['us']))
{
    include '../system/user.php';
       whorm(0, 'fo');
}
include '../system/head.php';
include '../system/navigator.php';
    echo $div_title . 'Обменник' . $div_end . '
         ' . $div_menu . '
         <img src="../ico/up.gif" alt=""/> <a href="index.php?">Обменник</a>
         ' . $block . '
         <a href="search.php?">Поиск</a><br/>
         <b>Популярные</b> |
         <a href="new.php?">Новые</a>
         ' . $div_end;
    if (isset($_GET['del'])) {
    if ($user['level'] != 4 && $user['level'] != 5) {
        header('Location: index.php');
        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);
         $SizeF = filesize($info['url']);
         // удаление рейтинга
           mysql_query("DELETE FROM `rating_files` WHERE `uid` = '$del'");
         // удаление комментов
           mysql_query("DELETE FROM `fo_komm` WHERE `uid` = '$del'");
         // удаление размера
           mysql_query("UPDATE `users` SET `fo_size` = '" . (minus(user_inf($info['author'], 'fo_size') - $SizeF)) . "' WHERE id = '$info[author]' LIMIT 1");
           if (file_exists($info['url'])) unlink($info['url']);
           if (file_exists($info['screen'])) unlink($info['screen']);
           // удаление файла
           $TXT = '<small>(' . date('d-m-y в H:i:s') . ')</small><br/>' . elite($user['id']) . ' ' . $user['user'] . ' удалил файл <b>' . $info['title'] . '</b> из обменника.';
           mysql_query("DELETE FROM `fo_files` WHERE `id` = '$del' LIMIT 1");
           header('Location: new.php');
        } else {
           header('Location: new.php');
        }
    }
    $select = mysql_result(mysql_query("SELECT COUNT(id) FROM `fo_files` WHERE `moder` = '0' AND `clicks` > '0'"), 0);
    $n = new navigator($select, 10, '?');
      if ($select != FALSE) {
        $i = 0;
          $view = mysql_query("SELECT * FROM `fo_files` WHERE `moder` = '0' AND `clicks` > '0' ORDER BY `clicks` DESC {$n->limit}");
           while($a = mysql_fetch_assoc($view)) {
            ##########################
            $ex = pathinfo($a['url']);
            $ext = strtolower($ex['extension']);
            if ($ext == 'zip') $format = '<img src="img/zip.gif" alt="*"/> ';
            elseif ($ext == 'rar') $format = '<img src="img/rar.gif" alt="*"/> ';
            elseif ($ext == 'gz') $format = '<img src="img/gz.gif" alt="*"/> ';
            elseif ($ext == 'tar') $format = '<img src="img/tar.gif" alt="*"/> ';
            else $format = '<img src="img/unknown.gif" alt="*"/> ';
            ##########################
            $Size = filesize($a['url']);
            $Size = get_size($Size);
            $inf = (!empty($a['info'])) ? $a['info'] : 'Без описания';
            $cont = (mb_strlen($inf, 'UTF8') > 100)
           ? mb_substr($inf, 0, 100, 'UTF8') . '...'
           : $inf;
            if ($user['level'] == 4 || $user['level'] == 5) {
                $dl = '<a href="pop.php?del='.$a['id'].'"><img src="../ico/delete.png" alt=""/></a> ';
            }
               echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
               echo $dl . '<br/>' . $format . ' <a href="info-'.$a['id'].'">' . $a['title'] . '</a> (' . $Size . ')<br/>' . bb_code($cont) . $div_end;
           }
          echo $n->navi();
      } else {
       echo 'Популярных файлов нет.<br/>';
     }
include '../system/foot.php';
?>