EngineGP/system/engine/megp/news.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

40 lines
1.4 KiB
PHP

<?php
if (!DEFINED('EGP'))
exit(header('Refresh: 0; URL=http://' . $_SERVER['HTTP_HOST'] . '/404'));
if ($id) {
$sql->query('SELECT `id`, `name`, `full_text`, `views`, `tags`, `date` FROM `news` WHERE `id`="' . $id . '" LIMIT 1');
if (!$sql->num())
include(ENG . '404.php');
$news = $sql->get();
$title = $news['name'];
$sql->query('UPDATE `news` set `views`="' . ($news['views'] + 1) . '" WHERE `id`="' . $id . '" LIMIT 1');
$html->get('news', 'sections/news');
$html->set('id', $news['id']);
$html->set('name', htmlspecialchars_decode($news['name']));
$html->set('text', htmlspecialchars_decode($news['full_text']));
$html->set('date', sys::today($news['date']));
$html->pack('main');
} else {
$title = 'Последние новости';
$sql->query('SELECT `id`, `name`, `text`, `views`, `tags`, `date` FROM `news` ORDER BY `id` DESC LIMIT 5');
while ($news = $sql->get()) {
$html->get('list', 'sections/news');
$html->set('id', $news['id']);
$html->set('name', htmlspecialchars_decode($news['name']));
$html->set('text', htmlspecialchars_decode($news['text']));
$html->set('date', sys::today($news['date']));
$html->pack('news');
}
$html->get('index', 'sections/news');
$html->set('list', isset($html->arr['news']) ? $html->arr['news'] : '');
$html->pack('main');
}
?>