Файл: public_html/element_ank_edit.php
Строк: 96
<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
$title = 'Изменение анкеты';
if (readcache('element_user_mesto'.$user['lost_id']) != $title) writecache('element_user_mesto'.$user['lost_id'], $title);
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
?>
<div class="nfl p5 mt5 mb5 mlra">
<div class="cntr small mb5">
<?php
if (empty($user['city']))
{
$user['city'] = 'Не указано';
}
if (empty($user['about']))
{
$user['city'] = 'Не указано';
}
if (empty($user['firstname']))
{
$user['firstname'] = 'Не указано';
}
if (empty($user['lastname']))
{
$user['lastname'] = 'Не указано';
}
if (empty($user['old']))
{
$user['old'] = '0';
}
if( $user['lost_privilege'] == 1)
{ $status = ', <b>Модератор</b>'; }
if( $user['lost_privilege'] == 2)
{ $status = ', <b>Полу-администратор</b>'; }
if( $user['lost_privilege'] == 3)
{ $status = ', <b>Администратор</b>'; }
echo ikonka_user($user['lost_race'], 'online').' <span class="yellow1 bold">'.$user['lost_login'].''.$status.'</span><br/>';
echo ($user['lost_town'] > 0) ? '<span class="yellow1"><img src="/images/town/race_'.$user_town['lost_race'].'.png" alt=""/> <a class="yellow1 bold" href="/town?id='.$user_town['lost_id'].'">'.$user_town['lost_name'].'</a>, '.town_users_zvanie($town_other[0]).'</span><br/>' : '';
echo '<span class="yellow1">'.$name_race[$user['lost_race']].', <span class="bold">'.$user['lost_level'].'</span> уровень</span>';
echo'</div>';
if (isset($_POST['firstname'], $_POST['lastname'], $_POST['city']))
{
$update = array();
if (strlen($_POST['firstname']) > 2)
{
$update['firstname'] = htmlspecialchars(trim($_POST['firstname']));
}
if (strlen($_POST['lastname']) > 2)
{
$update['lastname'] = htmlspecialchars(trim($_POST['lastname']));
}
if (isset($_POST['old']) && is_numeric($_POST['old']) && $_POST['old'] > 0)
{
$update['old'] = htmlspecialchars(trim($_POST['old']));
}
if (strlen($_POST['city']) > 1)
{
$update['city'] = htmlspecialchars(trim($_POST['city']));
}
if (strlen($_POST['about']) > 3)
{
$update['about'] = htmlspecialchars(trim($_POST['about']));
}
if (sizeof($update))
{
$sql = 'UPDATE `element_user` SET ';
foreach ($update as $key => $value)
{
$sql .= "`{$key}`='".mysql_real_escape_string($value)."',";
}
mysql_query(rtrim($sql, ',')." WHERE `lost_id`='{$user['lost_id']}' LIMIT 1");
writecache('element_users_id_'.$user['lost_id'], array_merge($user, $update));
}
header("Location: ?");
die;
}
?>
<div class="hr"></div>
<div class="mt5 small">
<form method="POST">
<span class="white">Имя: </span><br/><input type="text" name="firstname" value="<?= $user['firstname']; ?>" /> <br/>
<span class="white">Фамилия: </span><br/><input type="text" name="lastname" value="<?= $user['lastname']; ?>" /> <br/>
<span class="white">Возраст: </span><br/><input type="text" name="old" value="<?= $user['old']; ?>" /> <br/>
<span class="white">Город: </span><br/><input type="text" name="city" value="<?= $user['city']; ?>" /> <br/>
<span class="white">О себе: </span><br/><input type="text" name="about" value="<?= $user['about']; ?>" /> <br/>
<br/> <input type="submit" value="Сохранить" />
</form><br/>
<div class="ml5 mr5">
<a class="bl p5 block odd" href="/user">
<span class="small yellow1"><img src="/images/icons/1.gif"> Назад</span>
</a>
</div>
</div>
</div>
<?php
require_once './element_include/element_foot_user_true.php';
?>