Файл: ava/index.php
Строк: 100
<?
require'../includes.php';
$align='left';
$title='Аватары';
aut();
head();
who_add(0,'enter');
switch($mod){
default:
function count_dir($dir) {
global $sitetime;
$count=0;
$newcount=0;
$path = opendir($dir);
while ($file = readdir($path)) {
if (( $file != ".")&&($file != "..")&&($file != ".htaccess")&&($file != "index.php")&&($file != "name.dat")&& !ereg (".txt$", "$file")&& !ereg (".JPG$", "$file")&& !ereg (".GIF$", "$file")) {
$count ++;
$filetime=filemtime("$dir/$file")+(3600*24*5);
if($filetime>$sitetime){
$newcount ++;
}
}}
if($newcount>0){
$input=(int)$count.'/+'.(int)$newcount;
}else{
$input=(int)$count;
}
closedir ($path);
return $input;
}
function count_dir_size($dir)
{
global $mysql;
$dir=str_replace("//", "/", $dir);
$livetime=time()-3600;
$size=0;
$od=opendir($dir);
while ($rd=readdir($od))
{
if (is_dir("$dir/$rd") && $rd!='.' && $rd!='..')
{
$size=$size+count_dir_size("$dir/$rd");
}
elseif(!ereg(".name|error.log|.htaccess|.opis|.aut|.jad|.dat",$rd) && $rd!='.' && $rd!='..')
{
$size=$size+filesize("$dir/$rd");
}
}
return $size;
}
$downdir_array = array();
$dir = opendir (".");
while ($file = readdir ($dir)) {
if (is_dir($file)) {
if($file=="."||$file=="..") continue;
$downdir_array[]=$file;
}}
closedir ($dir);
sort($downdir_array);
$total = count($downdir_array);
for ($i = 0; $i < $total; $i++){
if(file_exists("$downdir_array[$i]/name.dat")){
$down_name=file_get_contents("$downdir_array[$i]/name.dat");
}else{$down_name=$downdir_array[$i];}
echo '<img src="../img/dir.gif" alt=""/> <a href="?mod=ava&path='.$downdir_array[$i].'&'.SID.'">'.$down_name.'</a> ('.count_dir($downdir_array[$i]).')<br/>';
}
break;
case 'ava':
$path = check($_GET['path']);
$col = 6;
$d=opendir("$path");
if(isset($_GET['list']))$list = check(intval($_GET['list']));
else if(isset($_POST['list'])) $list = check(intval($_POST['list']));
if(!isset($list)) $list = "1";
$n = "1";
while(($k=readdir($d))!==false){
if ($k=='.'||$k=='..'||$k=="index.php"||$k==".htaccess"||$k==".Thumbs.db") continue;
$n++;
}
closedir($d);
$num=($n/$col);if ($num!==(int)$num){$foo = (int) $num;$fo = ($foo + 1);}else{$fo=$num;}
for ($i="1"; $i<=$fo; $i++) {/*echo "<a href="1?list=$i">$i</a>|";*/}
if ($list == "") {$c="0";}else{$c=($col*($list-1));}
$d=opendir("$path");
$la = "-1";
echo "Аватар для <b>".$user["user"]."</b><br/>";
echo "Вы можете установить любой из этих аватаров в качестве личного в анкете, просто щелкните на понравившейся картинке.<br/>";
while(($e=readdir($d))){
if ($e=='.'||$e=='..'||$e=="index"||$e==".htaccess"||$e==".Thumbs.db") continue;
$la = $la + 1;
if($la>$c-1 and $la<$c+$col){
$laa = $la + 1; // Номер файла
echo "<a href="index?mod=addavatars&path=$path&ava=$e"><img src="$path/$e" alt="$e"/></a><br/> ";
}
}
for ($i="0"; $i<=$fo; $i++)
if ($list == "$path") {
$c="0";
}else{
$c=($col*($list-1));
}
$lis = $list + 1;
$lis1 = $list - 1;
echo "<br/>";
if ($lis1 < "1"){
echo "<<пред.";
}else{
echo "<a href="index?list=$lis1&mod=".$mod."&path=$path"><<пред. </a>";
}
if ($lis == "$i"){
echo "| след.>><br/>";
}else{
echo "| <a href="index?list=$lis&mod=".$mod."&path=$path">след.>></a><br/>";
}
if ($ver!='wml') echo "<form method="POST" action="index?mod=".$mod."&path=$path" name="auth">";
echo "Перейти к:<br/>";
echo "<input name="list" format="*N" size="3"/><br/>";
echo "странице<br/>";
if ($ver=='wml'){
echo "<anchor title="go">Пошёл<go href="index?$ses&&mod=avatars" method="post">";
echo "<postfield name="list" value="$(list)"/>";
echo "</go></anchor>";
echo "<br/>";
}else{
echo "<input type="submit" class="ibutton" value="Пошёл" name="enter"><br/>";
}
$alls = $i - 1;
echo "<br/>";
echo "Аватаров:<b> $n</b><br/>Страницa:<b> $list/$alls</b><br/>";
closedir($d);
break;
case 'addavatars':
$path = check($_GET['path']);
$ava = check($_GET['ava']);
$foto='ava/'.$path.'/'.$ava;
@query ("Update users set myavatar='".$foto."' WHERE id ='".$user['id']."'");
echo "<b>Ваш Аватар успешно установлен!</b><br/>";
break;
}
echo '<br />';
if ($mod)echo gb.'<a href="?">Аватары</a>'.div;
echo gb.'<a href="'.H.'my/index">Личный кабинет</a>'.div;
echo gb.'<a href="'.H.'enter">Прихожая</a>'.div;
foot();
?>