<?php
$lcheck = "b";
$z = "b";
global $maintheme;

if (((((((((((($_GET['view'] == "login2") or ($_GET['view'] == "logout") or ($_GET['view'] == "register") or ($_GET['view'] == "register2") or ($_GET['load'] == "comments") or ($_GET['view'] == "results") or ($_GET['load'] == "rss") or ($_GET['poll'] == "yes") or ($_GET['load'] == "logout") or ($_GET['view'] == "blogadd") or ($_GET['view'] == "blogadd2") or ($_GET['load'] == "af")))))))))))) {
} else {
eval (" ?>" . headera() . " <?php ");
echo "<script language='javascript'>
function awindow(towhere, newwinname, properties) {
window.open(towhere,newwinname,properties);
}
</script>";
}

$postponea = @mysql_query("SELECT * FROM ".$pre."content WHERE ver = '1'");
while($po = @mysql_fetch_array($postponea)) {
if ($po[postpone]) {
if (($po[postpone] == date("YmdHi")) or ($po[postpone] < date("YmdHi"))) {
$updatea = @mysql_query("UPDATE ".$pre."content SET ver = '0', postpone = '' WHERE id = '".$po[id]."'");
}
}
}
if ($_GET['view'] == "error") {
echo "<h2>Page not Found</h2>Sorry, but we cannot find the page you were looking for (<i>".$_SERVER['REQUEST_URI']."</i>&nbsp;). Try using our <a href='search.php'>search</a> feature. Thank you!";
}

if ($setting[online] == "No") {
echo "Sorry, but ".$setting[sitename]." is offline.";
} else {
if ($ipbancheck1 == "0") {
if ($numvb == "0"){
if ($setting[warn] == $naum) {
echo "You are banned from the site...now go away!";
} else {

if ($_GET['limit']) {
	$limit = $_GET['limit'];
} else {
	$limit = $setting[max_results];
}

if ($_GET['type']) {
	$type = $_GET['type'];
	$type2 = $_GET['type'];
	$type3 = $_GET['type'];
} else {
	$type = "DESC";
}

if ((!$_GET['type']) && ($template2[0] == "Yes")) {
	$type2 = "ASC";
}

if ((!$_GET['type']) && ($template2[0] == "No")) {
	$type2 = "DESC";
}

if ((!$_GET['type']) && ($template2[1] == "Yes")) {
	$type3 = "ASC";
}

if ((!$_GET['type']) && ($template2[1] == "No")) {
	$type3 = "DESC";
}

if ((!$_GET['by']) && ($template2[1] == "Yes")) {
	$by2 = "name";
}

if ((!$_GET['by']) && ($template2[1] == "No")) {
	$by2 = "id";
}

if ((!$_GET['by']) && ($template2[0] == "Yes")) {
	$by3 = "name";
}

if ((!$_GET['by']) && ($template2[0] == "No")) {
	$by3 = "id";
}

if ($_GET['by']) {
	$by = $_GET['by'];
	$by2 = $_GET['by'];
	$by3 = $_GET['by'];
} else {
	$by = "id";
}
if ($_GET['title']) {
$title = str_replace("-", " ", $_GET['title']);
echo "<title>".$title."</title>";
}

if ($_GET['load'] == "af") {
if ($_GET['view'] == "apply") {
eval (" ?>" . headera() . " <?php ");
echo "<form action='index.php?load=af&view=apply2' method='post'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"left\"><tr><td>Link</td><td><input type='radio' name='type' value='link'></td></tr><tr><td>Button</td><td><input type='radio' name='type' value='button'></td></tr><tr><td><input type='submit' value='Continue'></td></tr></table></form>";
eval (" ?>" . footera() . " <?php ");
}

if ($_GET['view'] == "apply3") {
session_start();
eval (" ?>" . headera() . " <?php ");
if (($_POST['sitename'] == "") or ($_POST['siteurl'] == "")) {
echo "Sorry but the <b>Site Name</b> and/or <b>Site URL</b> field have not been entered with data, please go back and fill in both of those fields.";
} else {

if ($setting[captcha] == Yes) {
session_start();
$salted = $_POST['captcha'];
global $captcha_salt;
if (md5($captcha_salt.$salted) != $_SESSION['captcha']) {
eval (" ?>" . headera() . " <?php ");
echo "Wrong CAPTCHA code entered, please go back and try again.";
echo $captcha_salt;
eval (" ?>" . footera() . " <?php ");
die;
}
}
	if ($_POST['type'] == "link") {
		$apply = mysql_query("INSERT INTO ".$pre."af VALUES ('null', '".$_POST['sitename']."', '".$_POST['siteurl']."', '".$_POST['where']."', 'link', '', '', '', 'no', '".time()."', '0')") or die(mysql_error());

	} else {
		$apply = mysql_query("INSERT INTO ".$pre."af VALUES ('null', '".$_POST['sitename']."', '".$_POST['siteurl']."', '".$_POST['where']."', 'button', '".$_POST['width']."', '".$_POST['height']."', '".$_POST['ss']."', 'no', '".time()."', '0')") or die(mysql_error());

	}
	if ($apply == TRUE) {
	echo "Thank you, ".$setting[sitename]." has received your application and will let you know of there decision on whether to affiliate or not.";
	}
	}
eval (" ?>" . footera() . " <?php ");
}

if ($_GET['view'] == "apply2") {
session_start();

eval (" ?>" . headera() . " <?php ");

	echo "<form action='index.php?load=af&view=apply3' method='post'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\">";
	echo '<tr><td>Site Name</td><td><input type="text" name="sitename"></td></tr><tr><td>Site URL</td><td><input type="text" name="siteurl" value="http://"></td></tr><tr><td>Open link in new window?</td><td><select name="where"><option value="popup">Yes</option><option value="_blank">No</option></select></td></tr>';

	if ($setting[captcha] == Yes) {
	
		$ts = time();
		?>
		<script language="JavaScript"><!--
		ts = <?= $ts ?>;
		--></script>
		<?php

		echo "<tr><td><img id='captcha' src='includes/captcha.php?img=".$ts."'></td></tr><tr><td>* Displayed Code?</td><td><input type='text' name='captcha'><a href=\"no_matter\" onclick=\"document.getElementById('captcha').src = 'includes/captcha.php?img=' + ++ts; return false\"> New CAPTCHA</a></td></tr>";
	}

	if ($_POST['type'] == "link") {
	echo '<input type="hidden" name="type" value="link"><tr><td><input type="submit" name="submit" value="Proceed"></td></tr>';
	} else {
		echo '<input type="hidden" name="type" value="button"><tr><td>Width of Button</td><td><input type="text" name="width" value="88"></td></tr><tr><td>Height of Button</td><td><input type="text" name="height" value="31"></td></tr><tr><td><i>Or...</i> Provide the URL of the button here</td><td><input type="text" name="ss" value="http://"></td></tr>';
	echo '<tr><td><input type="submit" value="Apply"></td></tr></table></form>';
	}
eval (" ?>" . footera() . " <?php ");
}

if ($_GET['view'] == "") {
eval (" ?>" . headera() . " <?php ");
$tempaf = mysql_query("SELECT * FROM ".$pre."templates WHERE name = 'AF Manager'");
while($row2 = mysql_fetch_array($tempaf)) {
	$aftemp = stripslashes($row2[template]);
}

$afm[0] = "{affiliate}";
$afm[1] = "{date}";

if ($_GET['limit'] == "") {
$afea = mysql_query("SELECT * FROM ".$pre."af WHERE verified = 'yes' ORDER BY `id` DESC");
} else {
$afea = mysql_query("SELECT * FROM ".$pre."af WHERE verified = 'yes' ORDER BY `id` DESC LIMIT ".$_GET['limit']);
}
while($row = mysql_fetch_array($afea)) {

if ($row[type] == "link") {
$afr[0] = "<a href='index.php?load=af&view=click&id=".$row[id]."' target='".$row[where2]."'>".$row[sitename]."</a>";

} else {

$filename = $setting[images]."/".$row[ss];

$page = @file_get_contents($filename);

if (!$page == NULL) {
$afr[0] = "<a href='index.php?load=af&view=click&id=".$row[id]."' target='".$row[where2]."'><img src='".$setting[images]."/".$row[ss]."' width='".$row[width]."' height='".$row[height]."'></a>";
} else {
$afr[0] = "<a href='index.php?load=af&view=click&id=".$row[id]."' target='".$row[where2]."'><img src='".$row[ss]."' width='".$row[width]."' height='".$row[height]."'></a>";
}
}
$afr[1] = date($setting[dformat], $row['date']);

echo str_replace($afm, $afr, $aftemp);
}
echo "<br><center>[ <a href='".$af_apply."'><b>Apply for Affiliation</b></a> ]</center>";
eval (" ?>" . footera() . " <?php ");
}

if ($_GET['view'] == "click") {
$sql = mysql_query("SELECT siteurl,clicks FROM ".$pre."af WHERE id = '".$_GET['id']."'");
$fetch = mysql_fetch_row($sql);

if ($fetch[1] == "") {
$clicks = 1;
} else {
$clicks = $fetch[1] + 1;
}

mysql_query("UPDATE ".$pre."af SET clicks = '".$clicks."' WHERE id = '".$_GET['id']."'");

header("location: ".$fetch[0]);
}
}

if ($_GET['load'] == "members") {
if ($_GET['view'] == "register2") {
session_start();
if (($_COOKIE[$pre."username"]) && ($_COOKIE[$pre."password"])) {
eval (" ?>" . headera() . " <?php ");
echo "Umm you already have an account";
die;
} else {

global $setting;

if ($setting[captcha] == Yes) {
session_start();
$salted = $_POST['captcha'];
global $captcha_salt;
if (md5($captcha_salt.$salted) != $_SESSION['captcha']) {
eval (" ?>" . headera() . " <?php ");
echo "Wrong code entered, go back and try again";
echo $captcha_salt;
eval (" ?>" . footera() . " <?php ");
die;
}
}

	$query4 = mysql_query("SELECT * FROM ".$pre."users WHERE username = '".check($_POST["user"])."'") or die(mysql_error());
    $check = mysql_num_rows($query4);
	if ($check > "0") {
	echo "Sorry, but the username <i>".$_POST["user"]."</i>, is already in use. Please go back and <a href='index.php?load=members&view=register'>choose another username</a>";
	} else {

if ($_POST['passwordc'] == "") {
echo "Sorry, but you did not provide a password. Please go back and <a href='index.php?load=members&view=register'>try again</a>";
} else {

$passk = check(md5($salt.$_POST["passwordc"]));
$userk = check(stripslashes($_POST['user']));

if (checkemail($_POST['email']) == TRUE) {

if ($setting[captcha] == Yes) {
session_start();
$salted = $_POST['captcha'];
global $captcha_salt;
if (md5($captcha_salt.$salted) != $_SESSION['captcha']) {
eval (" ?>" . headera() . " <?php ");
echo "Wrong CAPTCHA code entered, please go back and try again.";
echo $captcha_salt;
eval (" ?>" . footera() . " <?php ");
die;
}
}
if ($_POST['referral']) {
mysql_query("INSERT INTO ".$pre."points VALUES ('null', '".$_POST['referral']."', 'referral', '".$ref."', '".time()."')");
}

$registera1 = "INSERT INTO ".$pre."permissions VALUES ('null', '".$userk."', 'yes', 'no'";

	$catq = mysql_query("SELECT * FROM ".$pre."cat");
	while($row = mysql_fetch_array($catq)) {
		$registera1 .= ", 'no'";
	}
	$registera1 .= ")";

$register1 = mysql_query($registera1);

$register = "INSERT INTO ".$pre."users VALUES ('null', '".$userk."', '$passk', '".$_POST["email"]."'";

$levelh = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."userlevels WHERE level = '6' ORDER BY `id` DESC LIMIT 1"));
$rank = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."ranks WHERE points = '0' ORDER BY `points` DESC"));

$register .= ", '".$levelh[0]."', '".$rank[0]."', '0', 'no', 'no', '', '8', '3', '')";
$register3p = "INSERT INTO ".$pre."profile VALUES ('null', '".$userk."', '', '', '', '', '', '', '', '', '', '', ''";

$query = mysql_query("SELECT * FROM ".$pre."fields WHERE cat = 'users' ORDER BY `id` DESC");
while($row = mysql_fetch_array($query)) {
	$register3p .= ", ''";
}

$register3p .= ")";

mysql_query($register3p);
$register2 = mysql_query($register) or die(mysql_error());

if ($_POST['autologin']) {
if ($dcheck == "yes") {
setcookie($pre."username", $userk, time()+24*3600*30, "/", ".".$domain);
setcookie($pre."password", $passk, time()+24*3600*30, "/", ".".$domain);
setcookie($pre."login_date", time(), time()+24*3600*30, "/", ".".$domain);
} else {
setcookie($pre."username", $userk, time()+24*3600*30);
setcookie($pre."password", $passk, time()+24*3600*30);
setcookie($pre."login_date", time(), time()+24*3600*30);
}
}
}
}
if (($register2 == TRUE) && ($register1 == TRUE)) {
eval (" ?>" . headera() . " <?php ");
echo "Registration successfull! - <a href='".$_POST['url']."'>Return to where you were</a><br>";
} else {
eval (" ?>" . headera() . " <?php ");
echo "Sorry but that email is not valid<br>";
}
}
}
}

if (($_GET['view'] == "logout") && ($_COOKIE[$pre."username"])) {
mysql_query("UPDATE ".$pre."users SET logged = '0' WHERE username = '".$_COOKIE[$pre."username"]."'") or die(mysql_error());

if ($dcheck == "yes") {
setcookie($pre."username", "", ""-24*3600*30, "/", ".".$domain);
setcookie($pre."password", "", ""-24*3600*30, "/", ".".$domain);
setcookie($pre."login_date", "", ""-24*3600*30, "/", ".".$domain);
} else {
setcookie($pre."username", "", ""-24*3600*30);
setcookie($pre."password", "", ""-24*3600*30);
setcookie($pre."login_date", "", ""-24*3600*30);
}

eval (" ?>" . headera() . " <?php ");
echo re_direct("1000", "index.php");
echo "You are now logged out.";
}

if ($_GET['view'] == "login2") {
$loginuser = check(stripslashes($_POST['username']));
$loginpass = check(md5($salt.stripslashes($_POST['password'])));
$url = stripslashes($_POST['url']);

$sql2 = sprintf("SELECT * FROM ".$pre."users WHERE username = '%s' AND password = '%s'",
mysql_real_escape_string($loginuser),
mysql_real_escape_string($loginpass));
$login_check = mysql_num_rows(mysql_query($sql2));

if ($login_check == "1") {

if ($dcheck == "yes") {
setcookie($pre."username", $loginuser, time()+24*3600*30, "/", ".".$domain);
setcookie($pre."password", $loginpass, time()+24*3600*30, "/", ".".$domain);
setcookie($pre."login_date", time(), time()+24*3600*30, "/", ".".$domain);
} else {
setcookie($pre."username", $loginuser, time()+24*3600*30);
setcookie($pre."password", $loginpass, time()+24*3600*30);
setcookie($pre."login_date", time(), time()+24*3600*30);
}

$update = sprintf("UPDATE ".$pre."users SET logged = '".time()."' WHERE username = '%s' AND password = '%s'",
mysql_real_escape_string($_COOKIE[$pre."username"]),
mysql_real_escape_string($_COOKIE[$pre."password"]));
mysql_query($updatet);

eval (" ?>" . headera() . " <?php ");
echo "Login Successful! Welcome back ".$loginuser.". Continue to where you were...<a href='".$url."'><b>Continue</b></a>";

} else {
eval (" ?>" . headera() . " <?php ");

mysql_query("UPDATE ".$pre."users SET logged = '0' WHERE username = '".$loginuser."'") or die(mysql_error());

echo "Sorry, but your login info is incorrect. Please <b>go back</b> and try again.";
}
}

if ($_GET['view'] == "register") {
if (($_COOKIE[$pre."username"]) && ($_COOKIE[$pre."password"])) {
eval (" ?>" . headera() . " <?php ");
echo "Umm you already have an account";
die;
} else {
include ("includes/sajax.php");

sajax_init(); // Intialize Sajax
//$sajax_debug_mode = 1; //Uncomment to put Sajax in debug mode
sajax_export("check_user_exist"); // Register the function
sajax_handle_client_request(); // Serve client instances
?>
<script type="text/javascript">
    <?php
    sajax_show_javascript();
    ?>
    function check_handle(result) {
        if(result[0] == 'yes') {
            document.getElementById('not_available').style.display = 'none';
            document.getElementById('available').style.display = 'block';
        }
        else {
            document.getElementById('available').style.display = 'none';
            document.getElementById('not_available').style.display = 'block';
            var str = 'Sorry that username is not available try these <br />';
            for(i = 1; i < result[1]; i++) {
                str += "<input type=\"radio\" name=\"try\" onclick=\"switch_username('"+result[i+1]+"')\"/>" + result[i+1] + "<br />";
            }
            document.getElementById('not_available').innerHTML = str;
        }
    }

    function check_user_exist() {
        var user = document.getElementById('user').value;
        x_check_user_exist(user, check_handle);
		//document.write('</form>');
    }

        function switch_username(user) {
        document.getElementById('user').value = user;
    }
</script>

<style type="text/css">
    @import url( test.css );
	#available {
		display: none;
		color: green;
	}
	#not_available {
		display: none;
		color: red;
	}
</style>
<?php
if (empty($_GET['session_code'])) {
$session_code = md5(round(rand(0,40000)));
} else {
$session_code=$_GET['session_code'];
}

eval (" ?>" . headera() . " <?php ");
echo "<div id='register' name='register' class='noshow'><form action='index.php?load=members&view=register2&session_code=".$session_code."' method='post' onSubmit='return true'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\">";

?>
<tr><td><textarea name='terms' readonly cols='58' rows='7'><?php include("includes/tou.php"); ?></textarea></tr></td><br><br/>
<?php

echo "<input type='hidden' name='url' value='".$_SERVER['HTTP_REFERER']."'><tr><td>* Username</td><td><input type='text' name='user' id='user'></td></tr><tr><td>* Password</td><td><input type='password' name='passwordc'></td></tr><tr><td>* E-mail</td><td><input type='text' name='email'></td></tr>";
if ($setting[referral] == "yes") {
echo "<tr><td>&nbsp;&nbsp;&nbsp;Referral</td><td><select size='5' name='referral' multiple><option value=''>-------</option>";
echo users("");
echo "</select></td></tr>";
}
if ($setting[captcha] == Yes) {
$ts = time();
?>
<script language="JavaScript"><!--
ts = <?= $ts ?>;
--></script>
<?php

echo "<tr><td><img id='captcha' src='includes/captcha.php?img=".$ts."'></td></tr><tr><td>* Displayed Code?</td><td><input type='text' name='captcha'><a href=\"no_matter\" onclick=\"document.getElementById('captcha').src = 'includes/captcha.php?img=' + ++ts; return false\"> New CAPTCHA</a></td></tr><br><br/>";
}

echo "<tr><td>By proceeding you agree to the above terms of use</tr><td>";

echo "<tr><td><input type='checkbox' name='autologin' checked>Log me in</td><td><input type='button' value='Check' onclick='check_user_exist(); return false;'>&nbsp;&nbsp;<input type='submit' value='Sign Up'></td></tr></table></form></div>";
}
}

if ($_GET['view'] == "login") {
if (($_COOKIE[$pre."username"]) && ($_COOKIE[$pre."password"])) {
echo "Umm you are already logged in";
die;
} else {
echo '<form action="index.php?load=members&view=login2" method="post"><table cellpadding="2" cellspacing="0" border="0"><tr><td>Username:</td><td><input type="text" name="username" size="10"></td><tr><td>Password:</td><td><input type="password" name="password" size="10"></td></tr><tr><td><a href="forgotpw.php">Lost Password?</a></td></tr>';
echo 'Trouble logging in? A new password security system was implemented, old passwords must be reset, please follow the link above to do so.';
echo '<tr><td><input type="submit" name="submit" value="Log In"></td></tr></table>';
echo "<input type='hidden' name='url' value='".$_SERVER['HTTP_REFERER']."'></form>";
}
}

if ($_GET['view'] == "list") {
echo "<table cellpadding='5' cellspacing='0' border='0' width='98%' align='center'><tr><td><b>Username</b></td><td><b>E-Mail</b></td><td><b>Level</b></td><td><b>Rank</b></td></tr>";
$res = "SELECT * FROM ".$pre."users";
if ($_GET['rank']) {
$res .= " WHERE rank = '".$_GET['rank']."'";
}
$res .= " ORDER BY `id` DESC";
$query = mysql_query($res);
while($row = mysql_fetch_array($query)) {
echo "<tr><td>";

$query2 = mysql_query("SELECT id FROM ".$pre."profile WHERE username = '$row[username]'");
$pn1 = mysql_fetch_row($query2);
$pn2 = mysql_num_rows($query2);

$s = mysql_fetch_row(mysql_query("SELECT color FROM ".$pre."ranks WHERE name = '".$row[rank]."'"));

$pn = $pn2;
$pid = $pn1[0];
if ($pn == "") {
	echo "$row[username]";
} else {
	echo "<a href='index.php?load=elite&user=".$pn1[0]."'>$row[username]</a>";
}
	echo "</td><td><a href='mailto:".$row[email]."'>$row[email]</a></td><td>$row[level]</td><td><a href='boards.php?t=rankslist'><font color='".$s[0]."'>".$row[rank]."</font></a></td></tr>";
}
echo "</table>";
}

$ou = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."boardcp WHERE uid = '".$useridn."'"));
if (($ou > "0") && ($useridn)) {
if ($_GET['view'] == "warnuser") {
eval (" ?>" . headera() . " <?php ");

echo "<SCRIPT LANGUAGE='JavaScript'>var agree=confirm('Confirm warning of ".$_GET['user']."?');if (agree)document.write('');elsehistory.go(-1);</SCRIPT>";

$new_warn = $_GET['warn'] + 1;
mysql_query("UPDATE ".$pre."users SET warn = '".$new_warn."' WHERE username = '".$_GET['user']."'");

echo re_direct("1500", $_SERVER['HTTP_REFERER']);
echo "<b>".$_GET['user']."</b> has been warned. Taking you back to the previous page";
}

if ($_GET['view'] == "banuser") {
echo "<SCRIPT LANGUAGE='JavaScript'>var agree=confirm('Confirm ";
if ($_GET['type'] == "no") {
echo "un-";
}
echo "ban of ".$_GET['user']."?');if (agree)document.write('');elsehistory.go(-1);</SCRIPT>";

mysql_query("UPDATE ".$pre."users SET bansite = '".$_GET['type']."' WHERE username = '".$_GET['user']."'");

echo re_direct("1500", $_SERVER['HTTP_REFERER']);
echo "<b>".$_GET['user']."</b> has been ";
if ($_GET['type'] == "no") {
echo "unbanned";
} else {
echo "banned";
}
echo ". Taking you back to the previous page";
}
}

if ($_GET['view'] == "changepass") {
if ($_COOKIE[$pre."username"] == "") {
echo "Sorry, but you need to <a href='index.php?load=members&view=login&step=1'><b>login</b></a> or <a href='index.php?load=members&view=register'><b>register</b></a>";
} else {
echo "<form action='index.php?load=members&view=changepass2' method='post'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>New Password</b></td><td><input type='password' name='pass'></td></tr><tr><td><b>Confirm New Password</b></td><td><input type='password' name='pass2'></td></tr><tr><td><input type='submit' value='Change Password'></td></tr></table></form>";
}
}

if ($_GET['view'] == "changepass2") {
if ($_COOKIE[$pre."username"] == "") {
echo "Sorry, but you need to <a href='index.php?load=members&view=login'><b>login</b></a> or <a href='index.php?load=members&view=register'><b>register</b></a>";
die;
} else {
if ($_POST['pass'] == $_POST['pass2']) {
$sql = mysql_query("UPDATE ".$pre."users SET password = '".md5($salt.$_POST['pass'])."' WHERE username = '".$_COOKIE[$pre."username"]."'");

if ($sql == TRUE) {
eval (" ?>" . headera() . " <?php ");
echo "Congratulations, you have successfully changed your password to: <b>".$_POST['pass']."</b>";
}
} else {
echo "Passwords do not match. Go back and try again.";
}
}
}

if ($_GET['view'] == "profile") {
if ($_COOKIE[$pre."username"] == "") {
echo "<SCRIPT LANGUAGE=\"JavaScript\">

<!-- Begin
redirTime = \"1\";
redirURL = \"index.php?load=members&view=login&url=".$HTTP_SERVER_VARS['REQUEST_URI']."\";
function redirTimer() { self.setTimeout(\"self.location.href = redirURL;\",redirTime); }
//  End -->
</script>

<BODY onLoad=\"redirTimer()\">";
   }
// AUTH END
	if ($_GET['id'] == "") {
	if ((!$_POST['submit']) && ($_COOKIE[$pre."username"])) {
	$query="SELECT * FROM ".$pre."profile WHERE username = '".$_COOKIE[$pre."username"]."'";
	$result=mysql_query($query);
	while($row = mysql_fetch_array($result)) {
		$aim = stripslashes($row[aim]);
		$msn = stripslashes($row[msn]);
		$website = stripslashes($row[website]);
		$nickname = stripslashes($row[nickname]);
		$location = stripslashes($row[location]);
		$sig = stripslashes($row[sig]);
		$avatar = stripslashes($row[avatar]);
	
		echo "<center><a href='".$elite1.$_COOKIE[$pre."username"].$elite2."'>View Profile</a><br><a href='index.php?load=members&view=changepass'>Change Password</a></center><br><form action='index.php?load=members&view=profile' method='post'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>AIM</b></td><td><input type='text' name='aim' value='".$aim."'></td></tr><tr><td><b>MSN</b></td><td><input type='text' name='msn' value='".$msn."'></td></tr><tr><td><b>Website</b></td><td><input type='text' name='website' value='".$website."'></td></tr><tr><td><b>Nickname</b></td><td><input type='text' name='nickname' value='".$nickname."'></td></tr><tr><td><b>Location</b></td><td><input type='text' name='location' value='".$location."'></td></tr><tr><td><b>Avatar</b></td><td><input type='text' name='avatar' value='".$avatar."' size='36'></td><td>";
		if ($avatar) {
		echo "<script language='javascript'>function awindow(towhere, newwinname, properties) {window.open(towhere,newwinname,properties);}</script>";
		
		list($widtha, $heighta) = getimagesize($avatar);

		$heighta2 = $heighta + 16;
		$widtha2 = $widtha + 16;

		echo "<a href='javascript:awindow(\"".$avatar."\", \"\", \"width=".$widtha2.",height=".$heighta2.",scroll=yes\")'>Current Avatar</a>";
		}
		echo "</td></tr><tr><td><b>Signature</b></td><td><textarea name='sig' cols='33' rows='12'>".$sig."</textarea></td></tr>";

	$query2 = "SELECT * FROM ".$pre."fields WHERE cat = 'users' ORDER BY `id`";
	$result2 = mysql_query($query2);
	while($row2 = mysql_fetch_array($result2)) {
		$name = "$row2[name]";

		echo "<tr><td><b>".$name;
		if ($row2[des]) {
			echo " <a href='javascript:awindow(\"a_a_help.php?id=$row2[id]\", \"\", \"width=200,height=200,scroll=yes\")'><b>?</b></a>";
		}
		
		if ($row2[type] == "textarea") {
			echo "</td><td><textarea name='$name' cols=\"40\" rows=\"16\">".$row["$name"]."</textarea></td></tr>";
		} else {
			echo "</td><td><input type=\"text\" name='$name' value='".$row["$name"]."'></td></tr>";
		}
	}
	}
	echo "<tr><td><input type='submit' value='Submit Changes'></td></tr></table></form>";
		}
	if ($_POST['submit']) {
	$query = mysql_query("SELECT * FROM ".$pre."profile WHERE username = '".$_COOKIE[$pre."username"]."'");
	$rows = mysql_num_rows($query);

	if ($rows == "1") {

	$_POST["sig"] = addslashes($_POST["sig"]);

    $edit2 = "UPDATE ".$pre."profile SET aim = '".$_POST["aim"]."', msn = '".$_POST["msn"]."', website = '".$_POST["website"]."', nickname = '".$_POST["nickname"]."', location = '".$_POST["location"]."', sig = '".$_POST["sig"]."', avatar = '".$_POST["avatar"]."'";
	
	$query = mysql_query("SELECT * FROM ".$pre."fields WHERE cat = 'users' ORDER BY `id`") or die(mysql_error());
	while($row = mysql_fetch_array($query)) {
		$name = "$row[name]";
		$_POST["$name"] = addslashes($_POST["$name"]);
		if ($_POST["$name"]) {
		$edit2 .= ", ".$name." = '".$_POST["$name"]."'";
		}
	}
	
	$edit2 .= " WHERE username = '".$_COOKIE[$pre."username"]."'";

    $edit = mysql_query($edit2) or die(mysql_error());
	} else {
    $edit2 = "INSERT INTO ".$pre."profile VALUES ('null', '".$_COOKIE[$pre."username"]."', '".$_POST["aim"]."', '".$_POST["msn"]."', '".$_POST["website"]."', '".$_POST["nickname"]."', '".$_POST["location"]."', '".$_POST["sig"]."', '".$_POST["avatar"]."'";

	   		$query = mysql_query("SELECT * FROM ".$pre."fields WHERE cat = 'users' ORDER BY `id`") or die(mysql_error());
	while($row = mysql_fetch_array($query)) {
		$name = "$row[name]";
		$_POST["$name"] = addslashes($_POST["$name"]);
		if ($_POST["$name"] == "") {
		$edit2 .= ", ''";
		} else {
		$edit2 .= ", '".$_POST["$name"]."'";
		}
	}
$edit2 .= ")";

	$edit = mysql_query($edit2) or die(mysql_error());
	}
   if ($edit == TRUE) {
   echo "Your profile has been updated. Click <a href='index.php?load=members&view=profile'>here</a> to return back.";
   }
   }

   } else {

}
}

if ($_GET['view'] == "profile") {
if (($_GET['other'] == "posts") && ($_GET['id'])) {
	echo "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Subject</b></td><td><b>Date Posted</b></td><td><b>Forum Posted at</b></td>";

	$query="SELECT * FROM ".$pre."posts WHERE uid = '".$_GET['id']."' AND type = 'post'";
	$result=mysql_query($query);
	while($row = mysql_fetch_array($result)) {

		$qur = mysql_query("SELECT name FROM ".$pre."forums WHERE id = '".$row[fid]."'");
		$fet = mysql_fetch_row($qur);
		echo "<tr><td><a href='".$f2part1.$row[tid].$f2part2."#".$row[id]."'>".$row[subject]."</a></td><td>".date($setting[dformat], $row[date])."</td><td><a href='".$f1part1.$row[fid].$f1part2."'><b>".$fet[0]."</b></a></td></tr>";
	}
	$qur2 = mysql_query("SELECT username FROM ".$pre."profile WHERE id = '".$_GET['id']."'");
	$fet2 = mysql_fetch_row($qur2);

	echo "<tr><td><br><center><a href='index.php?load=elite&user=".$_GET['id']."'>[ <b>Back to ".$fet2[0]."'s profile</b> ]</a></center></td></tr></table>";
}

if (($_GET['other'] == "topics") && ($_GET['id'])) {
	echo "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Subject</b></td><td><b>Date Posted</b></td><td><b>Forum Posted at</b></td>";

	$query="SELECT * FROM ".$pre."posts WHERE uid = '".$_GET['id']."' AND type = 'topic'";
	$result=mysql_query($query);
	while($row = mysql_fetch_array($result)) {

		$qur = mysql_query("SELECT name FROM ".$pre."forums WHERE id = '".$row[fid]."'");
		$fet = mysql_fetch_row($qur);
		echo "<tr><td><a href='".$f2part1.$row[id].$f2part2."'>".$row[subject]."</a></td><td>".date($setting[dformat], $row[date])."</td><td><a href='".$f1part1.$row[fid].$f1part2."'><b>".$fet[0]."</b></a></td></tr>";
	}

	$qur2 = mysql_query("SELECT username FROM ".$pre."profile WHERE id = '".$_GET['id']."'");
	$fet2 = mysql_fetch_row($qur2);

	echo "<tr><td><br><center><a href='index.php?load=elite&user=".$_GET['id']."'>[ <b>Back to ".$fet2[0]."'s profile</b> ]</a></center></td></tr></table>";
}
}

eval (" ?>" . footera() . " <?php ");
}

if ($_GET['load'] == "pm") {
if ($_GET['box'] == "report") {
$result2 = mysql_query("SELECT * FROM ".$pre."pm WHERE jo = '".$_COOKIE[$pre."username"]."' AND box = 'report'") or die(mysql_error());
$num2 = mysql_num_rows($result2);
} else {
$result2 = mysql_query("SELECT * FROM ".$pre."pm WHERE jo = '".$_COOKIE[$pre."username"]."' AND box = 'inbox'") or die(mysql_error());
$num2 = mysql_num_rows($result2);
}

	$per = $num2/$setting[max_pm];

	echo "<script language='javascript'>function awindow(towhere, newwinname, properties) {window.open(towhere,newwinname,properties);}</script>";
	
	echo "<table cellpadding='5' align='center' cellspacing='0' border='0' width='98%' style='border:1px solid ".$fbcolor1."'><tr bgcolor='".$fbgcolor1."'>";
	
	echo "<td align='center'><a href='index.php?load=pm&box=in'>Inbox</a></td><td align='center'><a href='index.php?load=pm&box=sent'>Sentbox</a></td><td align='center'><a href='index.php?load=pm&box=tracked'>Tracked</a></td><td align='center'><a href='index.php?load=pm&new=msg'>Compose Message</a></td>";
	
	$sql = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."boardcp WHERE level = 'global' OR level = 'admin' OR level = 'mod'"));

	if ($sql > "0") {
	echo "<td align='center'><a href='index.php?load=pm&box=report'><b>Reportbox</b></a></td>";
	}
	
	echo "</tr></table><br><br>";

if (((($_GET['box'] == "tracked") && ($_GET['del'] == "") && ($_GET['msg'] == "") && ($_GET['confirm'] == "")))) {

	echo "<center><b>$num2</b> Messages/<b>$setting[max_pm]</b> Allowed | $per%</center><br><form action='index.php?load=pm&del=yes' name='form1' method='post'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Subject</b></td><td><b>From</b></td><td><b>Date</b></td><td><b>Delete?</b></td></tr>";

$query = mysql_query("SELECT * FROM ".$pre."pm WHERE jo = '".$_COOKIE[$pre."username"]."' AND box = 'tracked' ORDER BY `date` DESC");
while($row = mysql_fetch_array($query)) {
		 $id = "$row[id]";
		 $viewed = "$row[viewed]";
		 $subject = "$row[subject]";
		 $date = "$row[date]";
		 $to = "$row[jo]";
		 $userguy = "$row[who]";

		 echo "<tr><td><a href=\"index.php?load=pm&msg=$id\">";
		 if ($viewed == "0") {
			 echo "$subject";
		 } else {
			 echo "<b><i>$subject</b></i>";
		 }
		 echo "</a></td><td>$userguy</td><td>".date($setting[dformat], $date)."</td><td><input type=\"checkbox\" name=\"delete[]\" value=\"$id\"></td></tr>";
	}
echo "<tr><td><input type='submit' value='Delete'></td><td><input type='button' onclick='check(true);' value='Check All'></td><td><input type='button' onclick='check(false);' value='Uncheck All'></td></tr></table>";
}

if (((($_GET['box'] == "report") && ($_GET['del'] == "") && ($_GET['msg'] == "") && ($_GET['confirm'] == "")))) {

	echo "<center><b>$num2</b> Messages/<b>$setting[max_pm]</b> Allowed | $per%</center><br><form action='index.php?load=pm&del=yes' name='form1' method='post'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Subject</b></td><td><b>From</b></td><td><b>Date</b></td><td><b>Delete?</b></td></tr>";

$query = mysql_query("SELECT * FROM ".$pre."pm WHERE jo = '".$_COOKIE[$pre."username"]."' AND box = 'report' ORDER BY `date` DESC");
while($row = mysql_fetch_array($query)) {
		 $id = "$row[id]";
		 $viewed = "$row[viewed]";
		 $subject = "$row[subject]";
		 $date = "$row[date]";
		 $to = "$row[jo]";
		 $userguy = "$row[who]";

		 echo "<tr><td><a href=\"index.php?load=pm&msg=$id\">";
		 if ($viewed == "0") {
			 echo "$subject";
		 } else {
			 echo "<b><i>$subject</b></i>";
		 }
		 echo "</a></td><td>$userguy</td><td>".date($setting[dformat], $date)."</td><td><input type=\"checkbox\" name=\"delete[]\" value=\"$id\"></td></tr>";
	}
echo "<tr><td><input type='submit' value='Delete'></td><td><input type='button' onclick='check(true);' value='Check All'></td><td><input type='button' onclick='check(false);' value='Uncheck All'></td></tr></table>";
}

if ((((($_GET['box'] == "in") && ($_GET['del'] == "") && ($_GET['msg'] == "") && ($_GET['confirm'] == "") or ($_GET['box'] == ""))))) {

	echo "<center><b>$num2</b> Messages/<b>$setting[max_pm]</b> Allowed | $per%</center><br><form action='index.php?load=pm&del=yes' name='form1' method='post'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Subject</b></td><td><b>From</b></td><td><b>Date</b></td><td><b>Delete?</b></td></tr>";

$query = mysql_query("SELECT * FROM ".$pre."pm WHERE jo = '".$_COOKIE[$pre."username"]."' AND box = 'inbox' ORDER BY `date` DESC");
while($row = mysql_fetch_array($query)) {
		 $id = "$row[id]";
		 $viewed = "$row[viewed]";
		 $subject = "$row[subject]";
		 $date = "$row[date]";
		 $to = "$row[jo]";
		 $userguy = "$row[who]";

		 echo "<tr><td><a href=\"index.php?load=pm&msg=$id\">";
		 if ($viewed == "0") {
			 echo "$subject";
		 } else {
			 echo "<b><i>$subject</b></i>";
		 }
		 echo "</a></td><td>$userguy</td><td>".date($setting[dformat], $date)."</td><td><input type=\"checkbox\" name=\"delete[]\" value=\"$id\"></td></tr>";
	}
echo "<tr><td><input type='submit' value='Delete'></td><td><input type='button' onclick='check(true);' value='Check All'></td><td><input type='button' onclick='check(false);' value='Uncheck All'></td></tr></table>";
}

if (($_GET['box'] == "") && ($_GET['del'] == "") && ($_GET['confirm'] == "") && ($_GET['new'] == "")) {

    $id = $_GET['msg'];
	$row = mysql_fetch_row(mysql_query("SELECT who,message,date,subject,jo FROM ".$pre."pm WHERE id = '".$id."'"));
	$from = $row[0];
	$message = stripslashes($row[1]);
	$date = $row[2];
	$subject = $row[3];
	$jo = $row[4];

	echo "<title>".$setting[sitename]." > Inbox > $subject</title>";

	echo "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\" width=\"98%\" style='border:1px solid ".$fbcolor1."'><tr bgcolor='".$fbgcolor2."'><td><b>Subject:</b></td><td>$subject</td></tr><tr bgcolor='".$fbgcolor1."'><td><b>";

	$row1 = mysql_fetch_row(mysql_query("SELECT jo FROM ".$pre."pm WHERE id = '$id'"));
	$jo = $row1[0];

	if ($jo == $_COOKIE[$pre."username"]) {
	mysql_query("UPDATE ".$pre."pm SET viewed = '0' WHERE id = '$id'");
	$uid = mysql_fetch_row(mysql_query("SELECT id FROM ".$pre."profile WHERE username = '".$from."'"));
	echo "From:</b></td><td><a href='index.php?load=elite&user=".$uid[0]."'><b>$from</b></a>";
	} else {
    $uid = mysql_fetch_row(mysql_query("SELECT id FROM ".$pre."profile WHERE username = '".$jo."'"));
	echo "To:</b></td><td><a href='index.php?load=elite&user=".$uid[0]."'><b>$jo</b></a>";
	}

	echo " at <i>".date($setting[dformat], $date)."</i></td></tr><tr bgcolor='".$fbgcolor3."'><td><b>Message:</b></td><td>$message</td></tr></table><br>";
	
	echo "<table cellpadding='5' align='center' cellspacing='0' border='0' width='98%' style='border:1px solid ".$fbcolor1."'><tr bgcolor='".$fbgcolor2."'>";

	if ($jo == $_COOKIE[$pre."username"]) {
	  echo "<td><a href=\"index.php?load=pm&del=".$id."\"><img src='a_images/delete.jpg' style='border:1px solid black'></a></td><td align='right'><a href=\"index.php?load=pm&new=reply&id=".$id."\"><img src='a_images/reply.jpg' style='border:1px solid black'></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='index.php?load=pm&new=msg'><img src='a_images/pm.jpg' style='border:1px solid black'></a></td></tr></table>";
	} else {
	  echo "<td><a href=\"index.php?load=pm&box=in\">Go to Inbox</a></td></tr></table>";
	}
}

if ((((($_GET['del'] == "yes") && ($_GET['msg'] == "") && ($_GET['box'] == "") && ($_GET['confirm'] == "") && ($_GET['new'] == ""))))) {

echo "<title>".$setting[sitename]." > Inbox > Delete Message (s)</title>";

echo '<SCRIPT LANGUAGE="JavaScript">
var agree=confirm("Confirm Deletion?");
if (agree)
document.write("");
else
history.go(-1);
// End -->
</SCRIPT>';

while (list(, $val) = each ($_POST['delete'])) {
$delete = mysql_query("DELETE FROM ".$pre."pm WHERE id = '$val'");
}
if ($delete == TRUE) {
echo "Message(s) have been deleted. <a href='index.php?load=pm&box=in'>Return to Inbox</a>";
}
}

if (((($_GET['msg'] == "") && ($_GET['box'] == "") && ($_GET['confirm'] == "") && ($_GET['new'] == "")))) {
if ($_GET['del'] == "yes") {
} else {
echo "<title>".$setting[sitename]." > Inbox > Delete Message</title>";

echo '<SCRIPT LANGUAGE="JavaScript">
var agree=confirm("Confirm Deletion?");
if (agree)
document.write("");
else
history.go(-1);
// End -->
</SCRIPT>';

$delete = mysql_query("DELETE FROM ".$pre."pm WHERE id = '".$_GET['del']."'");

if ($delete == TRUE) {
echo "Message has been deleted. <a href='index.php?load=pm&box=in'>Return to Inbox</a>";
}
}
}
if (($_GET['box'] == "sent") && ($_GET['del'] == "") && ($_GET['msg'] == "") && ($_GET['confirm'] == "") && ($_GET['new'] == "")) {

	echo "<title>".$setting[sitename]." > Sentbox</title>";

	echo "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Subject</b></td><td><b>To</b></td><td><b>Date</b></td></tr>";

$query="SELECT * FROM ".$pre."pm WHERE who = '".$_COOKIE[$pre."username"]."' ORDER BY `id` DESC";
	$result=mysql_query($query);
	while($row = mysql_fetch_array($result)) {
		 $id = "$row[id]";
		 $viewed = "$row[viewed]";
		 $subject = "$row[subject]";
		 $date = "$row[date]";
		 $to = "$row[jo]";
		 $userguy = "$row[jo]";

		 echo "<tr><td><a href=\"index.php?load=pm&msg=$id\">$subject</a></td><td>$userguy</td><td>".date($setting[dformat], $date)."</td></tr>";
	}

echo "<tr><td><a href=\"index.php?load=pm&box=in\">Inbox</a></td><td><a href=\"index.php?load=pm&new=msg\">Compose a Message</a></td></tr></table>";
}

if (($_GET['box'] == "") && ($_GET['msg'] == "") && ($_GET['del'] == "") && ($_GET['confirm'] == "") && ($_GET['new'] == "reply") && ($_GET['sent'] == "")) {

	$query="SELECT * FROM ".$pre."pm WHERE id = '" . $_GET['id'] . "'";
	$result=mysql_query($query);
	while($row = mysql_fetch_array($result)) {
		 $id = "$row[id]";
		 $subject = "$row[subject]";
		 $jo = "$row[who]";
		 $message2 = "$row[message]";
		 $message = stripslashes($message2);
	}

		echo "<title>".$setting[sitename]." > Inbox > Reply > $subject</title>";

if (!$_POST['submit']) {
if ($setting[max_pm]-$num2 > 1) {

		echo "<form action=\"index.php?load=pm&new=reply&id=".$id."\" method=\"post\"><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Subject:</b></td><td><input type=\"text\" name=\"subject2\" value=\"Re: $subject\"></td></tr><tr><td>To:</td><td><input type=\"hidden\" name=\"tto\" value=\"$jo\">$jo</td></tr><tr><td><b>Message:</b></td><td>
<textarea name=\"messagea2\" cols=\"36\" rows=\"10\">

-- Original Message: $message --</textarea></td></tr><tr><td><input type=\"submit\" value=\"Send Reply\"></td><td><a href=\"index.php?load=pm&box=in\">Return to Inbox</a></td></tr></table></form>";
} else {

echo "Sorry ".$_COOKIE[$pre."username"].", but you have used up all the allotted messages. Please delete at least (1) message before replying to '$subject'.";
}
}

if ($_POST['submit']) {

$messageaa2 = addslashes($_POST['messagea2']);

$sent = mysql_query("INSERT INTO ".$pre."pm VALUES ('null', '1', '".$_POST['subject2']."', '$messageaa2', '".$_COOKIE[$pre."username"]."', '".$_POST['tto']."', '".time()."', 'inbox')");

if ($sent == TRUE) {
	echo "The reply has been sent to ".$_POST['tto'].". <a href=\"index.php?load=pm&box=in\">Return to Inbox</a>";
} else {
	echo "The reply could not be sent to ".$_POST['tto'].". Please click 'Back' on your browser and try again";
}
}
}

if (($_GET['msg'] == "") && ($_GET['new'] == "msg") && ($_GET['box'] == "") && ($_GET['del'] == "") && ($_GET['confirm'] == "") && ($_GET['sent'] == "")) {

echo "<title>".$setting[sitename]." > Inbox > Compose Message</title>";

if (!$_POST['submit']) {

echo "<form action=\"index.php?load=pm&new=msg\" method=\"post\"><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Subject:</b></td><td><input type=\"text\" name=\"subject\"></td></tr><tr><td><b>To:</b></td><td><select name=\"jo\">";

	if ($_GET['user']) {
	echo "<option value='".$_GET['user']."' selected'>-- ".$_GET['user']." --</option>";
	}
	$query="SELECT * FROM ".$pre."users";
	$result=mysql_query($query);
	while($row = mysql_fetch_array($result)) {
		$userguyr = "$row[username]";
        
		if ($userguyr == $_COOKIE[$pre."username"]) {
		} else {
		echo "<option value=\"$userguyr\">$userguyr</option>";
		}
	}
	   echo "</select></td></tr><tr><td><b>Message:</b></td><td><textarea name=\"message\" cols=\"36\" rows=\"10\"></textarea></td></tr><tr><td><input type=\"submit\" value=\"Send Message\"></td><td><a href=\"index.php?load=pm&box=in\">Return to Inbox</a></td></tr></table></form>";
}

if ($setting[max_pm]-$num2 > 1) {
if ($_POST['submit']) {

$message2 = addslashes($_POST['message']);

$sent = mysql_query("INSERT INTO ".$pre."pm VALUES ('null', '1', '".$_POST['subject']."', '$message2', '".$_COOKIE[$pre."username"]."', '".$_POST['jo']."', '".time()."', 'inbox')");

//This will e-mail the user of the account notifying them of the new PM

		$emailTo = $setting[email]; //Put your own email address here
		$body = "Name: $name \n\nEmail: $setting[email] \n\nSubject: $subject \n\nComments:\n $comments";
		$headers = 'That Gaming Site New Private Message <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $setting[email];

		mail($emailTo, $subject, $body, $headers);
		$emailSent = true;

if ($sent == TRUE) {
	echo "Message has been sent. <a href=\"index.php?load=pm&box=in\">Return to Inbox</a>";
} else {
	echo "Message could not be sent. Please click 'Back' on your browser and try again.";
}
}
} else {
echo "Sorry ".$_COOKIE[$pre."username"].", but ".$_POST['jo']." has used up all there allotted messages. Please tell them to delete at least (1) message.";
}
}
eval (" ?>" . footera() . " <?php ");
}

if ($_GET['load'] == "polls") {
if (($_GET['poll'] == "yes") && (is_numeric($_GET['id']))) {
$id = $_GET['id'];
if ($_COOKIE["p_".$id.""] == "") {

	$query="SELECT * FROM ".$pre."polls WHERE name = '".$_POST['check']."'";
	$result=mysql_query($query);
	while($row = mysql_fetch_array($result)) {
	$vote = "$row[votes]";
	}
	$query="SELECT * FROM ".$pre."polls WHERE name = '".$_POST['q']."'";
	$result=mysql_query($query);
	while($row = mysql_fetch_array($result)) {
	$vote2 = "$row[votes]";
	}

    $votes = $vote + 1;
	$votes2 = $vote2 + 1;

	setcookie("p_".$id."", $_POST['check'], time()+24*3600*14);

	$upd = mysql_query("UPDATE ".$pre."polls SET votes = '".$votes."' WHERE name = '".addslashes($_POST['check'])."'") or die(mysql_error());
	$upde = mysql_query("UPDATE ".$pre."polls SET votes = '".$votes2."' WHERE name = '".addslashes($_POST['q'])."'") or die(mysql_error());
	eval (" ?>" . headera() . " <?php ");

echo "Your vote has been submited. <a href='".$_SERVER['HTTP_REFERER']."'>Return to where you were...</a>";
} else {
	eval (" ?>" . headera() . " <?php ");
	echo "Sorry, but you have already voted on this poll. <a href='".$_SERVER['HTTP_REFERER']."'>Return to where you were...</a>";
}
}

if (($_GET['poll'] == "") && (is_numeric($_GET['id']))) {
$id = $_GET['id'];
if ($_COOKIE["p_".$id.""] == "") {
echo "<form action='index.php?load=polls&poll=yes&id=".$id."' method=\"post\"><table cellpadding='0' cellspacing='0' border='0'>";

$query="SELECT * FROM ".$pre."polls WHERE id = '".$id."' AND type = 'pollname'";
$result=mysql_query($query) or die(mysql_error());
while($rowf = mysql_fetch_array($result)) {
$poll = "$rowf[name]";
}

$query2npn="SELECT * FROM ".$pre."polls WHERE pname = '".$poll."' AND type = 'question'";
$result2npn=mysql_query($query2npn) or die(mysql_error());
while($rowet = mysql_fetch_array($result2npn)) {
echo "<tr><td><b>$rowet[name]<input type='hidden' name='q' value=\"".$rowet[name]."\"></b></td></tr>";
}

$queryo = mysql_query("SELECT * FROM ".$pre."polls WHERE pname = '".$poll."' AND type = 'option'") or die(mysql_error());
while($rowo = mysql_fetch_array($queryo)) {

echo "<tr><td>$rowo[name]</td><td><input type='radio' name='check' value='".$rowo[name]."'></td></tr>";
}

echo "<tr><td><input type='submit' value='Submit Vote'></td></tr></table></form>";
} else {
echo "<table cellpadding='3' cellspacing='0' border='0'>";

$query = mysql_query("SELECT name FROM ".$pre."polls WHERE id = '".$id."' AND type = 'pollname'");
$polle = mysql_fetch_row($query);
$poll = $polle[0];

$query="SELECT * FROM ".$pre."polls WHERE pname = '".$poll."' AND type = 'question'";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)) {
$num = "$row[votes]";
echo "<tr><td><b>$row[name]</b></td></tr>";
}

$query="SELECT * FROM ".$pre."polls WHERE pname = '".$poll."' AND type = 'option'";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)) {
if ($num == "0") {
$num = "1";
}
$nu = $row[votes]/$num;

if (($num == $row[votes]) && ($row[votes] > "0")) {
$nua = "100";
} else {
if ($row[votes] == "0") {
$nua = "0";
} else {
$nua = substr($nu, 2, 2);
}
}

if (($nu < "10") && ($nu > "0")) {
$nua = $nu * 100;
}

if (($num == $row[votes]) && ($row[votes] == "0")) {
$nua = "0";
}

echo  "<tr><td>$row[name]</td><td><i>".$row[votes]."</i> (".substr($nua,0,4)."%)</td></tr>";
if ($setting[poll_type] == "graphic") {
if ($nua > "0") {
echo "<tr><td><img src='a_images/poll.jpg' width='".$nua."%' height='10'></td></tr>";
} else {
echo "<tr><td><img src='a_images/poll.jpg' width='1%' height='10'></td></tr>";
}
}
}
echo  "<tr><td><b>Total Votes:</b></td><td>$num</td></tr></table>";
}
}

if ($_GET['id'] == "") {
$sql = mysql_query("SELECT * FROM ".$pre."polls WHERE type = 'pollname'");
while($r = mysql_fetch_array($sql)) {
$row = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."polls WHERE type = 'question' AND pname = '".$r[name]."'"));
echo "<a href='index.php?load=polls&id=".$r[id]."'>".stripslashes($row[0])."</a><br><br>";
}
}
eval (" ?>" . footera() . " <?php ");
}

if ($_GET['load'] == "rss") {
header("Content-type: text/xml");
if ($_GET['cat']) {
$cat = $_GET['cat'];
} else {
$cat = "news";
}
$rlimit = "10";

echo "<?xml version=\"1.0\" encoding=\"US-ASCII\"?><rss version=\"2.0\"><channel>";

echo "<title>".$setting[sitename]." - Latest ".ucfirst($cat)."</title><link>".$setting[siteurl]."</link><description>".$setting[sitename]." - ".$setting[siteurl]."</description><language>en-us</language><copyright>Copyright 2006, ".$setting[sitename].".</copyright><webMaster>".$setting[email]."</webMaster>";
 if ($cat == "media") {
 $sql = mysql_query("SELECT * FROM ".$pre."albums ORDER BY `id` DESC LIMIT ".$rlimit);
 } else {
 if ($cat == "posts") {
 $sql = mysql_query("SELECT * FROM ".$pre."posts WHERE type = 'post' ORDER BY `id` DESC LIMIT ".$rlimit);
 } else {
 if ($cat == "topics") {
 $sql = mysql_query("SELECT * FROM ".$pre."posts WHERE type = 'topic' OR type = 'Announcement' OR type = 'Sticky' ORDER BY `id` DESC LIMIT ".$rlimit);
 } else {
 $sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$cat."' ORDER BY `date` DESC LIMIT ".$rlimit);
 }
 }
 }
 while($r = mysql_fetch_array($sql)) {
   $short = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE name = 'Short' AND cat = 'content' AND id2 = '".$r[id]."'"));
   $systems = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."systems WHERE id = '".$r[systems]."'"));
   
   if (($r[cat] == "posts") or ($r[cat] == "topics")) {
   echo "<item><title>".$setting[sitename]." - Post: ".$r[subject]."</title><link>".$setting[siteurl]."/".$f2part1.$r[tid].$f2part2;
   if (ucfirst($r[cat]) == "posts") {
   echo "#".$r[id];
   }
   echo "</link><description>".stripslashes(substr($r[message],0,100))."</description><pubDate>".date("D, d M Y h:i:s T", $r[date])."</pubDate></item>";
   } else {

echo "<item><title>".$setting[sitename]." - ".$r[name]." (".$systems[0].") :: ".$r[cat]."</title><link>";
if (ucfirst($r[cat]) == "media") 	 {
echo $gpart1.$r[id].$gpart2;
} else 	 {
echo $part1.$r[id].$part2;
}
echo "</link>";
if (ucfirst($r[cat]) == "media") {
} else {
echo "<pubDate>".date("D, d M Y h:i:s T", $r[date])."</pubDate>";
}
if ($short[0]) {
echo "<description>".stripslashes(htmlspecialchars($short[0]))."</description><guid>".$setting[siteurl]."/".$part1.$r[id].fthrough($r[name], $r[cat]).$part2."</guid></item>";
} else {
echo "<description>".ucfirst($r[cat])." about ".$r[name]."</description><guid>".$setting[siteurl]."/".$part1.$r[id].fthrough($r[name], $r[cat]).$part2."</guid></item>";
}
}
}
echo "</channel></rss>";
}

if ($_GET['load'] == "search") {
if ($_GET['view'] == "") {
echo "<form action='index.php?load=search&view=results' method='post'><table cellpadding='2' cellspacing='2' border='0'><tr><td><input type='text' name='search' value='".$_GET['search']."'></td><td><select name='type'><option value='content'>Content</option><option value='games'>Games</option></select></td></tr><tr><td><input type='submit' value='Search'></td></tr></table></form>";
}

if ($_GET['view'] == "results") {
if(!isset($_GET['page'])){
    $page = 1;
} else {
    $page = $_GET['page'];
}

if ($_GET['search']) {
$searchentry = $_GET['search'];
} else {
$searchentry = $_POST['search'];
}
$searchentry = strip_tags(htmlentities($searchentry));

$from = (($page * $setting[max_results]) - $setting[max_results]);

$searca = mysql_query("SELECT * FROM ".$pre."games WHERE name LIKE '%" . $searchentry . "%'");
$searca2 = mysql_query("SELECT * FROM ".$pre."content WHERE name LIKE '%" . $searchentry . "%'");
$results = mysql_num_rows($searca && $searcha2);

if ($results == "1") {
$fet = mysql_fetch_row(mysql_query("SELECT id,name,cat FROM ".$pre."content WHERE name LIKE '%" . $searchentry . "%'"));
header("location: ".$part1.$fet[0].fthrough($fet[1], $fet[2]).$part2);

$fet2 = mysql_fetch_row(mysql_query("SELECT id,name FROM ".$pre."games WHERE name LIKE '%" . $searchentry . "%'"));
header("location: ".$gamepart1.$fet[0].fthrough($fet[1], "").$gamepart2);
}
} else {
eval (" ?>" . headera() . " <?php ");
echo "<title>".$setting[sitename]." :: ".$results." Search Results For - ".$searchentry."</title><a href='index.php'>Home</a> > <a href='search.php'>Search</a> > ".$searchentry." - ".$results." Results<br><br><table cellpadding='5' cellspacing='3' border='0' align='center'>";
    if ($_POST['type'] == "content") {
	$search = mysql_query("SELECT * FROM ".$pre."content WHERE name LIKE '%" . $searchentry . "%' ORDER BY `date` DESC LIMIT $from, $setting[max_results]");
	$search2 = mysql_query("SELECT * FROM ".$pre."games WHERE name LIKE '%" . $searchentry . "%' ORDER BY `id` DESC LIMIT $from, $setting[max_results]");
	}
	for($i = 1; $row = mysql_fetch_assoc($search && $search2); $i++) {
	$icona = mysql_fetch_row(mysql_query("SELECT icon FROM ".$pre."systems WHERE id = '".$row[systems]."'"));
		if ($row[systems]) {
		$icon = "<img src='".$icona[0]."'>";
		} else {
		$icon = "";
		}
		$n1 = $searchentry;
		$n2 = hilite($searchentry);
		$name = str_replace($n1, $n2, $row[name]);

		similar_text($searchentry, $row[name], $p);
		$p = str_replace(".", "", $p);

		echo "<tr><td><b>".$i.".</b></td><td><a href='";

		if ($_POST['type'] == "games") {
	    echo $gamepart1.$row[id].fthrough($row[name], "");
		} else {
		echo $part1.$row[id].fthrough($row[name], $row[cat]);
		}

		if ($_POST['type'] == "games") {
		echo $gamepart2;
		} else {
		echo $part2;
		}
		
		echo "'>".$name."</a>";
		
		if ($_POST['type'] == "content") {
		echo "&nbsp;&nbsp;(<i>".$row[cat]."</i>)&nbsp;&nbsp;";
		}
		echo $icon."</td>";
		if ($_POST['type'] == "content") {
		echo "<td>".date($setting[dformat], $row[date])."</td>";
		}
		
		echo "<td><b>Relevance</b>: ".substr($p,0,2)."%</td>";

		if ($_POST['type'] == "games") {
			echo "<td>".stripslashes($row[des])."</td>";
		}
		echo "</tr>";
	}

if ($_POST['type'] == "content") {
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM ".$pre."content WHERE name LIKE '%" . $searchentry . "%'"),0);
$total_results2 = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM ".$pre."games WHERE name LIKE '%" . $searchentry . "%'"),0);
}

$total_pages = ceil($total_results / $setting[max_results]);

echo "</table>";

if ($total_pages > "1") {

echo "<br><center>Select a Page<br>";

// Build Previous Link
if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"index.php?load=search&view=results&page=$prev\"><<Previous</a>&nbsp;";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i&nbsp;";
        } else {
            echo "<a href=\"index.php?load=search&view=results&page=$i\">$i</a>&nbsp;&nbsp;";
    }
}

// Build Next Link
if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"index.php?load=search&view=results&page=$next\">Next>></a>&nbsp;";
}
echo "</center>";
}
}

if ($_GET['view'] == "forums") {
if ($forumskin == "") {
$ffetch1 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."fskins WHERE id = '1'"));
$ffetch2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."fskins WHERE id = '4'"));
if (($ffetch1 > "0") or ($ffetch2 > "0")) {
if ($ffetch1 > "0") {
$forumskin = "1";
}
if ($ffetch2 > "0") {
$forumskin = "4";
}
} else {
$forumskin = "3";
}
}
$tempfetch = mysql_fetch_row(mysql_query("SELECT header,footer,header2,footer2,homeheader,homefooter,flist,clist,subforum,forumheader,forumfooter,topicheader,tlist,post,fbcolor1,fbgcolor1,fbgcolor2,fbgcolor3 FROM ".$pre."fskins WHERE id = '".$forumskin."'"));//subforum - header (for the forum part it gets the flist)

if ($_POST['search'] == "") {
	$skin1[] = "/{version}/";
	$skin1[] = "/{sitename}/";
	$skin1[] = "/{users}/"; // amount of users online
	$skin1[] = "/{online}/"; // the users that are online
	$skin1[] = "/{pms}/"; // amount of private messages
	$skin1[] = "/{new}/"; // amount of new private messages
	$skin1[] = "/{pm}/"; // display new private messages
	$skin1[] = "/{welcome}/"; // Displays "Welcome username" if person is logged in, other wise "Welcome Guest" and a link to login
	$skin1[] = "/{chooseskin}/";
	$skin1[] = "/{skinname}/"; // the name of the current skin being used
	$skin2[] = $version;
	$skin2[] = $setting[sitename];
	$skin2[] = online();
	$skin2[] = usersonline();
	$skin2[] = totalpms();
	$skin2[] = newpms();
	$skin2[] = pms();
	$skin2[] = welcome();
	$skin2[] = fskin();
	$skin2[] = skinname();
eval (" ?>" . str_replace($skin1, $skin2, stripslashes($tempfetch[0])) . " <?php ");
echo "<center><form action='index.php?load=search&view=forums' method='post'><input type='text' name='search'>&nbsp;<input type='submit' value='Search'></form></center>";
}
if ($_POST['search']) {
if(!isset($_GET['page'])){
    $page = 1;
} else {
    $page = $_GET['page'];
}

$from = (($page * $setting[max_results]) - $setting[max_results]);

$fid = $_GET['f'];

if ($_POST['type']) {
$ex = explode("|", $_POST['type']);
if ($ex[0] == "topic") {
$searca = mysql_query("SELECT * FROM ".$pre."posts WHERE message LIKE '%" . $_POST['search'] . "%' AND tid = '".$ex[1]."'");
$results = mysql_num_rows($searca);
} else {
$searca = mysql_query("SELECT * FROM ".$pre."posts WHERE subject LIKE '%" . $_POST['search'] . "%' AND fid = '".$ex[1]."' OR message LIKE '%" . $_POST['search'] . "%' AND fid = '".$ex[1]."'");
$results = mysql_num_rows($searca);
}
} else {
if ($_GET['f']) {
$searca = mysql_query("SELECT * FROM ".$pre."posts WHERE subject LIKE '%" . $_POST['search'] . "%'  AND fid = '".$fid."' OR message LIKE '%" . $_POST['search'] . "%' AND fid = '".$fid."'");
$results = mysql_num_rows($searca);
} else {
$searca = mysql_query("SELECT * FROM ".$pre."posts WHERE subject LIKE '%" . $_POST['search'] . "%' OR message LIKE '%" . $_POST['search'] . "%'");
$results = mysql_num_rows($searca);
}
}

if ($results == "1") {
if ($_POST['type']) {
$ex = explode("|", $_POST['type']);
if ($ex[0] == "topic") {
$fet = mysql_fetch_row(mysql_query("SELECT tid,type,id FROM ".$pre."posts WHERE message LIKE '%" . $_POST['search'] . "%' AND tid = '".$ex[1]."'"));
} else {
$fet = mysql_fetch_row(mysql_query("SELECT tid,type,id FROM ".$pre."posts WHERE subject LIKE '%" . $_POST['search'] . "%' AND fid = '".$ex[1]."' OR message LIKE '%" . $_POST['search'] . "%' AND fid = '".$ex[1]."'"));
}
} else {
if ($_GET['f']) {
$fet = mysql_fetch_row(mysql_query("SELECT tid,type,id FROM ".$pre."posts WHERE subject LIKE '%" . $_POST['search'] . "%'  AND fid = '".$fid."' OR message LIKE '%" . $_POST['search'] . "%' AND fid = '".$fid."'"));
} else {
$fet = mysql_fetch_row(mysql_query("SELECT tid,type,id FROM ".$pre."posts WHERE subject LIKE '%" . $_POST['search'] . "%' OR message LIKE '%" . $_POST['search'] . "%'"));
}
}
if ($fet[1] == "post") {
header("location: ".$f2part1.$fet[0].$f2part2."#".$fet[2]);
} else {
header("location: ".$f2part1.$fet[0].$f2part2);
}
} else {
	$skin1[] = "/{version}/";
	$skin1[] = "/{sitename}/";
	$skin1[] = "/{users}/"; // amount of users online
	$skin1[] = "/{online}/"; // the users that are online
	$skin1[] = "/{pms}/"; // amount of private messages
	$skin1[] = "/{new}/"; // amount of new private messages
	$skin1[] = "/{pm}/"; // display new private messages
	$skin1[] = "/{welcome}/"; // Displays "Welcome username" if person is logged in, other wise "Welcome Guest" and a link to login
	$skin1[] = "/{chooseskin}/";
	$skin1[] = "/{skinname}/"; // the name of the current skin being used
	$skin2[] = $version;
	$skin2[] = $setting[sitename];
	$skin2[] = online();
	$skin2[] = usersonline();
	$skin2[] = totalpms();
	$skin2[] = newpms();
	$skin2[] = pms();
	$skin2[] = welcome();
	$skin2[] = fskin();
	$skin2[] = skinname();
eval (" ?>" . str_replace($skin1, $skin2, stripslashes($tempfetch[0])) . " <?php ");


echo "<title>".$setting[sitename]." :: ".$results." Search Results For - ".$_POST['search']."</title><br><table cellpadding='3' cellspacing='0' border='0' width='98%' style='border:1px solid ".$tempfetch[14]."' align='center'><tr bgcolor='".$tempfetch[16]."'><td><b><a href='".$forumsurl."'>Home</a> > <a href='index.php?load=search&view=forums'>Search</a> > ".$_POST['search']."</b> - ".$results." Results</td><td align='right'>".$results." Results For :: ".$_POST['search']."</td></tr></table><br>";

echo "<table cellpadding='3' cellspacing='0' border='0' width='98%' style='border:1px solid ".$tempfetch[14]."' align='center'><tr bgcolor='".$tempfetch[15]."'><td align='center'><b>#</b></td><td align='center'><b>Topic Name</b></td>";
if ($fid) {
echo "<td align='center'><b>Forum</b></td>";
}
echo "<td align='center'><b>Poster</b></td><td align='center'><b>Replies</b></td><td align='center'><b>Last Post</b></td><td align='center'><b>Relevance</b></td></tr>";


    if ($_POST['type']) {
	$ex = explode("|", $_POST['type']);
	if ($ex[0] == "topic") {
	$search = mysql_query("SELECT * FROM ".$pre."posts WHERE message LIKE '%" . $_POST['search'] . "%' AND tid = '".$ex[1]."' ORDER BY `date` DESC LIMIT $from, $setting[max_results]");
	} else {
	$search = mysql_query("SELECT * FROM ".$pre."posts WHERE subject LIKE '%" . $_POST['search'] . "%' AND fid = '".$ex[1]."' OR message LIKE '%" . $_POST['search'] . "%' AND fid = '".$ex[1]."' ORDER BY `date` DESC LIMIT $from, $setting[max_results]");
	}
	} else {
    if ($_GET['f']) {
	$search = mysql_query("SELECT * FROM ".$pre."posts WHERE subject LIKE '%" . $_POST['search'] . "%'  AND fid = '".$fid."' OR message LIKE '%" . $_POST['search'] . "%' AND fid = '".$fid."' ORDER BY `date` DESC LIMIT $from, $setting[max_results]");
	} else {
	$search = mysql_query("SELECT * FROM ".$pre."posts WHERE subject LIKE '%" . $_POST['search'] . "%' OR message LIKE '%" . $_POST['search'] . "%' ORDER BY `id` DESC LIMIT $from, $setting[max_results]");
	}
	}
	for($i = 1; $row = mysql_fetch_assoc($search); $i++) {
		$n1 = $_POST['search'];
		$n2 = hilite($_POST['search']);
		$name = str_replace($n1, $n2, $row[subject]);

		similar_text($_POST['search'], $row[subject], $p4);
		similar_text($_POST['search'], $row[message], $p2);

		$p3 = $p4 * $p2/2;

		$p = str_replace(".", "", $p3);

		$fname = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."forums WHERE id = '".$fid."'"));
		$tid = $row[tid];

		echo "<tr bgcolor='".$tempfetch[17]."'><td align='center' style='border:1px solid ".$tempfetch[14]."'><b>".$i.".</b></td><td align='center' style='border:1px solid ".$tempfetch[14]."'><a href='";

		if ($row[type] == "post") {
		echo $f2part1.$row[tid].$f2part2."#".$row[id];
		} else {
		echo $f2part1.$row[id].$f2part2;
		}

		echo "'>".$name."</a></td>";
		if ($fid) {
		echo "<td align='center' style='border:1px solid ".$tempfetch[14]."'><a href='".$f1part1.$fid.$f1part2."'>".$fname[0]."</a></td>";
		}
		echo "<td align='center' style='border:1px solid ".$tempfetch[14]."'>";

	if ($row[uid]) {
	$user = mysql_fetch_row(mysql_query("SELECT username FROM ".$pre."profile WHERE id = '".$row[uid]."' LIMIT 1"));
	$usera = mysql_fetch_row(mysql_query("SELECT rank FROM ".$pre."users WHERE username = '".$user[0]."'"));
	$s = mysql_fetch_row(mysql_query("SELECT color FROM ".$pre."ranks WHERE name = '".$usera[0]."' ORDER BY `points` DESC"));

	$rank = "<a href='index.php?load=elite&user=".$row[uid]."'><font color='".$s[0]."'>".$user[0]."</font></a>";

if ($rank == "") {
echo "<a href='index.php?load=elite&user=".$row[uid]."'>".$user[0]."</a>";
} else {
print $rank;
}
	} else {
	echo "Visitor";
	}

	$replies = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."posts WHERE type = 'post' AND tid = '".$tid."'"));

	$lcount = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."posts WHERE type = 'post' AND tid = '".$tid."'"));

    if ($lcount > "0") {
	$user3 = mysql_fetch_row(mysql_query("SELECT uid FROM ".$pre."posts WHERE type = 'post' AND tid = '".$tid."' ORDER BY `date` DESC LIMIT 1"));
	$user4 = mysql_fetch_row(mysql_query("SELECT username FROM ".$pre."profile WHERE id = '".$user3[0]."'"));
	$user1 = $user3[0];
	$user2 = $user4[0];
	$query3w = mysql_fetch_row(mysql_query("SELECT date FROM ".$pre."posts WHERE type = 'post' AND tid = '".$tid."' ORDER BY `date` DESC LIMIT 1"));
	$date9 = $query3w[0];
	} else {
	$user1 = $row[uid];
	$user3 = mysql_fetch_row(mysql_query("SELECT username FROM ".$pre."profile WHERE id = '".$row[uid]."'"));
	$user2 = $user3[0];
    $query3w = mysql_fetch_row(mysql_query("SELECT date FROM ".$pre."posts WHERE id = '".$tid."' ORDER BY `date` DESC LIMIT 1"));
	$date9 = $query3w[0];
	}

	$last = date($setting[dformat], $date9)."<br>";

	if ($user1) {
	$ranks2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."posts WHERE uid = '".$user1."'"));
	$user = mysql_fetch_row(mysql_query("SELECT rank FROM ".$pre."users WHERE username = '".$user2."'"));
	$s = mysql_fetch_row(mysql_query("SELECT color FROM ".$pre."ranks WHERE name = '".$user[0]."' ORDER BY `points` DESC"));

	$rank = "<a href='index.php?load=elite&user=".$user1."'><font color='".$s[0]."'>".$user2."</font></a>";

if ($rank == "") {
$last .= "<a href='index.php?load=elite&user=".$user1."'>".$user2."</a>";
} else {
$last .= $rank;
}
		} else {
		$last .= "Visitor";
		}
	echo "</td><td align='center' style='border:1px solid ".$tempfetch[14]."'>".$replies."</td><td align='center' style='border:1px solid ".$tempfetch[14]."'>".$last."</td><td align='center' style='border:1px solid ".$tempfetch[14]."'>".substr($p,0,2)."%</td></tr>";
	}

if ($fid) {
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM ".$pre."posts WHERE subject LIKE '%" . $_POST['search'] . "%' OR message LIKE '%" . $_POST['search'] . "%' AND fid = '".$fid."'"),0);
} else {
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM ".$pre."posts WHERE subject LIKE '%" . $_POST['search'] . "%' OR message LIKE '%" . $_POST['search'] . "%'"),0);
}

$total_pages = ceil($total_results / $setting[max_results]);

echo "</table>";

if ($total_pages > "1") {

echo "<br><center>Select a Page<br>";

// Build Previous Link
if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"index.php?load=search&view=results&page=$prev\"><<Previous</a>&nbsp;";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i&nbsp;";
        } else {
            echo "<a href=\"index.php?load=search&view=results&page=$i\">$i</a>&nbsp;&nbsp;";
    }
}

// Build Next Link
if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"index.php?load=search&view=results&page=$next\">Next>></a>&nbsp;";
}
echo "</center>";
}
}
}
}
if ($_GET['view'] == "forums") {
	$skin1[] = "/{version}/";
	$skin1[] = "/{sitename}/";
	$skin1[] = "/{users}/"; // amount of users online
	$skin1[] = "/{online}/"; // the users that are online
	$skin1[] = "/{pms}/"; // amount of private messages
	$skin1[] = "/{new}/"; // amount of new private messages
	$skin1[] = "/{pm}/"; // display new private messages
	$skin1[] = "/{welcome}/"; // Displays "Welcome username" if person is logged in, other wise "Welcome Guest" and a link to login
	$skin1[] = "/{chooseskin}/";
	$skin1[] = "/{skinname}/"; // the name of the current skin being used
	$skin2[] = $version;
	$skin2[] = $setting[sitename];
	$skin2[] = online();
	$skin2[] = usersonline();
	$skin2[] = totalpms();
	$skin2[] = newpms();
	$skin2[] = pms();
	$skin2[] = welcome();
	$skin2[] = fskin();
	$skin2[] = skinname();
eval (" ?>" . str_replace($skin1, $skin2, stripslashes($tempfetch[1])) . " <?php ");
} else {
eval (" ?>" . footera() . " <?php ");
}
}

if ($_GET['load'] == "staff") {
if ($_GET['user'] == "") {
echo "<table cellpadding='7' align='center' cellspacing='4' border='0'><tr><td><b>Username</b></td><td><b>E-mail</b></td><td><b># of Items posted</b></td></tr>";

$result = mysql_query("SELECT * FROM ".$pre."users WHERE slist = 'Yes'");
while($row = mysql_fetch_array($result)) {

		$query = mysql_query("SELECT * FROM ".$pre."content WHERE username = '".$row[username]."'");
		$content = mysql_num_rows($query);

		echo "<tr><td><a href='index.php?load=staff&user=".$row[username]."'>".$row[username]."</a></td><td><a href='mailto:".$row[email]."'>".$row[email]."</td><td>".$content."</td></tr>";
}
echo "</table>";
} else {
$result = mysql_query("SELECT * FROM ".$pre."profile WHERE username = '".check($_GET['user'])."' LIMIT 1");
$profile = mysql_fetch_row($result);

$userid = $profile[0];

echo "<table cellpadding='4' cellspacing='2' border='0'><tr><td><table cellpadding='3' align='left' cellspacing='2' border='0'><tr valign='top'><tr><td><u>Info</u></td></tr><td><b>Username</b></td><td><a href='index.php?load=elite&user=".$profile[0]."'>".$profile[1]."</a></td></tr><tr><td><b>AIM</b></td><td>".$profile[2]."</td></tr><tr><td><b>MSN</b></td><td>".$profile[3]."</td></tr><tr><td><b>Nickname</b></td><td>".$profile[9]."</td></tr><tr><td><b>Avatar</b></td><td>";

if ($profile[12]) {
echo "<img src='".$profile[12]."' border='1'>";
} else {
echo "<i>No Avatar</i>";
}

echo "</td></td></tr></table></td><td valign='top'><table cellpadding='3' align='left' cellspacing='2' border='0'><tr><td><u>General Stats</u></td></tr>";

$result2 = mysql_query("SELECT * FROM ".$pre."content WHERE username = '".$_GET['user']."'");
$content = mysql_num_rows($result2);

$result21 = mysql_query("SELECT * FROM ".$pre."games WHERE username = '".$_GET['user']."'");
$games = mysql_num_rows($result21);

$result211 = mysql_query("SELECT * FROM ".$pre."posts WHERE uid = '".$userid."' AND type = 'post'");
$posts1 = mysql_num_rows($result211);

$result2111 = mysql_query("SELECT * FROM ".$pre."posts WHERE uid = '".$userid."' AND type = 'topic'");
$posts2 = mysql_num_rows($result2111);

echo "<tr><td><b>Content Posted</b></td><td>".$content."</td></tr><tr><td><b>Games Posted</b></td><td>".$games."</td></tr><tr><td><b>Posts posted</b></td><td>".$posts1."</td></tr><tr><td><b>Topics posted</b></td><td>".$posts2."</td></tr>";

echo "</table></td></tr><tr><td valign='top'><table cellpadding='3' align='left' cellspacing='2' border='0'><tr><td><u>Category Stats</u></td></tr>";

$cat = mysql_query("SELECT * FROM ".$pre."cat");
while($row = mysql_fetch_array($cat)) {

$cat2 = mysql_query("SELECT * FROM ".$pre."content WHERE username = '".$_GET['user']."' AND cat = '".$row[name]."'");
$catnum = mysql_num_rows($cat);
$catt = mysql_num_rows($cat2);

echo "<tr><td><b>".stripslashes($row[name])." posted</b></td><td>".$catt."</td></tr>";
}
echo "<tr><td><br><br></td></tr><tr><td><u>Bio</u></td></tr><tr><td>";
if ($bio) {
echo $bio;
} else {
echo "COMING SOON";
}
echo "</td></tr></table></td><td valign='top'><table cellpadding='3' align='left' cellspacing='2' border='0'><tr><td><u>Latest Content</u></td></tr>";

$cata = mysql_query("SELECT * FROM ".$pre."content WHERE username = '".$_GET['user']."' ORDER BY `id` DESC LIMIT 10");
while($row = mysql_fetch_array($cata)) {
	echo "<tr><td><a href='".$part1."".$row[id]."".$part2."'><b>".stripslashes($row[name])."</b></a> ".$row[cat]."</td></tr>";
}

echo "</table></td></tr></table>";
}
eval (" ?>" . footera() . " <?php ");
}

if ($_GET['load'] == "stats") {
if ($_GET['year'] == "") {
echo "<form action='index.php' method='get'><input type='hidden' name='load' value='stats'><input type='hidden' name='view' value='stats'><center><b>Check:</b>&nbsp;<select name='day'>";
for($i = 1; $i <= 31; $i++){
if ($i < "10") {
$y = "0".$i;
} else {
$y = $i;
}
echo "<option value='".$y."'";
if ($_GET['day'] == $y) {
echo " selected";
} else {
if ($y == date("d")) {
echo " selected";
}
}
echo ">".$y."</option>";
}
echo "</select>&nbsp;<select name='month'><option value='01'";
if (date("F") == "January") {
echo " selected";
}
echo ">January</option><option value='02'";
if (date("F") == "February") {
echo " selected";
}
echo ">February</option><option value='03'";
if (date("F") == "March") {
echo " selected";
}
echo ">March</option><option value='04'";
if (date("F") == "April") {
echo " selected";
}
echo ">April</option><option value='05'";
if (date("F") == "May") {
echo " selected";
}
echo ">May</option><option value='06'";
if (date("F") == "June") {
echo " selected";
}
echo ">June</option><option value='07'";
if (date("F") == "July") {
echo " selected";
}
echo ">July</option><option value='08'";
if (date("F") == "August") {
echo " selected";
}
echo ">August</option><option value='09'";
if (date("F") == "September") {
echo " selected";
}
echo ">September</option><option value='10'";
if (date("F") == "October") {
echo " selected";
}
echo ">October</option><option value='11'";
if (date("F") == "November") {
echo " selected";
}
echo ">November</option><option value='12'";
if (date("F") == "December") {
echo " selected";
}
echo ">December</option></select>&nbsp;<select name='year'>";
for($i = 2006; $i <= 2020; $i++){
echo "<option value='".$i."'";
if ($i == date("Y")) {
echo " selected";
}
echo ">".$i."</option>";
}
echo "</select>&nbsp;&nbsp;<input type='submit' value='Search'></form></center><br>";

if (date("m") == "01") {
$lmonth = "12";
} else {
$lmonth = date("m") - 1;
}

if (date("W") == "01") {
$lweek = "52";
} else {
$lweek = date("W") - 1;
}
if (date("z") == "0") {
$lday = "365";
$lyear = date("Y") -1;
} else {
$lday = date("z") - 1;
$lyear = date("Y");
}

if ($lweek < "10") {
$lweek = "0".$lweek;
} else {
$lweek = $lweek;
}

if ($lmonth < "10") {
$lmonth = "0".$lmonth;
} else {
$lmonth = $lmonth;
}

if ($_GET['year']) {
$views = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view' AND year = '".$_GET['year']."' AND month = '".$_GET['month']."' AND day = '".$_GET['day']."'"));
$uniques = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique' AND year = '".$_GET['year']."' AND month = '".$_GET['month']."' AND day = '".$_GET['day']."'"));
echo "<table cellspacing='0' cellpadding='3' border='0' align='left'><tr><td><b>Unique Visitors:</b> ".$uniques."<br><b>Views:</b> ".$views."<br><br><br></td></tr>";
$var[] = "";
$var2[] = "";
$var3[] = "";

$sql = mysql_query("SELECT * FROM ".$pre."stats WHERE year = '".$_GET['year']."' AND month = '".$_GET['month']."' AND day = '".$_GET['day']."' AND type = 'unique'");
while($r = mysql_fetch_array($sql)) {
$ex = explode("|", $r[info]);

$tvar1[] .= $ex[0];
$tvar2[] .= $ex[1];
if ($r[referral]) {
$tvar3[] .= $r[referral];
}
$avar .= $ex[0];
$bvar .= $ex[1];
if ($r[referral]) {
$cvar .= $r[referral];
}

if (array_search($ex[0], $var)) {
} else {
if ($ex[0] == " ") {
} else {
$var[] .= $ex[0];
}
}
if (array_search($ex[1], $var2)) {
} else {
if ($ex[1] == " ") {
} else {
$var2[] .= $ex[1];
}
}
if (array_search($r[referral], $var3)) {
} else {
if ($r[referral] == " ") {
} else {
$var3[] .= $r[referral];
}
}
}
$total1 = count($tvar1);
$total2 = count($tvar2);
$total3 = count($tvar3);
$count1 = count($var);
$count2 = count($var2);
$count3 = count($var3);
sort($var);
sort($var2);
sort($var3);
echo "<tr><td><b>Operating Systems:</b><br>";

while (list($i) = each($var)) {
if (strlen($var[$i]) < "5") {
$char = " ";
foreach(count_chars($avar, 1) as $chr => $hit) {
$tcount = $hit;
}
} else {
$tcount = substr_count($avar, $var[$i]);
}
if (($tcount == "0") && ($total1 == "0")) {
$total_1 = "0";
} else {
$total_1 = $tcount / $total1;
}
$total_1 = substr($total_1, 2, 2);
$total_1 = round($total_1, 1);

if ($total_1{0} == "0") {
$total_1 = str_replace("0", "", $total_1);
}

if (strlen($total_1) == "3") {
$total_1 = substr($total_1, 0, 2);
}

if (strlen($var[$i]) < "5") {
echo "Unknown ($total_1%)<br>";
} else {
echo $var[$i]." ($total_1%)<br>";
}
}
echo "<br></td></tr><tr><td><b>Browsers:</b><br>";
while (list($ia) = each($var2)) {
if (strlen($var2[$ia]) < "5") {
$char = " ";
foreach(count_chars($bvar, 1) as $chr => $hit) {
$tcount2 = $hit;
}
} else {
$tcount2 = substr_count($bvar, $var2[$ia]);
}
if (($tcount2 == "0") && ($total2 == "0")) {
$total_2 = "0";
} else {
$total_2 = $tcount2 / $total2;
}
$total_2 = substr($total_2, 2, 2);
$total_2 = round($total_2, 1);

if ($total_2{0} == "0") {
$total_2 = str_replace("0", "", $total_2);
}

if (strlen($total_2) == "3") {
$total_2 = substr($total_2, 0, 2);
}

if (strlen($var2[$ia]) < "5") {
echo "Unknown ($total_2%)<br>";
} else {
echo $var2[$ia]." ($total_2%)<br>";
}
}
echo "</td><br></td></tr><tr><td><b>Referrals:</b><br>";
while (list($ic) = each($var3)) {
if ($var3[$ic] == "") {
} else {
if (strlen($var3[$ic]) < "5") {
$char = " ";
foreach(count_chars($cvar, 1) as $chr => $hit) {
$tcount3 = $hit;
}
} else {
$tcount3 = substr_count($cvar, $var3[$ic]);
}
if (($tcount3 == "0") && ($total3 == "0")) {
$total_3 = "0";
} else {
$total_3 = $tcount3 / $total3;
}
$total_3 = substr($total_3, 2, 2);
$total_3 = round($total_3, 1);

if ($total_3{0} == "0") {
$total_3 = str_replace("0", "", $total_3);
}

if (strlen($total_3) == "3") {
$total_3 = substr($total_3, 0, 2);
}

if (strlen($var3[$ic]) < "5") {
echo "Unknown ($total_3%)<br>";
} else {
echo "<a href='".$var3[$ic]."'>";
if (strlen($var3[$ic]) > 80) {
echo substr($var3[$ic], 0, 77)."...";
} else {
echo substr($var3[$ic], 0, 80);
}
echo " ($total_3%)<br>";
}
}
}
echo "</tr></table><br><br>";
} else {
if (date("m") == "01") {
$lmonth = "12";
$lyear = date("Y") -1;
} else {
$lmonth = date("m") - 1;
$lyear = date("Y");
}

if (date("W") == "01") {
$lweek = "52";
} else {
$lweek = date("W") - 1;
}

if (date("z") == "0") {
if (date("L") == "1") {
$lday = "366";
} else {
$lday = "365";
}
$lyear = date("Y") -1;
} else {
$lday = date("z") - 1;
$lyear = date("Y");
}

if ($lweek < "10") {
$lweek = "0".$lweek;
} else {
$lweek = $lweek;
}

if ($lmonth < "10") {
$lmonth = "0".$lmonth;
} else {
$lmonth = $lmonth;
}

$views = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view'"));
$uniques = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique'"));
$viewsa9 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view' AND year = '".date("Y")."'"));
$uniquesa9 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique' AND year = '".date("Y")."'"));

$viewsb9 = mysql_fetch_row(mysql_query("SELECT tday FROM ".$pre."stats WHERE type = 'view' AND year = '".date("Y")."' ORDER BY `id` DESC LIMIT 1"));
$viewsc9 = mysql_fetch_row(mysql_query("SELECT tday FROM ".$pre."stats WHERE type = 'view' ORDER BY `id` ASC LIMIT 1"));

$uniquesb9 = mysql_fetch_row(mysql_query("SELECT tday FROM ".$pre."stats WHERE type = 'unique' AND year = '".date("Y")."' ORDER BY `id` DESC LIMIT 1"));
$uniquesc9 = mysql_fetch_row(mysql_query("SELECT tday FROM ".$pre."stats WHERE type = 'unique' AND year = '".date("Y")."' ORDER BY `id` ASC LIMIT 1"));//total/avg this year
$abcv9 = $viewsb9[0] - $viewsc9[0] + 1;
$abcu9 = $uniquesb9[0] - $uniquesc9[0] + 1;
$views9 = $viewsa9 / $abcv9;
$uniques9 = $uniquesa9 / $abcu9;

$views1 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view' AND day = '".date("d")."' AND month = '".date("m")."' AND week = '".date("W")."' AND year = '".date("Y")."'"));
$uniques1 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique' AND day = '".date("d")."' AND month = '".date("m")."' AND week = '".date("W")."' AND year = '".date("Y")."'"));
$views8 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view' AND tday = '".$lday."' AND year = '".$lyear."'"));
$uniques8 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique' AND tday = '".$lday."' AND year = '".$lyear."'"));//today/yesterday

$views2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view' AND week = '".date("W")."' AND year = '".date("Y")."'"));
$uniques2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique' AND week = '".date("W")."' AND year = '".date("Y")."'"));
$views7 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view' AND week = '".$lweek."' AND year = '".$lyear."'"));
$uniques7 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique' AND week = '".$lweek."' AND year = '".$lyear."'"));//week

$views3 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view' AND month = '".date("m")."' AND year = '".date("Y")."'"));
$uniques3 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique' AND month = '".date("m")."' AND year = '".date("Y")."'"));
$lmonths = $lmonth - 1;
$views4 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view' AND month = '".$lmonth."' AND year = '".$lyear."'"));
if ($views4 == 0) {
$lyears = $lyear - 1;
$views4 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view' AND month = '".$lmonths."' AND year = '".$lyears."'"));
}
$uniques4 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique' AND month = '".$lmonth."' AND year = '".$lyear."'"));//month
if ($uniques4 == 0) {
$lyears = $lyear - 1;
$uniques4 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique' AND month = '".$lmonths."' AND year = '".$lyears."'"));
}

$views5 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view' AND year = '".date("Y")."'"));
$uniques5 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique' AND year = '".date("Y")."'"));
$lyear = $lyear - 1;
$views6 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'view' AND year = '".$lyear."'"));
$uniques6 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."stats WHERE type = 'unique' AND year = '".$lyear."'"));//year

echo "<SCRIPT LANGUAGE='JavaScript'>
function donline () {
alert ('Days site has been online - ".$abcv9."');
}
</SCRIPT>";

echo "<table cellspacing='0' cellpadding='0' border='0' align='center' width='98%'><tr><td>&nbsp;</td><td><b>Uniques</b></td><td><b>Views</b></td></tr>
<tr><td><b>Average:</b></td><td>".$uniques9."</td><td>".$views9."</td></tr>	
<tr><td><b>Today:</b></td><td>".$uniques1."</td><td>".$views1."</td></tr>
<tr><td><b>Yesterday:</b></td><td>".$uniques8."</td><td>".$views8."</td></tr>

<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td><b>This Week:</b></td><td>".$uniques2."</td><td>".$views2."</td></tr>
<tr><td><b>This Month:</b></td><td>".$uniques3."</td><td>".$views3."</td></tr>
<tr><td><b>Last Week:</b></td><td>".$uniques7."</td><td>".$views7."</td></tr>
<tr><td><b>Last Month:</b></td><td>".$uniques4."</td><td>".$views4."</td></tr>

<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td><b>Total:</b></td><td><a href='javascript:donline()'>".$uniques."</a></td><td><a href='javascript:donline()'>".$views."</a></td></tr>
<tr><td><b>This Year:</b></td><td>".$uniques5."</td><td>".$views5."</td></tr>
<tr><td><b>Last Year:</b></td><td>".$uniques6."</td><td>".$views6."</td></tr></table><br><br>";
}
}
eval (" ?>" . footera() . " <?php ");
}

if (($_GET['load'] == "") && ($_GET['view'] == "")) {

$template = loadTemplate("templates/".$maintheme."/index.php");

eval (" ?>" . stripslashes($template) . " <?php ");

eval (" ?>" . footera() . " <?php ");
}

if ($_GET['load'] == "list") {
if ($_GET['view'] == "content") {
if ($_GET['t']) {

$template = loadTemplate("templates/".$maintheme."/".$_GET['t'].".php");

if ($_GET['s'] == "") {
echo abclist("?load=list&view=content", "");
} else {
echo abclist("?load=list&view=content&s=".$_GET['s'], "");
}
} else {
	$temp = loadTemplate("templates/".$maintheme."/".$template1[0].".php");

if ($_GET['s'] == "") {
echo abclist("?load=list&view=content", "");
} else {
echo abclist("?load=list&view=content&s=".$_GET['s'], "");
}
}

if ($temp == "") {
 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
if (($_GET['s']) && ($_GET['g'])) {
$query2 = mysql_query("SELECT name FROM ".$pre."games WHERE id = '".$_GET['g']."'");
$row3 = mysql_fetch_row($query2);

$sql = mysql_query("SELECT * FROM ".$pre."content WHERE systems = '".$_GET['s']."' AND games = '".$_GET['g']."' AND ver = '0' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
} else {
if (($_GET['s']) && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE systems = '".$_GET['s']."' AND ver = '0' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'])) {
$query2 = mysql_query("SELECT name FROM ".$pre."games WHERE id = '".$_GET['g']."'");
$row3 = mysql_fetch_row($query2);

$sql = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$_GET['g']."' AND ver = '0' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE ver = '0' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
}
} else {
if (($_GET['s']) && ($_GET['g'])) {
$query2 = mysql_query("SELECT name FROM ".$pre."games WHERE id = '".$_GET['g']."'");
$row3 = mysql_fetch_row($query2);

$sql = mysql_query("SELECT * FROM ".$pre."content WHERE systems = '".$_GET['s']."' AND games = '".$_GET['g']."' AND ver = '0'  ORDER BY `".$by."` ".$type." LIMIT ".$limit);
} else {
if (($_GET['s']) && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE systems = '".$_GET['s']."' AND ver = '0'  ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'])) {
$query2 = mysql_query("SELECT name FROM ".$pre."games WHERE id = '".$_GET['g']."'");
$row3 = mysql_fetch_row($query2);

$sql = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$_GET['g']."' AND ver = '0'  ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE ver = '0'  ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
}
}
while($row = mysql_fetch_array($sql)) {
	echo "- <a href='".$part1.$row[id].fthrough($row[name], $row[cat]).$part2."'>".stripslashes($row[name])."</a><br>";
}
eval (" ?>" . footera() . " <?php ");
	} else {

 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
if (($_GET['s']) && ($_GET['g'])) {
$query2 = mysql_query("SELECT name FROM ".$pre."games WHERE id = '".$_GET['g']."'");
$row3 = mysql_fetch_row($query2);

$sql = mysql_query("SELECT * FROM ".$pre."content WHERE systems = '".$_GET['s']."' AND games = '".$_GET['g']."' AND ver = '0' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
} else {
if (($_GET['s']) && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE systems = '".$_GET['s']."' AND ver = '0' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'])) {
$query2 = mysql_query("SELECT name FROM ".$pre."games WHERE id = '".$_GET['g']."'");
$row3 = mysql_fetch_row($query2);

$sql = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$_GET['g']."' AND ver = '0' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE ver = '0' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
}
} else {
if (($_GET['s']) && ($_GET['g'])) {
$query2 = mysql_query("SELECT name FROM ".$pre."games WHERE id = '".$_GET['g']."'");
$row3 = mysql_fetch_row($query2);

$sql = mysql_query("SELECT * FROM ".$pre."content WHERE systems = '".$_GET['s']."' AND games = '".$_GET['g']."' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
} else {
if (($_GET['s']) && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE systems = '".$_GET['s']."' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'])) {
$query2 = mysql_query("SELECT name FROM ".$pre."games WHERE id = '".$_GET['g']."'");
$row3 = mysql_fetch_row($query2);

$sql = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$_GET['g']."' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE ver = '0' AND save='0'  ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
}
}
while($row = mysql_fetch_array($sql)) {
    $system13 = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE id2 = '".$row[id]."' AND name = 'systems' AND cat = 'content'"));
	$systems = $system13[0];

	$short = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE id2 = '".$row[id]."' AND name = 'Short' AND cat = 'content'"));
	$image = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE id2 = '".$row[id]."' AND name = 'image' AND cat = 'content'"));
	
	$squery = mysql_query("SELECT icon,name FROM ".$pre."systems WHERE id = '".$systems."'");
	$systemsa = mysql_fetch_row($squery);

	    $pryr[0] = "{name}";
		$pryr[1] = "{link}";
		$pryr[2] = "{date}";
		$pryr[3] = "{id}";
		$pryr[4] = "{icon}";
		$pryr[5] = "{cat}";
		$pryr[6] = "{image}";
		$pryr[7] = "{short}";
		$aryr[0] = stripslashes($row[name]);
		$aryr[1] = $part1.$row[id].fthrough($row[name], $row[cat]).$part2;
		$aryr[2] = date($setting[dformat], $row[date]);
		$aryr[3] = $row[id];
		$aryr[4] = "<img src='".stripslashes($systemsa[0])."'>";
		$aryr[5] = $row[cat];
		$aryr[6] = $image[0];
		$aryr[7] = stripslashes($short[0]);

		eval (" ?>" . str_replace($pryr, $aryr, $temp) . " <?php ");
	}
}
if (($_GET['t'] == "") && ($template1[0])) {
eval (" ?>" . footera() . " <?php ");
}
}

if ($_GET['view'] == "games") {
if ($_GET['t']) {

	$temp = loadTemplate(stripslashes("templates/".$maintheme."/".$_GET['t'].".php"));

if ($_GET['s'] == "") {
echo abclist("?load=list&view=games", "");
} else {
echo abclist("?load=list&view=games&s=".$_GET['s'], "");
}
} else {

	$temp = loadTemplate(stripslashes("templates/".$maintheme."/".$template1[1].".php"));


if ($_GET['s'] == "") {
echo abclist("?load=list&view=games", "");
} else {
echo abclist("?load=list&view=games&s=".$_GET['s'], "");
}
}

if ($temp == "") {
if ($_GET['s'] == "") {
 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
$sql = mysql_query("SELECT * FROM ".$pre."games WHERE name LIKE '".$_GET['abc']."%' ORDER BY `".$by3."` ".$type3." LIMIT ".$limit);
} else {
$sql = mysql_query("SELECT * FROM ".$pre."games ORDER BY `".$by3."` ".$type3." LIMIT ".$limit);
}
} else {
 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
$sql = mysql_query("SELECT * FROM ".$pre."games WHERE system = '".$_GET['s']."' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by3."` ".$type3." LIMIT ".$limit);
} else {
$sql = mysql_query("SELECT * FROM ".$pre."games WHERE system = '".$_GET['s']."' ORDER BY `".$by3."` ".$type3." LIMIT ".$limit);
}
}
while($row = mysql_fetch_array($sql)) {
	echo "- <a href='".$gamepart1.$row[id].fthrough($row[name], "").$gamepart2."'>".stripslashes($row[name])."</a><br>";
}

eval (" ?>" . footera() . " <?php ");

} else {

if ($_GET['s'] == "") {
 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
$sql = mysql_query("SELECT * FROM ".$pre."games WHERE name LIKE '".$_GET['abc']."%' ORDER BY `".$by3."` ".$type3." LIMIT ".$limit);
} else {
$sql = mysql_query("SELECT * FROM ".$pre."games ORDER BY `".$by3."` ".$type3." LIMIT ".$limit);
}
} else {
 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
$sql = mysql_query("SELECT * FROM ".$pre."games WHERE system = '".$_GET['s']."' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by3."` ".$type3." LIMIT ".$limit);
} else {
$sql = mysql_query("SELECT * FROM ".$pre."games WHERE system = '".$_GET['s']."' ORDER BY `".$by3."` ".$type3." LIMIT ".$limit);
}
}
while($row = mysql_fetch_array($sql)) {

	$release = date($setting[dformat], $row['release']);
	$icon = mysql_fetch_row(mysql_query("SELECT icon FROM ".$pre."systems WHERE id = '".$row['system']."'"));

	    $pryr[0] = "{name}";
		$pryr[1] = "{link}";
		$pryr[2] = "{date}";
		$pryr[3] = "{id}";
		$pryr[4] = "{views}";
		$pryr[5] = "{username}";
		$pryr[6] = "{publisher}";
		$pryr[7] = "{developer}";
		$pryr[8] = "{genre}";
		$pryr[9] = "{release}";
		$pryr[10] = "{esrb}";
		$pryr[11] = "{des}";
		$pryr[12] = "{description}";
		$pryr[13] = "{icon}";
		$aryr[0] = stripslashes($row[name]);
		$aryr[1] = $gamepart1.$row[id].fthrough($row[name], "").$gamepart2;
		$aryr[2] = date($setting[dformat], $row[date]);
		$aryr[3] = $row[id];
		$aryr[4] = $row[stats];
		$aryr[5] = $row[username];
		$aryr[6] = $row[publisher];
		$aryr[7] = $row[developer];
		$aryr[8] = $row[genre];
		$aryr[9] = $release;
		$aryr[10] = $row[esrb];
		$aryr[11] = stripslashes($row[des]);
		$aryr[12] = stripslashes($row[des]);
		$aryr[13] = "<img src='".$icon[0]."'>";

		eval (" ?>" . str_replace($pryr, $aryr, $temp) . " <?php ");
	}
	eval (" ?>" . footera() . " <?php ");
}

if (($_GET['t'] == "") && ($template1[1])) {

}
}

if ($_GET['view'] == "publisher") {
if ($_GET['t']) {
$sqla = mysql_query("SELECT * FROM ".$pre."templates WHERE name = '".$_GET['t']."'");
while($user = mysql_fetch_array($sqla)) {
	$temp = stripslashes($user[template]);
}

echo abclist("?load=list&view=publisher", "");
} else {
$sqla = mysql_query("SELECT * FROM ".$pre."templates WHERE name = '".$template1[2]."'");
while($user = mysql_fetch_array($sqla)) {
	$temp = stripslashes($user[template]);
}

echo abclist("?load=list&view=publisher", "");
}

if ($temp == "") {
 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
$sql = mysql_query("SELECT * FROM ".$pre."pr WHERE type = '".$_GET['view']."' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by2."` ".$type2." LIMIT ".$limit);
} else {
$sql = mysql_query("SELECT * FROM ".$pre."pr WHERE type = '".$_GET['view']."' ORDER BY `".$by2."` ".$type2." LIMIT ".$limit);
}
while($row = mysql_fetch_array($sql)) {
	echo "- <a href='".$ppart1.$row[id].$ppart2."'>".stripslashes($row[name])."</a><br>";
}
eval (" ?>" . footera() . " <?php ");
	} else {

 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
$sql = mysql_query("SELECT * FROM ".$pre."pr WHERE type = '".$_GET['view']."' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by2."` ".$type2." LIMIT ".$limit);
} else {
$sql = mysql_query("SELECT * FROM ".$pre."pr WHERE type = '".$_GET['view']."' ORDER BY `".$by2."` ".$type2." LIMIT ".$limit);
}
while($row = mysql_fetch_array($sql)) {
	    $pryr[0] = "{name}";
		$pryr[1] = "{link}";
		$pryr[2] = "{date}";
		$pryr[3] = "{id}";
		$pryr[4] = "{site}";
		$pryr[5] = "{siteend}";
		$pryr[6] = "{des}";
        $pryr[7] = "{description}";
		$aryr[0] = stripslashes($row[name]);
		$aryr[1] = $ppart1.$row[id].$ppart2;
		$aryr[2] = date($setting[dformat], $row[date]);
		$aryr[3] = $row[id];
		$aryr[4] = "<a href='".$row[site]."'>";
		$aryr[5] = "</a>";
		$aryr[6] = stripslashes($row[des]);
		$aryr[7] = stripslashes($row[des]);

		eval (" ?>" . str_replace($pryr, $aryr, $temp) . " <?php ");
	}
}
if (($_GET['t'] == "") && ($template1[2])) {
eval (" ?>" . footera() . " <?php ");
}
}

if ($_GET['view'] == "developer") {
if ($_GET['t']) {
$sqla = mysql_query("SELECT * FROM ".$pre."templates WHERE name = '".$_GET['t']."'");
while($user = mysql_fetch_array($sqla)) {
	$temp = stripslashes($user[template]);
}

echo abclist("?load=list&view=developer", "");
} else {
$sqla = mysql_query("SELECT * FROM ".$pre."templates WHERE name = '".$template1[2]."'");
while($user = mysql_fetch_array($sqla)) {
	$temp = stripslashes($user[template]);
}

echo abclist("?load=list&view=developer", "");
}

if ($temp == "") {
 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
$sql = mysql_query("SELECT * FROM ".$pre."pr WHERE type = '".$_GET['view']."' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by2."` ".$type2." LIMIT ".$limit);
} else {
$sql = mysql_query("SELECT * FROM ".$pre."pr WHERE type = '".$_GET['view']."' ORDER BY `".$by2."` ".$type2." LIMIT ".$limit);
}
while($row = mysql_fetch_array($sql)) {
	echo "- <a href='".$ppart1.$row[id].$ppart2."'>".stripslashes($row[name])."</a><br>";
}
eval (" ?>" . footera() . " <?php ");

	} else {

 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
$sql = mysql_query("SELECT * FROM ".$pre."pr WHERE type = '".$_GET['view']."' AND name LIKE '".$_GET['abc']."%' ORDER BY `".$by2."` ".$type2." LIMIT ".$limit);
} else {
$sql = mysql_query("SELECT * FROM ".$pre."pr WHERE type = '".$_GET['view']."' ORDER BY `".$by2."` ".$type2." LIMIT ".$limit);
}
while($row = mysql_fetch_array($sql)) {
	    $pryr[0] = "{name}";
		$pryr[1] = "{link}";
		$pryr[2] = "{date}";
		$pryr[3] = "{id}";
		$pryr[4] = "{site}";
		$pryr[5] = "{siteend}";
		$pryr[6] = "{des}";
		$pryr[7] = "{des}";
		$aryr[0] = stripslashes($row[name]);
		$aryr[1] = $ppart1.$row[id].$ppart2;
		$aryr[2] = date($setting[dformat], $row[date]);
		$aryr[3] = $row[id];
		$aryr[4] = "<a href='".$row[site]."'>";
		$aryr[5] = "</a>";
		$aryr[6] = stripslashes($row[des]);
		$aryr[7] = stripslashes($row[des]);

		eval (" ?>" . str_replace($pryr, $aryr, $temp) . " <?php ");
	}
}
if (($_GET['t'] == "") && ($template1[2])) {
eval (" ?>" . footera() . " <?php ");
}
}

if ($_GET['view'] == "releases") {
echo "<center><u>Upcoming Releases</u></center><br><br><table cellpadding='3' cellspacing='0' border='0' width='98%' align='center'>";
$sql = mysql_query("SELECT * FROM ".$pre."games ORDER BY `release` ASC");
while($r = mysql_fetch_array($sql)) {
if (($r[release] > time()) && ($r[release] > "0")) {

$pub = mysql_fetch_row(mysql_query("SELECT id FROM ".$pre."pr WHERE name = '".$r[publisher]."'"));
$dev = mysql_fetch_row(mysql_query("SELECT id FROM ".$pre."pr WHERE name = '".$r[developer]."'"));

echo "<tr><td><a href='".$gamepart1.$r[id].fthrough($r[name], "").$gamepart2."'>".$r[name]."</a></td><td><a href='".$ppart1.$pub[0].$ppart2."'>".$r[publisher]."</a></td><td><a href='".$ppart1.$dev[0].$ppart2."'>".$r[developer]."</a></td><td>".date("M d, Y", $r[release])."</td></tr>";
}
}
echo "</table>";

eval (" ?>" . footera() . " <?php ");
}

if ($_GET['view'] == "systems") {
$sqla = mysql_query("SELECT * FROM ".$pre."templates WHERE name = '".$_GET['t']."'");
while($user = mysql_fetch_array($sqla)) {
	$temp = stripslashes($user[template]);
}

if ($temp == "") {
echo abclist("?load=list&view=systems", "");
 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
$sql = mysql_query("SELECT * FROM ".$pre."systems WHERE name LIKE '".$_GET['abc']."%' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
} else {
$sql = mysql_query("SELECT * FROM ".$pre."systems ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
while($row = mysql_fetch_array($sql)) {
echo "- <a href='index.php?id=systems&sid=".$row[abr]."'>".stripslashes($row[name])."</a><br>";
}

eval (" ?>" . footera() . " <?php ");
} else {
 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
$sql = mysql_query("SELECT * FROM ".$pre."systems WHERE name LIKE '".$_GET['abc']."%' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
} else {
$sql = mysql_query("SELECT * FROM ".$pre."systems ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
while($row = mysql_fetch_array($sql)) {
	    $pryr[0] = "{name}";
		$pryr[1] = "{link}";
		$pryr[2] = "{abr}";
		$pryr[3] = "{status}";
		$pryr[4] = "{icon}";
		$pryr[5] = "{id}";
		$aryr[0] = stripslashes($row[name]);
		$aryr[1] = "index.php?id=systems&sid=".$row[abr];
		$aryr[2] = stripslashes($row[abr]);
		$aryr[3] = stripslashes($row[status]);
		$aryr[4] = "<img src='".stripslashes($row[icon])."'>";
		$aryr[5] = $row[id];

		eval (" ?>" . str_replace($pryr, $aryr, $temp) . " <?php ");
	}
}
}

$sqls = mysql_query("SELECT * FROM ".$pre."cat");
while($rows = mysql_fetch_array($sqls)) {
if ($_GET['view'] == strtolower($rows[name])) {
if ($_GET['t']) {
$sqla = mysql_query("SELECT * FROM ".$pre."templates WHERE name = '".$_GET['t']."'");
while($user = mysql_fetch_array($sqla)) {
	$temp = stripslashes($user[template]);
}

if ($_GET['s'] == "") {
echo abclist("?load=list&view=".$_GET['view'], "");
} else {
echo abclist("?load=list&view=".$_GET['view']."&s=".$_GET['s'], "");
}
} else {
$temp = loadTemplate(stripslashes("templates/".$maintheme."/".$template1[0].".php"));

if ($_GET['s'] == "") {
echo abclist("?load=list&view=".$_GET['view'], "");
} else {
echo abclist("?load=list&view=".$_GET['view']."&s=".$_GET['s'], "");
}
}

if ($temp == "") {
 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
if (($_GET['s']) && ($_GET['g'])) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND systems = '".$_GET['s']."' AND games = '".$_GET['g']."' AND name LIKE '".$_GET['abc']."%' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
} else {
if (($_GET['s']) && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND systems = '".$_GET['s']."' AND name LIKE '".$_GET['abc']."%' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'])) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND games = '".$_GET['g']."' AND name LIKE '".$_GET['abc']."%' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND name LIKE '".$_GET['abc']."%' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
}
} else {
if (($_GET['s']) && ($_GET['g'])) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND systems = '".$_GET['s']."' AND games = '".$_GET['g']."' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
} else {
if (($_GET['s']) && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND systems = '".$_GET['s']."' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'])) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND games = '".$_GET['g']."' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
}
}
while($row = mysql_fetch_array($sql)) {

    $system13 = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE id2 = '".$row[id]."' AND name = 'systems' AND cat = 'content'"));
	$systems = $system13[0];

	$squery = mysql_query("SELECT icon,name FROM ".$pre."systems WHERE id = '".$systems."'");
	$icon = mysql_fetch_row($squery);

	echo "- <a href='".$part1.$row[id].fthrough($row[name], $row[cat]).$part2."'>".stripslashes($row[name])."</a> ";
	
	if ($icon[0]) {
	echo "<img src='".stripslashes($icon[0])."'>";
	}
	echo "<br>";
}
eval (" ?>" . footera() . " <?php ");
} else {
 if (($_GET['abc']) && (strlen($_GET['abc']) == 1)) {
if (($_GET['s']) && ($_GET['g'])) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND systems = '".$_GET['s']."' AND games = '".$_GET['g']."' AND name LIKE '".$_GET['abc']."%' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
} else {
if (($_GET['s']) && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND systems = '".$_GET['s']."' AND name LIKE '".$_GET['abc']."%' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'])) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND games = '".$_GET['g']."' AND name LIKE '".$_GET['abc']."%' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND name LIKE '".$_GET['abc']."%' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
}
} else {
if (($_GET['s']) && ($_GET['g'])) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND systems = '".$_GET['s']."' AND games = '".$_GET['g']."' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
} else {
if (($_GET['s']) && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND systems = '".$_GET['s']."' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'])) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND games = '".$_GET['g']."' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
if (($_GET['s'] == "") && ($_GET['g'] == "")) {
$sql = mysql_query("SELECT * FROM ".$pre."content WHERE cat = '".$_GET['view']."' AND ver = '0' ORDER BY `".$by."` ".$type." LIMIT ".$limit);
}
}
}
while($row = mysql_fetch_array($sql)) {
    $systems = $row[systems];
	$squery = mysql_query("SELECT icon,name FROM ".$pre."systems WHERE id = '".$systems."'");
	$icon = mysql_fetch_row($squery);

	    $pryr[0] = "{name}";
		$pryr[1] = "{link}";
		$pryr[2] = "{date}";
		$pryr[3] = "{id}";
		$pryr[4] = "{icon}";
		$pryr[5] = "{cat}";
		$pryr[6] = "{system}";
		$aryr[0] = stripslashes($row[name]);
		$aryr[1] = $part1.$row[id].fthrough($row[name], $row[cat]).$part2;
		$aryr[2] = date($setting[dformat], $row[date]);
		$aryr[3] = $row[id];
		$aryr[4] = "<img src='".$icon[0]."'>";
		$aryr[5] = $_GET['view'];
		$aryr[6] = $icon[1];

		eval (" ?>" . str_replace($pryr, $aryr, $temp) . " <?php ");
	}
	eval (" ?>" . footera() . " <?php ");
}
}
}
}

if ($_GET['load'] == "systems") {
$sys = mysql_fetch_row(mysql_query("SELECT skin FROM ".$pre."systems WHERE abr = '".$_GET['sid']."'"));

if ($sys[0]) {
$query="SELECT * FROM ".$pre."skins WHERE id = '".$sys[0]."'";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)) {

	 eval (" ?>" . stripslashes($row[header]) . " <?php ");

}
} else {

}

$templateu = loadTemplate("templates/".$maintheme."/systems.php");

$queryty="SELECT * FROM ".$pre."systems WHERE abr = '".$_GET['sid']."'";
$resultty=mysql_query($queryty);
while($row2 = mysql_fetch_array($resultty)) {
	   $sy1[0] = "{id}";
       $sy1[1] = "{name}";
	   $sy1[2] = "{abr}";
	   $sy1[3] = "{icon}";
	   $sy2[0] = $row2[id];
	   $sy2[1] = $row2[name];
	   $sy2[2] = $row2[abr];
	   $sy2[3] = "<img src='".$row2[icon]."'>";

	   eval (" ?>" . str_replace($sy1, $sy2, $templateu) . " <?php ");

}

$sys = mysql_fetch_row(mysql_query("SELECT skin FROM ".$pre."systems WHERE abr = '".$_GET['sid']."'"));

if ($sys[0]) {
$query="SELECT * FROM ".$pre."skins WHERE id = '".$sys[0]."'";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)) {

	 eval (" ?>" . stripslashes($row[footer]) . " <?php ");

}
} else {
eval (" ?>" . footera() . " <?php ");
}
}

if (($_GET['load'] == "content") && (is_numeric($_GET['game_id']))) {
$sys = mysql_fetch_row(mysql_query("SELECT skin FROM ".$pre."games WHERE id = '".$_GET['game_id']."'"));

if ($sys[0]) {
$query="SELECT * FROM ".$pre."skins WHERE id = '".$sys[0]."'";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)) {
eval (" ?>" . stripslashes($row[header]) . " <?php ");
}
} else {
}

$templateabc = loadTemplate("templates/".$maintheme."/games.php");

$query="SELECT * FROM ".$pre."games WHERE id = '".$_GET['game_id']."'";
$result=mysql_query($query);
while($rowbloo = mysql_fetch_array($result)) {
$stats = "$rowbloo[stats]";
$val = $stats + 1;

	$gamesql = mysql_fetch_row(mysql_query("SELECT id FROM ".$pre."pr WHERE name = '".$rowbloo['publisher']."'"));

	$gamesql2 = mysql_fetch_row(mysql_query("SELECT id FROM ".$pre."pr WHERE name = '".$rowbloo['developer']."'"));

    $btype = mysql_fetch_row(mysql_query("SELECT type2 FROM ".$pre."images WHERE name = '".$rowbloo['boxart']."'"));

	$albums = $rowbloo[album];
	
	$gamename = mysql_fetch_row(mysql_query("SELECT * FROM ".$pre."fielddata WHERE name = 'games' AND data = '".$_GET['game_id']."'"));
	
	$overall = mysql_fetch_row(mysql_query("SELECT * FROM ".$pre."fielddata WHERE name = 'Overall' AND id2 = '".$gamename[3]."'"));

	$vate[] = "{name}";
	$vate[] = "{username}";
	$vate[] = "{publisher}";
	$vate[] = "{developer}";
	$vate[] = "{genre}";
	$vate[] = "{release}";
	$vate[] = "{esrb}";
	$vate[] = "{boxart}";
	$vate[] = "{des}";
	$vate[] = "{description}";
	$vate[] = "{id}";
	$vate[] = "{views}";
	$vate[] = "{game-favorites}";
	$vate[] = "{game-playing}";
	$vate[] = "{game-tracked}";
	$vate[] = "{game-wishlist}";
	$vate[] = "{game-collection}";
	$vate[] = "{game-systems}";
	$vate[] = "{overall}";
	$tate[] = $rowbloo["name"];
	$tate[] = $rowbloo["username"];
	$tate[] = "<a href='".$ppart1.$gamesql[0].$ppart2."'>".$rowbloo['publisher']."</a>";
	$tate[] = "<a href='".$ppart1.$gamesql2[0].$ppart2."'>".$rowbloo['developer']."</a>";
	$tate[] = $rowbloo['genre'];
	if ((date("M - d - y", $rowbloo['date']) == "Dec - 31 - 69") or ($rowbloo['date'] == "0")) {
	$tate[] = $rowbloo['date'];
	} else {
	$tate[] = date($setting[dformat], $rowbloo['date']);
	}
	$tate[] = $rowbloo['esrb'];
	if ($rowbloo['boxart']) {
	if ($btype[0] == "ss") {
	if (($boxart1) && ($boxart2)) {
	$tate[] = "<img src='".$setting[images]."/".$rowbloo['boxart']."' border='1' width='".$boxart1."' height='".$boxart2."'>";
	} else {
	$tate[] = "<img src='".$setting[images]."/".$rowbloo['boxart']."' border='1'>";
	}
	} else {
	if (($boxart1) && ($boxart2)) {
	$tate[] = $rowbloo['boxart'];
	} else {
	$tate[] = $rowbloo['boxart'];
	}
	}
	} else {
	$tate[] = "a_images/noboxart.jpg";
	}
	$tate[] = stripslashes($rowbloo['des']);
	$tate[] = stripslashes($rowbloo['des']);
	$tate[] = $_GET['game_id'];
	$tate[] = $val;
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$rowbloo[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_f.jpg' border='1' title='Favorites' alt='Favorites'></a>";
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$rowbloo[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_t.jpg' border='1' title='Tracked' alt='Tracked'></a>";
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$rowbloo[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_p.jpg' border='1' title='Playing' alt='Playing'></a>";
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$rowbloo[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_w.jpg' border='1' title='Wishlist' alt='Wishlist'></a>";
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$rowbloo[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a>";
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elites&id=".$rowbloo[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_s.jpg' border='1' title='Systems' alt='Systems'></a>";
	if ($overall[2] == "") {
	$tate[] = "NR";
	} else {
	$tate[] = stripslashes($overall[2]);
	}

	if ($albums) {
	$gal = mysql_fetch_row(mysql_query("SELECT id,name FROM ".$pre."albums WHERE id = '".$albums."'"));

	$vate[] = "{".$name."}";
	$vate[] = "{gallery}";
	$vate[] = "{gallery;";
	$vate[] = "{endgallery}";
	$vate[] = ";gallery}";
	$vate[] = "{cat-gallery}";
	$tate[] = "<a href='".$gpart1.$gal[0].fthrough($gal[1], "").$gpart2."'>Gallery</a>";
	$tate[] = "<a href='".$gpart1.$gal[0].fthrough($gal[1], "").$gpart2."'>";
	$tate[] = "<a href='".$gpart1.$gal[0].fthrough($gal[1], "").$gpart2."'>";
	$tate[] = "</a>";
	$tate[] = "</a>";
	$tate[] = $gpart1.$galid[0].fthrough($galid[1], "").$gpart2;
	} else {
	$galid = mysql_fetch_row(mysql_query("SELECT id,name FROM ".$pre."albums WHERE name LIKE '%" . addslashes($rowbloo["name"]) . "%'"));
    if ($galid[0]) {
	$vate[] = "{".$name."}";
	$vate[] = "{gallery}";
	$vate[] = "{gallery;";
	$vate[] = "{endgallery}";
	$vate[] = ";gallery}";
	$vate[] = "{cat-gallery}";
	$tate[] = "<a href='".$gpart1.$galid[0].fthrough($galid[1], "").$gpart2."'>Gallery</a>";
	$tate[] = "<a href='".$gpart1.$galid[0].fthrough($galid[1], "").$gpart2."'>";
	$tate[] = "<a href='".$gpart1.$galid[0].fthrough($galid[1], "").$gpart2."'>";
	$tate[] = "</a>";
	$tate[] = "</a>";
	$tate[] = $gpart1.$galid[0].fthrough($galid[1], "").$gpart2;
	} else {
	$vate[] = "{".$name."}";
	$vate[] = "{gallery}";
	$vate[] = "{gallery;";
	$vate[] = "{endgallery}";
	$vate[] = ";gallery}";
	$vate[] = "{cat-gallery}";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	}
	}

	$sqlabc = mysql_query("SELECT * FROM ".$pre."cat ORDER BY `id` DESC");
	while ($ra = mysql_fetch_array($sqlabc)) {

		$brb = @mysql_fetch_row(@mysql_query("SELECT id,name,cat FROM ".$pre."content WHERE cat = '".$ra[name]."' AND games = '".$_GET['game_id']."'"));

        if ($brb[0]) {
		$vate[] = "{".$ra[name].";";
		$vate[] = ";".$ra[name]."}";
		$tate[] = "<a href='".$part1.$brb[0].fthrough($brb[1], $brb[2]).$part2."'>";
		$tate[] = "</a>";
		} else {
		$vate[] = "{".$ra[name].";";
		$vate[] = ";".$ra[name]."}";
		$tate[] = "";
		$tate[] = "";
		}
		}

mysql_query("UPDATE ".$pre."games SET stats = '".$val."' WHERE id = '".$_GET['game_id']."'");

$sql = mysql_query("SELECT * FROM ".$pre."fields WHERE cat = 'games'");
while ($row = mysql_fetch_array($sql)) {
$name = stripslashes($row[name]);

$dataa = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE name = '".$name."' AND id2 = '".$rowbloo['id']."' AND cat = 'games'"));
$data = stripslashes($dataa[0]);

$vate[] = "{".$name."}";
$tate[] = $data;
}
eval (" ?>" . stripslashes(str_replace($vate, $tate, $templateabc)) . " <?php ");
}

$sys = mysql_fetch_row(mysql_query("SELECT skin FROM ".$pre."games WHERE id = '".$_GET['game_id']."'"));

if ($sys[0]) {
$footer = mysql_fetch_row(mysql_query("SELECT footer FROM ".$pre."skins WHERE id = '".$sys[0]."'"));
eval (" ?>" . stripslashes($footer[0]) . " <?php ");
} else {
eval (" ?>" . footera() . " <?php ");
}
}

if (($_GET['load'] == "content") && (is_numeric($_GET['pr_id']))) {

$templatem = loadTemplate("templates/".$maintheme."/PR_Manager.php");


$sql2 = mysql_query("SELECT * FROM ".$pre."pr WHERE id = '".$_GET['pr_id']."'");
while($row = mysql_fetch_array($sql2)) {
	$vm[] = "{name}";
	$vm[] = "{site}";
	$vm[] = "{description}";
	$vm[] = "{country}";
	$vm[] = "{phone}";
	$vm[] = "{address}";
	$vm[] = "{logo}";
	$tm[] = $row["name"];
	$tm[] = $row["site"];
	$tm[] = stripslashes($row['des']);
	$tm[] = stripslashes($row['country']);
	$tm[] = stripslashes($row['phone']);
	$tm[] = stripslashes($row['address']);
	$tm[] = stripslashes($row['logo']);

}
eval (" ?>" . str_replace($vm, $tm, $templatem) . " <?php ");
eval (" ?>" . footera() . " <?php ");
}

if (($_GET['load'] == "content") && (is_numeric($_GET['id']))) {
$sys2 = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE id2 = '".$_GET['id']."' AND name = 'games' AND cat = 'content'"));

if ($sys[0]) {
$sql = mysql_query("SELECT * FROM ".$pre."skins WHERE id = '".$sys[0]."'");
while($r = mysql_fetch_array($sql)) {
eval (" ?>" . stripslashes($r[header]) . " <?php ");
}
}

$sql2 = mysql_query("SELECT * FROM ".$pre."content WHERE id = '".$_GET['id']."' AND ver = '0'");
while($row30 = mysql_fetch_array($sql2)) {
$cat = "$row30[cat]";
$postpone = "$row30[postpone]";
$ver = "$row30[ver]";
$stats = "$row30[stats]";
$lev = "$row30[lev]";

if (($lev == "Yes") && ($_COOKIE[$pre."username"] == "")) {
echo "Sorry, but you must be a member of ".$setting[sitename]." in order to view this content. Please <a href='".$register."'>Register</a> or <a href='".$login."'>Login</a>. Thank you.";
} else {


$templatebhe = loadTemplate("templates/".$maintheme."/".$cat.".php");

$cnum2 = mysql_query("SELECT * FROM ".$pre."comments WHERE aid = '".$_GET['id']."'");
$cnum = mysql_num_rows($cnum2);


	$systemsabc = mysql_fetch_row(mysql_query("SELECT * FROM ".$pre."fielddata WHERE id2 = '".$_GET['id']."' AND name = 'systems' AND cat = 'content'"));
	$systems = $systemsabc[2];
	$gamesabc = mysql_fetch_assoc(mysql_query("SELECT * FROM ".$pre."fielddata WHERE name = 'games' AND id2 = '".$_GET['id']."' AND cat = 'content'"));
	$games = $gamesabc[data];

	$albums = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE id2 = '".$_GET['id']."' AND name = 'albums' AND cat = 'content'"));
	$gamename = mysql_fetch_row(mysql_query("SELECT name,album FROM ".$pre."games WHERE id = '".$games."'"));
	$systemsa = mysql_fetch_row(mysql_query("SELECT icon,name FROM ".$pre."systems WHERE id = '".$systems."'"));

    $wordsql = mysql_query("SELECT * FROM ".$pre."fields WHERE type = 'textarea'");
	while($r = mysql_fetch_array($wordsql)) {
	$wname = $r[name];

	if (($r[cat] == "") or ($r[cat] == $row30[cat])) {
	$test = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE id2 = '".$_GET['id']."' AND name = '".$wname."' AND cat = 'content'"));
	$ov .= $test[0]." ";
	}
	}

    $wordcount = word_count($ov);

	$vate[] = "{name}";
	$vate[] = "{cat}";
	$vate[] = "{systems}";
	$vate[] = "{icon}";
	$vate[] = "{username}";
	$vate[] = "{date}";
	$vate[] = "{views}";
	$vate[] = "{cform}";
	$vate[] = "{comments}"; // shows the comments
	$vate[] = "{clink}";
	$vate[] = "{endclink}";
	$vate[] = "{cnum}";
	$vate[] = "{id}";
	$vate[] = "{wordcount}";
	if (($games) && ($_COOKIE[$pre."username"])) {
	$vate[] = "{game-favorites}";
	$vate[] = "{game-playing}";
	$vate[] = "{game-tracked}";
	$vate[] = "{game-wishlist}";
	$vate[] = "{game-collection}";
	$vate[] = "{game-systems}";
	}
	$vate[] = "{gamename}";
	$vate[] = "{userreview-rating}";
	$vate[] = "{userreview;";
	$vate[] = ";userreview}";
	$tate[] = stripslashes($row30["name"]);
	$tate[] = $row30["cat"];
	$tate[] = stripslashes($systemsa[1]);
	$tate[] = "<img src='".stripslashes($systemsa[0])."'>";
	$tate[] = stripslashes($row30["username"]);
	if ((date("M - d - y", $row30['date']) == "Dec - 31 - 69") or ($row30['date'] == "0")) {
	$tate[] = $row30['date'];
	} else {
	$tate[] = date($setting[dformat], $row30['date']);
	}

	$val = $stats + 1;

	$tate[] = $val;
	$tate[] = "<a href='javascript:awindow(\"comments.php?load=comments&aid=".$_GET[id]."\", \"\", \"width=600,height=400,scroll=yes\")'>Post Comment</a>";
    $tate[] = "<a href='javascript:awindow(\"comments.php?load=comments&j=".$_GET['id']."\", \"\", \"width=600,height=450,scroll=yes\")'>View Comments</a>";
	$tate[] = "<a href='comments.php?load=comments&id=".$_GET['id']."'>";
	$tate[] = "</a>";
	$tate[] = "$cnum";
	$tate[] = $_GET['id'];
	$tate[] = $wordcount;
	if (($games) && ($_COOKIE[$pre."username"])) {
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$games."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_f.jpg' border='1' title='Favorites' alt='Favorites'></a>";
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$games."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_t.jpg' border='1' title='Tracked' alt='Tracked'></a>";
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$games."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_p.jpg' border='1' title='Playing' alt='Playing'></a>";
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$games."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_w.jpg' border='1' title='Wishlist' alt='Wishlist'></a>";
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$games."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a>";
	$tate[] = "<a href='javascript:awindow(\"index.php?load=elite&view=elites&id=".$systems."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$setting[siteurl]."/a_images/elite_s.jpg' border='1' title='Systems' alt='Systems'></a>";
	}
	$tate[] = $gamename;
    
	$uss = mysql_fetch_row(mysql_query("SELECT overall,id FROM ".$pre."userreviews WHERE games = '".$games."'"));

	$tate[] = $uss[0];
	$tate[] = "<a href='userreviews.php?id=".$uss[1]."'>";
	$tate[] = "</a>";

	$gameid = stripslashes($games);

	if ($gamename[1]) {
	$gal = mysql_fetch_row(mysql_query("SELECT id,name FROM ".$pre."albums WHERE id = '".$gamename[1]."'"));

	$vate[] = "{".$name."}";
	$vate[] = "{gallery}";
	$vate[] = "{gallery;";
	$vate[] = "{endgallery}";
	$vate[] = ";gallery}";
	$vate[] = "{cat-gallery}";
	$tate[] = "<a href='".$gpart1.$gal[0].fthrough($gal[1], "").$gpart2."'>Gallery</a>";
	$tate[] = "<a href='".$gpart1.$gal[0].fthrough($gal[1], "").$gpart2."'>";
	$tate[] = "<a href='".$gpart1.$gal[0].fthrough($gal[1], "").$gpart2."'>";
	$tate[] = "</a>";
	$tate[] = "</a>";
	$tate[] = $gpart1.$galid[0].fthrough($gal[1], "").$gpart2;
	} else {
	$galid = mysql_fetch_row(mysql_query("SELECT id,name FROM ".$pre."albums WHERE name LIKE '%" . addslashes($row30["name"]) . "%'"));
    if ($galid[0]) {
	$vate[] = "{".$name."}";
	$vate[] = "{gallery}";
	$vate[] = "{gallery;";
	$vate[] = "{endgallery}";
	$vate[] = ";gallery}";
	$vate[] = "{cat-gallery}";
	$tate[] = "<a href='".$gpart1.$galid[0].fthrough($galid[1], "").$gpart2."'>Gallery</a>";
	$tate[] = "<a href='".$gpart1.$galid[0].fthrough($galid[1], "").$gpart2."'>";
	$tate[] = "<a href='".$gpart1.$galid[0].fthrough($galid[1], "").$gpart2."'>";
	$tate[] = "</a>";
	$tate[] = "</a>";
	$tate[] = $gpart1.$galid[0].fthrough($galid[1], "").$gpart2;
	} else {
	$vate[] = "{".$name."}";
	$vate[] = "{gallery}";
	$vate[] = "{gallery;";
	$vate[] = "{endgallery}";
	$vate[] = ";gallery}";
	$vate[] = "{cat-gallery}";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	}
	}

    if ($gameid) {
	$sqlabc = mysql_query("SELECT * FROM ".$pre."cat ORDER BY `id` DESC");
	while ($ra = mysql_fetch_array($sqlabc)) {
	


		$brb = mysql_fetch_row(mysql_query("SELECT id,name,cat FROM ".$pre."content WHERE cat = '".$ra[name]."' AND id = '".$games[id]."'"));

        if ($brb[0]) {
		$vate[] = "{".$ra[name].";";
		$vate[] = ";".$ra[name]."}";
		$vate[] = "{cat-".$ra[name]."}";
		$tate[] = "<a href='".$part1.$brb[0].fthrough($brb[1], $brb[2]).$part2."'>";
		$tate[] = "</a>";
		$tate[] = $part1.$brb[0].fthrough($brb[1], $brb[2]).$part2;
		} else {
		$vate[] = "{".$ra[name].";";
		$vate[] = ";".$ra[name]."}";
		$vate[] = "{cat-".$ra[name]."}";
		$tate[] = "";
		$tate[] = "";
		$tate[] = "";
		}
		}
	} else {
	$sqlabca = mysql_query("SELECT * FROM ".$pre."cat ORDER BY `id` DESC");
	while ($raa = mysql_fetch_array($sqlabca)) {
	$vate[] = "{".$raa[name].";";
	$vate[] = ";".$raa[name]."}";
	$vate[] = "{cat-".$ra[name]."}";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	}
	}
     
	if ($gameid) {
	$gamef = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."games WHERE id = '".$games."'"));
	$vate[] = "{cat-games}";
	$tate[] = $gamepart1.$games.fthrough($gamef[0], "").$gamepart2;
	$sql4 = mysql_query("SELECT * FROM ".$pre."fields WHERE cat = 'games' ORDER BY `id` DESC");
	while ($l = mysql_fetch_array($sql4)) {
		$vate[] = "{game-".$l[name]."}";

	$z = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE id2 = '".$gameid."' AND cat = 'games' AND name = '".$l[name]."'"));

	$tate[] = stripslashes($z[0]);
	}
	}

	if ($gameid == "") {
	$sql4 = mysql_query("SELECT * FROM ".$pre."fields WHERE cat = 'games' ORDER BY `id` DESC");
	while ($l = mysql_fetch_array($sql4)) {
	$vate[] = "{game-".$l[name]."}";
	$tate[] = "";
	}
	}

    if ($row30[username]) {
	$p = mysql_fetch_row(mysql_query("SELECT aim,msn,website,nickname,location,sig,avatar FROM ".$pre."profile WHERE username = '".$row30[username]."'"));
	$vate[] = "{user-aim}";
	$vate[] = "{user-msn}";
	$vate[] = "{user-website}";
	$vate[] = "{user-nickname}";
	$vate[] = "{user-location}";
	$vate[] = "{user-sig}";
	$vate[] = "{user-avatar}";
	$tate[] = $p[0];
	$tate[] = $p[1];
	$tate[] = $p[2];
	$tate[] = $p[3];
	$tate[] = $p[4];
	$tate[] = stripslashes($p[5]);
	if ($p[6]) {
	$tate[] = "<img src='".stripslashes($p[6])."'>";
	} else {
	$tate[] = "";
	}
	} else {
	$vate[] = "{user-aim}";
	$vate[] = "{user-msn}";
	$vate[] = "{user-website}";
	$vate[] = "{user-nickname}";
	$vate[] = "{user-location}";
	$vate[] = "{user-sig}";
	$vate[] = "{user-avatar}";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	$tate[] = "";
	}

    if ($gameid) {
	
	$gamesda = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE name = 'games' AND data = '".$gameid."' AND cat = 'content'"));

	
	$m = mysql_fetch_assoc(mysql_query("SELECT * FROM ".$pre."games WHERE id = '".$gameid."'"));
	$ma = mysql_fetch_assoc(mysql_query("SELECT * FROM ".$pre."pr WHERE name = '".$m[publisher]."'"));
	$ma2 = mysql_fetch_assoc(mysql_query("SELECT * FROM ".$pre."pr WHERE name = '".$m[developer]."'"));
	$price = mysql_fetch_row(mysql_query("SELECT * FROM ".$pre."fielddata WHERE name = 'Price' AND cat = 'games' AND id2 = '".$gameid."'"));
	$buy = mysql_fetch_row(mysql_query("SELECT * FROM ".$pre."fielddata WHERE name = 'Buy' AND cat = 'games' AND id2 = '".$gameid."'"));
	$overall = mysql_fetch_row(mysql_query("SELECT * FROM ".$pre."fielddata WHERE name = 'Overall' AND id2 = '".$gameid."'"));
	$platform = mysql_fetch_row(mysql_query("SELECT * FROM ".$pre."systems WHERE id = '".$m[system]."'"));
	
	$gamesql3 = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."pr WHERE name = '".$m['developer']."'"));
	
	$gamesql4 = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."pr WHERE name = '".$m['publisher']."'"));

	$vate[] = "{game-id}";
	$tate[] = $gameid;

	$vate[] = "{game-publisher}";
	$tate[] = "<a href='".$ppart1.$ma[id].fthrough($gamesql4[0], "").$ppart2."'>".$m['publisher']."</a>";

	$vate[] = "{game-developer}";
	$tate[] = "<a href='".$ppart1.$ma2[id].fthrough($gamesql3[0], "").$ppart2."'>".$m['developer']."</a>";

	$vate[] = "{game-genre}";
	$tate[] = stripslashes($m[genre]);
    if ($m[date] == "") {
	$release = "None";
	} else {
	$release = date($setting[dformat], $m[date]);
    }
	$vate[] = "{game-release}";
	$tate[] = $release;

	$vate[] = "{game-views}";
	$tate[] = stripslashes($m[4]);

	$k = mysql_fetch_row(mysql_query("SELECT id FROM ".$pre."profile WHERE username = '".$m[5]."'"));

	$vate[] = "{game-user}";
	$tate[] = "<a href='index.php?load=elite&user=".$k[0]."'>".stripslashes($m[5])."</a>";

	$vate[] = "{game-des}";
	$tate[] = stripslashes($m[6]);

	$vate[] = "{game-boxart}";
	if ($m['boxart'] == "") {
	$tate[] = "<img src='".$siteurl."/a_images/noboxart.jpg'>";
	} else {
	$tate[] = "<img src=\"thumbnail.php?src=".$m['boxart']."&h=200&w=141&q=100&zc=0\">";
	}

	$vate[] = "{game-esrb}";
	$tate[] = stripslashes($m[esrb]);
	
	$vate[] = "{game-icon}";
	$tate[] = "<img src='".stripslashes($platform[3])."'>";

	$vate[] = "{game-name}";
	$tate[] = stripslashes($m[name]);
	
	$vate[] = "{Price}";
	$tate[] = stripslashes($price[2]);
	
	$vate[] = "{buy}";
	$tate[] = stripslashes($buy[2]);
	
	$vate[] = "{overall}";
	if ($overall[2] == "") {
	$tate[] = "NR";
	} else {
	$tate[] = stripslashes($overall[2]);
	}
	}
	
	if ($gameid == "") {
	$vate[] = "{game-publisher}";
	$tate[] = "";

	$vate[] = "{game-developer}";
	$tate[] = "";

	$vate[] = "{game-genre}";
	$tate[] = "";

	$vate[] = "{game-release}";
	$tate[] = "";

	$vate[] = "{game-views}";
	$tate[] = "";

	$vate[] = "{game-user}";
	$tate[] = "";

	$vate[] = "{game-des}";
	$tate[] = "";
	
	$vate[] = "{Overall}";
	$tate[] = "";

	$vate[] = "{game-boxart}";
	$tate[] = "";

	$vate[] = "{game-esrb}";
	$tate[] = "";

	$vate[] = "{game-name}";
	$tate[] = "";
	
	$vate[] = "{Price}";
	$tate[] = "";
	
	$vate[] = "{Overall}";
	$tate[] = "";
	
	}

	$id = $_GET['id'];

	//

mysql_query("UPDATE ".$pre."content SET stats = '".$val."' WHERE id = '".$id."'");

$sys21[0] = $row30[games];

$sql = mysql_query("SELECT * FROM ".$pre."fields WHERE cat = '".$cat."' OR cat = 'global' OR cat = ''");
while ($row = mysql_fetch_array($sql)) {
$name = "$row[name]";
$type = "$row[type]";

if ($type == "games") {
if ($gameid) {
$gamename = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."games WHERE id = '".$gameid."'"));
		$vate[] = "{".$name."}";
	    $vate[] = "{game;";
	    $vate[] = ";game}";
		$tate[] = stripslashes($gamename[0]);
		$tate[] = "<a href='".$gamepart1.$gameid.fthrough($gamename[0], "").$gamepart2."'>";
		$tate[] = "</a>";
} else {
		$vate[] = "{".$name."}";
	    $vate[] = "{game;";
	    $vate[] = ";game}";
		$tate[] = "";
		$tate[] = "";
		$tate[] = "";
}
} else {
$dataa = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE name = '".$name."' AND id2 = '".$id."' AND cat = 'content'"));
//$yars = str_replace('face="Times New Roman" size="3"', 'size="2"', stripslashes($dataa[0]));
$yars = explode("{newpage}", stripslashes($dataa[0]));

if ($dataa[0]) {
$vate[] = "{".$name."}";
if (count($yars) > 1) {
$total_results = count($yars);
if ($_GET['page']) {
$page = $_GET['page'] - 1;
} else {
$page = 0;
}
$tate[] = $yars[$page];
} else {
$tate[] = $yars[0];
}
} else {
$vate[] = "{".$name."}";
$tate[] = "";
}
}
}

if(!isset($_GET['page'])){
    $page = 1;
} else {
    $page = $_GET['page'];
}

$from = (($page * 1) - 1);

//START PAGINATION
$total_pages = ceil($total_results / 1);
if ($total_pages > 1) {
$showthis .= "<center>";

// Build Previous Link
if($page > 1){
    $prev = ($page - 1);
$showthis .= "<a href=\"index.php?load=content&id=".$_GET['id']."&page=$prev\"><<Previous</a>&nbsp;";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
$showthis .= "$i&nbsp;";
        } else {
$showthis .= "<a href=\"index.php?load=content&id=".$_GET['id']."&page=$i\">$i</a>&nbsp;";if (($i/25) == (int)($i/25)) {echo "<br>";}
    }
}

// Build Next Link
if($page < $total_pages){
    $next = ($page + 1);
$showthis .= "<a href=\"index.php?load=content&id=".$_GET['id']."&page=$next\">Next>></a>";
}
$showthis .= "</center>";
}
//THIS CONTROLS PAGINATION

$vate[] = "{pagelist}";
$tate[] = $showthis;

$quer = mysql_query("SELECT * FROM ".$pre."content WHERE id = '".$id."' AND postpone = '' AND ver = '0'");
$i = mysql_num_rows($quer);
if ($i > "0") {
if (($postpone == date("YmdHi")) or ($postpone < date("YmdHi"))) {
if ($cat) {
eval (" ?>" . stripslashes(str_replace($vate, $tate, $templatebhe)) . " <?php ");
}
}
} else {
if ($cat) {
eval (" ?>" . stripslashes(str_replace($vate, $tate, $templatebhe)) . " <?php ");
}
}

$sys22 = mysql_fetch_row(mysql_query("SELECT data FROM ".$pre."fielddata WHERE id2 = '".$_GET['id']."' AND name = 'albums' AND cat = 'content'"));
$sys23 = mysql_fetch_row(mysql_query("SELECT cat FROM ".$pre."content WHERE id = '".$_GET['id']."' AND cat = 'content'"));

$sysabc[] = $sys21[0];
$sysabc[] = $sys22[0];
$sysabc[] = $sys23[0];

$fetch7 = @implode(",", $sysabc);
$sys2 = @explode(",", $fetch7);

if ((($sys2[1] == "media") && ($albpages == "Yes") && ($sys2[2]))) {
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM ".$pre."images WHERE album = '".$sys2[2]."'"),0);

$total_pages = ceil($total_results / $setting[max_results]);

echo "<center>Select a Page</center><br>";

// Build Previous Link
if ($page > 1) {
    $prev = ($page - 1);
    echo "<a href=\"index.php?id=".$_GET['id']."&p=$prev\"><<Previous</a>&nbsp;";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i&nbsp;";
        } else {
            echo "<a href=\"index.php?id=".$_GET['id']."&p=$i\">$i</a>&nbsp;";if (($i/25) == (int)($i/25)) {echo "<br>";}
    }
}

// Build Next Link
if ($page > 1) {
    $next = ($page + 1);
    echo "<a href=\"index.php?id=".$_GET['id']."&p=$next\">Next>></a>";
}
echo "</center>";
}

if ($sys[0]) {
$query="SELECT * FROM ".$pre."skins WHERE id = '".$sys[0]."'";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)) {

	 eval (" ?>" . stripslashes($row[footer]) . " <?php ");

}
} else {
eval (" ?>" . footera() . " <?php ");
}
}
}
}

}
}
}
}
?>