<?php

 defined('_IN_JOHNCMS') or die('Error: restricted access');
$count_us = mysql_result(mysql_query("select count(`id`) from `lider` where `time` >= '".time()."' and `user_id` = '".$user_id."'"),0);

$count = mysql_result(mysql_query("select count(*) from `lider` where `time` >= '".time()."'"),0);
		echo '<div class="phdr"><a href="lider/index.php" style="color: #fff;">'.$lng['day_lider'].'</a> ' .($count_us ? '' : '| <a href="lider/index.php?act=get" style="color: #fff;"><small>'.$lng['get_lider'].'</small></a>' ) . '</div>';	
if	($count	> 0) {
	
echo '<div class="menu">';
			$sets1 = explode('|', file_get_contents('lider/sets.dat'));
			$req = mysql_query("select * from `lider` where `time` >= '".time()."' order by rand() limit 1");
			$res = mysql_fetch_array($req);
			$us = mysql_fetch_array(mysql_query("SELECT `name`, `live`, `yearofbirth`, `dayb`, `monthb` FROM `users` WHERE `id` = '" . $res['user_id'] . "' LIMIT 1"));
			echo '<table><tr>';
			if ($sets1[1]) {
					if (file_exists('files/users/photo/' . $res['user_id'] . '_small.jpg')) 
						echo '<td><img src="../files/users/photo/' . $res['user_id'] . '_small.jpg"  border="0" width="32" height="32"/></td>';
					else 
						echo '<td><img src="/images/empty.png" border="0" width="32"  height="32"/></td>';
					
				}
			echo '<td><img src="/images/user.png" style="vertical-align: middle;" border="0"/> <a href ="../users/profile.php?user='.$res['user_id'].'">' . functions::checkout($us['name']). '</a>';
			if ($sets1[2]) {
						if (!$us['yearofbirth'] or !$us['monthb'] or !$us['dayb']) 
							$a = 0;
						else {
							$r = mktime(0, 0, 0, $us['monthb'], $us['dayb'], $us['yearofbirth']);  
							$age = (time()-$r)/31536000; 
							list($a) = explode(".",$age);   
						}
						echo '<span style="font-size:14px;"> , '.$a.' '.$lng['let'].', '.$us['live'].'</span>';
			}
			$text = html_entity_decode($res['text']);
echo '<br><img src="/images/talk.gif" style="vertical-align: middle;" border="0"/> <i>'.$text.'</i>' ;
			echo '</td></tr></table>';			
		} 
		else echo '<div class="menu">'.$lng['not_liders'].'</div>';
echo '</div>';