Файл: sources/admin/edit_ban.php
Строк: 109
<?php
if (!defined('VAPHP')) {
die("Этот файл недоступен.");
}
class edit_ban extends base {
function edit_ban() {
global $CONF, $DB, $FORM, $LNG, $TMPL;
$TMPL['header'] = $LNG['a_edit_ban_header'];
$id = intval($FORM['id']);
list($TMPL['id']) = $DB->fetch("SELECT id FROM {$CONF['sql_prefix']}_ban WHERE id = {$id}", __FILE__, __LINE__);
if ($TMPL['id']) {
if (!isset($FORM['submit'])) {
$this->form();
}
else {
$this->process();
}
}
else {
$this->error($LNG['a_del_ban_invalid_id'], 'admin');
}
}
function form() {
global $CONF, $DB, $LNG, $TMPL;
list($TMPL['string'], $TMPL['field'], $TMPL['matching']) = $DB->fetch("SELECT string, field, matching FROM {$CONF['sql_prefix']}_ban WHERE id = {$TMPL['id']}", __FILE__, __LINE__);
if ($TMPL['matching']) {
$matching_menu = "<option value="1" selected="selected">{$LNG['a_man_bad_words_exact']}</option>n<option value="0">{$LNG['a_man_bad_words_global']}</option>n";
}
else {
$matching_menu = "<option value="1">{$LNG['a_man_bad_words_exact']}</option>n<option value="0" selected="selected">{$LNG['a_man_bad_words_global']}</option>n";
}
if ($TMPL['field']=='url') {$field_menu.="<option value="url" selected="selected">{$LNG['g_short_url']}</option>";} else {$field_menu.="<option value="url">{$LNG['g_short_url']}</option>";}
if ($TMPL['field']=='email') {$field_menu.="<option value="email" selected="selected">{$LNG['g_email']}</option>";} else {$field_menu.="<option value="email">{$LNG['g_email']}</option>";}
if ($TMPL['field']=='ip') {$field_menu.="<option value="ip" selected="selected">{$LNG['g_ip']}</option>";} else {$field_menu.="<option value="ip">{$LNG['g_ip']}</option>";}
$TMPL['admin_content'] = <<<EndHTML
<form action="{$TMPL['site_url']}/index.php?a=admin&b=edit_ban&id={$TMPL['id']}" method="post">
{$LNG['a_man_ban_string']}<br>
<input type="text" name="string" class="Input" value="{$TMPL['string']}" /><br><br>
{$LNG['a_man_ban_field']}<br>
<select name="field" class="Input">
$field_menu</select><br><br>
{$LNG['a_man_ban_matching']}<br>
<select name="matching" class="Input">
{$matching_menu}</select><br><br>
<input name="submit" type="submit" class="ButtonNormal" value="{$LNG['a_edit_ban_header']}" />
</form>
EndHTML;
}
function process() {
global $CONF, $DB, $FORM, $LNG, $TMPL;
$TMPL['string'] = $DB->escape($FORM['string']);
$TMPL['field'] = $DB->escape($FORM['field']);
$TMPL['matching'] = intval($FORM['matching']);
$DB->query("UPDATE {$CONF['sql_prefix']}_ban SET string = '{$TMPL['string']}', field = '{$TMPL['field']}', matching = {$TMPL['matching']} WHERE id = {$TMPL['id']}", __FILE__, __LINE__);
$TMPL['admin_content'] = $LNG['a_edit_ban_edited'];
}
}
?>