Просмотр файла include/mindex.php

Размер файла: 9.92Kb
<?
if( in_array($status, array('admin', 'moderator')) )
			{
list($maxOnl, $time) = explode("<>", file_get_contents("online.txt"));
	$online = mysql_result(
	          mysql_query("SELECT COUNT(*)
	                       FROM `session`
	                       WHERE `time` > ".(time() - (10 * 60))), 0);
	if($online > intval($maxOnl))
	{
		fwrite(fopen('online.txt', 'w'), $online.'<>'.date('d.m.y H:i:s'));
	}
	if($version == "wml")
	{
		header('Content-type: text/vnd.wap.wml; charset=utf-8');
		header("Cache-Control: no-cache");
		echo(doctype("".date('H:i')." Модер-форум")."\r\n");
		echo($tag);
		
		if($authorize)
		{
			echo('<a href="./?p=24&amp;v=wml&amp;sid='.$sid.'">Приват');
			
			$private = mysql_result(
			           mysql_query("SELECT COUNT(*)
			                        FROM `private`
			                        WHERE `name`='".$username."'
			                        AND `new`=1
			                        AND `mod`='i'"), 0);
			echo((empty($private) ? ' - 0</a>' : '</a> - <a href="./?p=24&amp;v=wml&amp;sid='.$sid.'&amp;new=1">'.$private.'</a>'));
			$sten = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username='".$username."'"));
$stenid=$sten['id'];
			echo(" | <a href=\"./?p=29&amp;sid=".$sid."&amp;v=wml\">Стена");
			$st = mysql_result(
				           mysql_query("SELECT COUNT(*)
				                        FROM `stena`
				                        WHERE `stenid`='".$stenid."'
				                        AND `s`=1"), 0);
				//echo((empty($st) ? ' - 0</a>' : '</a> - <a href="./?p=29&amp;stenid='.$stenid.'&amp;v=xhtml&amp;sid='.$sid.'&amp;sn=1">'.$st.'</a>'));
			echo((empty($st) ? ' - 0</a>' : ' - '.$st.'</a>'));
			echo("<br />");
			echo('<a href="./?p=0&amp;v=wml&amp;sid='.$sid.'">Общий форум</a> | ');
			if($status == "admin")
			{
				echo('<a href="./?p=27&amp;v=wml&amp;sid='.$sid.'"><b>Админка</b></a> | ');
			}
			if( in_array($status, array('admin', 'moderator')) )
			{
				  echo("<a href='./?p=26&amp;back=" . base64_encode(htmlspecialchars($_SERVER['REQUEST_URI'])) . "&amp;sid=$sid&amp;v=wml'>Бан по нику</a><br />\r\n");
			}
		}
		$mmfs = mysql_query("SELECT *
					      FROM mforums
 					      ORDER BY mforums.pos"
					);

$mmaPosts = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(mposts.time) AS mt
							 FROM mposts
							 LEFT JOIN mthemes
							 ON mposts.id_theme=mthemes.id"));
				
	while($mmforums = mysql_fetch_assoc($mmfs))
	{
		$mmpcnt = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(mposts.time) AS mt
							 FROM mposts
							 LEFT JOIN mthemes
							 ON mposts.id_theme=mthemes.id
							 WHERE id_forum=".$mmforums['id']));
			$mmlastTimeQ = mysql_query("SELECT * FROM `mcounter`
			                          WHERE `username`='".$username."'
			                          AND `fid`=".$mmforums['id']);
            $mmlastTimeR = mysql_fetch_assoc($mmlastTimeQ);
			$mmlastTime = $mmlastTimeR['time'];

			$mmnPosts =   mysql_result(
			            mysql_query("SELECT COUNT(*)
									 FROM mposts, mthemes
									 WHERE mposts.id_theme=mthemes.id
									 AND id_forum=".$mmforums['id']."
									 AND mposts.time > '".$mmlastTime."'
									 AND mposts.name != '".$username."'
									 GROUP BY mthemes.id_forum"), 0);

			if($mmnPosts < 1)
			{
				$mmnPosts = '0';
			}
			$mmnQPosts = $mmnPosts+$mmnQPosts;
		}
		echo("<br/>Новых/Всего: <b>(".intval($mmnQPosts)."/".intval($mmaPosts['cnt']).")</b><br />");
	}
		elseif($version == "xhtml")
		{
			header("Content-type: text/html; charset=utf-8");
			header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
   header("Cache-Control: no-cache, must-relative");
			echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>'.date('H:i').' Модер-форум</title>
</head>
<body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
<tr><td align="center" bgcolor="'.$style['title'].'">
<font color="#FFFFFF"><b>Модер-форум</b></font>
</td></tr>
<tr><td bgcolor="'.$style['bottom'].'">
'.$tag.'');
			if($authorize)
			{
				echo('<a href="./?p=24&amp;v=xhtml&amp;sid='.$sid.'">Приват');
				$private = mysql_result(
				           mysql_query("SELECT COUNT(*)
				                        FROM `private`
				                        WHERE `name`='".$username."'
				                        AND `new`=1
				                        AND `mod`='i'"), 0);
				echo((empty($private) ? ' - 0</a>' : '</a> - <a href="./?p=24&amp;v=xhtml&amp;sid='.$sid.'&amp;new=1">'.$private.'</a>'));
				$sten = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username='".$username."'"));
$stenid=$sten['id'];
			echo(" | <a href=\"./?p=29&amp;sid=".$sid."&amp;v=xhtml\">Стена");
			$st = mysql_result(
				           mysql_query("SELECT COUNT(*)
				                        FROM `stena`
				                        WHERE `stenid`='".$stenid."'
				                        AND `s`=1"), 0);
				//echo((empty($st) ? ' - 0</a>' : '</a> - <a href="./?p=29&amp;stenid='.$stenid.'&amp;v=xhtml&amp;sid='.$sid.'&amp;sn=1">'.$st.'</a>'));
			echo((empty($st) ? ' - 0</a>' : ' - '.$st.'</a>'));
			echo("<br />");
			}
			echo('<a href="./?p=0&amp;v=xhtml&amp;sid='.$sid.'"><b>Общий форум</b></a> | ');
			if($status == "admin")
					{
						echo('<a href="./?p=27&amp;v=xhtml&amp;sid='.$sid.'"><b>Админка</b></a> | ');
					}
					if( in_array($status, array('admin', 'moderator')) )
					{
						 echo("<a href='./?p=26&amp;back=" . base64_encode(htmlspecialchars($_SERVER['REQUEST_URI'])) . "&amp;sid=$sid&amp;v=xhtml'>Бан по нику</a><br />\r\n");
					}
$mmfs = mysql_query("SELECT *
					      FROM mforums
 					      ORDER BY mforums.pos"
					);

$mmaPosts = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(mposts.time) AS mt
							 FROM mposts
							 LEFT JOIN mthemes
							 ON mposts.id_theme=mthemes.id"));
				
	while($mmforums = mysql_fetch_assoc($mmfs))
	{
		$mmpcnt = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(mposts.time) AS mt
							 FROM mposts
							 LEFT JOIN mthemes
							 ON mposts.id_theme=mthemes.id
							 WHERE id_forum=".$mmforums['id']));
			$mmlastTimeQ = mysql_query("SELECT * FROM `mcounter`
			                          WHERE `username`='".$username."'
			                          AND `fid`=".$mmforums['id']);
            $mmlastTimeR = mysql_fetch_assoc($mmlastTimeQ);
			$mmlastTime = $mmlastTimeR['time'];

			$mmnPosts =   mysql_result(
			            mysql_query("SELECT COUNT(*)
									 FROM mposts, mthemes
									 WHERE mposts.id_theme=mthemes.id
									 AND id_forum=".$mmforums['id']."
									 AND mposts.time > '".$mmlastTime."'
									 AND mposts.name != '".$username."'
									 GROUP BY mthemes.id_forum"), 0);

			if($mmnPosts < 1)
			{
				$mmnPosts = '0';
			}
			$mmnQPosts = $mmnPosts+$mmnQPosts;
		}
		echo("Новых/Всего: <b>(".intval($mmnQPosts)."/".intval($mmaPosts['cnt']).")</b><br />");
			echo($tagC);
			echo('</td></tr><tr><td bgcolor="'.$style['text'].'">'.$tag);
		}
		$f = mysql_query("SELECT *
					      FROM mforums
 					      ORDER BY mforums.pos"
 		);
	while($forums = mysql_fetch_assoc($f))
	{
		$pcnt = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(mposts.time) AS mt
							 FROM mposts
							 LEFT JOIN mthemes
							 ON mposts.id_theme=mthemes.id
							 WHERE id_forum=".$forums['id']));
		if($authorize)
		{
			$lastTimeQ = mysql_query("SELECT * FROM `mcounter`
			                          WHERE `username`='".$username."'
			                          AND `fid`=".$forums['id']);
            $lastTimeR = mysql_fetch_assoc($lastTimeQ);
			$lastTime = $lastTimeR['time'];

			$newPosts = @intval(
			            mysql_result(
			            mysql_query("SELECT COUNT(*)
									 FROM mposts, mthemes
									 WHERE mposts.id_theme=mthemes.id
									 AND id_forum=".$forums['id']."
									 AND mposts.time > '".$lastTime."'
									 AND mposts.name != '".$username."'
									 GROUP BY mthemes.id_forum"), 0)).'/';

			if($newPosts < 1)
			{
				$newPosts = '0/';
			}

		}
		echo(date("d/m H:i", $pcnt['mt'])."<b>(".$newPosts.intval($pcnt['cnt']).")</b><br />\r\n");
		echo('<b><a href="./?p=3&amp;f='.$forums['id'].'&amp;sid='.$sid.'&amp;v='.$version.'">'.$forums['name'].'</a></b><br /> <br />');
	}
	$fonl = mysql_query("SELECT nickname FROM `session` WHERE `time` > ".(time() - (10 * 60)));
	$uonl = mysql_num_rows($fonl);
	if($version == "wml")
	{
		echo('<br />');
		if($authorize)
		{
		echo('<a href="./?p=12&amp;sid='.$sid.'&amp;v=wml&amp;rnd='.$ref.'">Online: <b>'.intval($uonl).'</b></a><br />');
}
echo('<a href="./?p=20&amp;v=wml&amp;sid='.$sid.'">Поиск</a> | ');
//echo('<a href="./?p=13&amp;sid='.$sid.'&amp;v=wml">Топ-20</a> | ');
//echo('<a href="./?p=11&amp;sid='.$sid.'&amp;v=wml">Статистика</a> | ');
echo('<a href="./?p=14&amp;v=wml&amp;sid='.$sid.'">Помощь</a> | ');
		if($authorize)
		{
			echo('<a href="./?p=28&amp;logout=1&amp;v=wml&amp;sid='.$sid.'"><b>Выход</b></a><br />');
		}
echo($tagC.'
</p></card></wml>');
	}
		elseif($version == "xhtml")
		{
			echo($tagC.'</td></tr>');
			echo("<tr><td bgcolor=\"".$style['bottom']."\">\r\n".$tag);
			if($authorize)
				{
		echo('<a href="./?p=12&amp;sid='.$sid.'&amp;v=xhtml&amp;rnd='.$ref.'">Online: <b>'.intval($uonl).'</b></a><br />');
		}
echo('<a href="./?p=20&amp;v=xhtml&amp;sid='.$sid.'">Поиск</a> | ');
//echo('<a href="./?p=13&amp;sid='.$sid.'&amp;v=xhtml">Топ-20</a> | ');
//echo('<a href="./?p=11&amp;sid='.$sid.'&amp;v=xhtml">Статистика</a> | ');
echo('<a href="./?p=14&amp;v=xhtml&amp;sid='.$sid.'">Помощь</a> | ');
				if($authorize)
				{
					echo('<a href="./?p=28&amp;logout=1&amp;v=xhtml&amp;sid='.$sid.'"><b>Выход</b></a><br />');
				}
echo($tagC.'</td></tr></table>
</body></html>');
		}}
?>