Файл: sources/admin/delete_subcat.php
Строк: 53
<?php
if (!defined('VAPHP')) {
die("Этот файл недоступен.");
}
class delete_subcat extends base
{
function delete_subcat()
{
global $CONF, $DB, $FORM, $LNG, $TMPL;
if (is_array($FORM['id']) && count($FORM['id']) > 1)
{
$TMPL['id'] = "array";
$LNG['a_del_subcat_header'] = $LNG['a_del_subcat_headers'];
$LNG['a_del_subcat_done'] = $LNG['a_del_subcat_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']}_subcat WHERE id = {$TMPL['id']}", __FILE__, __LINE__);
}
$TMPL['header'] = $LNG['a_del_subcat_header'];
if ($TMPL['id'])
{
if (!isset($FORM['submit']))
{
$this->warning();
}
else
{
$this->process();
}
}
else
{
$this->error($LNG['a_del_subcat_invalid_id'], 'admin');
}
}
function warning()
{
global $FORM, $LNG, $TMPL;
$ids = '';
if (is_array($FORM['id']) && count($FORM['id']) > 1)
{
$del_warn = $LNG['a_del_subcat_warns'];
foreach ($FORM['id'] as $id)
{
$ids .= "<input type="hidden" name="id[]" value="{$id}" />n";
}
}
else
{
$del_warn = $LNG['a_del_subcat_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_subcat" method="post">
{$ids}<input type="submit" class="ButtonNormal" name="submit" value="{$LNG['a_del_subcat_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_subcat_done'];
}
function do_delete($id)
{
global $CONF, $DB;
$DB->query("DELETE FROM {$CONF['sql_prefix']}_sites WHERE idsubcat='{$id}'", __FILE__, __LINE__);
$DB->query("DELETE FROM {$CONF['sql_prefix']}_subcat WHERE id='{$id}'", __FILE__, __LINE__);
}
}
?>