File size: 5.53Kb
<?php
require('includes/header.php');
require('includes/utils.php');
require('includes/db.php');
require('includes/config.php');
$message = '';
if((isset($_POST['login']) && isset($_POST['pass'])) || (isset($_GET['id']) || isset($_GET['p'])))
{
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$_POST = decode_array($_POST);
$users = mysql_query('SELECT id, login FROM users WHERE login = "' . addslashes($_POST['login']) . '" AND password = "' . md5($_POST['pass']) . '"');
}
else
{
$_GET = decode_array($_GET);
$users = mysql_query('SELECT id, login FROM users WHERE id = "' . (int)($_GET['id']) . '" AND login = "' . addslashes($_GET['p']) . '"');
}
if(mysql_num_rows($users) == 0)
{
?>
<wml>
<card id="error" title="error" ontimer="main.php"><timer value="15"/>
<p align="center">
Неправильный логин/пароль
</p>
</card>
</wml>
<?php
}
else
{
// show main page
$user = mysql_fetch_array($users, MYSQL_ASSOC);
$id = $user['id'];
$login = $user['login'];
if(isset($_GET['clear']) && $_GET['clear'] == 1)
{
$banners = mysql_query('SELECT banner FROM users WHERE login = "' . $login . '"');
list($banner) = mysql_fetch_array($banners);
if($banner == 'top' || $banner == 'bottom')
$random_link = get_random_link();
else
$random_link = '';
// clearing main page
$fp = fopen("$login/index.wml", 'w');
$counter_tag = '<img src="http://' . $server_name . '/counter.php?id=' . $id . '" alt="counter"/>';
$clear_page = '<?xml version="1.0" encoding="UTF-8"?>';
$clear_page .= <<<CLEARPAGE
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
<card id="index" title="Главная">
<do type="prev" label="Назад"><prev/></do>
<p align="center">
$random_link
<br/>
$counter_tag
</p>
</card>
</wml>
CLEARPAGE;
fputs($fp, $clear_page);
fclose($fp);
$message = 'Главная страница очищена';
}
else if(isset($_GET['go']) && $_GET['go'] == 'clear')
{
mysql_query('DELETE FROM guest_book WHERE user_id = "' . $id . '"');
$message = 'Гостевая книга очищена';
}
?>
<wml>
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
<card id="main" title="Меню">
<p align="center">
<?php
if($message != '')
echo $message . "\n<br/>\n";
$users_active = mysql_query('SELECT active FROM users WHERE id = "' . $id . '" AND login = "' . $login . '"');
list($user_active) = mysql_fetch_array($users_active);
if(!$user_active)
echo 'Внимание! Ваш аккаунт заблокирован. Обратитесь к администратору: ' . $admin_email . '<br/>';
?>
<a href="edit.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>">Редактор</a><br/>
<a href="manager.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>">Менеджер страниц</a><br/>
<a href="content.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>">Менеджер закачанных файлов</a><br/>
<a href="viewlinks.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>">Каталог ссылок</a><br/>
<a href="viewnews.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>">Новости</a><br/>
<a href="viewpolls.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>">Голосования</a><br/>
<a href="main.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>&go=clear">Очистить гостевую</a><br/>
*********<br/>
<a href="main.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>&clear=1">Очистить главную страницу (index.wml)</a><br/>
*********<br/>
<a href="editprofile.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>">Ваш профайл</a><br/>
*********<br/>
<a href="index.php">Wap-builder</a>
</p>
</card>
</wml>
<?php
}
}
else
{
?>
<wml>
<card id="auth" title="Авторизация">
<do type="options" name="main" label="Wap-builder"><go href="index.php"/></do>
<p align="center">
<b>Авторизация</b><br/>
Логин:<br/>
<input name="login" title="Login"/><br/>
Пароль:<br/>
<input name="pass" title="Password"/><br/>
<anchor title="Sign">Ok<go href="main.php" method="post">
<postfield name="login" value="$(login)"/>
<postfield name="pass" value="$(pass)"/>
</go></anchor><br/>
<a href="lostpassword.php">Забыли пароль?<br/></a>
<a href="index.php">Wap-builder</a>
</p>
</card>
</wml>
<?php
}
?>