View file pages/avators.php

File size: 2.28Kb
<?php

$title='Смена аватара';
 require"../system/config.php"; 
 require"../system/func.php"; 
 require"../system/head.php";
 require"../system/error.php";  
 echo'<div class="i" align="center">'.$title.'</div>';
if($vhod==1){}else{header("Location: ../index.php"); exit;}

$act = $_GET['act'];

echo '<div class="i"> <b>Галерея аватаров 1</b></div>';

$a = array();
if(!isset($act)){

$dir = opendir ("../images/avators");
while ($file = readdir ($dir))
{if (( $file != ".") && ($file != "..") && ($file != ".htaccess") && ($file != ".guest.gif") && ($file != "index.php")&& ($file != "Thumbs.db")&& ($file != "noavatar.gif"))
{$a[]=$file;}}
closedir ($dir);
sort($a);

$total = count($a);

$page = abs((int)$_GET['page']);
if($page < 0 || $page > $total) $page = 0;
if ($total < $page + 10) $end = $total;
else $end = $page + 10;
for ($i = $page; $i < $end; $i++){

echo '<img src="../images/avators/'.$a[$i].'" alt=""> ';


echo ' <a href="avators.php?act=avatar&amp;av='.$a[$i].'&amp;'.$s.'">Выбрать</a><br>';}
echo'<div class="p">';
strpage($page, 10, $total, "avators.php");
echo'</div>';
$qq=mysql_fetch_array(mysql_query("SELECT `avator` FROM `users` WHERE `id_user`='$id_user'"));
if($qq['avator']==""){
echo '<br>Cейчас ваш аватар: <img src="../images/avators/noavatar.gif" alt="">';
}else{echo '<br>Cейчас ваш аватар: <img src="../images/'.$qq['avator'].'" alt="">';}
echo '<br>Всего доступно аваторов: '.(int)$total.'<br>';
}

// Выбор аватаров
if($act=="avatar"){
if(isset($_GET['av']) && $_GET['av']!="" && !eregi("[^a-z0-9_\.()-]",$_GET['av'])){

$av=$_GET['av'];

if(file_exists("../images/avators/$av")){

$savav=check("avators/$av");
mysql_query("UPDATE `users` SET `avator`='$savav' WHERE `id_user`='$id_user'");

echo '<br>Аватар успешно выбран!<br>';
echo 'Cейчас ваш аватар: <img src="../images/avators/'.$av.'" alt=""><br>';

}else{echo'Неверный адрес аватара!<br>';}
}else{echo'Недопустимое название аватара!<br>';}
echo '<br><img src="../design/default/act.gif" alt=""> <a href="avators.php?'.$s.'">Вернуться</a>';
}



include_once"../system/foot.php";
?>