Размер файла: 1.41Kb
<?php
include 'inc/db.php';
include 'inc/1.php';
if (!$user){
header("Location: /index.php");
exit;
}
if (!$_GET['avatar']){
if (!$_GET['p'])$_GET['p']=1;
$p=intval($_GET['p']);
$q=mysql_query("SELECT `id` FROM `obmen` WHERE `ras` = 'jpg' OR `ras` = 'gif' OR `ras` = 'png' OR `ras` = 'bmp' OR `ras` = 'tif'");
$start=($p*15-15);
$qq=mysql_query("SELECT `id`, `time` FROM `obmen` WHERE `ras` = 'jpg' OR `ras` = 'gif' OR `ras` = 'png' OR `ras` = 'bmp' OR `ras` = 'tif' ORDER BY `time` DESC LIMIT $start, 15");
$b=1;
while ($f=mysql_fetch_assoc($qq)){
$pp=($b%2);
div("p$pp");
echo "<a href='?avatar=$f[id]'><img src='obmen/$f[id].file' width='70'></a>";
nodiv();
$b++;
}
$q1=(mysql_num_rows($q)/15);
$q2=round(mysql_num_rows($q)/15);
if ($q1>$q2)$pages=($q2+1);
else
$pages=$q2;
pages($pages, $p, "?p");
}
else
{
$ava=mysql_fetch_assoc(mysql_query("SELECT * FROM `obmen` WHERE `id` = '".intval($_GET['avatar'])."'"));
if (mysql_num_rows(mysql_query("SELECT * FROM `obmen` WHERE `id` = '".intval($_GET['avatar'])."'"))==0){
header("Location: /avatar.php");
exit;
}
$b=(($ava['ras']=='jpg') || ($ava['ras']=='png') || ($ava['ras']=='gif') || ($ava['ras']=='bmp') || ($ava['ras']=='tif'));
if (!$b){
header("Location: /avatar.php");
exit;
}
mysql_query("UPDATE `user` SET `avatar` = '".intval($_GET['avatar'])."' WHERE `id` = '$user[id]'");
header("Location: /ank.php");
exit;
}
include 'inc/foot.php';
?>