Файл: sources/admin/delete_site.php
Строк: 53
<?php
if (!defined('VAPHP')) {
die("Этот файл недоступен.");
}
class delete_site extends base
{
function delete_site()
{
global $CONF, $DB, $FORM, $LNG, $TMPL;
if (is_array($FORM['id']) && count($FORM['id']) > 1)
{
$TMPL['id'] = "array";
$LNG['a_del_site_header'] = $LNG['a_del_site_headers'];
$LNG['a_del_site_done'] = $LNG['a_del_site_dones'];
}
else
{
if (is_array($FORM['id']) && count($FORM['id']) == 1)
{
$TMPL['id'] = intval($FORM['id'][0]);
}
else
{
$TMPL['id'] = intval($FORM['id']);
}
list($TMPL['id']) = $DB->fetch("SELECT id FROM {$CONF['sql_prefix']}_sites WHERE id = {$TMPL['id']}", __FILE__, __LINE__);
}
$TMPL['header'] = $LNG['a_del_site_header'];
if ($TMPL['id'])
{
if (!isset($FORM['submit']))
{
$this->warning();
}
else
{
$this->process();
}
}
else
{
$this->error($LNG['a_del_site_invalid_id'], 'admin');
}
}
function warning()
{
global $FORM, $LNG, $TMPL;
$ids = '';
if (is_array($FORM['id']) && count($FORM['id']) > 1)
{
$del_warn = $LNG['a_del_site_warns'];
foreach ($FORM['id'] as $id)
{
$ids .= "<input type="hidden" name="id[]" value="{$id}" />n";
}
}
else
{
$del_warn = $LNG['a_del_site_warn'];
$ids .= "<input type="hidden" name="id[]" value="{$TMPL['id']}" />n";
}
$TMPL['admin_content'] = <<<EndHTML
{$del_warn}<br><br>
<form action="index.php?a=admin&b=delete_site" method="post">
{$ids}<input type="submit" class="ButtonNormal" name="submit" value="{$LNG['a_del_site_header']}" />
</form>
EndHTML;
}
function process()
{
global $FORM, $LNG, $TMPL;
if (is_array($FORM['id']) && count($FORM['id']) > 1)
{
foreach ($FORM['id'] as $id)
{
$this->do_delete($id);
}
}
else
{
$this->do_delete($TMPL['id']);
}
$TMPL['admin_content'] = $LNG['a_del_site_done'];
}
function do_delete($id)
{
global $CONF, $DB;
$DB->query("DELETE FROM {$CONF['sql_prefix']}_sites WHERE id='{$id}'", __FILE__, __LINE__);
}
}
?>