File size: 11.79Kb
<?php
include '../sys/db.php';
include '../sys/conf.php';
include '../sys/start.php';
include '../sys/functions.php';
$config_title_name = "Подтверждение";
include '../style/head.php';
echo "<div class=title>Подтверждение файлов в обменнике</div>\n";
if(isset($user['login'])){
if( isset($user['level']) || $user['level']=='1' || $user['level']=='2' || $user['level']=='3'){
$act = isset($_GET['act']) ? $_GET['act'] : '';
switch($act){
default:
function pages($start, $total, $page, $onpage){
if ($start != 0) echo '<a href="'.$page.'?start='.($start - $onpage).'"><-Назад</a> ';
else echo '<-Назад';
echo ' | ';
if ($total > $start + $onpage)
echo ' <a href="'.$page.'?start='.($start + $onpage).'">Далее-></a>';
else echo 'Далее->';
if($total>0){
$ba = ceil($total/$onpage);
$ba2 = $ba*$onpage-$onpage;
echo '<br/>Страницы:';
$asd = $start-($onpage*3);
$asd2 = $start+($onpage*4);
if($asd<$total && $asd>0) echo ' <a href="'.$page.'?start=0">1</a> ... ';
for($i=$asd; $i<$asd2;){
if($i<$total && $i>=0){
$ii = floor(1+$i/$onpage);
if ($start==$i) echo ' <b>['.$ii.']</b>';
else echo ' <a href="'.$page.'?start='.$i.'">'.$ii.'</a>';}
$i=$i+$onpage;}
if($asd2<$total) echo ' ... <a href="'.$page.'?start='.$ba2.'">'.$ba.'</a>';
}}
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `exchanger_files` WHERE `confirm` = '0'"),0);
$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
if($start > $total) $start = 0;
if ($total < $start + 10) $end = $total;
else $end = $start + 10;
$files = mysql_query("SELECT * FROM `exchanger_files` WHERE `confirm` = '0' ORDER BY `time` DESC LIMIT $start, 10");
if (mysql_num_rows($files)!=0){
while($file = mysql_fetch_array($files)){
echo "<div class=content> <a href='?act=file&id=".$file['id']."'> ".$file['name']."</a>
[<a href='?act=confirm&id=".$file['id']."'>Подтвердить</a>]
[<a href='?act=edit&id=".$file['id']."'>Редактировать</a>]
<br>".$file['description']."</div>\n";
}
echo "<div class=stat>\n";
pages($start, $total, 'exchanger_confirm.php', 10);
echo "</div>\n";
}else{echo "<div class=content><br><img src='../img/lock.gif' alt=''> Файлов для подтверждения нет!<br><br></div>\n";}
echo "<div class=stat><a href='index.php'>Админка</a></div>\n";
echo "<div class=stat><a href='../index.php'>Прихожая</a></div>\n";
break;
case('file'):
$id = intval($_GET['id']);
if ($id){
$check = mysql_fetch_array(mysql_query("SELECT * FROM `exchanger_files` WHERE `id` = '$id'"));
if($check != 0){
$files = mysql_query("SELECT * FROM `exchanger_files` WHERE `id` = '$id'");
$file = mysql_fetch_array($files);
$section = mysql_query("SELECT * FROM `exchanger_section` WHERE `id` = '$file[section]'");
$sec = mysql_fetch_array($section);
$exchanger = mysql_query("SELECT * FROM `exchanger` WHERE `id` = '$file[exchanger]'");
$exc = mysql_fetch_array($exchanger);
echo "<div class=title>Обменник / ".$exc['name']." / ".$sec['name']." / ".$file['name']."</div>";
echo "<div class=content>\n";
$translite_dir = transliter($exc[name]);
$translite_kat = transliter($sec[name]);
$ufile = "../files/exchanger/$translite_dir/$translite_kat/".$file['file']."";
$ufilez = round(filesize($ufile)/1024,1);
$ext = strtolower(substr($file['file'], 1 + strrpos($file['file'], ".")));
if ($exc['type'] == '1'){
echo "<img src='../img/down.gif' alt=''> <a href='../files/exchanger/$translite_dir/$translite_kat/".$file['file']."'>Скачать $ext</a> [$ufilez Kb]<br>\n";
echo "</div>\n";
echo "<div class=content>\n";
echo "Тип файла: <b>$ext</b> <br>\n";
if($file[artist] != NULL){echo "Описание: ".$file['artist']."<br>\n";}
if($file[genre] != NULL){echo "Жанр: ".$file['genre']."<br>\n";}
if($file[album] != NULL){echo "Альбом: ".$file['album']."<br>\n";}
echo "</div>\n";}
elseif ($exc['type'] == '2'){
if($file[screenshot] != NULL){
echo "<img src='../screenshots.php?file=".$file['screenshot']."' alt=''><br>\n";
}else{ echo "Скриншота нет! <br><br>\n";}
echo "<img src='../img/down.gif' alt=''> <a href='files/exchanger/$translite_dir/$translite_kat/".$file['file']."'>Скачать</a> $ext [$ufilez Kb]<br>\n";}
elseif ($exc['type'] == '3'){
echo "<img src='../img/down.gif' alt=''> <a href='files/exchanger/$translite_dir/$translite_kat/".$file['file']."'>Скачать</a> $ext [$ufilez Kb]<br>\n";}
elseif ($exc['type'] == '4'){
if($file[screenshot] != NULL){
echo "<img src='../screenshots.php?file=".$file['screenshot']."' alt=''><br>\n";
}else{ echo "Скриншота нет! <br><br>\n";}
echo "<img src='../img/down.gif' alt=''> <a href='files/exchanger/$translite_dir/$translite_kat/".$file['file']."'>Скачать</a> $ext [$ufilez Kb]<br>\n";}
elseif ($exc['type'] == '5'){
$size = getimagesize ("../files/exchanger/$translite_dir/$translite_kat/".$file['file']."");
echo "<img src='../exchanger_image.php?dir=$translite_dir&kat=$translite_kat&file=".$file['file']."&H=73&W=60' alt=''><br>\n";
echo "<img src='../img/down.gif' alt=''> <a href='files/exchanger/$translite_dir/$translite_kat/".$file['file']."'>Скачать</a> $ext [$size[0]x$size[1], $ufilez Kb]<br>\n";
echo "Другой размер: <br>\n";
$arr = array ("128x128","120x160","132x176","176x220","240x320");
foreach($arr as $v){
list ($H,$W) = explode ("x",$v);
echo"[<a href='../exchanger_image.php?dir=$translite_dir&kat=$translite_kat&file=".$file['file']."&H=$H&W=$W'>$v</a>] ";}}
elseif ($exc['type'] == '6'){
$size = getimagesize ("../files/exchanger/$translite_dir/$translite_kat/".$file['file']."");
$ufile = "../files/exchanger/$translite_dir/$translite_kat/".$file['file']."";
$ufilez = round(filesize($ufile)/1024,1);
echo "<img src='../exchanger_image.php?dir=$translite_dir&kat=$translite_kat&file=".$file['file']."&H=73&W=60' alt=''><br>\n";
echo "<img src='../img/down.gif' alt=''> <a href='../files/exchanger/$translite_dir/$translite_kat/".$file['file']."'>Скачать</a> $ext [$size[0]x$size[1], $ufilez Kb]<br>\n";}
echo "</div>\n";
if($file[description] != NULL){echo "<div class=content><b>Описание</b>: ".$file['description']."</div>\n";}
$uploaded = mysql_query("SELECT * FROM `users` WHERE `id` = '$file[uploaded]'");
$upl = mysql_fetch_array($uploaded);
echo "<div class=content>\n";
if ($upl[gender] == '1'){
echo "Добавил: <a href='../anketa.php?id=".$file['uploaded']."'>".$upl['login']."</a><br>\n";}
elseif ($upl[gender] == '2'){
echo "Добавила: <a href='../anketa.php?id=".$file['uploaded']."'>".$upl['login']."</a><br>\n";}
$timedat = date("d.m.Y", time($file[time]));
if ($exc['type'] == '4' || $exc['type'] == '2'){ echo "Для телефонов: ";
if($file[model] == '1'){echo "LG <br>\n";}
elseif($file[model] == '2'){echo "Motorola <br>\n";}
elseif($file[model] == '3'){echo "Nokia <br>\n";}
elseif($file[model] == '4'){echo "Samsung <br>\n";}
elseif($file[model] == '5'){echo "Siemens <br>\n";}
elseif($file[model] == '6'){echo "Sony Ericsson <br>\n";}
elseif($file[model] == '7'){echo "Windows Mobile <br>\n";}}
if ($exc['type'] == '2'){ echo "Размер экрана: ";
if($file[sized] == '1'){echo "128x160 <br>\n";}
elseif($file[sized] == '2'){echo "128x160 <br>\n";}
elseif($file[sized] == '3'){echo "208x208 <br>\n";}
elseif($file[sized] == '4'){echo "240x320 <br>\n";}
elseif($file[sized] == '5'){echo "176x208 <br>\n";}
elseif($file[sized] == '6'){echo "240x320 <br>\n";}
elseif($file[sized] == '7'){echo "352x416 <br>\n";}}
echo "Загружен: $timedat<br>\n";
echo "Закачек: ".$file['download']."<br>\n";
echo "</div>\n";
}else{echo "<div class=content><br><img src='../img/error.gif' alt=''> Такого файла не существует!<br><br></div>\n";}
}else{echo "<div class=content><br><img src='../img/error.gif' alt=''> Не выбран ID!<br><br></div>\n";}
echo "<div class=stat><a href='exchanger_confirm.php'>Назад</a></div>\n";
echo "<div class=stat><a href='../exchanger.php'>В обменник</a></div>\n";
echo "<div class=stat><a href='../index.php'>Прихожая</a></div>\n";
break;
case('confirm'):
mysql_query("UPDATE `exchanger_files` SET `confirm`= '1' WHERE `id` = '".intval($_GET['id'])."'");
header ("Location: exchanger_confirm.php"); exit;
break;
case('edit'):
echo "<div class=content>\n";
if ($_POST['save']){
if (isset($_POST['name']) && strlen(stripcslashes(htmlspecialchars($_POST['name'])))<=50){
$name = stripcslashes(htmlspecialchars($_POST['name']));
mysql_query("UPDATE `exchanger_files` SET `name` = '$name' WHERE `id` = '".intval($_GET['id'])."' LIMIT 1");
}else{ echo "Название привышает 50 символов!\n";}
if (isset($_POST['description']) && strlen(stripcslashes(htmlspecialchars($_POST['description'])))<=50){
$description = stripcslashes(htmlspecialchars($_POST['description']));
mysql_query("UPDATE `exchanger_files` SET `description` = '$description' WHERE `id` = '".intval($_GET['id'])."' LIMIT 1");
}else{ echo "Описание привышает 500 символов!\n";}
if (isset($_POST['adult']) && strlen(stripcslashes(htmlspecialchars($_POST['adult'])))<=2){
$adult = stripcslashes(htmlspecialchars($_POST['adult']));
mysql_query("UPDATE `exchanger_files` SET `18` = '$adult' WHERE `id` = '".intval($_GET['id'])."' LIMIT 1");}
if (isset($_POST['artist']) && strlen(stripcslashes(htmlspecialchars($_POST['artist'])))<=50){
$artist = stripcslashes(htmlspecialchars($_POST['artist']));
mysql_query("UPDATE `exchanger_files` SET `artist` = '$artist' WHERE `id` = '".intval($_GET['id'])."' LIMIT 1");}
if (isset($_POST['genre']) && strlen(stripcslashes(htmlspecialchars($_POST['genre'])))<=50){
$genre = stripcslashes(htmlspecialchars($_POST['genre']));
mysql_query("UPDATE `exchanger_files` SET `genre` = '$genre' WHERE `id` = '".intval($_GET['id'])."' LIMIT 1");}
if (isset($_POST['album']) && strlen(stripcslashes(htmlspecialchars($_POST['album'])))<=50){
$album = stripcslashes(htmlspecialchars($_POST['album']));
mysql_query("UPDATE `exchanger_files` SET `album` = '$album' WHERE `id` = '".intval($_GET['id'])."' LIMIT 1");}
}
$check = mysql_fetch_array(mysql_query("SELECT * FROM `exchanger_files` WHERE `id` = '".intval($_GET['id'])."'"));
if($check != 0){
$files = mysql_query("SELECT * FROM `exchanger_files` WHERE `id` = '".intval($_GET['id'])."'");
$file = mysql_fetch_array($files);
$exchanger = mysql_query("SELECT * FROM `exchanger` WHERE `id` = '$file[exchanger]'");
$exc = mysql_fetch_array($exchanger);
echo "<form action='?act=edit&id=".intval($_GET['id'])."' method='post'>\n";
echo "Название (Max-50): <br><input name='name' value='".$file['name']."' type='text'><br>\n";
echo "Описание (Max-300):<br><textarea name='description' cols='20' rows='3' id='text'>".$file['description']."</textarea><br>\n";
if ($exc['type'] == '1'){
echo "Артист (Max-50): <br><input name='artist' value='".$file['artist']."' type='text'><br>\n";
echo "Жанр (Max-50): <br><input name='genre' value='".$file['genre']."' type='text'><br>\n";
echo "Альбом (Max-50): <br><input name='album' value='".$file['album']."' type='text'><br>\n";}
echo "Файл для взрослых:<br>\n";
echo "Да ";
if($file['18']=="1"){echo " <input name='adult' type='radio' value='1' checked>";
}else{echo "<input name='adult' type='radio' value='1'>";}
echo " | ";
if($file['18']=="0"){echo "<input name='adult' type='radio' value='0' checked>";
}else{echo "<input name='adult' type='radio' value='0'>";}
echo "Нет<br>\n";
echo "<input name='save' type='submit' value='Изменить'></form>\n";
echo "</div>\n";
}else{echo "<div class=content><br><img src='../img/error.gif' alt=''> Такого файла не существует!<br><br></div>\n";}
echo "<div class=stat><a href='exchanger_confirm.php'>Назад</a></div>\n";
break;
}}
if(isset($user['level']) && $user['level']=='0'){
header ("Location: ../index.php"); exit;}
} else {header ("Location: ../index.php"); exit;}
include '../style/foot.php';
?>