Файл: sources/admin/settings.php
Строк: 463
<?php
if (!defined('VAPHP')) {
die("Этот файл недоступен.");
}
class settings extends base
{
function settings()
{
global $CONF, $DB, $FORM, $LNG, $TMPL;
$TMPL['header'] = $LNG['a_s_header'];
if (!isset($FORM['submit']))
{
$this->form();
}
else
{
$this->process();
}
}
function form()
{
global $CONF, $DB, $LNG, $TMPL;
$languages_menu = '';
$languages = array();
$dir = opendir("{$CONF['path']}/languages/");
while (false !== ($file = readdir($dir)))
{
$file = str_replace('.php', '', $file);
if (is_file("{$CONF['path']}/languages/{$file}.php"))
{
require "{$CONF['path']}/languages/{$file}.php";
$languages[$file] = $translation;
}
}
natcasesort($languages);
foreach ($languages as $file => $translation)
{
if ($file == $CONF['default_language'])
{
$languages_menu .= "<option value="{$file}" selected="selected">{$translation}</option>n";
}
else
{
$languages_menu .= "<option value="{$file}">{$translation}</option>n";
}
}
require "{$CONF['path']}/languages/{$CONF['default_language']}.php";
$skins_menu = '';
$skins = array();
$dir = opendir("{$CONF['path']}/skins/");
while (false !== ($file = readdir($dir)))
{
if ($file != '.' && $file != '..' && is_file("{$CONF['path']}/skins/{$file}/info.php"))
{
require "{$CONF['path']}/skins/{$file}/info.php";
$skins[$file]=$name;
}
}
natcasesort($skins);
foreach ($skins as $file => $skin)
{
if ($file == $CONF['default_skin'])
{
$skins_menu .= "<option value="{$file}" selected="selected">{$skin}</option>n";
}
else
{
$skins_menu .= "<option value="{$file}">{$skin}</option>n";
}
}
if (!$CONF['active_default'])
{
$active_default_menu = "<option value="0" selected="selected">{$LNG['a_s_yes']}</option>n<option value="1">{$LNG['a_s_no']}</option>n";
}
else
{
$active_default_menu = "<option value="0">{$LNG['a_s_yes']}</option>n<option value="1" selected="selected">{$LNG['a_s_no']}</option>n";
}
if ($CONF['email_from_site'])
{
$email_from_site_menu = "<option value="1" selected="selected">{$LNG['a_s_yes']}</option>n<option value="0">{$LNG['a_s_no']}</option>n";
}
else
{
$email_from_site_menu = "<option value="1">{$LNG['a_s_yes']}</option>n<option value="0" selected="selected">{$LNG['a_s_no']}</option>n";
}
if ($CONF['backlink_require'])
{
$backlink_require_menu = "<option value="1" selected="selected">{$LNG['a_s_yes']}</option>n<option value="0">{$LNG['a_s_no']}</option>n";
}
else
{
$backlink_require_menu = "<option value="1">{$LNG['a_s_yes']}</option>n<option value="0" selected="selected">{$LNG['a_s_no']}</option>n";
}
if ($CONF['captcha']) {
$captcha_menu = "<option value="1" selected="selected">{$LNG['a_s_on']}</option>n<option value="0">{$LNG['a_s_off']}</option>n";
}
else {
$captcha_menu = "<option value="1">{$LNG['a_s_on']}</option>n<option value="0" selected="selected">{$LNG['a_s_off']}</option>n";
}
if ($CONF['backlink_check_start']) {
$backlink_check_start = "<option value="1" selected="selected">{$LNG['a_s_on']}</option>n<option value="0">{$LNG['a_s_off']}</option>n";
}
else {
$backlink_check_start = "<option value="1">{$LNG['a_s_on']}</option>n<option value="0" selected="selected">{$LNG['a_s_off']}</option>n";
}
if($CONF['site_sorting_field'] == 'id') {$site_sorting_field_menu = "<option value="id" selected="selected">{$LNG['a_s_sorting_date']}</option>n<option value="num_views">{$LNG['a_s_sorting_num_views']}</option>n";}
else {$site_sorting_field_menu = "<option value="id">{$LNG['a_s_sorting_date']}</option>n<option value="num_views" selected="selected">{$LNG['a_s_sorting_num_views']}</option>n";}
if($CONF['site_sorting'] == 'desc') {$site_sorting_menu = "<option value="desc" selected="selected">{$LNG['a_s_sorting_desc']}</option>n<option value="asc">{$LNG['a_s_sorting_asc']}</option>n";}
else {$site_sorting_menu = "<option value="desc">{$LNG['a_s_sorting_desc']}</option>n<option value="asc" selected="selected">{$LNG['a_s_sorting_asc']}</option>n";}
if($CONF['type_link'] == 'direct') {$type_link_menu = "<option value="direct" selected="selected">{$LNG['a_s_type_link_direct']}</option>n<option value="0">{$LNG['a_s_type_link_redirect']}</option>n";}
else {$type_link_menu = "<option value="direct">{$LNG['a_s_type_link_direct']}</option>n<option value="0" selected="selected">{$LNG['a_s_type_link_redirect']}</option>n";}
if($CONF['find_text']) {$what_find_menu = <<<EndHTML
<input type="radio" name="find_text_radio" value="0" />{$LNG['a_s_find_all_link']}<br>
<input type="radio" name="find_text_radio" value="1" CHECKED/>{$LNG['a_s_find_enter_text']}
<input type="text" name="find_text" class="Input" value='{$CONF['find_text']}' />
EndHTML;
}
else {$what_find_menu = <<<EndHTML
<input type="radio" name="find_text_radio" value="0" CHECKED/>{$LNG['a_s_find_all_link']}<br>
<input type="radio" name="find_text_radio" value="1" />{$LNG['a_s_find_enter_text']}
<input type="text" name="find_text" class="Input"/>
EndHTML;
}
$TMPL['admin_content'] = <<<EndHTML
<form action="index.php?a=admin&b=settings" method="post">
<span class="SeparatorLabel">{$LNG['a_s_general']}</span>
{$LNG['a_s_cat_name']}<br>
<input type="text" name="list_name" class="Input" value="{$CONF['list_name']}" /><br><br>
{$LNG['a_s_default_language']}<br>
<select name="default_language" class="Input">
{$languages_menu}</select><br><br>
{$LNG['a_s_default_skin']}<br>
<select name="default_skin" class="Input">
{$skins_menu}</select><br><br>
{$LNG['a_s_email_from_site']}<br>
<select name="email_from_site" class="Input">
{$email_from_site_menu}</select><br><br>
{$LNG['a_s_your_email']}<br>
<input type="text" name="your_email" class="Input" value="{$CONF['your_email']}" /><br><br>
<span class="SeparatorLabel">{$LNG['a_s_catalog']}</span>
{$LNG['a_s_active_default']}<br>
<select name="active_default" class="Input">
{$active_default_menu}</select><br><br>
{$LNG['a_s_max_name']}<br>
<input type="text" name="max_name" class="Input" value="{$CONF['max_name']}" /><br><br>
{$LNG['a_s_max_descr']}<br>
<input type="text" name="max_descr" class="Input" value="{$CONF['max_descr']}" /><br><br>
{$LNG['a_s_min_descr']}<br>
<input type="text" name="min_descr" class="Input" value="{$CONF['min_descr']}" /><br><br>
{$LNG['a_s_cut_descr']}<br>
<input type="text" name="cut_descr" class="Input" value="{$CONF['cut_descr']}" /><br><br>
{$LNG['a_s_sorting']}<br>
<select name="site_sorting_field" class="Input">
{$site_sorting_field_menu}</select>
<select name="site_sorting" class="Input">
{$site_sorting_menu}</select><br><br>
{$LNG['a_s_type_link']}<br>
<select name="type_link" class="Input">
{$type_link_menu}</select><br><br>
<span class="SeparatorLabel">{$LNG['a_s_backlink']}</span>
{$LNG['a_s_backlink_require']}<br>
<select name="backlink_require" class="Input">
{$backlink_require_menu}</select><br><br>
{$LNG['a_s_backlink_check_start']}<br>
<select name="backlink_check_start" class="Input">
{$backlink_check_start}</select><br><br>
{$LNG['a_s_backlink_check']}<br>
<input type="text" name="backlink_check" class="Input" value="{$CONF['backlink_check']}" /><br><br>
{$LNG['a_s_backlink_view']}<br>
<textarea name="backlink_view" rows="5" class="LongInput">{$CONF['backlink_view']}</textarea><br><br>
{$LNG['a_s_what_find']}<br>
{$what_find_menu}<br><br>
<span class="SeparatorLabel">{$LNG['a_s_security']}</span>
{$LNG['a_s_captcha']}<br>
<select name="captcha" class="Input">
{$captcha_menu}</select><br><br>
{$LNG['a_s_default_psw_captcha']}<br>
<input type="text" name="default_psw_captcha" class="Input" value="{$CONF['default_psw_captcha']}" /><br><br>
<input name="submit" type="submit" class="ButtonNormal" value="{$LNG['a_s_header']}" />
</form>
EndHTML;
}
function process()
{
global $CONF, $DB, $FORM, $LNG, $TMPL;
$list_name = $DB->escape($FORM['list_name']);
$default_language = $DB->escape($FORM['default_language']);
$default_skin = $DB->escape($FORM['default_skin']);
$email_from_site = intval($FORM['email_from_site']);
$your_email = $DB->escape($FORM['your_email']);
$active_default = intval($FORM['active_default']);
$max_name = intval($FORM['max_name']);
if ($max_name < 10) { $max_name = 10; }
$max_descr = intval($FORM['max_descr']);
if ($max_descr < 10) { $max_descr = 10; }
$min_descr = intval($FORM['min_descr']);
if ($min_descr > $max_descr) { $min_descr = $CONF['min_descr']; }
if ($min_descr < 0) { $min_descr = 0; }
$cut_descr = intval($FORM['cut_descr']);
if ($cut_descr < 0 or $cut_descr > $max_descr) { $cut_descr = $max_name; }
$site_sorting_field = $DB->escape($FORM['site_sorting_field']);
$site_sorting = $DB->escape($FORM['site_sorting']);
$type_link = $DB->escape($FORM['type_link']);
$backlink_require = intval($FORM['backlink_require']);
$backlink_check_start = intval($FORM['backlink_check_start']);
$backlink_check = intval($FORM['backlink_check']);
if ($backlink_check < 1) { $backlink_check = 1; }
$backlink_view = $DB->escape($FORM['backlink_view']);
$find_text_radio = intval($FORM['find_text_radio']);
if($find_text_radio) {$find_text = $DB->escape($FORM['find_text']);} else {$find_text = '';}
$captcha = intval($FORM['captcha']);
$default_psw_captcha = $DB->escape($FORM['default_psw_captcha']);
$DB->query("UPDATE {$CONF['sql_prefix']}_settings SET list_name = '{$list_name}', default_language = '{$default_language}', default_skin = '{$default_skin}', email_from_site = '{$email_from_site}', your_email = '{$your_email}',
active_default = '{$active_default}', max_name = '{$max_name}', max_descr = '{$max_descr}', min_descr= '{$min_descr}', cut_descr = '{$cut_descr}', site_sorting_field = '{$site_sorting_field}', site_sorting = '{$site_sorting}', type_link = '{$type_link}',
backlink_require = '{$backlink_require}', backlink_check_start = '{$backlink_check_start}', backlink_check = '{$backlink_check}', backlink_view = '{$backlink_view}', find_text = '{$find_text}',
captcha = '{$captcha}', default_psw_captcha = '{$default_psw_captcha}'
", __FILE__, __LINE__);
$TMPL['admin_content'] = $LNG['a_s_updated'];
}
}
?>