Файл: my/files.php
Строк: 152
<?
define('GCMS',true);
define('ROOT','../');
require_once (ROOT.'system/power.php');
if ($aut) {
$diz -> head('Мои файлы');
$diz -> title('Мои файлы');
switch($mode){
///фото
case 'photo':
$count = $db -> dbcount('COUNT(`id`)','files',"`user` = '".$ya['id']."' and `what`='foto'");
if($count>0){
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1;
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
////------------------/////
$for = $db -> query("SELECT `id`,`name`,`url`,`info` FROM `files` where `user`='".$ya['id']."' and `what`='foto' order by `time` DESC LIMIT ".$start.",".$num);
while ($assoc = $for -> fetch_assoc()) {
$foto = ''.ROOT.'downloads/foto/'.$assoc['url'];
echo '<div class="menu"><a href="'.ROOT.'photo'.$assoc['id'].'" class="menutuch"/>
<table width=100%>
<tr valign="top">
<td width=2%><img src="/system/resize.php?img='.$foto.'&width=48&height=48&i=0"/></td>
<td>'.$assoc['name'].'</td></tr></table></a></div>';
}
$act = '?mode=photo';
echo $func -> pagenav($act,$page,$total);
} else echo '<div class="fon">У вас нет фотографий.</div>';
echo '<div class="levo"><a href="?" class="levo_tuch">'.$diz -> img('back.png').' Назад</a></div>';
break;
///аудио
case 'audio':
$count = $db -> dbcount('COUNT(`id`)','files',"`user` = '".$ya['id']."' and `format`='mp3'");
if($count>0){
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1;
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
////------------------/////
$for = $db -> query("SELECT `id`,`name`,`url`,`info` FROM `files` where `user`='".$ya['id']."' and `format`='mp3' order by `time` DESC LIMIT ".$start.",".$num);
while ($assoc = $for -> fetch_assoc()) {
echo '<div class="fon"><span class="date">'.$assoc['name'].'</span>'.$func->player(ROOT.'downloads/other/'.$assoc['url'],3).'</div>';
echo '<div class="zap">
<a class="zap_b" href="?mode=red_audio&id='.$assoc['id'].'">Изменить</a>
<a class="zap_b" href="?mode=delete&id='.$assoc['id'].'&do=audio">Удалить</a>
</div>';
}
$act = '?mode=audio';
echo $func -> pagenav($act,$page,$total);
} else echo '<div class="fon">У вас нет аудиозаписей.</div>';
echo '<div class="levo"><a href="?" class="levo_tuch">'.$diz -> img('back.png').' Назад</a></div>';
break;
///изменение аудио
case 'red_audio':
$count = $db -> dbcount('COUNT(`id`)','files','`id`="'.$id.'" and `format`="mp3" and `user`="'.$ya['id'].'"');
$f = $db -> query("SELECT * FROM `files` where `id`='".$id."' and `format`='mp3' and `user`='".$ya['id']."'")-> fetch_assoc();
if($count>0){
if (empty($_POST['name'])) {
$diz -> head('Изменение аудиозаписи');
$diz -> title('Изменение аудиозаписи');
echo '<div class="fon">
<form action="?id='.$id.'&mode=red_audio" method="post">
Название:<br/>
<textarea name="name" rows="'.$ya['height'].'" cols="'.$ya['width'].'">'.$f['name'].'</textarea><br/>
<input type="submit" value="Изменить"/></form></div>';
} else {
$name = shit($_POST['name']);
$db -> query("Update `files` SET `name` = '".$name."' where `id`='".$id."'");
header('location: ?mode=audio');
}
echo '<div class="levo"><a href="?mode=audio" class="levo_tuch">'.$diz -> img('back.png').' Назад</a></div>';
}else header('location: ?');
break;
///удаление файлов
case 'delete':
$f = $db -> query("SELECT * FROM `files` where `id`='".$id."' and `user`='".$ya['id']."' and `what`<>'foto'")-> fetch_assoc();;
if ($f['id']>0){
if (!isset($_GET['true'])) {
$diz -> head('Удаление файла');
$diz -> title('Удаление файла');
echo '<div class="fon">Вы действительно желаете удалить выбранный файл?</div>';
echo '<div class="dialog">
<a class="dialog_m" href="?id='.$id.'&do='.$do.'&mode=delete&true">Да</a>
<a class="dialog_m" href="?mode='.$do.'">Нет</a>
</div>';
} else {
if(file_exists(ROOT.'downloads/other/'.$f['url']))unlink(ROOT.'downloads/other/'.$f['url']);
$db -> query("DELETE FROM `files` WHERE `id` = '".$id."'");
header('location: ?mode='.$do);
}
} else header('location: ?mode='.$do);
break;
///прочее
case 'other':
$count = $db -> dbcount('COUNT(`id`)','files',"`user` = '".$ya['id']."' and `format`<>'mp3' and `what`<>'foto'");
if($count>0){
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1;
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
////------------------/////
$for = $db -> query("SELECT `id`,`name`,`url`,`info`,`format` FROM `files` where `user`='".$ya['id']."' and `format`<>'mp3' and `what`<>'foto' order by `time` DESC LIMIT ".$start.",".$num);
while ($assoc = $for -> fetch_assoc()) {
if($assoc['format']=='jpg' or $assoc['format']=='png' or $assoc['format']=='jpeg' or $assoc['format']=='gif'){
if(file_exists(ROOT.'downloads/other/'.$assoc['url']))$photo_url=ROOT.'downloads/other/'.$assoc['url']; else $photo_url=ROOT.'downloads/foto/'.$assoc['url'];
echo '<div class="fon"><a href="'.$photo_url.'">
<img style="padding:5px;" src="/system/resize.php?img='.$photo_url.'&width=124&height=124&i=0"/></a></div>';
}
echo '<div class="zap">
<a class="zap_b" href="?mode=delete&id='.$assoc['id'].'&do=other">Удалить</a>
</div>';
}
$act = '?mode=other';
echo $func -> pagenav($act,$page,$total);
} else echo '<div class="fon">У вас нет файлов.</div>';
echo '<div class="levo"><a href="?" class="levo_tuch">'.$diz -> img('back.png').' Назад</a></div>';
break;
///Главная
default:
echo '<div class="new">Обшая информация</div>';
$all = $db -> dbcount('COUNT(`id`)','files','`user`="'.$ya['id'].'"');
if($all>0){
$size=0;
$sql = $db -> query("SELECT `what`,`url` FROM `files`");
while ($f = $sql -> fetch_assoc()) {
if(file_exists(ROOT.'downloads/'.$f['what'].'/'.$f['url']))$size=$size+filesize(''.ROOT.'downloads/'.$f['what'].'/'.$f['url']);
}
}else $size=0;
echo '<div class="fon">Всего файлов: <span class="chet">'.$all.'</span><br/>
Общий размер: <span class="chet">'.$func->size($size).'</span></div>';
$all_photo = $db -> dbcount('COUNT(`id`)','files','`user`="'.$ya['id'].'" and `what`="foto"');
echo '<div class="menu"><a href="?mode=photo" class="menutuch">Фотографии <span class="chet">'.$all_photo.'</span></a></div>';
$all_audio = $db -> dbcount('COUNT(`id`)','files','`user`="'.$ya['id'].'" and `format`="mp3"');
echo '<div class="menu"><a href="?mode=audio" class="menutuch">Аудиозаписи <span class="chet">'.$all_audio.'</span></a></div>';
$all_other = $db -> dbcount('COUNT(`id`)','files','`user`="'.$ya['id'].'" and `what`<>"foto" and `format`<>"mp3"');
echo '<div class="menu"><a href="?mode=other" class="menutuch">Прочее <span class="chet">'.$all_other.'</span></a></div>';
}
echo '<div class="levo"><a href="./" class="levo_tuch">'.$diz -> img('back.png').' Личный кабинет</a></div>';
echo '<div class="levo"><a href="/index.php" class="levo_tuch">'.$diz -> img('home.png').' На главную</a></div>';
#####Копирайт#######
$diz -> out($msg);
} else header('location: '.ROOT.'/aut.php');
?>