View file users/my_files.php

File size: 1.92Kb
<?
include('../core/core.php');
include(BASEDIR.INC.'func.php');
include(BASEDIR.INC.'session.php');
include(BASEDIR.INC.'session_user.php');
$mode = htmlspecialchars($_GET['mode']);
include(BASEDIR.INC.'head.php');
if(is_user()){
$users = mysql_query('SELECT * FROM users WHERE login = "'.$_COOKIE['login'].'"');
$users = mysql_fetch_assoc($users);
$admin = $users['status'];
$login = mysql_real_escape_string(htmlspecialchars($_GET['login']));
if($login == NULL){$login =  $_COOKIE['login'];} else { $login = $login; }
show_title('Файлы пользователей!');
switch ($mode):
case 'index':
if($login == $_COOKIE['login']){echo '<div class="razdel">Мои файлы</div>';} else {echo '<div class="razdel">Файлы '.$login.'</div>';}
define('TOPAGE',10);
$page=(int)$_GET['page'];  
     
   $q=mysql_result(mysql_query("SELECT COUNT(*) FROM `files` WHERE `login`='".$login."'"),0);  
      
    $total = intval(($q - 1) / TOPAGE) + 1;  
      
    if(empty($page) or $page < 0) $page = 1;  
      
    if($page > $total) $page = $total;  
      
    $start = $page * TOPAGE -TOPAGE;  

    $g=mysql_query("SELECT * FROM `files` WHERE `login`='".$login."' ORDER BY `id` DESC LIMIT $start,".TOPAGE."");  
while($u=mysql_fetch_array($g)){ 
echo'<div class="menu">';
echo''.$u['link'].'';
echo'</div>';
}
if ($page != $total) $nextpage = ' <a href="?mode=index&page='. ($page + 1) .'">Далее</a>';  
if($page - 1 > 0) $pageback = '<a href="?mode=index&page='. ($page - 1) .'">Назад</a> ';  
if($q == 0){ echo'Файлов нету!'; }

echo''.$pageback.'  '.$nextpage.'';
break;
default: 
header ('location: ?mode=index'); 
endswitch;
echo'<a href="/">На главную</a>';
} else {echo '<div class="razdel">Доступ закрыт!</div>';
echo'<div class="menu">Доступ разрешен только зарегистированым!</div>';
}
include(BASEDIR.INC.'foot.php');
?>