View file NuclearCMS_v.1.0.0/forum/include/index.php

File size: 16.02Kb
<?

include_once("us.php");
$id = $infoUserRows['id'];

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(!mysql_result(mysql_query("SELECT * FROM wcab WHERE id_user=".$id), 0))
{
echo ('<a href="'.$forumdir.'p=32&amp;s=1&amp;v=wml&amp;sid='.$sid.'&amp;rnd='.$ref.'">'.$tag.'<b>Оплата за общение!'.$tagC.'</b></a><br />');
}*/
		if($authorize)
		{
			echo('<a href="./?p=24&amp;rnd='.$ref.'&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;rnd=".$ref."&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><br />' : ' - '.$st.'</a><br />'));
			if( in_array($status, array('admin', 'moderator')) )
			{
//////////////////////////
			$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('<a href="./?p=1&amp;rnd='.$ref.'&amp;v='.$version.'&amp;sid='.$sid.'"><b>Модер-форум('.intval($mmnPosts).'/'.$mmaPosts['cnt'].')</b></a> | ');
			}
			if($status == "admin")
			{
				echo('<a href="./?p=27&amp;rnd='.$ref.'&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");
			}
			echo('<br />');
		}
		if($authorize)
		{
					$fs = mysql_query("SELECT *
					      FROM forums
 					      ORDER BY forums.pos"
					);

$aPosts = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(posts.time) AS mt
							 FROM posts
							 LEFT JOIN themes
							 ON posts.id_theme=themes.id"));
				
	while($forums = mysql_fetch_assoc($fs))
	{
		$pcnt = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(posts.time) AS mt
							 FROM posts
							 LEFT JOIN themes
							 ON posts.id_theme=themes.id
							 WHERE id_forum=".$forums['id']));
			$lastTimeQ = mysql_query("SELECT * FROM `counter`
			                          WHERE `username`='".$username."'
			                          AND `fid`=".$forums['id']);
            $lastTimeR = mysql_fetch_assoc($lastTimeQ);
			$lastTime = $lastTimeR['time'];

			$nPosts =   mysql_result(
			            mysql_query("SELECT COUNT(*)
									 FROM posts, themes
									 WHERE posts.id_theme=themes.id
									 AND id_forum=".$forums['id']."
									 AND posts.time > '".$lastTime."'
									 AND posts.name != '".$username."'
									 GROUP BY themes.id_forum"), 0);

			if($nPosts < 1)
			{
				$nPosts = '0';
			}
			$nQPosts = $nPosts+$nQPosts;
		}
		
echo("Новых/Всего: <b>(".intval($nQPosts)."/".intval($aPosts['cnt']).")</b><br />");
}
else if (!$authorize)
{
$aPosts = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(posts.time) AS mt
							 FROM posts
							 LEFT JOIN themes
							 ON posts.id_theme=themes.id"));


echo("Всего: <b>(".$aPosts['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>');
/*if(!mysql_result(mysql_query("SELECT * FROM wcab WHERE id_user=".$id), 0))
{
echo ('<tr bgcolor="#deebf1"><td colspan="2"><a href="'.$forumdir.'p=32&amp;s=1&amp;v=xhtml&amp;sid='.$sid.'&amp;rnd='.$ref.'">'.$tag);
//echo('<center><a href="http://uptraf.ru">UPTRAF.RU Скупает рекламу за 1000 руб!</a><br /></center>');
echo('<a href="'.$forumdir.'p=32&amp;s=1&amp;v=xhtml&amp;sid='.$sid.'&amp;rnd='.$ref.'"><b>Оплата за общение!'.$tagC.'</b></a><br /></td></tr>');
}*/
echo('<tr><td bgcolor="'.$style['bottom'].'">
'.$tag);

			if($authorize)
			{
				echo('<a href="./?p=24&amp;rnd='.$ref.'&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;rnd=".$ref."&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 />");
			}




			if( in_array($status, array('admin', 'moderator')) )
			{
//////////////////////////
			$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('<a href="./?p=1&amp;rnd='.$ref.'&amp;v=xhtml&amp;sid='.$sid.'"><b>Модер-форум('.intval($mmnQPosts).'/'.$mmaPosts['cnt'].')</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");
					}

/////////////////////////////////////////////
if($authorize)
		{
					$fs = mysql_query("SELECT *
					      FROM forums
 					      ORDER BY forums.pos"
					);

$aPosts = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(posts.time) AS mt
							 FROM posts
							 LEFT JOIN themes
							 ON posts.id_theme=themes.id"));
				
	while($forums = mysql_fetch_assoc($fs))
	{
		$pcnt = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(posts.time) AS mt
							 FROM posts
							 LEFT JOIN themes
							 ON posts.id_theme=themes.id
							 WHERE id_forum=".$forums['id']));
			$lastTimeQ = mysql_query("SELECT * FROM `counter`
			                          WHERE `username`='".$username."'
			                          AND `fid`=".$forums['id']);
            $lastTimeR = mysql_fetch_assoc($lastTimeQ);
			$lastTime = $lastTimeR['time'];

			$nPosts =   mysql_result(
			            mysql_query("SELECT COUNT(*)
									 FROM posts, themes
									 WHERE posts.id_theme=themes.id
									 AND id_forum=".$forums['id']."
									 AND posts.time > '".$lastTime."'
									 AND posts.name != '".$username."'
									 GROUP BY themes.id_forum"), 0);

			if($nPosts < 1)
			{
				$nPosts = '0';
			}
			$nQPosts = $nPosts+$nQPosts;
		}
		
echo("Новых/Всего: <b>(".intval($nQPosts)."/".intval($aPosts['cnt']).")</b>");
}
else
{
$aPosts = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(posts.time) AS mt
							 FROM posts
							 LEFT JOIN themes
							 ON posts.id_theme=themes.id"));


echo("Всего: <b>(".$aPosts['cnt'].")</b>");
}


/////////////////////////////////////////////


			echo($tagC);
			echo('</td></tr><tr><td bgcolor="'.$style['text'].'">'.$tag);
		}
		$f = mysql_query("SELECT *
					      FROM forums
 					      ORDER BY forums.pos"
 		);
 		if(isset($_GET['tarifs']))
		{
		echo('<u>Стоимость за 1 сообщение.</u><br />');
		}
	while($forums = mysql_fetch_assoc($f))
	{
		$pcnt = mysql_fetch_assoc(
		        mysql_query("SELECT COUNT(*) AS cnt, MAX(posts.time) AS mt
							 FROM posts
							 LEFT JOIN themes
							 ON posts.id_theme=themes.id
							 WHERE id_forum=".$forums['id']));
		if($authorize)
		{
			$lastTimeQ = mysql_query("SELECT * FROM `counter`
			                          WHERE `username`='".$username."'
			                          AND `fid`=".$forums['id']);
            $lastTimeR = mysql_fetch_assoc($lastTimeQ);
			$lastTime = $lastTimeR['time'];

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

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

		}
		
		if(isset($_GET['tarifs']))
		{
		echo('<b>'.$forums['name'].'</b>');
		} else
		{
		echo(date("d/m H:i", $pcnt['mt'])."<b>(".$newPosts.intval($pcnt['cnt']).")</b><br />\r\n");
		if($authorize)
		{
		echo('<b><a href="./?p=2&amp;f='.$forums['id'].'&amp;rnd='.$ref.'&amp;sid='.$sid.'&amp;v='.$version.'">'.$forums['name'].'</a></b>');
		}
		else
		{
		echo('<b><a href="./?p=2&amp;f='.$forums['id'].'&amp;rnd='.$ref.'&amp;v='.$version.'">'.$forums['name'].'</a></b>');
		}
		}
		if(isset($_GET['tarifs']))
		{
		if($forums['id'] == "1")
		{
		echo(' - 0.1');
		}
		elseif($forums['id'] != "20" && $forums['id'] != "16" && $forums['id'] != "18" && $forums['id'] != "19")
		{
		echo(' - 0.3');
		}
		else
		{
		echo(' - 0.00');
		}
		}
		echo('<br /> <br />');
	}
	if(isset($_GET['tarifs']))
		{
		echo('<u>Все суммы указаны в рублях.</u><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=33&amp;v=wml&amp;sid='.$sid.'&amp;rnd='.$ref.'">Кабинет</a> | ');
		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;stat&amp;sid='.$sid.'&amp;v=wml">Статистика</a> | ');
		//echo('<a href="./?p=14&amp;v=wml&amp;sid='.$sid.'">Помощь</a> | ');
		echo('<a href="./?p=28&amp;logout=1&amp;v=wml&amp;sid='.$sid.'"><b>Выход</b></a><br />');
		}
		else
		{
		echo('Online: <b>'.intval($uonl).'</b><br />');
		echo('<a href="./?p=19&amp;v=wml&amp;rnd='.$ref.'">Авторизация</a> | ');
		echo('<a href="./?p=20&amp;v=wml">Поиск</a> | ');
		//echo('<a href="./?p=11&amp;v=wml&amp;rnd='.$ref.'">Статистика</a> | ');
		echo('<a href="./?p=14&amp;v=wml">Помощь</a><br />');
		echo('<center>wml | <a href="./?v=xhtml">html</a><br /></center>');
}
echo($tagC.'
</p></card></wml>');
	}
		elseif($version == "xhtml")
		{
			echo($tagC.'</td></tr>');
			echo("<tr><td bgcolor=\"".$style['bottom']."\">\r\n".$tag);
			if(!$authorize)
				{
				echo('Online: <b>'.intval($uonl).'</b><br />');
					echo('
					<a href="./?p=19&amp;v=xhtml&amp;rnd='.$ref.'">Авторизация</a> | 
					<a href="./?p=20&amp;v=xhtml">Поиск</a> | ');
					//echo('<a href="./?p=11&amp;v=xhtml&amp;rnd='.$ref.'">Статистика</a> | ');
					echo('<a href="./?p=14&amp;v=xhtml">Помощь</a><br />');
					echo('<tr><td align="center" bgcolor="'.$style['bottom'].'">
					<center><a href="./?v=wml">wml</a> | html<br /></center></td></tr>');
				}
		else
		{
		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=33&amp;v=xhtml&amp;sid='.$sid.'&amp;rnd='.$ref.'">Кабинет</a> | ');
		echo('<a href="./?p=20&amp;v=xhtml&amp;sid='.$sid.'">Поиск</a> | ');
		//echo('<a href="./?p=13&amp;sid='.$sid.'&amp;v=xhtml&amp;rnd='.$ref.'">Топ-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> | ');
		echo('<a href="./?p=28&amp;logout=1&amp;v=xhtml&amp;sid='.$sid.'"><b>Выход</b></a><br />');
		}
echo($tagC.'</td></tr>');
echo("</table>
</body></html>");
		}
?>