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

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

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

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

@$mod=$_GET['mod'];

head('Форум');
echo '<small>';

if(!$user){
	echo '<a href="login.php?forum">Вход</a> | <a href="reg.php">Регистрация</a><br/>';
	echo 'Здесь можно общаться без регистрации!<br/>---<br/>';
}

else {
	
	mysql_query("UPDATE `wip_users` SET `loc`='forums', `forum_online`='".time()."' WHERE `id`='".$user['id']."';");
	
	echo 'Привет <b>'.$user['nick'].'</b><br/>';
	
	@$contacts=mysql_fetch_row(mysql_query("select count(id), sum(msg) from wip_contacts where uid='$user[id]';"));

	if(@$contacts[1]) echo '<b>Вам поступило '.@$contacts[1].' новых сообщений!</b><br/>';
	else $contacts[1] = 0;
	
	echo '<a href="contacts.php?sid='.$sid.'">Контакт-лист</a> ['.$contacts[1].'/'.$contacts[0].']<br/>';
	
	if($user['forum_admin']) echo '<a href="forum_admin.php?'.$sess.'">Админка</a><br/>';
	if($user['forum_moder']) echo '<a href="forum_moder.php?'.$sess.'">Модерка</a><br/>';
	
	echo '<a href="my_sets.php?'.$sess.'">Настройки форума</a><br/>';
	echo '<a href="help.php?'.$sess.'mod=forum_rules">Правила форума</a><br/>';
	echo '---<br/>';
}


echo '<b>Общие форумы:</b><br/>';

$select = mysql_query("SELECT `id`, `name` FROM `wip_forum_forums` WHERE `group`=0 ORDER BY `pos`");

if(mysql_affected_rows()<1){
	echo 'Форумов нет<br/>';
}

else {
	
	while($res = mysql_fetch_assoc($select)){
		
		$q = mysql_query("SELECT COUNT(`id`) FROM `wip_forum_topics` WHERE `fid`='".$res['id']."' UNION SELECT COUNT(`id`) FROM `wip_forum_messages` WHERE `fid`='".$res['id']."';");
		
		$thms = (@mysql_result($q, 0)) ? mysql_result($q, 0) : 0;
		$msgs = (@mysql_result($q, 1)) ? mysql_result($q, 1) : mysql_result($q, 0);
		
		echo '<b><a href="forum_topics.php?'.$sess.'fid='.$res['id'].'">'.$res['name'].'</a></b> ['.$thms.'/'.$msgs.']<br/>';
		
		/*$last=mysql_fetch_row(mysql_query("SELECT `t`.`name`, `u`.`nick`, `m`.`time`, `t`.`id` FROM `wip_users` AS `u`, `wip_forum_messages` AS `m`, `wip_forum_topics` AS `t` WHERE `u`.`id` = `m`.`uid` AND `t`.`fid` = '".$res['id']."' AND `t`.`id` = `m`.`tid` ORDER BY `m`.`id` DESC LIMIT 1;"));

		if($last[0]){
		
			$all=mysql_fetch_row(mysql_query("SELECT COUNT(`id`) FROM `wip_forum_messages` WHERE `tid` = '".$last[3]."';"));
			
			$tlim = ($user) ? $user['forum_tlim'] : 10;
			$pgs=ceil($all[0]/$tlim);
			
			$ldate=false;
			$ldate = (date('d.m.Y', $last[2]) == date('d.m.Y')) ? '[ceгoдня / ' : '['.date('d.m', $last[2]).' / ';
			$ldate.=date('H:i', $last[2]).']';
			
			echo 'Teмa: <i><a href="forum_messages.php?'.$sess.'tid='.$last[3].'&amp;s='.$pgs.'">'.$last[0].'</a></i><br/>';
			echo 'Посл: '.$last[1].' '.$ldate.'<br/>';
		}
		echo '---<br/>';*/
	}
	
}

echo '---<br/>';

$onl = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `wip_users` WHERE `loc` LIKE '%forum\_%' AND `forum_online` > '".(time()-300)."';"), 0);
echo 'На форуме <a href="forum_online.php?'.$sess.'">'.$onl.'</a> '.word_case('человек:человека:человек', $onl).'<br/>';

if($user) echo '<a href="enter.php?'.$sess.'">Главное меню</a><br/>';
echo '<a href="index.php">На главную</a>';
echo '</small>';
foot();

mysql_close($link);
?>