Location: PHPKode > projects > Modular Site Manager > htdocs/inc/content.inc.php
<?php
/*
 * Content Class
 * @Copyright: Vouksh.info 2005
 * @Description: Class to control the content.
 */

if(!isset($_GET['page']) && !isset($_GET['section'])){
	$page = "Home";
} elseif(isset($_GET['section'])) {
	$page = $_GET['section'];
} else {
	$page = $_GET['page'];
}
class content
{
	function navTop()
	{
		global $page, $mysql;
	//	$mysql = new mysql(DB_MAIN);
		$sel = $mysql->select(PRE."config", "section='topnav'", "id");
		$a = mysql_fetch_assoc($sel);
		$set1 = explode("~", $a['setting']);
		$set2 = explode("~", $a['setting2']);
		$sep = array_combine($set1, $set2);
		foreach($sep as $name => $url)
		{
			if(preg_match('@'.$page.'@', $url))
			{
				echo "<li id=\"top-active\">".$name."</li>";
			} else {
				echo "<li><a href=\"".$url."\">".$name."</a></li>";
			}
		}
	}

		// Navigation Side box

	function navigation()
	{
		global $mysql;
		//$mysql = new mysql(DB_MAIN);
		$sel = $mysql->select(PRE."config", "id='4'", "id");
		while($set = mysql_fetch_array($sel))
		{
			$set1 = explode("~", $set['setting']);
			$set2 = explode("~", $set['setting2']);
			$all = array_combine($set1, $set2);
			echo "<ul>\n";
			foreach($all as $opt => $url)
			{
				echo "<li><a href=\"".$url."\">".$opt."</a></li>\n";
			}
			echo "</ul>";
		}
	//
	}

	// Statistics side box
	#TODO: cache it. every 1/2 hour, get the new stats.
	function stats()
	{
		global $today_hits, $total_hits, $unique_hits, $last_day, $REMOTE_ADDR, $mysql;
		//$mysql = new mysql(DB_MAIN);
		$tut_no = $mysql->rcount(PRE.'tutorials');
		$dlnum = $mysql->rcount(PRE.'downloads');
		$codedbno = $mysql->rcount(PRE.'codedb');
		$posts = $mysql->rcount(PRE.'forums_posts');
		$threads = $mysql->rcount(PRE.'forums_threads');
		$ret = "<strong>Hits today:</strong> ".$today_hits."<br />
		<strong>Unique hits:</strong> ".$unique_hits."<br />
		<strong>Yesterdays hits:</strong> ".$last_day."<br />
		<strong>Tutorials: </strong>".$tut_no."<br />
		<strong>Downloads:</strong> ".$dlnum."<br />
		<strong>CodeDB Submissions:</strong> ".$codedbno."<br />
		<strong>Threads/Posts:</strong> ".$threads.'/'.$posts.'<br />';

		$ret .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div>
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" style="border: none;" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!" />
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----" /></div></form>
<a href="http://www.activewebhosting.com/freeipod?www.vouksh.info">Vote for this site and Win A FREE iPod!</a>';
		return $ret;
	}
	// Site Spotlight :)
	function sitespot()
	{
		global $mysql;
		$select = $mysql->select(PRE."sotw", NULL, "id", "DESC", "1");
		$r = mysql_fetch_array($select);
		$image=$r['image'];
		$sotwid=$r['id'];
		$sitename=$r['site'];
		$desc=$r['descr'];
		$rating=$r['rating'];
		$graphics=$r['graphics'];
		$content=$r['content'];
		$clicks=$r['clicks'];
		$ret = "Site Name: <a href=\"/sotw_man/click.php?id=".$sotwid."\">".$sitename."</a><br />
		Rating: ".$rating."<br />
		Graphics: ".$graphics."<br />
		Content: ".$content."<br />
		<a href=\"sotw_man/click.php?id=".$sotwid."\"><img src=\"".$image."\" style=\"border: none;\" alt=\"".$sitename."\" title=\"".$sitename."\" /></a><br />
		".$desc." <br />
		Clicks: ".$clicks;
		return $ret;
	}

	function memberpanel()
	{
		global $_COOKIE, $user, $mysql;
		if(!isset($_COOKIE['mid']) || $_COOKIE['mid'] == "-1" || $_COOKIE['mid'] == "")
		{
			$ret = "Welcome guest! Please login or <a href=\"Members/Register\">Register</a>";
			$ret .= '<fieldset>
					<form action="misc/login.php" method="post">
						<div>
							<div style="width: 30%; float: left; text-align: right; padding-top: 3px;">Username: </div><div style="width: 70%; float: right;"><input type="text" value="Username" name="username" onfocus="this.value=\'\'" /><br /></div>
							<div style="width: 30%; float: left; text-align: right; padding-top: 3px;">Password: </div><div style="width: 70%; float: right;"><input type="password" name="password" /><br /></div>
							<div  style="width: 100%; float: left;"><input type="submit" value="Login" name="submit" /></div>
						</div>
					</form>
				</fieldset>
				<div class="buttondiv"><a href="Members/ForgotPass">Forgot your password?</a></div>';
		} else {
			//$mysql = new mysql(DB_MAIN);
			$members = $mysql->select(PRE."members", "id='".$user."'", "id");
			$a = mysql_fetch_array($members);
			$ret = "<div style=\"float: left; width: 60%;\"><ul id=\"member-nav\">
					<li><a href=\"Members/Messages/\">My Messages</a></li>
					<li><a href=\"Members/CP/\">My Control Panel</a></li>
					<li><a href=\"ImGal-Submit/\">Submit an image</a></li>
					<li><a href=\"Tutorial-Submit/\">Submit a tutorial</a></li>
					<li><a href=\"Download-Submit/\">Submit a download</a></li>";
			if($a['groups'] == "1")
			{
				$ret .= "<li><a href=\"admin.php\">Admin Panel</a></li>";
			}
			$ret .= "<li><a href=\"misc/logout.php\">Logout</a></li>";
			$ret .= "</ul>";
			$ret .= "</div><div style=\"float: right;width: 40%;text-align: center;\">Welcome to Vouksh.info, ".$a['username']."!<br />";
			if(isset($a['avatar']) && !empty($a['avatar']))
			{
				$ret .= "<img src=\"avatar.php?f=".$a['avatar']."\" style=\"max-width: 80px; max-height: 80px; vertical-align: middle;\" alt=\"".$a['username']."'s Avatar\" /></div>";
			} else {
				$ret .= "</div>";
			}
			$pms = mysql_num_rows($mysql->select(PRE."messages", "owner='".$_COOKIE['mid']."' AND folder='inbox'", "id"));
			$ret .=  '<br /><div style="float: left; text-align: center; width: 40%">You have <a href="Members/Messages/Inbox">'.$pms.'</a> Message(s).</div>';
		}
		$ret .= '<div class="error" id="merror"></div>';
		return $ret;
	}
	function affiliates()
	{
		global $mysql;
		echo "<div style=\"text-align: center;\">";
		$select = $mysql->select(PRE."affiliates", 'status="yes"', "rand()", "DESC", "8");
		while($row = mysql_fetch_array($select))
		{
			$id = $row["id"];
			$sitename = stripslashes($row["sitename"]);
			$address = stripslashes($row["address"]);
			$button = stripslashes($row["button"]);
			$out = $row["clicksout"];
			$in = $row["clicksin"];
			if (!empty($button)) {
			echo "<a href=\"/out/".$id."\" title=\"".$sitename." {~[In: ".$in." | Out: ".$out."]\"><img src=\"".$button."\" style=\"border: none; width: 81px; height: 31px;\" alt=\"".$sitename." {~[In: ".$in." | Out: ".$out."]\" /></a>";
		}
		}
		//$conn->close();
		echo "<br /><a href=\"v5/AffApply/\" style=\"text-align:center;\">Trade Links?</a></div>";
	}

	//Displays the latest gallery image's thumbnail
	function latest_gallery()
	{
		//$mysql = new mysql(DB_MAIN);
		global $mysql;
		$sel = $mysql->select(PRE."imgal", NULL, "id", "DESC", "1");
		$a = mysql_fetch_array($sel);
		$ret = "<div style=\"text-align: center;\"><a href=\"ImGal/".$a['cat']."/".$a['id']."/\"><img src=\"http://www.vouksh.info/imgs/".$a['cat']."/".$a['thumb']."\" alt=\"Click to view this gallery image!\" /></a></div>";
		return $ret;
	}

	function doMain()
	{
		// Display the main content renard!
		global $_GET, $_POST, $REMOTE_ADDR, $_SESSION, $_SERVER, $mysql;
		$usertheme = getuserinfoid("theme", $_COOKIE['mid']);
		if(empty($usertheme))
		{
			$theme = DEFAULT_THEME;
		} else {
			$theme = $usertheme;
		}
		if (!isset($_GET['page']) || empty($_GET['page']))
		{
			$page = "Home";
		} else {
			$page = $_GET['page'];
		}
		if (isset($_GET['error']) || isset($_GET['section']))
		{
			$page = "null";
		}
		if (!is_file("content/".$page.".php")) {
			ob_clean();
			die("The page $page does not exist");
		}

		if(strpos($page, "../") == "true")
		{
			ob_clean();
			die("HACKING ATTEMPT!");
		}
		if(!is_null($page))
		{
			include(SITE_PATH."content/".$page.".php");
		}

		$error = $_GET['error'];
		if (isset($_GET['error'])) {
			$ret = include("$error.shtml");
		}
		if(isset($_GET['section']))
		{
			$this->section($_GET['section']);
			//$ret = true;
		}
		return false;
	}

	// Section code. Tutorials, ImGal, etc. This gonna have ALOT of lines...
	function section($section)
	{
		global $user, $_COOKIE, $_POST, $_GET, $_SESSION, $_SERVER, $HTTP_REFERER, $REMOTE_ADDR, $mysql;
		//$mysql = new mysql(DB_MAIN);
		$usertheme = getuserinfoid("theme", $_COOKIE['mid']);
		if(empty($usertheme))
		{
			$theme = DEFAULT_THEME;
		} else {
			$theme = $usertheme;
		}
			switch(strtolower($section)) {
				case "tutorials":
					include "tutorials.inc.php";
				break;
				case 'tut-alt':
					include "tutorials-alt.inc.php";
				break;
				case "imgal":
					include "imgal.inc.php";
				break;
				case "downloads":
					include "downloads.inc.php";
				break;
				case "members":
					include "members.inc.php";
				break;
				case "blogs":
					include "blogs.inc.php";
				break;
				case "forums":
					include "forums.inc.php";
				break;
				case 'codedb':
					include "codedb.inc.php";
				break;
				case "imgal-submit":
					echo '<fieldset>
							<form id="imgal_submission" action="misc/imgal_submit.php" method="post" enctype="multipart/form-data" >
								<!-- <div class="formtext">Author:</div><div class="formdiv"><input name="author" type="text" /></div>-->
								<div class="formtext">Category:</div><div class="formdiv">
									<select name="cat" id="cat">';
									$cats = listcats("imgal");
									foreach($cats as $cat => $disp)
									{
										echo '<option value="'.$cat.'">'.$disp.'</option>';
									}
									echo '</select>
								</div>
								<div class="formtext">File:</div><div class="formdiv"><input name="image" type="file" /></div>
								<div class="formtext">Alt text:</div><div class="formdiv"><input type="text" name="alt" /></div>
								<div class="buttondiv"><input type="submit" name="Submit" value="Submit" /></div>
							</form>
						</fieldset>';
						if(isset($_GET['serror']))
						{
							switch($_GET['serror'])
							{
								case "needauthor":
									echo '<div class="error">Error: You need to put an author name</div>';
								break;
								case "needalt":
									echo '<div class="error">Error: You need to put an alternate text.</div>';
								break;
								case "needimage":
									echo '<div class="error">Error: You either didn\'t provide an image, or the file you did provide wasn\t an image</div>';
								break;
							}
						}
				break;
				case "download-submit":
					echo '				<form method="post" action="misc/dl_submit.php" enctype="multipart/form-data">
					<div>
						<div class="formtext">File Name</div>
						<div class="formdiv"><input name="name" type="text" /></div>
						<div class="formtext">Category</div>
						<div class="formdiv">
							<select name="cat">'."\n";
							$cats = listcats("downloads");
							foreach($cats as $cat => $disp)
							{
								echo '	<option value="'.$cat.'">'.$disp.'</option>'."\n";
							}
							echo '</select>
						</div>
						<div class="formtext">Description</div>
						<div class="formdiv">
							<textarea name="desc" cols="20" rows="5"></textarea>
						</div>
						<div class="formtext">File</div>
						<div class="formdiv"><input type="file" name="download" /></div>
						<div class="formtext">Full Description</div>
						<div class="formdiv">
							<textarea name="longdesc" cols="50" rows="10" class="wysiwyg"></textarea>
						</div>
						<div class="buttondiv">
							<input type="submit" name="Submit" value="Submit" />
							<input type="reset" name="Reset" value="Reset" />
						</div>
					</div>
				</form>';
					if(isset($_GET['serror']))
					{
						switch($_GET['serror'])
						{
							case "nolongdesc":
								echo '<div class="error">Error: You need to put a long description of the file.</div>';
							break;
							case "nodesc":
								echo '<div class="error">Error: You need to put a short description.</div>';
							break;
							case "nofile":
								echo '<div class="error">Error: You didn\'t provide a file.</div>';
							break;
						}
					}
				break;
				case "tutorial-submit":
					echo '<form id="tut_submission" method="post" action="misc/tut_submit.php">
						<div class="buttondiv">You may use HTML &amp; PHP to write this. use [php][/php] to highlight php, and standard bbcode for the rest if you wish to. </div>
						<div class="formtext">Tutorial Name </div>
						<div class="formdiv"><input name="name" type="text" id="name" /></div>
						<div class="formtext">Category</div>
						<div class="formdiv">
								<select name="cat">';
								$cats = listcats("tutorials");
								foreach($cats as $cat => $disp)
								{
									echo '<option value="'.$cat.'">'.$disp.'</option>';
								}
								echo '</select>
						</div>
						<div class="formtext">Level</div>
						<div class="formdiv">
							<select name="level" id="level">
								<option value="easy">Easy</option>
								<option value="moderate">Moderate</option>
								<option value="hard">Hard</option>
							</select>
						</div>
						<div class="formtext">Preview Image*</div>
						<div class="formdiv"><input type="text" name="image" id="image" /></div>
						<div class="formtext">Description</div>
						<div class="formdiv">
							<textarea name="desc" cols="20" rows="5"></textarea>
						</div>
						<div class="formtext"><label for="external">Is it external?</label></div>
						<div class="formdiv"><input type="checkbox" name="external" id="external" value="yep" /></div>
						<div class="formtext">Link (if it\'s external)</div>
						<div class="formdiv"><input type="text" name="link" id="link" /></div>
						<div class="buttondiv" style="margin-top:5px;">Tutorial</div>
						<div class="buttondiv" style="margin-top:5px;">
						<textarea name="tutorial" cols="75" rows="25"></textarea>
						</div>
						<div class="buttondiv">
						<input type="submit" name="Submit" value="Submit" />
						<input type="reset" name="Reset" value="Reset" />
						</div>
					</form>
					*If you don\'t provide one, there are default ones automatically added.';
					if(isset($_GET['serror']))
					{
						switch($_GET['serror'])
						{
							case "needdesc":
								echo '<div class="error">Error: You need to put a description.</div>';
							break;
							case "needtut":
								echo '<div class="error">Error: You must write the tutorial.</div>';
							break;
							case "needname":
								echo '<div class="error">Error: You need a tutorial name.</div>';
							break;
						}
					}
				break;

			}
	}
	// Phew, that's done. Thank god!

	// News controller. Make it easier :)
	function news($limit)
	{
		global $mysql;
		$sel = $mysql->select(PRE."news", NULL, "id", "DESC", $limit);
		$rows = mysql_num_rows($sel);
		for($i = 0; $i < $rows; $i++)
		{
			if($i % 2) {
				$style = "row1";
			} else {
				$style = "row2";
			}
			$r=mysql_fetch_array($sel);
			$subject=$r["subject"];
			$submission=$r["submission"];
			$name=$r["name"];
			$date=date(DATE ,$r["date"]);
			$email=$r["email"];
			$id=$r["id"];
			$comsrows = mysql_num_rows($mysql->select(PRE."comments", "id='$id'", "id", "DESC", "1"));
			echo "<div class=\"".$style."\" style=\"border:1px solid #000;\">
			<div style=\"text-align:center; background: #111; color: #ccc; font-size: 12px; font-weight: bold;\">".$subject." (#".$id.")</div><br />
			<br />
			<div style=\"text-align: left;\">".$submission."</div>
			<br />
			<div style=\"text-align:center; background: #aaa; color: #111;\">
			Posted by <a href=\"mailto:".$email."\">".$name."</a> on ".$date."
			<br />
			<a href=\"Comments/".$id."\">Comments (".$comsrows.")</a>
			</div>
			<div id=\"news-".$id."\"><br /></div>
			</div>";
		}
		return true;
	}
	function newsarchive()
	{
		//$mysql = new mysql(DB_MAIN);
		global $mysql;
		// Pagination crap..
		if(empty($_GET['view']) || !isset($_GET['view']))
		{
			$view = 1;
		} else {
			$view = $_GET['view'];
		}
		if(isset($_COOKIE['mid']))
		{
			$limit = getuserinfo('pglimit');
		} else {
			$limit = 10;
		}
		if($limit < 5)
		{
			$limit = 10;
		}
		$totalrows	= mysql_num_rows($mysql->select(PRE."news", NULL, "id"));
		$limitvalue = $view * $limit - ($limit);
		// end pagination crap
		$sel = $mysql->select(PRE."news", NULL, "id", "DESC", $limitvalue.",".$limit);
		$rows = mysql_num_rows($sel);
		$style="row1";
		while($r=mysql_fetch_array($sel))
		{
			$subject=$r["subject"];
			$submission=$r["submission"];
			$name=$r["name"];
			$date=date(DATE, $r["date"]);
			$email=$r["email"];
			$id=$r["id"];

			if($style == "row1") {
				$style = "row2";
			} else {
				$style = "row1";
			}
			$comsrows = mysql_num_rows($mysql->select(PRE."comments", "id='$id'", "id", "DESC", "1"));

			echo "<div class=\"".$style."\" style=\"border:1px solid #000;\">
			<div style=\"text-align:center; background: #111; color: #ccc; font-size: 12px; font-weight: bold;\">".$subject." (#".$id.")</div><br />
				<br />
				<div style=\"text-align: left;\">".$submission."</div>
				<br />
				<div style=\"text-align:center; background: #aaa; color: #111;\">
				Posted by <a href=\"mailto:".$email."\">".$name."</a> on ".$date."
				<br />
				<a href=\"Comments/".$id."\">Comments (".$comsrows.")</a>
				</div>
				<div id=\"news-".$id."\"><br /></div>
				</div>\n";
		}
		// More pagination crap..
		echo '<div style="font-weight:bold;text-align:center;">';
		if($view != 1)
		{
			$pageprev = $view-1;
			echo '<a href="v5/News&amp;view='.$pageprev.'">&lt;&lt;</a> ';
		}
		$numofpages = $totalrows / $limit;
		for($i = 1; $i <= $numofpages; $i++)
		{
			if($i == $view)
			{
				echo $i." ";
			} else {
				echo '<a href="v5/News&amp;view='.$i.'">'.$i.'</a> ';
			}
		}
		if(($totalrows % $limit) != 0)
		{
			if($i == $view)
			{
				echo $i.' ';
			} else {
				echo '<a href="v5/News&amp;view='.$i.'">'.$i.'</a> ';
			}
		}
		if(($totalrows - ($limit * $view)) > 0)
		{
			$pagenext = $view+1;
			echo '<a href="v5/News&amp;view='.$pagenext.'">&gt;&gt;</a>';
		}
		echo '</div>';
		// end more pagination crap
	}
	function newsone($id)
	{
		global $mysql;
		$sel = $mysql->select(PRE."news", "id='".$id."'", "id", "DESC", "1");
		$rows = mysql_num_rows($sel);
		$r=mysql_fetch_array($sel);
		$subject=$r["subject"];
		$submission=$r["submission"];
		$name=$r["name"];
		$date=$r["date"];
		$email=$r["email"];
		$comsrows = mysql_num_rows($mysql->select(PRE."comments", "id='$id'", "id", "DESC", "1"));
		if($i % 2) {
			$style = "row1";
		} else {
			$style = "row2";
		}
		echo "<div class=\"".$style."\" style=\"border:1px solid #000;\"><div style=\"text-align:center; background: #111; color: #ccc; font-size: 12px; font-weight: bold;\">".$subject." (#".$id.")</div><br />
		<br />
		<div style=\"text-align: left;\">".$submission."</div>
		</div>";
		echo "<hr style=\"width:75%;\" /><div style=\"margin-top: 10px;\">";
		$tc['query'] = $mysql->select(PRE."comments", "id='".$_GET['id']."'", "postid", "DESC");
		$tc['rows'] = mysql_num_rows($tc['query']);
		if(!$tc['rows'])
		{
			echo("No comments yet! Leave one!");
		} else {
			if($tc['rows'] == "1")
			{
				$a = array("is", "comment");
			} else {
				$a = array("are", "comments");
			}
			echo 'There '.$a["0"].' '.$tc["rows"].' '.$a["1"];
			for($i = 0; $i < $tc['rows']; $i++)
			{
				if($i % 2) { //this means if there is a remainder
					$style = "row1";
				} else { //if there isn't a remainder we will do the else
					$style = "row2";
				}
				$tcom=mysql_fetch_array($tc['query']);
				$name = $tcom['username'];
				$email = explode("@", $tcom['email']);
				$message = $tcom['message'];
				$date = date(DATE , $tcom['date']);
				$id = $tcom['id'];
				echo "<div class=\"$style\" style=\"margin-top: 5px; height: 50px; overflow: auto;\">
				<div style=\"width: 15%; float: left;\"><a href=\"javascript:email('$email[0]','$email[1]');\">$name</a><br />
				$date</div>
				<div style=\"width: 80%; float: right;\">$message</div>
				</div>";
			}
		}
		echo "<hr style=\"width: 95%;\" /><div style=\"margin-bottom: 60px; height: 100px;\"><form id=\"tutcommform\" method=\"post\" action=\"misc/news-comment-in.php\"><div>Post a Comment.</div>";
		if(!isset($_COOKIE['mid']))
		{
			echo "<div style=\"float: left; text-align: right; width: 15%; padding-top: 3px;\">Username</div>
			<div style=\"float: right; width:80%;\"><input name=\"username\" type=\"text\" /></div>
			<div style=\"float: left; text-align: right; width: 15%; padding-top: 3px;\">Email</div>
			<div style=\"float: right; width:80%;\"><input name=\"email\" type=\"hidden\" /></div>";
		} else {
			echo '<div><input type="hidden" name="username" value="'.$_COOKIE["user"].'" />
			<input type="hidden" name="email" value="'.getuserinfo("email").'" /></div>';
		}
		echo "<div style=\"text-align: right; width:15%; float:left; padding-top: 3px;\">Message<br /></div><div style=\"float: right; width:80%;\"><textarea name=\"message\" class=\"wysiwyg\" cols=\"60\" rows=\"14\"></textarea></div>
		<div style=\"float: left; width:100%; text-align: center;\"><input name=\"id\" type=\"hidden\" id=\"id\" value=\"".$_GET['id']."\" />
		<input type=\"submit\" name=\"Submit\" value=\"Submit\" />
		<input type=\"reset\" name=\"Reset\" value=\"Reset\" />      </div>
		</form></div>";
		if(isset($_GET['cerror']))
		{
			echo '<div class="error">Error: You skipped some info. Please fill it all out</div>';
		}
		echo "</div>";
	}

	function doRSS($type)
	{
		//$mysql = new mysql(DB_MAIN);
		global $mysql;
		switch($type)
		{
			case 'news':
				$sel = $mysql->select(PRE."news", NULL, "id", "DESC");
				while($r=mysql_fetch_array($sel))
				{
					$subject=$r["subject"];
					$name=$r["name"];
					$date=$r["date"];
					$id = $r['id'];
					echo "\t\t<item>\t\t\t<title>" . $subject . "</title>\n\t\t\t<link>".SITE_URL."Comments/".$id."</link>\n\t\t</item>";
				}
			break;
			case 'tutorials':
				$sel = $mysql->select(PRE."tutorials", NULL, "id", "DESC");
				while($r=mysql_fetch_array($sel))
				{
					$name=$r["name"];
					$cat=$r["cat"];
					$date=$r["date"];
					$author = $r['author'];
					echo "\t\t<item>\t\t\t<title>" . $name . "</title>\n\t\t\t<link>".SITE_URL."Tutorial/".$cat."/".str_replace(array(' ', '+'), "_", urlencode($name))."/</link>\\n\t\t</item>";
				}
			break;
		}
	return true;
	}

	function breadcrumb()
	{
		global $_GET, $mysql;
		if(isset($_GET['section']) && !isset($_GET['subsec']) && !isset($_GET['subsec']) && !isset($_GET['id']))
		{
			$ret = $_GET['section'];
		} elseif(isset($_GET['section']) && isset($_GET['subsec']) && !isset($_GET['id']))
		{
			$ret = $_GET['section'].' &gt; ';
			$ret .= str_replace('_', ' ', $_GET['subsec'].$_GET['cat']);
		} elseif(isset($_GET['id']))
		{
			$ret = str_replace(array('_', '-', '+'), array(' ', '/', '&amp;'), $_GET['id']);
		} else
		{
			if(!isset($_GET['page'])){
				$ret = "Home";
			} else {
				$ret = $_GET['page'];
			}
		}
		return trim(stripslashes($ret));
	}

	function poll()
	{
		global $_COOKIE, $HTTP_REFERER, $_POST, $PHP_SELF, $_GET, $REQUEST_URI, $mysql;
		$ident = $_COOKIE['mid'];
		//$mysql = new mysql(DB_MAIN);
		$redir = $HTTP_REFERER;
		$getq1 = $mysql->select(PRE."poll", NULL, "id", "DESC", "1");
		$getq = mysql_fetch_array($getq1);
		$checkvoted = $mysql->select(PRE."poll_votes", "ident='".$ident."' AND poll_id='".$getq['id']."'", "id");
		$voted = mysql_num_rows($checkvoted);
		if(isset($_GET['page']) || isset($_GET['section']))
		{
			$urlpref = "&amp;";
		} else {
			$urlpref= "?";
		}
		if ($voted == "0" && !$_POST['pollsubmit'] && !isset($_GET['results']) && isset($_COOKIE['mid']))
		{
			echo "<div style=\"text-align: center; font-weight:bold;\">".$getq['question']."</div>";
			$getchoice1 = $mysql->select(PRE."poll_choices", "pollid='".$getq['id']."'", "id", "ASC");
			echo "<fieldset><form method=\"post\" action=\"".$PHP_SELF."\">";
			while ($choices = mysql_fetch_array($getchoice1))
			{
				echo "<div class=\"buttondiv\" style=\"text-align: left;\"><input type=\"radio\" value=\"".$choices['id']."\" name=\"choices\" id=\"ch-".$choices['id']."\" />&nbsp;&nbsp;&nbsp;&nbsp;<label for=\"ch-".$choices['id']."\">".$choices['text']."</label></div>";
			}
			echo "<div class=\"buttondiv\"><input type=\"submit\" value=\"Submit\" name=\"pollsubmit\" /></div>
			</form></fieldset><div class=\"buttondiv\"><a href=\"".$REQUEST_URI."".$urlpref."results\">Results</a></div>";
		}
		elseif ($_POST['pollsubmit'] && $voted == "0" && !isset($_GET['results']) && isset($_COOKIE['mid']))
		{
			$pchoiceq = $mysql->select(PRE."poll_choices", "pollid='".$getq['id']."' AND id='".$_POST['choices']."'", "id", "ASC", "1");
			while ($pchoices = mysql_fetch_array($pchoiceq))
			{
				//$choiceid = $pchoices['id'];
				$choice = $_POST['choices'];
				$pone = $pchoices['votes'] + 1;
				$mysql->update(PRE."poll_choices", "votes = votes + 1", "id='".$choice."'");
				$mysql->insert(PRE."poll_votes", array('poll_id', 'ident', 'choice', 'date'), array($getq['id'], $ident, $choice, "NOW()"));
				header("Location: ".$HTTP_REFERER);
			}
			//print_r($_POST);
		} else {
			$totalvotes = 0;
			$getnumvotes = $mysql->select(PRE."poll_choices", "pollid='".$getq['id']."'", "id", "ASC");
			while($votes = mysql_fetch_array($getnumvotes))
			{
				$totalvotes = $totalvotes + $votes['votes'];
			}

			echo ("<div style=\"text-align: center; font-weight:bold;\">$getq[question]</div><br />");
			$getpoll1  = $mysql->select(PRE."poll_choices", "pollid='".$getq['id']."'", "id", "ASC");
			while ($getpoll = mysql_fetch_array($getpoll1))
			{
				@$numvotes = $getpoll['votes'] / $totalvotes;
				$numvotes2 = $numvotes * 100;
				//echo ($getpoll['text']);
				$round = ceil($numvotes2)-5;
				if($round <= "0")
				{
					$round = $round+5;
				}
				echo "<div style=\"text-align: left;\">".$getpoll['text']." (".$getpoll['votes']." votes)</div><div class=\"pollresult\" style=\"width: ".$round."%; \">&nbsp;</div>";
			}
		}
	}
	function latestposts()
	{
		global $mysql;
		$sel = $mysql->select(PRE.'forums_posts', NULL, "id", "DESC");
		for($i=0;$i<5;$i++)
		{
			$a = mysql_fetch_assoc($sel);
			$sel2 = $mysql->select(PRE.'forums_threads', "id='".$a['threadid']."'", "id");
			$b = mysql_fetch_assoc($sel2);
			$sel3 = $mysql->select(PRE.'forums_forums', "id='".$b['forumid']."'", "id");
			$c = mysql_fetch_assoc($sel3);
			if($c['perms'] > "1")
			{
				$i--;
			} else {
				echo '<a href="Forums/Thread/'.$b["id"].'/">'.$b['subject'].'</a> ('.gmdate(DATE.'g:i A', $a["date"]).')<br />';
			}
		}
	}

	function showflooder()
	{
		$show = new flooder();
		$show->show("20");

		if(!isset($_COOKIE['mid']))
		{
			$ret = "<br /><div style=\"text-align: left\">You must be registered to post in the flooder</div>";
		} else {
			$ret = '<div style="text-align:left; ">
			<fieldset>
				<form action="vou-flooder/tagin.php" method="post">
				<div>Message:<br /></div>
				<div><textarea name="message" rows="4" cols="20" id="message"></textarea></div>
				<div><br /></div>
				<div><input type="submit" name="Submit" value="Submit" /></div></form>
			</fieldset>
			</div>';
		}
		return $ret;
	}

	function parsetheme($txt, $theme=DEFAULT_THEME)
	{
		global $mysql, $xajax;
		$ret = preg_replace(
			array(
				"@{IF=(.+)}
				(.+)
				{/IF}@esm",
				"@{CLASS=(.+); FUNCTION=(.+)}@e",
				"@{INCLUDE=(.+)}@e",
				"!{SITE_URL}!",
				"!{THEMEDIR}!",
			),
			array(
				"if(\"\\1\") { echo(\"\\2\"); }",
				"$\\1->\\2();",
				"include('\\1');",
				SITE_URL,
				"themes/".$theme.'/',
			),
				$txt
		);
		return $ret;
	}

	function dotheme()
	{
		$usertheme = getuserinfoid("theme", $_COOKIE['mid']);
		if(empty($usertheme))
		{
			$theme = DEFAULT_THEME;
		} else {
			$theme = $usertheme;
		}
		$file = file(SITE_PATH.'themes/'.$theme.'/setup.vtheme');
		foreach($file as $line)
		{
			$ret = $this->parsetheme($line, $theme);
			echo $ret;
		}
		//print_r($parse);
	}

	function themepart($part)
	{
		$usertheme = getuserinfoid("theme", $_COOKIE['mid']);
		if(empty($usertheme))
		{
			$theme = DEFAULT_THEME;
		} else {
			$theme = $usertheme;
		}
		$file = file("themes/".$theme."/".$part.".tpl");
		foreach($file as $line)
		{
			$ret .= $this->parsetheme($line);
		}
		return $ret;
	}
}
include "flooder.php";
?>
Return current item: Modular Site Manager