<!--/***************** DO NOT REMOVE! *********************/---->
<!--/*   Author: Nevezhyn Evgeny  Date : 10/01/2003       */---->
<!--/*             All Rights Reserved ...                */---->
<!--/*        Supplied by WTN-WDYL Team `2004             */---->
<!--/***************** DO NOT MODIFY! *********************/---->

<?php
echo "<html><head>";
include("var.php");
$maxThread = 9;
echo "<title>Фотогаллерея : $sitename</title>";
include("top.php");
@$db=mysql_connect($bdhost,$bdlogin,$bdpass);
@mysql_select_db($bdname,$db);
$n = getenv('REQUEST_URI');
if (!isset($g) or $g=='%') {$g='%';$gtit='Все';}
elseif (isset($g)) {$gtit=$g;}
$result = @mysql_query("SELECT ID,category,status,reiting,date FROM $textable WHERE category LIKE '$g' and status='ok' order by reiting DESC,date");
$totaltexts=@mysql_num_rows($result);
if(!isset($page)) $page = 1;
if( $totaltexts <= $maxThread ) $totalPages = 1;
elseif( $totaltexts % $maxThread == 0 ) $totalPages = $totaltexts / $maxThread;
else $totalPages = ceil( $totaltexts / $maxThread );
if( $totaltexts == 0 ) $threadStart = 0;
else $threadStart = $maxThread * $page - $maxThread + 1;
if( $page == $totalPages ) $threadEnd = $totaltexts;
else $threadEnd = $maxThread * $page;
$initialMsg = $maxThread * $page - $maxThread;
$pages = (int) (($totaltexts + $maxThread - 1) / $maxThread);
$line = "Страница: |";
for ($k = 1; $k <= $pages; $k++) {
  if ($k != $page) {
if ($g=='%') {$line .= "<a href=\"$n?g=%&page=$k\"> $k </a>|";}
else {
$line .= "<a href=\"$n&page=$k\"> $k </a>|";}}
  if ($k == $page) {$line .= " $k |";}
}
echo "<h3 align=center>Фотогаллерея&nbsp;:&nbsp;$gtit&nbsp;</h3>";
if ($totaltexts == 0) {
echo "<center>Анкет пока нет!<br><br><a href=# onClick=history.go(-1)>Вернуться назад</a><br><br>";
}
else
{ //2
echo ("
<center><table class=vfbord2 width=90% height=356><tr><td width=100% height=356 valign=top align=center>
<table class=vfbord bgcolor=#330000 width=97%><tr><td width=100%><p align=center><a href=gallery.php>Все</a>
");
$baze = file("category.dat");
for ($i=0;$i<count($baze);$i++){
echo "&nbsp;|&nbsp;<a href=gallery.php?g=$baze[$i]>$baze[$i]</a>";}
echo ("
</td></tr></table>
<table class=vfbord bgcolor=#330000 width=97%><tr><td width=100%><p align=center>Всего фотографий: <b>$totaltexts</b></td></tr></table>
<table width=97% class=vfbord3><tr>
");
$c=0;
$result = @mysql_query("SELECT ID,name,category,foto1,foto2,foto3,foto4,foto5,aid,date,reiting,status FROM $textable WHERE status='ok' and category LIKE '$g' order by reiting DESC,date LIMIT $initialMsg, $maxThread");
while ($myrow=mysql_fetch_array($result)) 
{ //4
$ID=$myrow["ID"];
$name=$myrow["name"];
$category=$myrow["category"];
$foto1=$myrow["foto1"];
$foto2=$myrow["foto2"];
$foto3=$myrow["foto3"];
$foto4=$myrow["foto4"];
$foto5=$myrow["foto5"];
if ($foto1 != "") {$fotourl=$foto1;}
else {if ($foto2 != "") {$fotourl=$foto2;}
else {if ($foto3 != "") {$fotourl=$foto3;}
else {if ($foto4 != "") {$fotourl=$foto4;}
else {if ($foto5 != "") {$fotourl=$foto5;}
}}}}
if ($c==0 or ($c/3) == 1 or ($c/3) == 2){
echo "</tr><tr><td valign=middle class=vfbord><p align=center><a href=list.php?g=$category&link=$ID><img src=$photodir$fotourl border=0 height=150></a></td>";}
else {
echo "<td valign=middle class=vfbord><p align=center><a href=list.php?g=$category&link=$ID><img src=$photodir$fotourl border=0 height=150></a></td>";}
$c=$c+1;
} //4
echo "</table><center><table width=97%><tr><td class=vfbord><p align=center>$line</td></tr></table></td></tr></table><br><br>";
} //2
include("down.php");
?>