Файл: moduls/files/index.php
Строк: 198
<?php
/**
* @package Prime Social
* @link http://primesocial.ru
* @copyright Copyright (C) 2016 Prime Social
* @author BoB | http://primesocial.ru/about
*/
require_once('../../core/start.php');
require_once('func.php');
check_auth();
$id = abs(num($_GET['user']));
$ank = DB::$dbs->queryFetch("SELECT * FROM ".USERS." WHERE `user_id` = ? ", array($id));
if (empty($ank)) {
head('Foydalanuvchi topilmadi');
echo DIV_TITLE . 'Foydalanuvchi topilmadi' . CLOSE_DIV;
echo DIV_BLOCK . 'Foydalanuvchi topilmadi' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifaga</a> / <b>Foydalanuvchi topilmadi</b>' . CLOSE_DIV;
exit();
}
switch ($select) {
default:
head('Foydalanuvchining shahsiy fayllari: ' . $ank['nick']);
if ($_POST['add'] && $ank['user_id'] == $user['user_id']) {
$name = html($_POST['name']);
$type = abs(num($_POST['type']));
if (empty($name)) {
$err .= 'Bo`lim nomini yozing<br />';
}
if (empty($type)) {
$err .= 'Bo`lim turini tanlang<br />';
}
if (!empty($err)) {
echo DIV_ERROR . $err . CLOSE_DIV;
} else {
DB::$dbs->query("INSERT INTO ".FILES." (`name`, `type`, `user_id`) VALUES (?, ?, ?)", array($name, $type, $user['user_id']));
header("Location: ".HOME."/files/".$user['user_id']."/");
}
}
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".FILES." WHERE `user_id` = ? ", array($ank['user_id']));
if (empty($all)) {
echo DIV_BLOCK . 'Bo`limlar ochilmagan' . CLOSE_DIV;
} else {
$sql = DB::$dbs->query("SELECT * FROM ".FILES." WHERE `user_id` = ? ORDER BY `id` DESC", array($ank['user_id']));
while($folder = $sql -> fetch()) {
echo DIV_LI . ''.icon('folder.gif').' <a href="'.HOME.'/files/'.$ank['user_id'].'/'.$folder['id'].'/">'.$folder['name'].'</a>' . CLOSE_DIV;
}
}
if ($ank['user_id'] == $user['user_id']) {
echo DIV_AUT;
echo '<form action="#" method="POST">';
echo '<b>Yangi bo`lim:</b><br /><input type="text" name="name" /><br />';
echo 'Turi:<br /><select name="type">';
echo '<option value="1">Rasmlar</option>';
echo '<option value="2">Video</option>';
echo '<option value="3">Musiqa</option>';
echo '<option value="4">Java-dasturlar</option>';
echo '<option value="5">Android</option>';
echo '<option value="6">Windows Mobile</option>';
echo '<option value="7">iPhone</option>';
echo '<option value="8">Bada</option>';
echo '<option value="9">Flash</option>';
echo '<option value="10">Mavzular</option>';
echo '<option value="11">Symbian</option>';
echo '</select><br />';
echo '<input type="submit" name="add" value="Yaratish" /></form>';
echo CLOSE_DIV;
}
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/id'.$ank['user_id'].'">'.$ank['nick'].'</a> / <b>Shahsiy fayllar</b>' . CLOSE_DIV;
break;
case 'folder':
$folder = DB::$dbs->queryFetch("SELECT * FROM ".FILES." WHERE `id` = ? && `user_id` = ? ", array(abs(num($_GET['folder'])), $ank['user_id']));
if (empty($folder)) {
head('Bo`lim topilmadi');
echo DIV_TITLE . 'Bo`lim topilmadi' . CLOSE_DIV;
echo DIV_ERROR . 'Foydalanuvchi topilmadi' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/id'.$ank['user_id'].'">'.$ank['nick'].'</a> / <a href="'.HOME.'/files/'.$ank['user_id'].'/">Shahsiy fayllar</a> / <b>Bo`lim topilmadi</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
head('Shahsiy fayllari: ' . $ank['nick'] . ' | ' . $folder['name']);
if (isset($_GET['del']) && $ank['user_id'] == $user['user_id']) {
if (!isset($_GET['go'])) {
echo DIV_LI . '<b>O`chirishni tastiqlang:</b> <a href="?del&go">[O`chirish]</a> <a href="'.HOME.'/files/'.$ank['user_id'].'/'.$folder['id'].'/">[Yo`q]</a>' . CLOSE_DIV;
} else {
$sql = DB::$dbs->query("SELECT * FROM ".FILES_FILE." WHERE `folder_id` = ? ", array($folder['id']));
while($file = $sql -> fetch()) {
unlink('../../files/usfiles/' . $file['url']);
}
DB::$dbs->query("DELETE FROM ".FILES_FILE." WHERE `folder_id` = ? ", array($folder['id']));
DB::$dbs->query("DELETE FROM ".FILES." WHERE `id` = ? ", array($folder['id']));
header("Location: ".HOME."/files/".$ank['user_id']."/");
}
}
if (isset($_GET['edit']) && $ank['user_id'] == $user['user_id']) {
if ($_POST['edit']) {
$name = html($_POST['name']);
$type = abs(num($_POST['type']));
if (empty($name) || empty($type)) {
echo DIV_ERROR . 'Bo`lim nomini kiriting' . CLOSE_DIV;
} else {
DB::$dbs->query("UPDATE ".FILES." SET `name` = ?, `type` = ? WHERE `id` = ? ", array($name, $type, $folder['id']));
header("Location: ".HOME."/files/".$ank['user_id']."/".$folder['id']."/");
}
}
echo DIV_AUT;
echo '<form action="#" method="POST">';
echo 'Bo`limni tahrirlash:<br /><input type="text" value="'.$folder['name'].'" name="name" /><br />';
echo 'Turi:<br /><select name="type">';
echo '<option '.(1 == $folder['type'] ? 'selected="selected"' : NULL).' value="1">Rasmlar</option>';
echo '<option '.(2 == $folder['type'] ? 'selected="selected"' : NULL).' value="2">Video</option>';
echo '<option '.(3 == $folder['type'] ? 'selected="selected"' : NULL).' value="3">Musiqa</option>';
echo '<option '.(4 == $folder['type'] ? 'selected="selected"' : NULL).' value="4">Java-dasturlar</option>';
echo '<option '.(5 == $folder['type'] ? 'selected="selected"' : NULL).' value="5">Android</option>';
echo '<option '.(6 == $folder['type'] ? 'selected="selected"' : NULL).' value="6">Windows Mobile</option>';
echo '<option '.(7 == $folder['type'] ? 'selected="selected"' : NULL).' value="7">iPhone</option>';
echo '<option '.(8 == $folder['type'] ? 'selected="selected"' : NULL).' value="8">Bada</option>';
echo '<option '.(9 == $folder['type'] ? 'selected="selected"' : NULL).' value="9">Flash</option>';
echo '<option '.(10 == $folder['type'] ? 'selected="selected"' : NULL).' value="10">Mavzular</option>';
echo '<option '.(11 == $folder['type'] ? 'selected="selected"' : NULL).' value="11">Symbian</option>';
echo '</select><br /><br />';
echo '<input type="submit" name="edit" value="O`zgartirsh" /></form>';
echo CLOSE_DIV;
}
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".FILES_FILE." WHERE `folder_id` = ? && `user_id` = ? && `status` = '0' ", array($folder['id'], $ank['user_id']));
if (empty($all)) {
echo DIV_BLOCK . 'Fayllar kiritilmagan' . CLOSE_DIV;
} else {
$n = new Navigator($all,$config['write']['files_file'],'folder='.$folder['id'].'&user='.$ank['user_id'].'&select=folder');
$sql = DB::$dbs->query("SELECT * FROM ".FILES_FILE." WHERE `folder_id` = ? && `user_id` = ? && `status` = '0' ORDER BY `id` DESC LIMIT {$n->start()}, ".$config['write']['files_file']." ", array($folder['id'], $ank['user_id']));
while($file = $sql -> fetch()) {
echo DIV_LI . '<a href="'.HOME.'/files/'.$ank['user_id'].'/'.$folder['id'].'/'.$file['id'].'/">'.$file['name'].'</a>' . CLOSE_DIV;
}
echo $n->navi();
}
if ($ank['user_id'] == $user['user_id']) {
echo DIV_AUT;
echo '<form action="'.HOME.'/files/'.$ank['user_id'].'/'.$folder['id'].'/upload/" enctype="multipart/form-data" method="POST">';
echo '<b>Fayl kiritish:</b> ['.$folder['name'].']<br /><input type="file" name="file"/><br /><br />';
echo '<b>Faqat ushbu formatdagi fayllarni kiritish mumkun:</b> ';
echo type_view($folder['type']);
echo '<br /><br />';
if ($folder['type'] == 3) {
echo 'Ijrochi:<br /><input type="text" name="artist" /><br /><br />';
echo 'Nomi:<br /><input type="text" name="track" /><br /><br />';
echo 'Albom:<br /><input type="text" name="album" /><br /><br />';
} else {
echo 'Qanday ko`rsatish [nomi]:<br /><input type="text" name="name" /><br /><br />';
}
if ($folder['type'] > 1 && $folder['type'] != 3) {
if ($folder['type'] == 4 || $folder['type'] == 5 || $folder['type'] == 6 || $folder['type'] == 7 || $folder['type'] == 8 || $folder['type'] == 11) {
echo 'Ta`rif:<br /><textarea name="info" /></textarea><br /><br />';
echo 'Til:<br /><input type="text" name="lang" /><br /><br />';
}
echo '<b>Skrinshotlar:</b> <br />
<input name="screen[]" type="file" multiple="true" />';
}
echo '<input type="submit" name="upload" value="Yuklash" />';
echo '</form>';
echo CLOSE_DIV;
}
if ($ank['user_id'] == $user['user_id']) {
echo DIV_BLOCK;
echo '<a href="?edit"><b>'.$folder['name'].'</b> bo`limini tahrirlash</a><br />';
echo '<a href="?del"><b>'.$folder['name'].'</b> bo`limini o`chirish</a><br />';
echo CLOSE_DIV;
}
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/id'.$ank['user_id'].'">'.$ank['nick'].'</a> / <a href="'.HOME.'/files/'.$ank['user_id'].'/">Shahsiy fayllar</a> / <b>'.$folder['name'].'</b>' . CLOSE_DIV;
break;
}
require_once('../../core/stop.php');
?>