| Server IP : 103.82.32.14 / Your IP : 216.73.217.121 Web Server : Apache/2.2.32 (Unix) mod_ssl/2.2.32 OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 System : Linux cloud.lonmanhoabinh.com 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : lonmakmf ( 524) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /home/forumhet/public_html/incfiles/classes/ |
Upload File : |
<?php
/**
* @package JohnCMS
* @link http://johncms.com
* @copyright Copyright (C) 2008-2011 JohnCMS Community
* @license LICENSE.txt (see attached file)
* @version VERSION.txt (see attached file)
* @author http://johncms.com/about
*/
defined('_IN_JOHNCMS') or die('Restricted access');
class mainpage {
public $news; // Текст новостей
public $newscount; // Общее к-во новостей
public $lastnewsdate; // Дата последней новости
private $settings = array ();
function __construct() {
global $set;
$this->settings = unserialize($set['news']);
$this->newscount = $this->newscount() . $this->lastnewscount();
$this->news = $this->news();
}
// Запрос свежих новостей на Главную
private function news() {
global $lng;
if ($this->settings['view'] > 0) {
$reqtime = $this->settings['days'] ? time() - ($this->settings['days'] * 86400) : 0;
$req = mysql_query("SELECT * FROM `news` WHERE `time` > '$reqtime' ORDER BY `time` DESC LIMIT " . $this->settings['quantity']);
if (mysql_num_rows($req) > 0) {
$i = 0;
$news = '';
while (($res = mysql_fetch_array($req)) !== false) {
$text = $res['text'];
// Если текст больше заданного предела, обрезаем
if (mb_strlen($text) > $this->settings['size']) {
$text = mb_substr($text, 0, $this->settings['size']);
$text = htmlentities($text, ENT_QUOTES, 'UTF-8');
$text .= ' <a href="news/index.php">' . $lng['next'] . '...</a>';
} else {
$text = htmlentities($text, ENT_QUOTES, 'UTF-8');
}
// Если включены переносы, то обрабатываем
if ($this->settings['breaks'])
$text = str_replace("\r\n", "<br/>", $text);
// Обрабатываем тэги
if ($this->settings['tags']) {
$text = bbcode::tags($text);
} else {
$text = bbcode::notags($text);
}
// Обрабатываем смайлы
if ($this->settings['smileys']) {
$text = functions::smileys($text);
}
// Определяем режим просмотра заголовка - текста
$news .= '<div class="news">';
switch ($this->settings['view']) {
case 2:
$news .= '<a href="news/index.php">' . $res['name'] . '</a>';
break;
case 3:
$news .= $text;
break;
default :
$news .= '<b>' . $res['name'] . '</b><br />' . $text;
}
// Ссылка на каменты
if (!empty($res['kom']) && $this->settings['view'] != 2 && $this->settings['kom'] == 1) {
$mes = mysql_query("SELECT COUNT(*) FROM `forum` WHERE `type` = 'm' AND `refid` = '" . $res['kom'] . "'");
$komm = mysql_result($mes, 0) - 1;
if ($komm >= 0) {
$s_kom = mysql_query("SELECT * FROM `forum` WHERE `id` = '$res[kom]'");
$s_kom1 = mysql_fetch_assoc($s_kom);
$news .= '<br /><a href="/forum/' . $res['kom'] . '/' . $s_kom1['seo'] . '.html">' . $lng['discuss'] . '</a> (' . $komm . ')';
}
}
$news .= '</div>';
++$i;
}
return $news;
} else {
return false;
}
}
}
// Счетчик всех новостей
private function newscount() {
$req = mysql_query("SELECT COUNT(*) FROM `news`");
$res = mysql_result($req, 0);
return ($res > 0 ? $res : '0');
}
// Счетчик свежих новостей
private function lastnewscount() {
$req = mysql_query("SELECT COUNT(*) FROM `news` WHERE `time` > '" . (time() - 259200) . "'");
$res = mysql_result($req, 0);
return ($res > 0 ? '/<span class="red">+' . $res . '</span>' : false);
}
}