View file wip-site-portal/src/forum_online.php

File size: 1.99Kb
<?
require('ini.php');
$link=connect();

$user=login('nick, loc, forum_tlim', 'forums', true);

if($user) $sess = 'sid='.$sid.'&amp;';
else $sess = false;

@$fid = intval($_GET['fid']);

head('Кто онлайн : форум');
echo '<small>';

if(!$fid){
	$on_forums = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `wip_users` WHERE `loc` LIKE '%forum\_%' AND `forum_online`>'".(time()-300)."';"), 0);

	if($on_forums<1) echo '<b>На форумах никого нет</b><br/>';
	
	else {
	
		$select = mysql_query("SELECT `id`, `name` FROM `wip_forum_forums` WHERE `group`=0 ORDER BY `pos`");
	
		while($res = mysql_fetch_assoc($select)){
			
			$q = mysql_query("SELECT `nick` FROM `wip_users` WHERE `loc`='forum_".$res['id']."' AND `forum_online`>'".(time()-300)."' ;");
			$on = mysql_affected_rows();
				
			if($on>0){
				echo '<a href="forum_topics.php?'.$sess.'fid='.$res['id'].'">'.$res['name'].'</a> ['.$on.']<br/>';
				
				while($users = mysql_fetch_row($q)) echo $users[0].', ';
				echo '<br/>';
			}
		}
	}
}

else {
	
	$forum = mysql_result(mysql_query("SELECT `name` FROM `wip_forum_forums` WHERE `id`='".$fid."'"), 0);
	
	if(mysql_affected_rows()<1){
		echo '<b>Неверный форум</b><br/>';
	}

	else {
		$select = mysql_query("SELECT `nick` FROM `wip_users` WHERE `loc`='forum_".$fid."' AND `forum_online`>'".(time()-300)."';");
		$on_c = mysql_affected_rows();
		
		$on_str = ($on_c<1) ? 'никого нет' : $on_c.' '.word_case('человек:человека:человек', $on_c).':';
		
		echo 'На форуме <a href="forum_topics.php?'.$sess.'fid='.$fid.'">'.$forum.'</a> сейчас '.$on_str.'<br/>';
		
		if($on_c>0){
			while($res = mysql_fetch_row($select)) echo $res[0].', ';
			echo '<br/>';
		}
	
	}
}

echo '---<br/>';
echo '<a href="forums.php?'.$sess.'">Форумы</a> ';
if($user) echo '| <a href="enter.php?'.$sess.'">Главное меню</a>';
echo '</small>';
foot();

mysql_close($link);
?>