Файл: sources/admin.php
Строк: 113
<?php
if (!defined('VAPHP')) {
die("Этот файл недоступен.");
}
class admin extends base
{
function admin()
{
global $CONF, $FORM, $LNG, $TMPL;
$TMPL['header'] = $LNG['a_header'];
if (!isset($_COOKIE['vaphp_sid_admin']))
{
$this->login();
}
else
{
require_once("{$CONF['path']}/sources/session.php");
$session = new session;
list($type, $data) = $session->get($_COOKIE['vaphp_sid_admin']);
if ($type == 'admin')
{
$session->update($_COOKIE['vaphp_sid_admin']);
// Массив содержит доступные .php файлы в директории sources/admin
$action = array(
'settings' => 1,
'manage_bad_words' => 1,
'delete_bad_word' => 1,
'edit_bad_word' => 1,
'cat' => 1,
'subcat' => 1,
'edit_cat' => 1,
'delete_cat' => 1,
'new_cat' => 1,
'delete_subcat' => 1,
'edit_subcat' => 1,
'new_subcat' => 1,
'add_site' => 1,
'check_backlink' => 1,
'delete_site' => 1,
'edit_site' => 1,
'manage_site' => 1,
'approve' => 1,
'backup_database' => 1,
'manage_ban' => 1,
'delete_ban' => 1,
'edit_ban' => 1
);
if (isset($FORM['b']) && isset($action[$FORM['b']]))
{
$page_name = $FORM['b'];
require_once("{$CONF['path']}/sources/admin/{$page_name}.php");
$page = new $page_name;
$TMPL['content'] = $this->do_skin('admin');
}
elseif (isset($FORM['b']) && $FORM['b'] == 'logout')
{
$this->logout();
}
else
{
$this->main();
}
}
else
{
$this->login();
}
}
}
function login()
{
global $CONF, $DB, $FORM, $LNG, $TMPL;
if (!isset($FORM['password']) || !$FORM['password'])
{
$TMPL['content'] = $this->do_skin('admin_login');
}
else
{
sleep(1);
if ($CONF['admin_password'] == $FORM['password'])
{
require_once("{$CONF['path']}/sources/session.php");
$session = new session;
$session->create('admin', 1);
$this->main();
}
else
{
$this->error($LNG['g_invalid_p']);
}
}
}
function logout()
{
global $CONF, $LNG, $TMPL;
require_once("{$CONF['path']}/sources/session.php");
$session = new session;
$session->delete($_COOKIE['vaphp_sid_admin']);
$TMPL['content'] = $LNG['a_logout_message'];
}
function main()
{
global $DB, $CONF, $LNG, $TMPL;
$TMPL['admin_content'] = "{$LNG['a_main']}<br><br>";
list($num_waiting) = $DB->fetch("SELECT COUNT(*) FROM {$CONF['sql_prefix']}_sites WHERE check_admin = '0'", __FILE__, __LINE__);
if ($num_waiting == 1)
{
$TMPL['admin_content'] .= "<a href="{$TMPL['site_url']}/index.php?a=admin&b=approve"><b>{$LNG['a_main_approve']}</b></a><br><br>";
}
elseif ($num_waiting > 1)
{
$TMPL['admin_content'] .= "<a href="{$TMPL['site_url']}/index.php?a=admin&b=approve"><b>".sprintf($LNG['a_main_approves'], $num_waiting)."</b></a><br><br>";
}
list($num_sites) = $DB->fetch("SELECT COUNT(*) FROM {$CONF['sql_prefix']}_sites", __FILE__, __LINE__);
$TMPL['admin_content'] .= sprintf($LNG['a_main_all'], $num_sites);
$TMPL['content'] = $this->do_skin('admin');
}
}
?>