Файл: sources/admin/edit_bad_word.php
Строк: 80
<?php
if (!defined('VAPHP')) {
die("Этот файл недоступен.");
}
class edit_bad_word extends base {
function edit_bad_word() {
global $CONF, $DB, $FORM, $LNG, $TMPL;
$TMPL['header'] = $LNG['a_edit_bad_word_header'];
$id = intval($FORM['id']);
list($TMPL['id']) = $DB->fetch("SELECT id FROM {$CONF['sql_prefix']}_bad_words WHERE id = {$id}", __FILE__, __LINE__);
if ($TMPL['id']) {
if (!isset($FORM['submit'])) {
$this->form();
}
else {
$this->process();
}
}
else {
$this->error($LNG['a_del_bad_word_invalid_id'], 'admin');
}
}
function form() {
global $CONF, $DB, $LNG, $TMPL;
list($TMPL['word'], $TMPL['replacement'], $TMPL['matching']) = $DB->fetch("SELECT word, replacement, matching FROM {$CONF['sql_prefix']}_bad_words 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";
}
$TMPL['admin_content'] = <<<EndHTML
<form action="{$TMPL['site_url']}/index.php?a=admin&b=edit_bad_word&id={$TMPL['id']}" method="post">
<span class="SeparatorLabel">{$LNG['a_edit_bad_word_header']}</span>
{$LNG['a_man_bad_words_word']}<br>
<input type="text" name="word" class="Input" value="{$TMPL['word']}" /><br><br>
{$LNG['a_man_bad_words_replacement']}<br>
<input type="text" name="replacement" class="Input" value="{$TMPL['replacement']}" /><br><br>
{$LNG['a_man_bad_words_matching']}<br>
<select name="matching" class="Input">
{$matching_menu}</select><br><br>
<input name="submit" class="ButtonNormal" type="submit" value="{$LNG['a_edit_bad_word_header']}" />
</form>
EndHTML;
}
function process() {
global $CONF, $DB, $FORM, $LNG, $TMPL;
$TMPL['word'] = $DB->escape($FORM['word']);
$TMPL['replacement'] = $DB->escape($FORM['replacement']);
$TMPL['matching'] = intval($FORM['matching']);
$DB->query("UPDATE {$CONF['sql_prefix']}_bad_words SET word = '{$TMPL['word']}', replacement = '{$TMPL['replacement']}', matching = {$TMPL['matching']} WHERE id = {$TMPL['id']}", __FILE__, __LINE__);
$TMPL['admin_content'] = $LNG['a_edit_bad_word_edited'];
}
}
?>