File size: 2.85Kb
<?php
// блок администрирования
include "config.inc.php";
include "unicode.lib.php";
include "header.php";
print "<card id=\"Admin-panel\" title=\"Admin-panel\">\n";
print "<p>";
if (!@mysql_connect($db_host,$db_user,$db_pass)) {
print "Ошибка соединения с mysql!<br/>";
}
else {
if (!@mysql_select_db($db_name)) {
print "Ошибка, такой базы не существует!<br/>";
}
}
$db_result=0;$db_result = array(); $ibx = 0;
$db_query = mysql_query("select name,url,description,date,views,today from $table_wapcat where today>0 order by today desc");
while ($row = mysql_fetch_row($db_query)) $db_result[$ibx++] = $row;
$all_count = count($db_result);
$sites_count = $all_count;
$total_pages = ceil($sites_count/$page_limit);
if (!$nfrom) $nfrom = 0;
for ($i=0; $i<$total_pages; $i++) {
$page_number=$i*$page_limit;
if ($page_number!=$nfrom) {$pages_links = $pages_links."|<a href='admin.php?pass=".$pass."&mode=edit&nfrom=".$page_number."'>".($i+1)."</a>|";}
else {$pages_links = $pages_links."(".($i+1).")";}
}
$nto = $nfrom+$page_limit;
if ($nto>$sites_count) $nto=$sites_count;
if(!$pass) {
print utf_encode("Ваш пароль: <br/><input name=\"pass\"/><br/>\n");
print "<a href=\"admin.php?pass=$(pass)\">".utf_encode("Войти")."</a><br/>\n";
print "<a href=\"index.php\">".utf_encode("Главная")."</a>\n";
}
else {
if($pass != $admin_pass) {
print utf_encode("Ошибка, неверный пароль!<br/>");
print "<a href=\"admin.php\">".utf_encode("Вернуться")."</a><br/>\n";
print "<a href=\"index.php\">".utf_encode("Главная")."</a><br/>\n";
}
else {
if(!$mode) $mode = "edit";
switch($mode) {
case "edit":
for ($i=$nfrom;$i<$nto;$i++) {
$name = $db_result[$i][0];
$url = $db_result[$i][1];
$description = $db_result[$i][2];
print ($i+1).". <a href=\"".$url."\" title=\"".$url."\">".$description."</a><br/>";
print "<a href=\"admin.php?pass=".$pass."&mode=delete&name=".$name."\">".utf_encode("Удалить")."</a><br/>";
}
print utf_encode("Страницы: ".$pages_links."<br/>");
print "<a href=\"admin.php\">".utf_encode("Выйти")."</a><br/>\n";
print "<a href=\"index.php\">".utf_encode("Главная")."</a><br/>\n";
break;
case "delete":
if(mysql_query("delete from $table_wapcat where name='".$name."'")) {
print utf_encode("Аккаунт $name удален из каталога!<br/>\n");
}
else {
print utf_encode("Удаление невозможно!<br/>\n");
}
print "<a href=\"admin.php?pass=".$pass."\">".utf_encode("Вернуться")."</a><br/>\n";
print "<a href=\"index.php\">".utf_encode("Главная")."</a><br/>\n";
break;
}
}
}
@mysql_close();
print "</p>";
include "footer.php";
?>