<?php

 defined('_IN_JOHNCMS') or die('Error: restricted access');
if (empty($id)) {
    $textl = 'lider';
} else {
    $req = mysql_query("SELECT `text` FROM `lider` WHERE `id`= '" . $id . "'");
    $res = mysql_fetch_assoc($req);
    $hdr = strtr($res['text'], array(
        '&laquo;' => '',
        '&raquo;' => '',
        '&quot;'  => '',
        '&amp;'   => '',
        '&lt;'    => '',
        '&gt;'    => '',
        '&#039;'  => ''
    ));
    $hdr = mb_substr($hdr, 0, 30);
    $hdr = functions::checkout($hdr);
    $textl = mb_strlen($res['text']) > 30 ? $hdr . '...' : $hdr;
}
$count_us = mysql_result(mysql_query("select count(`id`) from `lider` where `time` >= '".time()."' and `user_id` = '".$user_id."'"),0);
echo '<div class="phdr" align="center"><b><a href="lider/index.html">Kun anketasi</a>('.$count_us.')';
if ($user_id) {
echo '' .($count_us ? '' :'&#160;|<a href="lider/index.html?act=get"><small>Kun anketasi bo\'lish</small></a>' ) . '';
}
echo '</b></div><div class="menu">';
$count = mysql_result(mysql_query("select count(*) from `lider` where `time` >= '".time()."'"),0);
			
if	($count	> 0) {
			$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`, `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'] . '.jpg'))
echo '<td><img src="../files/users/photo/' . $res['user_id'] . '.jpg"  border="0" width="60"/></td>';
					else 
echo '<td><img src="lider/no_photo.jpg" border="0" width="60"/></td>';

					
				}

echo '<td><img src="lider/users.png"> Nik:<a href ="../users/profile.html?user='.$res['user_id'].'"><b>' . $us['name'] . '</b></a><br/>';
			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 '<img src="lider/age.png"> Yoshi: '.$a;
			}
echo '<br /><img src="lider/text.png"> Matn: <i><b>' . $res['text'] .' </b></i>' ;
if($user_id){
echo '<td><a href="/mail/index.html?act=write&amp;id='.$res['user_id'].'"><img src="lider/sms.png"/></a>';
}
echo '</td></tr></table></div>';
}
else echo 'Kun liderlari yo\'q';
echo '</div>';