Файл: minichat_by_KoT/minichat_by_KoT/gallery.php
Строк: 57
<?php
##########################################
# ~ Разработка отдельных модулей ~~~~~~~ #
# ~ и написание скриптов на php (c)KoT ~ #
# ~ ICQ: 7675072 ~~~~~~~~~~~~~~~~~~~~~~~ #
# ~ Site: 4atlove.ru ~~~~~~~~~~~~~~~~~~~ #
# ~ E-mail: notefree@bk.ru ~~~~~~~~~~~~~ #
##########################################
require 'sid.php';
header("Cache-Control: no-cache");
header('Content-Type:text/html; charset=UTF-8');
require 'config.php';
$link = connect_db();
list($row, $id, $ps) = check_login($link);
include 'head.php';
include 'pages.php';
whorm(0, 'gallery');
echo $div1 . '<b>Фотогалерея</b>' . $div5;
if (isset($_GET['delete'])) {
if (!ctype_digit($_GET['nk'])) { header('Location: index.php?isset=403'); die; }
$nk = (int)$_GET['nk'];
if ($row['level'] == 2) {
$s = mysql_query("SELECT `img` FROM `users` WHERE `id`='$nk' LIMIT 1");
$rr = mysql_fetch_array($s);
$myfotos = $rr['img'];
$ras = explode('.', $myfotos);
$types = $ras[1];
if (!file_exists("photo/".$nk.".".$types."")) {
echo $bad . 'Фото не установлено!' . $div5;
} else {
if (mysql_query("UPDATE `users` SET `img`='' WHERE `id`='$nk'")) {
unlink("photo/".$nk.".".$types."");
echo $good . 'Фото успешно удалено!' . $div5;
} else {
echo $bad . 'Ошибка удаления фото!' . $div5;
}
}
} else {
echo $bad . 'Нет прав!' . $div5;
}
}
$num = mysql_result(mysql_query("SELECT count(`id`) as num FROM `users` WHERE `img`!=''"),0);
if ($num == 0) {
echo $bad . 'Фотогалерея пока пуста...' . $div5;
} else {
if (!isset($s)) $s = 0;
$mx = round(($num/10)+0.45);
if ($s > $mx) $s = $mx;
if ($s == 0) $s = 1;
$ot = (($s - 1) * 10) + 1;
$do = $s * 10;
if ($do > $num) $do = $num;
$o = $ot - 1;
$n = $ot;
if ($do == 0) $n = $o;
$sql_1 = mysql_query("SELECT `id`,`user`,`votefoto`,`img` FROM `users` WHERE `img`!='' ORDER BY `votefoto` DESC LIMIT ".abs(intval($o)).", ".abs(intval($do))."");
echo $div3;
for ($i = $ot; $i <= $do; $i++) {
$sql_2 = mysql_fetch_assoc($sql_1);
$nk = $sql_2['id'];
$img = $sql_2['img'];
$user = $sql_2['user'];
$count = $sql_2['votefoto'];
settype($nk, 'integer');
$form = explode('.', $img);
$type = $form[1];
if ($row['level'] == 2) {
$del = '<a href="gallery.php?nk='.$nk.'&delete"><b>[</b>Уд.<b>]</b></a>';
}
echo '<a href="photo/'.$nk.'.'.$type.'"><b>'.col($user).'</b></a> |
Голосов: ['.$count.']<br/>
<a href="vote.php?nk='.$nk.'&go=vote"><b>[</b>Голосовать<b>]</b> '.$del.'</a><br/>';
}
$next = $s + 1;
$prev = $s - 1;
if ($num > $do) {
$ot = (($next - 1) * 10) + 1;
$do = $next * 10;
if ($do > $num) $do = $num;
echo $fsize1;
echo '<a href="gallery.php?s='.$next.'">» Назад</a><br/>';
echo $fsize2;
}
if ($s > 1) {
$ot = (($prev - 1) * 10) + 1;
$do = $prev * 10;
echo '<a href="gallery.php?s='.$prev.'">» Далее</a><br/>';
}
}
echo $div5 . $div3 . '
<a href="menu.php?'.$ref.'"><b>В меню</b></a><br/>' . $div5;
include 'foot.php';
?>