View file pages/avators.php

File size: 4.22Kb
<?php
// mod by Golem http://veplog.ru

require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/isset.php";

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

if(!isset($action)){


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

$total = count($a);

$start = (int)$_GET['start'];
if($start < 0 || $start > $total){$start = 0;}
if ($total < $start + $config_avlist){ $end = $total; }
else {$end = $start + $config_avlist; }
for ($i = $start; $i < $end; $i++){

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

if ($provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!=""){
echo ' <a href="avators.php?action=avatar&amp;av='.$a[$i].'&amp;'.SID.'">Выбрать</a>';}

echo'<br></div></div>';
}

echo'<div class=body>';
if ($start != 0) {echo '<a href="avators.php?start='.($start - $config_avlist).'&amp;'.SID.'">&lt;пред. </a> ';}else{echo'&lt;пред. ';}
echo'|';
if ($total > $start + $config_avlist) {echo ' <a href="avators.php?start='.($start + $config_avlist).'&amp;'.SID.'"> след.&gt;</a>';}else{echo' след.&gt;';}

if($total>0){
$ba=ceil($total/$config_avlist);
$ba2=floor($total/$config_avlist)*$config_avlist;

echo '<br>Стр.:';
$asd=$start-($config_avlist*4);
$asd2=$start+($config_avlist*5);

if($asd<$total && $asd>0){echo ' <a href="avators.php?start=0&amp;'.SID.'">1</a> ... ';}

for($i=$asd; $i<$asd2;)
{
if($i<$total && $i>=0){
$ii=floor(1+$i/$config_avlist);

if ($start==$i) {
echo ' <b>'.$ii.'</b>';
} else {
echo ' <a href="avators.php?start='.$i.'&amp;'.SID.'">'.$ii.'</a>';
}}

$i=$i+$config_avlist;}
if($asd2<$total){echo ' ... <a href="avators.php?start='.$ba2.'&amp;'.SID.'">'.$ba.'</a></div>';}
}




if ($provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!=""){
if($udata[43]==""){$udata[43]="images/avators/noavatar.gif";}
echo '<div class=panel><small class="gr">Выберите понравившийся вам аватар<br><img src="../'.$udata[43].'" alt=""><br>Cейчас ваш аватар ';
}
echo '<br>Всего доступно аваторов: '.(int)$total.'</small></div>';
}

//---------------------------- Выбор аватаров --------------------------//
if($action=="avatar"){
if ($provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!=""){

if(isset($_GET['av']) && $_GET['av']!="" && !eregi("[^a-z0-9_\.()-]",$_GET['av'])){

$av=$_GET['av'];

if(file_exists("../images/avators/$av")){
//------------------------------ Запись в профиль ----------------------------//
$ufile = file_get_contents(BASEDIR."local/profil/$log.prof");
$udata = explode(":||:",$ufile);

$udata[43]=check("images/avators/$av");
for ($u=0; $u<$config_userprofkey; $u++){
$utext.=$udata[$u].':||:';}

if($udata[0]!="" && $udata[1]!="" && $udata[4]!="" && $utext!=""){
$fp=fopen(BASEDIR."local/profil/$log.prof","a+");
flock($fp,LOCK_EX);
ftruncate($fp,0);
fputs($fp,$utext);
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
unset($utext);
}

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

}else{echo'Неверный адрес аватара!<br>';}
}else{echo'Недопустимое название аватара!<br>';}

echo '<br>- <a href="avators.php?'.SID.'">Вернуться</a><br>';
}
}


echo'<div class="btm">[<a href="../index.php?'.SID.'">На главную</a>]</div>';
include_once"../themes/$config_themes/foot.php";
?>