Файл: modules/user/status.php
Строк: 46
<?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_pe = load_lng('profile_edit'); // Подключаем файл языка
$title = $lang_pe['status']; // Заголовок страницы
$module = 'edit'; // Модуль
  /**
    * Проверка наличия авторизации
  **/
  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 . "'")); // получаем данные пользователя
  /**
    * Если пытаемся редактировать чужой профиль, проверяем права доступа
  **/
  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_pe['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['status'] . '</b></div>';
  /**
    * Сохраняем данные
  **/
  if (isset($_POST['save'])) {
    $profile['status'] = txt(mb_substr($_POST['status'], 0, 50));
    mysql_query("UPDATE `users` SET `status` = '" . $profile['status'] . "' WHERE `id` = '$ID' LIMIT 1");
    echo display_message($lang_pe['status_edit_success']);
  }
  /**
    * Форма
  **/
  echo '<div class="main"><form method="post" action="status.php' . ($ID != $user['id'] ? '?id=' . $ID : '') . '">' .
  $lang_pe['status_text'] . ':<br />' .
  '<input type="text" name="status" value="' . $profile['status'] . '" /><br />' .
  '<input type="submit" name="save" value="' . $lang['save'] . '" />' .
  '</form></div>';
  require_once(HOME .'/incfiles/footer.php'); // Подключаем ноги
?>