Файл: modules/user/settings.php
Строк: 143
<?php
/****
* @package LiveCMS
* @link livecms.org
* @author MyZik
* @version See attached file VERSION.txt
* @license See attached file LICENSE.txt
* @copyright Copyright (C) LiveCMS Development Team
****/
$lang_uset = load_lng('user_settings'); // Подключаем файл языка
$lang_pe = load_lng('profile_edit');
$title = $lang_uset['edit_settings']; // Заголовок страницы
$module = 'set_user'; // Модуль
// проверка наличия авторизации
if (!isset($user)) {
require_once(HOME .'/incfiles/header.php');
echo '<div class="error">' . $lang['only_users'] . '</div>';
echo '<div class="home">' .
'<img src="/design/themes/' . $set_user['theme'] . '/images/back.png" alt="" /> <a href="/index.php">' . $lang['back'] . '</a>' .
'</div>';
require_once(HOME .'/incfiles/footer.php');
}
if (isset($_GET['id'])) {
$ID = intval($_GET['id']);
} else {
$ID = $user['id'];
}
$profile = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $ID . "'"));
$setUser = mysql_fetch_assoc(mysql_query("SELECT * FROM `user_settings` WHERE `user_id` = '" . $ID . "'"));
if (($ID != $user['id']) && ($user['rights'] < 8) || ($user['rights'] >= 8 && $user['rights'] < $profile['rights'])) {
require_once(HOME .'/incfiles/header.php');
echo '<div class="error">' . $lang_uset['error_rights'] . '</div>';
require_once(HOME .'/incfiles/footer.php');
}
if (isset($_GET['id']) && !is_numeric($_GET['id'])) {
require_once(HOME .'/incfiles/header.php');
echo '<div class="error">' . $lang['error_parameter'] . '</div>';
require_once(HOME .'/incfiles/footer.php');
}
require_once(HOME .'/incfiles/header.php'); // Подключаем шапку
/**
* Небольшая панель навигации
**/
echo '<div class="title"><a href="edit.php' . ($ID != $user['id'] ? '&id=' . $ID . '' : '') . '">' . $lang_pe['edit_profile'] . ($ID != $user['id'] ? ' "' . $profile['login'] . '"' : '') . '</a> | <b>' . $lang_pe['settings'] . '</b></div>';
if (isset($_POST['save'])) {
$setUser['show_avatars'] = isset($_POST['show_avatars']) && $_POST['show_avatars'] == 'no' ? 'no' : 'yes';
$setUser['language'] = isset($_POST['language']) ? input($_POST['language']) : $cms_set['language'];
$setUser['sex_view'] = isset($_POST['sex_view']) && $_POST['sex_view'] == 'text' ? 'text' : 'icons';
$setUser['num_pages'] = isset($_POST['num_pages']) ? intval($_POST['num_pages']) : 10;
$setUser['theme'] = isset($_POST['theme']) ? txt($_POST['theme']) : 'default';
$arr = array();
$dir = opendir(HOME . '/design/themes');
while ($oTheme = readdir($dir)) {
if (($oTheme != '.') && ($oTheme != '..') && ($oTheme != '.svn'))
$arr[] = str_replace('.css', '', $oTheme);
}
closedir($dir);
if (!in_array($setUser['theme'], $arr))
$setUser['theme'] = 'default';
mysql_query("UPDATE `user_settings` SET
`language` = '" . $setUser['language'] . "',
`num_pages` = '" . $setUser['num_pages'] . "',
`sex_view` = '" . $setUser['sex_view'] . "',
`show_avatars` = '" . $setUser['show_avatars'] . "',
`theme` = '" . $setUser['theme'] . "' WHERE `user_id` = '" . $ID . "'");
echo display_message($lang_uset['edit_success']);
}
/**
* Форма
**/
echo '<div class="main"><form action="settings.php' . ($ID != $user['id'] ? "?id=" . $ID . "" : "") . '" method="post">' .
$lang_uset['show_avatars'] . '<br />' .
'<input type="radio" name="show_avatars" value="yes" ' . ($setUser['show_avatars'] == 'yes' ? 'checked="checked"' : '') . ' /> ' . $lang_uset['show_avatars_yes'] .
' <input type="radio" name="show_avatars" value="no" ' . ($setUser['show_avatars'] == 'no' ? 'checked="checked"' : '') . ' /> ' . $lang_uset['show_avatars_no'] . '<br />' .
$lang_uset['sex_view'] . '<br />' .
'<input type="radio" name="sex_view" value="icons" ' . ($setUser['sex_view'] == 'icons' ? 'checked="checked"' : '') . ' /> ' . $lang_uset['sex_view_icons'] .
' <input type="radio" name="sex_view" value="text" ' . ($setUser['sex_view'] == 'text' ? 'checked="checked"' : '') . ' /> ' . $lang_uset['sex_view_text'] . '<br />' .
$lang_uset['num_pages'] . '<br />' .
'<input type="text" name="num_pages" value="' . $setUser['num_pages'] . '" /><br />' .
$lang_uset['theme_skin'] . '<br />' .
'<select name="theme">';
$dir = opendir(HOME . '/design/themes');
while ($oTheme = readdir($dir)) {
if (($oTheme != '.') && ($oTheme != '..') && ($oTheme != '.svn')) {
$oTheme = str_replace('.css', '', $oTheme);
echo '<option' . ($setUser['theme'] == $oTheme ? ' selected="selected">' : '>') . '<img src="/design/icons/cabinet/new_journal.png" alt="" /> ' .$oTheme . '</option>';
}
}
closedir($dir);
echo '</select><br />';
echo $lang['select_language'] . ':<br />';
$Dir = opendir(HOME . '/incfiles/languages');
while ($oLang = readdir($Dir)) {
if (($oLang != '.') && ($oLang != '..') && ($oLang != '.svn')) {
$oLang = str_replace('_core.lng', '', $oLang);
echo '<input type="radio" name="language" value="' . $oLang . '"' . ($setUser['language'] == $oLang ? ' checked="checked"' : '') . ' /> <img src="/design/icons/languages/' . $oLang . '.png" alt="' . $oLang . '" /> ' . $oLang . '<br />';
}
}
closedir($Dir);
echo '<input type="submit" name="save" value="' . $lang['save'] . '" /></form></div>';
require_once(HOME .'/incfiles/footer.php'); // Подключаем ноги
?>