<?

/**
 * @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('Error: restricted access');

$mp = new mainpage();



//echo '<div class="phdr"><b>' . $lng['information'] . '</b></div>';

echo '<div class="phdr"><a href="news/index.php">Новости</a><span style="float:right;">' . $mp->newscount . '</div>';
echo '<div class="newss">' .  $mp->news . ' </div>';
?>
<br>
<?
/*
-----------------------------------------------------------------
Блок общения
-----------------------------------------------------------------
*/
// Ссылка на гостевую
if ($set['mod_guest'] || $rights >= 7)
 echo '<div class="menu"><a href="guestbook/index.php">' . $lng['guestbook'] . '</a><span style="float:right;"> ' . counters::guestbook (). '</span></div>';
?>
<br>
<?
// Ссылка на Форум
if (!$forum){
        $topics = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topics` "), 0);
        $posts = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_posts` "), 0);
}else{  
}    
if ($set['mod_forum'] || $rights >= 7)
    echo '<div class="razd phdr"><a href="forum/">' . $lng['forum'] . '</a> <span style="float:right;">'.$topics.' / '.$posts.  '</span></div>';
      
/*
-----------------------------------------------------------------
Последние темы на форуме
-----------------------------------------------------------------
*/
require_once 'forum/includes/functoins.php';

$op = mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_settings` WHERE `key` = 'toppl' LIMIT 1"));
 
$limit = $op['val']; // Сколько тем выводить
$tim = time();
$topicQuery2 = mysql_query("SELECT * FROM `forum_topics` WHERE `timetop` > '$tim' ORDER BY `time` DESC LIMIT $limit ");

while ($topicRes2 = mysql_fetch_assoc($topicQuery2)){
  echo '<div class="menu">';$sub = ' <i class="fa fa-user" aria-hidden="true"></i> '.$topicRes2['user'];
  if ($topicRes2['count'] > 1){
    $lastPost = explode(':|:', $topicRes2['lastpost']);
    $sub .= ' / '.$lastPost[0];
  }
  echo ''.show_topic2($topicRes2, $sub.' <i class="fa fa-clock-o" aria-hidden="true"></i> '.functions::display_date($topicRes2['time']).' <span class="badge">топ</span><br />').'';  
echo '</div>';}

$tim = time();
$limit = 20; // Сколько тем выводить
$topicQuery = mysql_query("SELECT * FROM `forum_topics` WHERE `timetop` < '$tim'  ORDER BY `time` DESC LIMIT $limit ");

while ($topicRes = mysql_fetch_assoc($topicQuery)){
  echo '<div class="menu">';$sub = ' <i class="fa fa-user" aria-hidden="true"></i> '.$topicRes['user'];
  if ($topicRes['count'] > 1){
    $lastPost = explode(':|:', $topicRes['lastpost']);
    $sub .= ' / '.$lastPost[0];
  }
  echo ''.show_topic2($topicRes, $sub.' <i class="fa fa-clock-o" aria-hidden="true"></i> '.functions::display_date($topicRes['time']).'<br />').'';  
echo '</div>';}


$total=mysql_result(mysql_query('SELECT COUNT(*) FROM `dnevniki` WHERE `views` > "0" and `dnid` = "txt" ;'), 0);
echo '<br /><div class="phdr"><a href="/blogs">Новое в блогах</a> </div>';
if($total > 0)
{
   $res1 = mysql_query('SELECT * FROM `dnevniki` WHERE `dnid` = "txt" ORDER BY `id` DESC LIMIT 5');
   $i=1;
   while($res = mysql_fetch_array($res1))
   {
      echo ($i % 2) ? '<div class="menu">' : '<div class="menu">';
      echo '<a href="/blogs?act=view&amp;id='.$res['id'].'"> '.htmlentities($res['zag'], ENT_QUOTES, 'UTF-8').'</a><br />';
         $cont = mysql_result(mysql_query("SELECT COUNT(*) FROM `dnevniki` WHERE `dnid` = 'com' AND `com_id` = '".$res['id']."'"), 0);

      echo '<i class="fa fa-user"></i> '.$res['username'].' <i class="fa fa-clock-o"></i> '.date("d.m.y / H:i", $res['vr']).'  <i class="fa fa-eye" aria-hidden="true"></i> '.$res['views'].' <i class="fa fa-comments" aria-hidden="true"></i> '.$cont.'</div>';
      echo '';
      $i++;
   }} 

?>

 



