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

<?php
include("var.php");
echo "<html><head><title>Администрирование Рейтинга: $sitename</title>";
echo "<META HTTP-EQUIV=\"Expires\" Content=\"Mon, 28 Mar 1999 00:00:01 GMT\">";
include("top.php");
$db=@mysql_connect($bdhost,$bdlogin,$bdpass);
@mysql_select_db($bdname,$db);
$err1="Неверный пароль!<br>";
$err2="Не выбрано ни одной анкеты!<br>";
$error = "";
if ($QUERY_STRING != "del"){
$n = getenv('REQUEST_URI');
$n = ereg_replace("\?.*$","",$n);
$result = @mysql_query("SELECT ID,name,reiting FROM $textable order by name");
$totalThread = @mysql_num_rows($result);
$mes = $totalThread;
unset($result);
if(!isset($page)) $page = 1;
if( $totalThread <= $maxThread ) $totalPages = 1;
elseif( $totalThread % $maxThread == 0 ) $totalPages = $totalThread / $maxThread;
else $totalPages = ceil( $totalThread / $maxThread );
if( $totalThread == 0 ) $threadStart = 0;
else $threadStart = $maxThread * $page - $maxThread + 1;
if( $page == $totalPages ) $threadEnd = $totalThread;
else $threadEnd = $maxThread * $page;
$initialMsg = $maxThread * $page - $maxThread;
$pages = (int) (($totalThread + $maxThread - 1) / $maxThread);
$line = "Страница: |";
for ($k = 1; $k <= $pages; $k++) {
  if ($k != $page) {$line .= "<a href=\"adminr.php?page=$k\"> $k </a>|";}
  if ($k == $page) {$line .= " $k |";}
}
echo "<center><p><strong><big>Администрирование Рейтинга</strong></big><p>Пометьте программу, рейтинг которой нужно изменить, установите новое значение, введите логин и пароль администратора и нажмите на кнопку \"Установить\".<p>";
echo "Всего анкет: <b>$totalThread</b><br>$line</p>";
echo "<form name=delreg method=post action=adminr.php?del><table border=0 width=95% class=vfbord2><tr><td><table width=100% border=0 class=vfbord>";
echo "<tr class=vfbord bgcolor=#330000><td><strong>&nbsp;</strong></td><td><strong>Имя</strong></td><td><strong>Категория</strong></td><td><strong>Город</strong></td><td><strong>Рейтинг</strong></td><td><strong>Голосов</strong></td></tr>";
$result = @mysql_query("SELECT ID,name,category,city,aid,reiting,sum,status FROM $textable order by name LIMIT $initialMsg, $maxThread");
while($myrow=mysql_fetch_array($result)) {
$ID=$myrow["ID"];
$name=$myrow["name"];
$category=$myrow["category"];
$city=$myrow["city"];
$aid=$myrow["aid"];
$sum=$myrow["sum"];
$reiting=$myrow["reiting"];
echo "<tr><td class=vfbord><input type=radio name=delmes[] value=$ID></td>";
echo "<td class=vfbord><a href=list.php?g=$category&link=$ID target=_blank>$name</a></td>";
echo "<td class=vfbord>$category</td>";
echo "<td class=vfbord>$city</td>";
echo "<td class=vfbord><b>$reiting</b></td>";
echo "<td class=vfbord>$sum</td></tr>";
}
echo "<tr><td colspan=6 class=vfbord align=left><b>Новое значение </b><input type=text name=newvalue size=6 value=0></td></tr></td></tr></table></table>";
echo "<p><center>$line<p>";
if ($REMOTE_ADDR != $adminip)
{
echo ("
<center><table>
<tr><td align=right><strong><font color=#FF0000>*</font>Логин:</strong></td>
<td><input type=text name=namenew size=30></td></tr>
<tr><td align=right><strong><font color=#FF0000>*</font>Пароль:</strong></td>
<td><input type=password name=passnew size=30></td></tr>
</table>
");
}
echo ("
<hr width=90% size=1>
<center><input type=submit value='Установить' name=submit></form>
");
}
if ($QUERY_STRING == "del"){
if ($REMOTE_ADDR != $adminip)
{
if (($adminname != $namenew) or ($adminpass != $passnew)) {
	$error .= "$err1";}
}
if (count($delmes)==0) {
	$error .= "$err2";}
if ($error != ""){
echo "<center><h3>Ошибка</h3><font color=red>$error</font><p><a href=# onClick=history.go(-1)>Вернуться назад</a><p><br><br><br><br><br><br><br><br>";
}
if ($error==""){
unset($result);
for ($i=0;$i<count($delmes);$i++){
$sql="update $textable SET reiting='$newvalue' WHERE ID=$delmes[$i]";
$result=@mysql_query($sql,$db);
}
echo "<center><b>Рейтинг изменен!</b><br><a href=adminr.php>Вернуться</a><p><br><br><br><br>";
}
}
echo "<center><a href=admin.php>На общую страницу администрирования</a><br><br>";
mysql_close($db);
include("down.php");
?>