<?php

defined('_IN_JOHNCMS') or die('Error: restricted access');


$mp = new mainpage();

/*
-----------------------------------------------------------------
Блок информации
-----------------------------------------------------------------
*/
if ($user_id) {
echo '<div class="phdr"><b>'.$lng['cup_turn'].'</b></div>';

$r = mysql_query("SELECT * FROM `r_cup` WHERE `status` != 'yes' order by time ASC");
while ($arr = mysql_fetch_array($r))
{
	$b = mysql_query("SELECT * FROM `r_bilet` where id_cup = '" . $arr[id] . "' order by time desc;");
$totalbilet = mysql_num_rows($b);

echo"<table class='menu' width='100%'><tbody>
		<tr>
		<td width='15%' align='center'>
		<img class='image_table' src='/images/cup/b_$arr[id_cup].jpg' alt='CUP' heigth='80' width='80' />
		</td>
		<td width='85%'>
<a href='$home/tournament/cup.php?id=$arr[id]'>";
		if($totalbilet<8){echo'<b style="color: #FF2F2F;">';}else{
	echo"<b>";	
}
		echo''.$arr['name'].'</b></a>
		<div class="sub">
		'.$lng['date'].': <b>'.date("d.m H:i", $arr['time']).' </b><br />
		'.$lng['cup_players'].': <b>'.$totalbilet.'/8</b><br />
                '.$lng['award'].': <b>$'.$arr['priz'].'</b><br />
		</div></td>
		</tr>
		</tbody></table>';
}

}
echo '<div class="phdr"><b>' . $lng['news'] . '</b></div>';
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_news` WHERE `refid`='1'".($rights < 7 ? " AND `time`<='" . time() . "'":"")), 0);
$req = mysql_query("SELECT `id` , `img` , `reads`, `name`, `text`, `time` FROM `cms_news` WHERE `refid`='1'".($rights < 7 ? " AND `time`<='" . time() . "'":"")."
ORDER BY `time` DESC LIMIT $start,$kmess");


if ($total){
$i = 1;
while (($row = mysql_fetch_assoc($req)) !== false) {
echo '<div class="menu"><div style="float:left; width: 45px;">';
if(empty($row['img'])) {
	echo'<img src="'.$home.'/images/empty_news.png" width="40" height="40" alt="MENEJER.CF" class="news_img">';
					   } else {
	echo'<img src="'.$row['img'].'" width="40" height="40" alt="MENEJER.CF" class="news_img">';					   
							  }
echo'</div><div style="margin-left:45px;"> <a href="' . $set['homeurl'] . '/news_' . $row['id'] . '.html"> ' . htmlentities($row['name'], ENT_QUOTES, 'UTF-8') . '</a>
<div style="color:gray"><i class="fa fa-eye"></i> '. $row['reads'] .'&nbsp;&nbsp;<i class="fa fa-comments-o"></i> ' . mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_news_comments` WHERE `refid`='" . $row['id'] . "'"), 0) . '  </div></div>';
echo '<div style="clear:both;"></div>';
echo '</div></div>';
}

if ($total > $kmess) {
echo '<div class="topmenu">' . functions::display_pagination('/index.php?', $start, $total, $kmess) . '</div>';
}
}else{
echo '<div class="menu">'.$lng_news['news_does_not_exist'].'</div>';
}
if ($user_id) {
$winner_cup = mysql_query("SELECT * FROM `r_priz` order by time desc LIMIT 10;");
echo '<div class="phdr">'.$lng['cup_winners'].'</div>';


while ($wc = mysql_fetch_array($winner_cup)) {
$club = mysql_fetch_array(mysql_query("SELECT * FROM `fman_clubs` WHERE `id`='". $wc['win'] ."' LIMIT 1;"));

echo '<div class="menu"><div style="float:left; width: 45px;">';

	echo'<img src="'.$home.'/images/cup/b_'.$wc['id_cup'].'.jpg" width="40" height="40" alt="MENEJER.CF" class="news_img">';

echo'</div><div style="margin-left:45px;"> <a href="' . $set['homeurl'] . ''.$wc['url'].'"> ' . htmlentities($wc['name'], ENT_QUOTES, 'UTF-8') . '</a>&nbsp;&nbsp;<span class="gray" style="font-size: x-small; float:right;">'.functions::display_date($wc['time']).'</span>
<div class="info_user" style="font-size: 15px;"><i class="fa fa-trophy"></i> <a href="'.$home.'/man/club.php?id='.$club['id'].'">'. $club['name'] .'</a>&nbsp;&nbsp;<i class="fa fa-usd" style="font-size:14px;"></i>'.number_format($wc[priz],0,"."," ").'</div></div>';
echo '<div style="clear:both;"></div>';
echo '</div></div>';

}
}
/*
-----------------------------------------------------------------
Блок меню
-----------------------------------------------------------------
*/
echo '<div class="phdr"><b>' . $lng['menu'] . '</b></div>';
echo '<div class="menu"><a href="news/index.php"><i class="fa fa-newspaper-o"></i> ' . $lng['news'] . '</a> (' . $mp->newscount . ')</div>' .

  '<div class="menu"><a href="pages/faq.php">&nbsp;&nbsp;<i class="fa fa-info"></i>&nbsp;&nbsp;' . $lng['information'] . ', FAQ</a></div>'.
  '<div class="menu"><a href="football/index.php"><i class="fa fa-newspaper-o"></i>&nbsp;<b>' . $lng['football_news'] . '</b></a></div>'.
	 '<div class="menu"><a href="/shop/index.php"><i class="fa fa-shopping-basket"></i> ' . $lng['shop'] . '</a></div>'.
	 '<div class="menu"><a href="/man/index.php"><i class="fa fa-futbol-o"></i> <b style="color:red;">' . $lng['fm'] . '</a></b></div>'.
 '<div class="menu"><a href="/bashorat/index.php"><i class="fa fa-futbol-o"></i> <b>' . $lng['bashorat_f'] . '</a></b> (' . counters::bookmaker() . ')</div>'.
	'<div class="menu"><b><a href="/fanclub/index.php"><i class="fa fa-smile-o"></i>  ' . $lng['fanclub'] . '</a></b></div>'.
	'<div class="menu"><b><a href="/games/knb/index.php"><i class="fa fa-hand-peace-o"></i>  ' . $lng['knb'] . '</a></b></div>'.
	'<div class="menu"><a href="/mchat/index.php"><i class="fa fa-comment-o"></i> ' . $lng['mchat'] . '</a> (' . counters::users() . ')</div>';	
// Ссылка на гостевую
if ($set['mod_guest'] || $rights >= 7)
    echo '<div class="menu"><a href="guestbook/index.php"><i class="fa fa-book"></i> ' . $lng['guestbook'] . '</a> (' . counters::guestbook() . ')</div>';
// Ссылка на Форум
if ($set['mod_forum'] || $rights >= 7)
    echo '<div class="menu"><a href="forum/"><i class="fa fa-commenting-o"></i>  ' . $lng['forum'] . '</a> (' . counters::forum() . ')</div>';
if ($user_id || $set['active']) {
	echo'<div class="menu"><a href="users/index.php"><i class="fa fa-users"></i> ' . $lng['users'] . '</a> (' . counters::users() . ')</div>' .
        '<div class="menu"><a href="users/album.php"><i class="fa fa-camera-retro"></i> ' . $lng['photo_albums'] . '</a> (' . counters::album() . ')</div>';
}
echo'<div class="menu"><a href="users/index.php?act=top"><i class="fa fa-bar-chart"></i>' . $lng['users_top'] . '</a></div>';

include ('lider/main.php');
$lastuser = mysql_query("select * from `users` where `id` > 0 order by `id` DESC limit 2");
echo '<div class="phdr"><b>'.$lng['last_users_2'].'</b></div>';
while($fl=mysql_fetch_array ($lastuser)){
echo '<div class="menu"><a href="users/profile.php?user='. $fl['id'].'"><i class="fa fa-user-o"></i>  '.$fl['name'].'</a></div>';
}
?>