EngineGP/system/sections/user/lk/settings.php
Sergei Solovev 276ec7f3eb Updating the server name reference in code
This change replaces the use of $_SERVER['SERVER_NAME'] with $_SERVER['HTTP_HOST'] throughout the codebase. The modification ensures consistency and compliance with best practices, since $_SERVER['HTTP_HOST'] is often used to extract the host header from an HTTP request. This update may improve compatibility and security, especially in scenarios where the Host header plays a key role in proper server configuration and routing. Please review and test the changes carefully to ensure smooth functionality in different environments.
2023-12-23 04:50:14 +03:00

59 lines
2 KiB
PHP

<?php
if (!DEFINED('EGP'))
exit(header('Refresh: 0; URL=http://' . $_SERVER['HTTP_HOST'] . '/404'));
$sql->query('SELECT `notice_news`, `notice_help` FROM `users` WHERE `id`="' . $user['id'] . '" LIMIT 1');
$user = array_merge($user, $sql->get());
if (isset($url['action']) and in_array($url['action'], array('upload', 'news', 'help', 'important'))) {
switch ($url['action']) {
case 'upload':
$file = isset($_POST['value']) ? $_POST['value'] : exit;
$name = isset($_POST['name']) ? $_POST['name'] : exit;
$pname = explode('.', $name);
$type = strtolower(end($pname));
if (!in_array($type, array('png', 'gif', 'jpg', 'bmp')))
exit('Допустимый формат изображений: png, gif, jpg, bmp.');
$aData = explode(',', $file);
if (file_put_contents(ROOT . 'upload/avatars/' . $user['id'] . '.' . $type, base64_decode(str_replace(' ', '+', $aData[1]))))
exit($user['id'] . ':ok');
exit('Ошибка загрузки: убедитесь, что изображение не повреждено и имеет правильный формат.');
case 'news':
$notice = $user['notice_news'] ? 0 : 1;
$sql->query('UPDATE `users` set `notice_news`="' . $notice . '" WHERE `id`="' . $user['id'] . '" LIMIT 1');
sys::outjs(array('s' => 'ok'));
case 'help':
$notice = $user['notice_help'] ? 0 : 1;
$sql->query('UPDATE `users` set `notice_help`="' . $notice . '" WHERE `id`="' . $user['id'] . '" LIMIT 1');
sys::outjs(array('s' => 'ok'));
}
}
$html->get('settings', 'sections/user/lk');
$html->set('id', $user['id']);
$html->set('ava', users::ava($user['id']));
if ($user['notice_news'])
$html->unit('notice_news', true);
else
$html->unit('notice_news');
if ($user['notice_help'])
$html->unit('notice_help', true);
else
$html->unit('notice_help');
$html->pack('main');
?>