<?php
include_once'../system/xcms_core.php';$title='Загруз-центр';
if($_COOKIE['style']=='web')require_once '../system/web_head.php'; else require_once '../system/head.php';
switch($act){
case 'add_screen':
$q=$db->query("select * from `files` where `id`='$id'")->fetch(PDO::FETCH_ASSOC);
if($q){
if($user['level']>4){
$files=$_FILES['screen']['name'];
if(move_uploaded_file($_FILES['screen']['tmp_name'],'../files/screens/file-'.$id.'-'.$files)){
$db->query("insert into `screens` set `name`='../files/screens/file-$id-$files', `file`='$id'");
echo'<div class="menu">Скриншот добавлен → <a href="/dl/file'.$id.'">Далее</a></div>';
}
echo'<div class="menu">
<form action="#" method="post" enctype="multipart/form-data">
<input type="file" name="screen"><input type="submit" value="Загрузить">
</form>
</div>';
back('/dl/file'.$id);
}else{echo'<div class="menu">Только для адмнистраторов</div>';}
}else{echo'<div class="menu">Ошибка идентификатора</div>';}
break;
case 'load':
if($user['level']>3){
if(!empty($_POST['cat'])){$cat=protect(intval($_POST['cat']));$cat1=$db->query("select * from `podcat` where `id`='$cat'")->fetch(PDO::FETCH_ASSOC);}else{$cat=1;}
if(!empty($_POST['name']))$name=protect($_POST['name']);else $name=0; if(!empty($_POST['desc']))$desc=nl2br(protect($_POST['desc'])); else $desc=0;
if(!empty($_POST['namea']))$namea=protect($_POST['namea']);else $namea=0; if(!empty($_POST['desca']))$desca=nl2br(protect($_POST['desca'])); else $desca=0;
if(!empty($_POST['nameb']))$nameb=protect($_POST['nameb']);else $nameb=0; if(!empty($_POST['descb']))$descb=nl2br(protect($_POST['descb'])); else $descb=0;
if(!empty($_POST['namec']))$namec=protect($_POST['namec']);else $namec=0; if(!empty($_POST['descc']))$descc=nl2br(protect($_POST['descc'])); else $descc=0;
if(!empty($_POST['named']))$named=protect($_POST['named']);else $named=0; if(!empty($_POST['descd']))$descd=nl2br(protect($_POST['descd'])); else $descd=0;
if(move_uploaded_file($_FILES['somename']['tmp_name'], '../files/files/'.$_FILES['somename']['name'])){$db->query("insert into `files` set `name`='$name', `cat`='$cat1[cat]', `podcat`='$cat', `time`='$time', `file`='files/".$_FILES['somename']['name']."', `bitrate`='$desc', `duration`='0'");echo'<div class="menu">Файл <b>1</b> загружен</div>';}
if(move_uploaded_file($_FILES['somenamea']['tmp_name'], '../files/files/'.$_FILES['somenamea']['name'])){$db->query("insert into `files` set `name`='$namea', `cat`='$cat1[cat]', `podcat`='$cat', `time`='$time', `file`='files/".$_FILES['somenamea']['name']."', `bitrate`='$desca', `duration`='0'");echo'<div class="menu">Файл <b>2</b> загружен</div>';}
if(move_uploaded_file($_FILES['somenameb']['tmp_name'], '../files/files/'.$_FILES['somenameb']['name'])){$db->query("insert into `files` set `name`='$nameb', `cat`='$cat1[cat]', `podcat`='$cat', `time`='$time', `file`='files/".$_FILES['somenameb']['name']."', `bitrate`='$descb', `duration`='0'");echo'<div class="menu">Файл <b>3</b> загружен</div>';}
if(move_uploaded_file($_FILES['somenamec']['tmp_name'], '../files/files/'.$_FILES['somenamec']['name'])){$db->query("insert into `files` set `name`='$namec', `cat`='$cat1[cat]', `podcat`='$cat', `time`='$time', `file`='files/".$_FILES['somenamec']['name']."', `bitrate`='$descc', `duration`='0'");echo'<div class="menu">Файл <b>4</b> загружен</div>';}
if(move_uploaded_file($_FILES['somenamed']['tmp_name'], '../files/files/'.$_FILES['somenamed']['name'])){$db->query("insert into `files` set `name`='$named', `cat`='$cat1[cat]', `podcat`='$cat', `time`='$time', `file`='files/".$_FILES['somenamed']['name']."', `bitrate`='$descd', `duration`='0'");echo'<div class="menu">Файл <b>5</b> загружен</div>';}
echo'<div class="menu">
<form action = "#" method = "post" enctype = "multipart/form-data">
В категорию: <select name="cat">';
$total=$db->query("select `id` from `podcat`")->rowCount();
if($total){
$sef=$db->query("select * from `podcat` order by `id`");
while($ff=$sef->fetch(PDO::FETCH_ASSOC)){
$q=$db->query("select `name` from `cat` where `id`='$ff[cat]'")->fetch(PDO::FETCH_ASSOC);
echo '<option value="'.$ff['id'].'">'.$q['name'].' → '.$ff['name'].'</option>';
}
echo '</select></div>
<div class="menu">Название:<br /><input name="name" type="text" size="30"><br />Файл:<br /><input type = "file" name = "somename" /><br />Описание:<br /><textarea name="desc"></textarea></div>
<div class="citatka">Название:<br /><input name="namea" type="text" size="30"><br />Файл:<br /><input type = "file" name = "somenamea" /><br />Описание:<br /><textarea name="desca"></textarea></div>
<div class="menu">Название:<br /><input name="nameb" type="text" size="30"><br />Файл:<br /><input type = "file" name = "somenameb" /><br />Описание:<br /><textarea name="descb"></textarea></div>
<div class="citatka">Название:<br /><input name="namec" type="text" size="30"><br />Файл:<br /><input type = "file" name = "somenamec" /><br />Описание:<br /><textarea name="descc"></textarea></div>
<div class="menu">Название:<br /><input name="named" type="text" size="30"><br />Файл:<br /><input type = "file" name = "somenamed" /><br />Описание:<br /><textarea name="descd"></textarea></div>
<div class="citatka" style="text-align:center;"><input type = "submit" value = "Загрузить файлы" />
</form></div> ';
}else{echo'<div class="menu">Создайте подразделы</div>';}
}else{echo'<div class="menu">Ошибка авторизации</div>';}
break;
case 'down':
$q=$db->query("select * from `files` where `id`='$id'")->fetch(PDO::FETCH_ASSOC);
if($q){
$w=$db->query("select `id` from `files_down` where `ip`='$sess_ip' and `ua`='$sess_ua' and `file`='$id'")->rowCount();
if(!$w){
$db->query("insert into `files_down` set `ip`='$sess_ip', `ua`='$sess_ua', `file`='$id', `time`='$time'");
$db->prepare("update `files` set `down`=`down`+1 where `id`='$id'")->execute();
}
echo '<meta http-equiv="refresh" content="0; url = /files/'.$q['file'].' ">';
}else{echo'<div class="menu">Ошибка идентификатора</div>';}
break;
case 'file':
$q=$db->query("select * from `files` where `id`='$id'")->fetch(PDO::FETCH_ASSOC);
if($q){
$db->prepare("update `files` set `view`=`view`+1 where `id`='$id'")->execute();
if($user['level']>3)
echo'<div class="menu" style="text-align:center;">
<a href="/moduls/delete.php?act=5&id='.$id.'">Удалить</a> | <a href="/moduls/edit.php?act=4&id='.$id.'">Редактировать</a> | <a href="/dl/file'.$id.'/add_screen">Добавить скрин</a></div>';
/* Скриншоты */
$total=$db->query("select `id` from `screens` where `file`='$id'")->rowCount();
if($total){
echo'<div class="head">Скриншоты:</div>';
$sql=$db->query("select * from `screens` where `file`='$id'");
echo'<div class="menu" style="text-align:center;">';
while($res=$sql->fetch(PDO::FETCH_ASSOC)){
$i++;
echo '<a href="'.$res['name'].'">'.pic($res['name'],50,50).'</a>';
if($i==5)echo'<br />';
}
echo'</div>';
}
$ex=strtolower(substr(strrchr($q['file'], '.'), 1)); #формат файла
/* Вывод информации для каждого типа файлов */
if($ex=='mp3' or $ex=='wav' or $ex=='ogg'){
echo'<div class="menu"><object type="application/x-shockwave-flash" data="/player/ump3player.swf" height="67" width="380">
<param name="wmode" value="transparent" /><param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="always" /><param name="movie" value="/player/ump3player.swf" />
<param name="FlashVars" value="way=../files/'.$q[file].'&swf=/player/ump3player.swf&w=380&h=67&&autoplay=0&q=&skin=grey&volume=100&comment=" />
</object></div>';
if($ex=='mp3'){
include_once '../audioclass.php';
$AF = new AudioFile;
$AF->loadFile('../files/'.$q[file]);
$AF->printSampleInfo();
}
}
elseif($ex=='3gp' or $ex=='flv'){
}
elseif($ex=='mp4'){
?>
<script src="/player/video.js"></script>
<script>
videojs.options.flash.swf = "/player/video-js.swf";
</script>
<script type="text/javascript" src="/files/js/jquery.js"></script>
<script type="text/javascript" src="/files/js/main.js"></script>
<div class="menu"><video class="video-js vjs-default-skin" controls preload="none" width="300" height="150"
poster=""
data-setup="{}">
<source src="<?='../files/'.$q['file'];?>" type='video/mp4' />
<track kind="captions" src="/player/demo.captions.vtt" srclang="en" label="English"></track>
<track kind="subtitles" src="/player/demo.captions.vtt" srclang="en" label="English"></track>
<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
</video><br /><br /></div>
<?php
}
elseif($ex=='jpg' or $ex=='png' or $ex=='gif' or $ex=='jpeg'){
if($ex=='jpg' or $ex=='jpeg'){
echo'<div class="menu" style="text-align:center;"><img src="/files/'.$q['file'].'" style="width:55%;" alt="" /></div>';
}else{
echo'<div class="menu" style="text-align:center;"><img src="/files/'.$q['file'].'" style="width:55%;" alt="" /></div>';
}
}
elseif($ex=='txt'){
echo'<div class="menu">';
$f = fopen("../files/$q[file]", "r");
while(!feof($f)){echo'<b>'.fgets($f).'<br /></b>';}
fclose($f);
echo'</div>';
}
if(!empty($q['bitrate']))echo'<div class="citatka">'.$q['bitrate'].'</div>';
$count_down=$db->query("select `id` from `files_down` where `file`='$id'")->rowCount();
echo'<div class="menu">';
if($q['time'])echo'<b>Добавлен:</b> '.clock($q['time']).'<br />';
if($q['view'])echo'<b>Просмотров:</b> '.$q['view'].'<br />';
if($count_down)echo'<b>Скачиваний:</b> '.$count_down.'</br />';
echo'<b>Размер:</b> '.sizer('../files/'.$q['file']).'<br />';
echo'<a href="/dl/down'.$id.'" style="text-align:center;display:block;">Скачать '.$q['name'].' ('.sizer('../files/'.$q['file']).')</a>';
echo'</div>';
back('/dl/podcat'.$q['podcat']);
}else{echo'<div class="menu">Ошибка идентификатора</div>';}
break;
case 'podcat':
$q=$db->query("select * from `podcat` where `id`='$id'")->fetch(PDO::FETCH_ASSOC);
if($q){
$k_post=$db->query("select `id` from `files` where `podcat`='$id'")->rowCount();
if($k_post){
$k_page=k_page($k_post,$set['p_str']);$page=page($k_page);$start=$set['p_str']*$page-$set['p_str'];
$sql=$db->query("select * from `files` where `podcat`='$id' order by `id` desc limit $start, $set[p_str]");
echo'<div class="touch">';
while($res=$sql->fetch(PDO::FETCH_ASSOC)){
echo'<div class="menu"><a href="/dl/file'.$res['id'].'">';
$ex=strtolower(substr(strrchr($res['file'], '.'), 1)); #формат файла
if($ex=='jpg' or $ex=='jpeg' or $ex=='png' or $ex=='gif')echo'<img src="/files/'.$res['file'].'" alt="" style="height:30px;width:30px;float:left;margin-right:3px;"/>';
elseif($ex=='mp4' or $ex=='3gp' or $ex=='flv' or $ex=='avi')echo'<img src="/files/images/video.png" alt="" style="height:30px;width:30px;float:left;margin-right:3px;"/>';
elseif($ex=='mp3' or $ex=='wav' or $ex=='ogg' or $ex=='amr')echo'<img src="/files/images/mp3.png" alt="" style="height:30px;width:30px;float:left;margin-right:3px;"/>';
elseif($ex=='zip' or $ex=='rar')echo'<img src="/files/images/zip.png" alt="" style="height:30px;width:30px;float:left;margin-right:3px;"/>';
elseif($ex=='txt')echo'<img src="/files/images/txt.png" alt="" style="height:30px;width:30px;float:left;margin-right:3px;"/>';
echo'<b>'.$res['name'].'</b><br />Размер: '.sizer('../files/'.$res['file']).'</a></div>';
}
echo'</div>';
if ($k_page>1)str('/dl/podcat'.$id.'/',$k_page,$page); // Вывод страниц
}else{echo'<div class="menu">Здесь пока пусто</div>';}
back('/dl/cat'.$q['cat']);
}else{echo'<div class="menu">Ошибка идентификатора</div>';}
break;
case 'cat':
$q=$db->query("select * from `cat` where `id`='$id'")->fetch(PDO::FETCH_ASSOC);
if($q){
$k_post=$db->query("SELECT `id` FROM `podcat` WHERE `cat`='$id'")->rowCount();
if($k_post){
echo'<div class="touch">';
$k_page=k_page($k_post,$set['p_str']);$page=page($k_page);$start=$set['p_str']*$page-$set['p_str'];
$sql=$db->query("select * from `podcat` where `cat`='$id' order by `id` desc limit $start, $set[p_str]");
while($res=$sql->fetch(PDO::FETCH_ASSOC)){
echo'<div class="menu">
<a href="/dl/podcat'.$res['id'].'">'.$res['name'].' '.right($db->query("select `id` from `files` where `podcat`='$res[id]'")->rowCount()).'</a></div>';
}
echo'</div>';
if ($k_page>1)str('/dl/cat'.$id.'/',$k_page,$page); // Вывод страниц
}else{echo'<div class="menu">Файлов еще нет</div>';}
}else{echo'<div class="menu">Ошибка идентификатора</div>';}
back('/dl');
break;
case 'top':
$total=$db->query("select `id` from `files`")->rowCount();
if($total){
$sql=$db->query("select * from `files` order by `down` desc limit $set[p_str]");
echo'<div class="touch">';
while($res=$sql->fetch(PDO::FETCH_ASSOC)){
echo'<div class="menu"><a href="/dl/file'.$res['id'].'">- '.$res['name'].' '.right('Загрузок: '.$res['down']).'</a></div>';
}
echo'</div>';
}else{echo'<div class="menu">Файлов еще нет</div>';}
break;
default:
echo'<div class="touch">';
if($user['level']>3)echo'
<div class="menu"><a href="/admin?act=zc">Управление загруз-центром</a></div>
<div class="menu"><a href="/dl?act=load">Добавить файл</a></div>';
echo'
<div class="menu"><a href="/dl/top">Топ файлов</a></div>
<div class="menu"><a href="#">Новые файлы</a></div>
<div class="menu"><a href="#">Поиск</a></div>
</div>';
echo '<div class="head">Категории</div>';
$total=$db->query("select `id` from `cat`")->rowCount();
if($total){
$sql=$db->query("select * from `cat` order by `id`");
echo'<div class="touch">';
while($res=$sql->fetch(PDO::FETCH_ASSOC)){
echo'<div class="menu"><a href="/dl/cat'.$res['id'].'">'.$res['name'].'</a></div>';
$total_=$db->query("select `id` from `podcat` where `cat`='$res[id]'")->rowCount();
if($total_){
$sql_=$db->query("select * from `podcat` where `cat`='$res[id]' order by `id` asc");
while($res_=$sql_->fetch(PDO::FETCH_ASSOC)){
$files_new=$db->query("select `id` from `files` where `podcat`='$res_[id]' and `time`>($time-86400)")->rowCount();
if($files_new)$new='/<span style="color:red;">'.$files_new.'</span>';else $new='';
echo'<div class="citatka"><a href="/dl/podcat'.$res_['id'].'">'.$res_['name'].' '.right($db->query("select `id` from `files` where `podcat`='$res_[id]'")->rowCount().$new).'</a></div>';
}
}else{echo'<div class="citatka">Подкаталогов еще нет</div>';}
}
echo'</div>';
}else{echo'<div class="menu">Категории не созданы</div>';}
echo'<div class="menu" style="text-align:center;">Файлов: '.$db->query("select `id` from `files`")->rowCount().'</div>';
back('/');
}
if($_COOKIE['style']=='web')require_once '../system/web_foot.php'; else require_once '../system/foot.php';
?>