Файл: sources/admin/edit_cat.php
Строк: 43
<?php
if (!defined('VAPHP'))
{
die("Этот файл недоступен.");
}
class edit_cat extends base
{
function edit_cat()
{
global $CONF, $DB, $FORM, $LNG, $TMPL;
$TMPL['header'] = $LNG['a_edit_cat_header'];
$id = intval($FORM['id']);
list($TMPL['id']) = $DB->fetch("SELECT id FROM {$CONF['sql_prefix']}_cat WHERE id = {$id}", __FILE__, __LINE__);
if ($TMPL['id'])
{
if (!isset($FORM['submit']))
{
$this->form();
}
else
{
$this->process();
}
}
else
{
$this->error($LNG['a_del_cat_invalid_id'], 'admin');
}
}
function form()
{
global $CONF, $DB, $LNG, $TMPL;
list($TMPL['id'], $TMPL['name']) = $DB->fetch("SELECT id, name FROM {$CONF['sql_prefix']}_cat WHERE id = {$TMPL['id']}", __FILE__, __LINE__);
$TMPL['admin_content'] = <<<EndHTML
<form action="{$TMPL['site_url']}/index.php?a=admin&b=edit_cat&id={$TMPL['id']}" method="post">
<span class="SeparatorLabel">{$LNG['a_edit_cat_header']}</span>
{$LNG['a_cat_id']}<br>
<input type="text" class="SmallInput" readonly value="{$TMPL['id']}" /><br><br>
{$LNG['a_edit_cat_name']}<br>
<input type="text" name="name" class="Input" value="{$TMPL['name']}" /><br><br>
<input name="submit" class="ButtonNormal" type="submit" value="{$LNG['a_edit_cat_header']}" />
</form>
EndHTML;
}
function process()
{
global $CONF, $DB, $FORM, $LNG, $TMPL;
$TMPL['name'] = $DB->escape($FORM['name']);
$DB->query("UPDATE {$CONF['sql_prefix']}_cat SET name = '{$TMPL['name']}' WHERE id = {$TMPL['id']}", __FILE__, __LINE__);
$TMPL['admin_content'] = $LNG['a_edit_cat_edited'];
}
}
?>