<?
if ($mode=='foto_topg') {
$aid=intval(@$_REQUEST['aid']);
$b=mysql_query("SELECT * FROM zn_fototop WHERE aid='$aid' AND fid='$userid'");
if (($aid!=$userid) and (mysql_num_rows($b)==0)) {
mysql_query("UPDATE zn_anket SET rating=rating+1 WHERE id='$aid'");
mysql_query("INSERT INTO zn_fototop SET aid='$aid', fid='$userid'");
echo "Ваш голос принят!<br/>";
}
if (empty($_REQUEST['fback'])) {
$mode='foto_top';
}
if (@$_REQUEST['fback']=='showanket') {
list($l)=mysql_fetch_row(mysql_query("SELECT login FROM zn_anket WHERE id='$aid'"));
header("Location: http://$_SERVER[HTTP_HOST]$workdir/?mode=showanket&l=".urlencode($l));
ob_end_clean();
exit;
}
}
if ($mode=='foto_top') {
$v=@$_GET['v'];
if (!empty($_GET['v'])) {
echo "<a href=\"$workdir/?mode=foto_top\">Все</a><br/>";
}
echo "<a href=\"$workdir/?mode=foto_top&v=m\">Только парни</a><br/>";
echo "<a href=\"$workdir/?mode=foto_top&v=w\">Только девушки</a><br/>";
$caponpage=5;
if (isset($_REQUEST['n'])) {$n=intval($_REQUEST['n']);} else {$n=0;}
$a=mysql_fetch_array(mysql_query("SELECT COUNT(*) AS c FROM zn_anket WHERE photo='1'"));
$c=$a['c'];
$av='';
if (@$_GET['v']=='m') $av=" AND sex='m'";
if (@$_GET['v']=='w') $av=" AND sex='w'";
$ag=mysql_query("SELECT * FROM zn_anket WHERE photo>='1'$av ORDER BY best DESC, rating DESC, lastdate DESC LIMIT $n,$caponpage");
while($bs=mysql_fetch_array($ag))
{
echo "</div><div class=b>
<img src=\"mfoto.php?id={$bs['id']}_{$bs['defphoto']}\" alt=\"\"/><br/>
<a href=\"$workdir/?mode=showanket&l=".urlencode($bs['login'])."\">".$bs['login']."</a>";
$op=mysql_fetch_array(mysql_query("SELECT * FROM zn_anket WHERE login='$bs[login]' AND sex!='0'"));
if ($op['sex']=='m') {$sex="М";}
if ($op['sex']=='w') {$sex="Ж";}
echo " ($sex) $op[vozrast]<br/>";
echo "Голосов: $op[rating]";
if ($op['rating']>0) {
echo " <a href=\"$workdir/?mode=foto_topw&aid=$op[id]\">[кто проголосовал]</a>";
}
echo "<br/>";
$b=mysql_query("SELECT * FROM zn_fototop WHERE aid='$op[id]' AND fid='$userid'");
if (($op['id']!=$userid) and (mysql_num_rows($b)==0)) {
echo "<a href=\"$workdir/?mode=foto_topg&aid=$op[id]\">Голосовать</a><br/>";
}
}
echo "</div><div class=\"b\">";
if ($c>$caponpage) {
if ($n>0) {
$pp=$n-$caponpage;
if ($pp<0) {$pp=0;}
echo "<a href=\"$workdir/?mode=foto_top&n=$pp&v=$v\">Назад</a> ";
}
if ($n<$c) {
$np=$n+$caponpage;
if ($np<=$c) {
echo "<a href=\"$workdir/?mode=foto_top&n=$np&v=$v\">Далее</a>";
}
}
}
echo "</div><div class=\"b\">";
echo "» <a href=\"$workdir/?mode=menu\"><b>Меню</b></a>\n";
}
if ($mode=='foto_topw') {
if (isset($_REQUEST['n'])) {$n=intval($_REQUEST['n']);} else {$n=0;}
$aid=intval(@$_REQUEST['aid']);
$op=mysql_fetch_array(mysql_query("SELECT * FROM zn_anket WHERE id='$aid'"));
echo "За $op[login] проголосовали:<br/>";
$a=mysql_fetch_array(mysql_query("SELECT COUNT(*) AS c FROM zn_fototop WHERE aid='$aid'"));
$c=$a['c'];
$r=mysql_query("SELECT * FROM zn_fototop WHERE aid='$aid' LIMIT $n, $caponpage");
while ($a=mysql_fetch_array($r)) {
$ap=mysql_fetch_array(mysql_query("SELECT * FROM zn_anket WHERE id='$a[fid]'"));
echo "<a href=\"$workdir/?mode=showanket&l=".urlencode($ap['login'])."\">".$ap['login']."</a>";
if ($ap['sex']=='m') {$sex="М";}
if ($ap['sex']=='w') {$sex="Ж";}
echo " ($sex) $ap[vozrast]<br/>";
}
echo "</div><div class=\"b\">";
if ($c>$caponpage) {
if ($n>0) {
$pp=$n-$caponpage;
if ($pp<0) {$pp=0;}
echo "<a href=\"$workdir/?mode=foto_topw&n=$pp&aid=$aid\">Назад</a> ";
}
if ($n<$c) {
$np=$n+$caponpage;
if ($np<=$c) {
echo "<a href=\"$workdir/?mode=foto_topw&n=$np&aid=$aid\">Далее</a>";
}
}
}
echo "</div><div class=\"b\">";
echo "» <a href=\"$workdir/?mode=foto_top\">Фотогалерея</a><br/>\n";
echo "» <a href=\"$workdir/?mode=menu\"><b>Меню</b></a>\n";
}
?>