<?php
$la = "a";
$z = "b";
eval (" ?>" . headera() . " <?php ");
if ($_GET['load'] == "elite") {
if ((((((((((((((((($_GET['view'] == "newsletterss") or ($_GET['view'] == "friendsver1") or ($_GET['view'] == "friendsver2") or ($_GET['view'] == "friendsver3") or ($_GET['view'] == "delete") or ($_GET['view'] == "friendsver4") or ($_GET['view'] == "elitef") or ($_GET['view'] == "elitec") or ($_GET['view'] == "elitep") or ($_GET['view'] == "elitet") or ($_GET['view'] == "elitew") or ($_GET['view'] == "elites") or ($_GET['view'] == "blogd") or ($_GET['view'] == "newsletters") or ($_GET['view'] == "newsletters2"))))))))))))))))) {
if (($_COOKIE[$pre."username"]) && ($_COOKIE[$pre."password"])) {

if (($_GET['view'] == "delete") && ($_GET['id'])) {
$sql = mysql_query("DELETE FROM ".$pre."elite WHERE id = '".$_GET['id']."'");

if ($sql == TRUE) {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td><b>Item deleted</b>. This window will close in 3 seconds.";
}
}

if ($_GET['view'] == "newsletters") {
echo "Which format? HTML/Text<br><input type=checkbox onclick=\"window.location='index.php?load=elite&view=newsletterss&id=".$_GET['id']."&type=html'; return true;\"> / <input type=checkbox onclick=\"window.location='index.php?load=elite&view=newsletterss&id=".$_GET['id']."&type=text'; return true;\">";
}

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

	$sql = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."newsletter WHERE cat = '".$_GET['id']."' AND type = 'subscribers' AND name = '".$_COOKIE[$pre."username"]."'"));

	$fetch = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."newsletter WHERE id = '".$_GET['id']."'"));

	if ($sql == "0") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>You are now subcribed to <b>".$fetch[0]."</b> newsletter. This window will close in 3 seconds.";

	$sql2 = mysql_query("INSERT INTO ".$pre."newsletter VALUES ('null', '".$_COOKIE[$pre."username"]."', 'subscribers', '".$_GET['type']."', '".$_GET['id']."', '".time()."')") or die(mysql_error());
	} else {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>You are already subcribed to this newsletter! Window will close in 3 seconds.";
	}	
}

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

	$fetch = mysql_fetch_row(mysql_query("SELECT name FROM ".$pre."newsletter WHERE id = '".$_GET['id']."'"));

	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>You are now unsubcribed to <b>".$fetch[0]."</b> newsletter. This window will close in 3 seconds.";

	$sql = mysql_query("DELETE FROM ".$pre."newsletter WHERE id = '".$_GET['id']."'") or die(mysql_error());
}

if ($_GET['view'] == "friendsver1") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>Friend Added. This window will close in 3 seconds.";

	$sql = mysql_query("UPDATE ".$pre."friends SET ver = 'yes' WHERE id = '".$_GET['id']."'");
}

if ($_GET['view'] == "blogd") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>Blog entry deleted. This window will close in 3 seconds.";

	$sql = mysql_query("DELETE FROM ".$pre."blog WHERE id = '".$_GET['id']."'");
}

if ($_GET['view'] == "friendsver2") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>Friend Request declined. This window will close in 3 seconds.";

	$sql = mysql_query("DELETE FROM ".$pre."friends WHERE id = '".$_GET['id']."'");
}

if ($_GET['view'] == "friendsver3") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>Friend Request Deleted. This window will close in 3 seconds.";

	$sql = mysql_query("DELETE FROM ".$pre."friends WHERE id = '".$_GET['id']."'");
}

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

	$sql3 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."friends WHERE pid = '".$useridn."' AND pid2 = '".$_GET['id']."'"));

	if ($sql3 == "0") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>Friend Request sent. This window will close in 3 seconds.";

	$sql = mysql_query("INSERT INTO ".$pre."friends VALUES ('null', '".$useridn."', '".$_GET['id']."', 'no', '".time()."')");

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

	$message = "Hello,<br><br>".$_COOKIE[$pre."username"]." has sent a friend request to you. To accept or decline this request, click one of the links below:<br><br><center><b>[</b> <a href='javascript:awindow(\"index.php?load=elite&view=friendsver1&id=".$useridn."\", \"\", \"width=20,height=10,scroll=yes\")'>Accept</a> <b>|</b> <a href='javascript:awindow(\"index.php?load=elite&view=friendsver2&id=".$useridn."\", \"\", \"width=20,height=10,scroll=yes\")'>Decline</a> <b>]</b></center><br><br>Sincerely,<br>The ".$sitename." team";

	$sql2 = mysql_query("INSERT INTO ".$pre."pm VALUES ('null', '1', 'Friend Request', '".addslashes($message)."', '".$_COOKIE[$pre."username"]."', '".$name[0]."', '".time()."')") or die(mysql_error());
	} else {
	
		echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>This person is already your friend! Window will close in 3 seconds.";
	}
}

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

	$sql = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE game = '".$_GET['id']."' AND type = 'favorites' AND pid = '".$useridn."'"));

	if ($sql == "0") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>Game Added to your <b>Favorites</b>. This window will close in 3 seconds.";

	$sql2 = mysql_query("INSERT INTO ".$pre."elite VALUES ('null', '".$useridn."', '".$_GET['id']."', 'favorites', '".time()."')") or die(mysql_error());
	} else {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>This game is already in your favorites! Window will close in 3 seconds.";
	}	
}

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

	$sql = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE game = '".$_GET['id']."' AND type = 'playing' AND pid = '".$useridn."'"));

	if ($sql == "0") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>Game Added to your <b>Playing</b> list. This window will close in 3 seconds.";

	$sql2 = mysql_query("INSERT INTO ".$pre."elite VALUES ('null', '".$useridn."', '".$_GET['id']."', 'playing', '".time()."')") or die(mysql_error());
	} else {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>This game is already in your playing list! Window will close in 3 seconds.";
	}	
}

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

	$sql = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE game = '".$_GET['id']."' AND type = 'tracked' AND pid = '".$useridn."'"));

	if ($sql == "0") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>Game Added to your <b>Tracked</b> list. This window will close in 3 seconds.";

	$sql2 = mysql_query("INSERT INTO ".$pre."elite VALUES ('null', '".$useridn."', '".$_GET['id']."', 'tracked', '".time()."')") or die(mysql_error());
	} else {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>This game is already in your tracked list! Window will close in 3 seconds.";
	}	
}

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

	$sql = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE game = '".$_GET['id']."' AND type = 'collection' AND pid = '".$useridn."'"));

	if ($sql == "0") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>Game Added to your <b>Collection</b>. This window will close in 3 seconds.";

	$sql2 = mysql_query("INSERT INTO ".$pre."elite VALUES ('null', '".$useridn."', '".$_GET['id']."', 'collection', '".time()."')") or die(mysql_error());
	} else {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>This game is already in your collection! Window will close in 3 seconds.";
	}	
}

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

	$sql = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE game = '".$_GET['id']."' AND type = 'wishlist' AND pid = '".$useridn."'"));

	if ($sql == "0") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>Game Added to your <b>Wishlist</b>. This window will close in 3 seconds.";

	$sql2 = mysql_query("INSERT INTO ".$pre."elite VALUES ('null', '".$useridn."', '".$_GET['id']."', 'wishlist', '".time()."')") or die(mysql_error());
	} else {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>This game is already in your wishlist! Window will close in 3 seconds.";
	}	
}

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

	$sql = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE game = '".$_GET['id']."' AND type = 'systems' AND pid = '".$useridn."'"));

	if ($sql == "0") {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td><b>System</b> Added. This window will close in 3 seconds.";

	$sql2 = mysql_query("INSERT INTO ".$pre."elite VALUES ('null', '".$useridn."', '".$_GET['id']."', 'systems', '".time()."')") or die(mysql_error());
	} else {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>You already have this system listed! Window will close in 3 seconds.";
	}	
}
} else {
	echo "<BODY onLoad='setTimeout(window.close, 3000)'><link rel='stylesheet' type='text/css' href='ta3.css'><table><tr><td>Sorry but you are<b>not logged in</b>. This window will close in 3 seconds.";
}
} else {

if (((((((((((((((($_GET['view'] == "newsletterss") && ($_GET['view'] == "friendsver1") && ($_GET['view'] == "friendsver2") && ($_GET['view'] == "friendsver3") && ($_GET['view'] == "friendsver4") && ($_GET['view'] == "elitef") && ($_GET['view'] == "elitec") && ($_GET['view'] == "elitep") && ($_GET['view'] == "elitet") && ($_GET['view'] == "elitew") && ($_GET['view'] == "elites") && ($_GET['view'] == "newsletters") && ($_GET['view'] == "blogd") && ($_GET['view'] == "newsletters2")))))))))))))))) {
} else {
if ($_GET['user'] == "") {
if (($_GET['view'] == "blogadd") or ($_GET['view'] == "blogadd2")) {
$tops .= "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" style=\"border:1px solid black\"><tr><td><a href='index.php?load=elite&view=friends'><img src='a_images/elite_friends.jpg' alt='Friends' border='0'></a></td><td><a href='index.php?load=elite&view=favorites'><img src='a_images/elite_favorites.jpg' alt='Favorites' border='0'></a></td><td><a href='index.php?load=elite&view=playing'><img src='a_images/elite_playing.jpg' alt='Now Playing' border='0'></a></td><td><a href='index.php?load=elite&view=tracked'><img src='a_images/elite_tracked.jpg' alt='Tracked' border='0'></a></td><td><a href='index.php?load=elite&view=collection'><img src='a_images/elite_collection.jpg' alt='Collection' border='0'></a></td><td><a href='index.php?load=elite&view=systems'><img src='a_images/elite_systems.jpg' alt='Systems' border='0'></a></td><td><a href='index.php?load=elite&view=wishlist'><img src='a_images/elite_wishlist.jpg' alt='Wishlist' border='0'></a></td></tr><tr><td><a href='index.php?load=elite&view=newsletter'><img src='a_images/elite_newsletter.jpg' alt='Newsletter' border='0'></a></td><td><a href='index.php?load=elite&view=blog'><img src='a_images/elite_blog.jpg' alt='Blog' border='0'></a></td><td><a href='".$elite1.$_COOKIE[$pre."username"].$elite2."'><img src='a_images/elite_profile.jpg' alt='Profile' border='0'></a></td><td><a href='index.php?load=elite'><img src='a_images/profile2.jpg' alt='My Profile' border='0'></a></td></tr></table><script language='javascript'>function awindow(towhere, newwinname, properties) {window.open(towhere,newwinname,properties);}</script>";
if ($_GET['view']) {
$tops .= "<title>".$sitename." - Elite - ".$_GET['view']."</title>";
} else {
$tops .= "<title>".$sitename." - Elite</title>";
}
} else {
echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" style=\"border:1px solid black\"><tr><td><a href='index.php?load=elite&view=friends'><img src='a_images/elite_friends.jpg' alt='Friends' border='0'></a></td><td><a href='index.php?load=elite&view=favorites'><img src='a_images/elite_favorites.jpg' alt='Favorites' border='0'></a></td><td><a href='index.php?load=elite&view=playing'><img src='a_images/elite_playing.jpg' alt='Now Playing' border='0'></a></td><td><a href='index.php?load=elite&view=tracked'><img src='a_images/elite_tracked.jpg' alt='Tracked' border='0'></a></td><td><a href='index.php?load=elite&view=collection'><img src='a_images/elite_collection.jpg' alt='Collection' border='0'></a></td><td><a href='index.php?load=elite&view=systems'><img src='a_images/elite_systems.jpg' alt='Systems' border='0'></a></td><td><a href='index.php?load=elite&view=wishlist'><img src='a_images/elite_wishlist.jpg' alt='Wishlist' border='0'></a></td></tr><tr><td><a href='index.php?load=elite&view=newsletter'><img src='a_images/elite_newsletter.jpg' alt='Newsletter' border='0'></a></td><td><a href='index.php?load=elite&view=blog'><img src='a_images/elite_blog.jpg' alt='Blog' border='0'></a></td><td><a href='".$elite1.$_COOKIE[$pre."username"].$elite2."'><img src='a_images/elite_profile.jpg' alt='Profile' border='0'></a></td><td><a href='index.php?load=elite'><img src='a_images/profile2.jpg' alt='My Profile' border='0'></a></td></tr></table><script language='javascript'>function awindow(towhere, newwinname, properties) {window.open(towhere,newwinname,properties);}</script>";
if ($_GET['view']) {
echo "<title>".$sitename." - Elite - ".$_GET['view']."</title>";
} else {
echo "<title>".$sitename." - Elite</title>";
}
}
} else {
if ($_GET['user']) {
$_GET['user'] = strip_tags(htmlentities($_GET['user']));
if (is_numeric($_GET['user'])) {
$lroc = mysql_fetch_row(mysql_query("SELECT username FROM ".$pre."profile WHERE id = '".$_GET['user']."'"));
$user_id = $_GET['user'];
$_GET['user'] = $lroc[0];
} else {
$lroc = mysql_fetch_row(mysql_query("SELECT id FROM ".$pre."profile WHERE username = '".$_GET['user']."'"));
$user_id = $lroc[0];
}
if ($_GET['view']) {
echo "<title>".$sitename." - Elite - ".$_GET['user']."'s ".$_GET['view']."</title>";
} else {
echo "<title>".$sitename." - Elite - ".$_GET['user']."'s Profile</title>";
}
echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\" style=\"border:1px solid black\"><tr><td><a href='index.php?load=elite&view=friends&user=".$_GET['user']."'><img src='a_images/elite_friends.jpg' alt='Friends' border='0'></a></td><td><a href='index.php?load=elite&view=favorites&user=".$_GET['user']."'><img src='a_images/elite_favorites.jpg' alt='Favorites' border='0'></a></td><td><a href='index.php?load=elite&view=playing&user=".$_GET['user']."'><img src='a_images/elite_playing.jpg' alt='Now Playing' border='0'></a></td><td><a href='index.php?load=elite&view=tracked&user=".$_GET['user']."'><img src='a_images/elite_tracked.jpg' alt='Tracked' border='0'></a></td><td><a href='index.php?load=elite&view=collection&user=".$_GET['user']."'><img src='a_images/elite_collection.jpg' alt='Collection' border='0'></a></td><td><a href='index.php?load=elite&view=systems&user=".$_GET['user']."'><img src='a_images/elite_systems.jpg' alt='Systems' border='0'></a></td><td><a href='index.php?load=elite&view=wishlist&user=".$_GET['user']."'><img src='a_images/elite_wishlist.jpg' alt='Wishlist' border='0'></a></td></tr><tr><td><a href='index.php?load=elite&view=blog&user=".$_GET['user']."'><img src='a_images/elite_blog.jpg' alt='Blog' border='0'></a></td><td><a href='".$elite1.$_GET['user'].$elite2."'><img src='a_images/elite_profile.jpg' alt='Profile' border='0'></a></td><td><a href='index.php?load=elite'><img src='a_images/profile2.jpg' alt='My Profile' border='0'></a></td></tr></table><script language='javascript'>function awindow(towhere, newwinname, properties) {window.open(towhere,newwinname,properties);}</script>";
}
}


if (($_GET['view'] == "") && ($_GET['user'])) {
echo "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\" width=\"448\"><tr><td>";

    if ($_GET['user']) {
	$row = mysql_fetch_row(mysql_query("SELECT aim,msn,website,nickname,location,username,yahoo,icq,gtalk,birthday,id FROM ".$pre."profile WHERE username = '".$_GET['user']."'"));
	echo profile($row[10], $_GET['user']);
	}
	$aim = stripslashes($row[0]);
	$msn = stripslashes($row[1]);
	$website = stripslashes($row[2]);
	$nickname = stripslashes($row[3]);
	$location = stripslashes($row[4]);
	$yahoo = stripslashes($row[6]);
	$icq = stripslashes($row[7]);
	$gtalk = stripslashes($row[8]);
	$bday = explode("|", $row[9]);


	echo "</td><td align='left'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>AIM</b></td><td><a href='aim:goim?screenname=".$aim."&message=Hello+Are+you+there?'>".$aim."</a></td></tr><tr><td><b>MSN</b></td><td>".$msn."</td></tr><tr><td><b>YIM</b></td><td><a href='http://edit.yahoo.com/config/send_webmesg?.target=".$yahoo."&.src=pg'>".$yahoo."</a></td></tr><tr><td><b>ICQ</b></td><td><a href='http://www.icq.com/whitepages/cmd.php?uin=".$icq."&action=message'>".$icq."</a></td></tr><tr><td><b>Google Talk</b></td><td>".$gtalk."</td></tr><tr><td><b>Website</b></td><td><a href='".$website."' target='popup'>".substr($website, 0, 50)."</a></td></tr><tr><td><b>Nickname</b></td><td>".$nickname."</td></tr><tr><td><b>Location</b></td><td>".$location."</td></tr><tr><td><b>Birthday</b></td><td>";
	if ($bday[0]) {
	echo $bday[0]."&nbsp;".$bday[1].",&nbsp;".$bday[2];
	}
	echo "</td></tr>";
    
	if ($ufields == "yes") {
	$result2 = mysql_query("SELECT * FROM ".$pre."fields WHERE cat = 'users'");
	while($row2 = mysql_fetch_array($result2)) {
	$name = "$row2[name]";
	echo"<tr><td><b>".$name."</b></td><td>".stripslashes($row["$name"])."</td></tr>";
	}
	}

	echo "</table></td></tr><tr><td>&nbsp;</td><td><a href='index.php?load=members&action=profile&id=".$row[10]."&other=posts'>View posts</a>&nbsp;|&nbsp;<a href='index.php?load=members&action=profile&id=".$row[10]."&other=topics'>View topics</a>";
		
	$proc = mysql_fetch_row(mysql_query("SELECT slist,bansite,warn FROM ".$pre."users WHERE username = '".$row[5]."'"));

	if ($proc[0] == "Yes") {
	echo "&nbsp;|&nbsp;<a href='".$staff1.$row[5].$staff2."'>View content</a>";
	}
    if ($userlevel < "3") {
	echo "&nbsp;|&nbsp;<a href='index.php?load=members&action=banuser&user=".$row[5];
	if ($proc[1] == "yes") {
	echo "&type=no'>Un-Ban User</a>";
	} else {
	echo "&type=yes'>Ban User</a>";
	}
	echo "&nbsp;|&nbsp;<a href='index.php?load=members&action=warnuser&user=".$row[5]."'&warn=".$proc[2].">Warn User</a>";
	}
	echo "</td></tr></table>";
}

if (($_GET['view'] == "newsletter") && ($_GET['user'] == "")) {
echo authuser();

echo "<table cellpadding='2' cellspacing='1' border='0' align='center'><tr>";

$sql = mysql_query("SELECT * FROM ".$pre."newsletter WHERE type = 'cat'");
$ia = mysql_num_rows($sql);
for($i = 1; $r = mysql_fetch_assoc($sql); $i++) {

echo "<td><center><b>".$r[name]."</b><br><img src='".$r[content]."' border='1'><br>";

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."newsletter WHERE type = 'subscribers' AND name = '".$_COOKIE[$pre."username"]."' AND cat = '".$r[id]."'"));

if ($sql2 == "0") {
echo "<b>[ <a href='javascript:awindow(\"index.php?load=elite&view=newsletters&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'>Subcribe</a> ]</b>";
} else {
$sql3 = mysql_fetch_row(mysql_query("SELECT id FROM ".$pre."newsletter WHERE type = 'subscribers' AND name = '".$_COOKIE[$pre."username"]."' AND cat = '".$r[id]."'"));

echo "<b>[ <a href='javascript:awindow(\"index.php?load=elite&view=newsletters2&id=".$sql3[0]."\", \"\", \"width=20,height=10,scroll=yes\")'>Unsubscribe</a> ]</b>";
}

if (($ia % 3) === 0) {
		echo "</tr><tr>";
}
}
echo "</tr></table>";
}

if ($_GET['view'] == "t") {
echo authuser();

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

$_POST['search'] = strip_tags(htmlentities($_POST['search']));

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

$searca = mysql_query("SELECT * FROM ".$pre."systems WHERE name LIKE '%" . $_POST['search'] . "%'");
$results = mysql_num_rows($searca);

echo "<title>".$sitename." :: ".$results." Search Results For - ".$_POST['search']."</title><table cellpadding='5' cellspacing='3' border='0' align='center'><tr><td align='center'><center>".$results." Results For :: ".$_POST['search']."</center><br><br></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."systems WHERE name LIKE '%" . $_POST['search'] . "%'");
while($row = mysql_fetch_array($search)) {
		$n1 = "/".$_POST['search']."/";
		$n2 = "<b>".$_POST['search']."</b>";
		$name = preg_replace($n1, $n2, $row[name]);

		similar_text($_POST['search'], $row[name], $p);

		echo "<tr><td><a href='".$system1.$row[abr].$system2."'>".$name."</a></td><td><b>Relevance</b>: ".round(substr($p, 0, 4), 2)."%</td><td><a href='javascript:awindow(\"index.php?load=elite&view=elites&id=".$row[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_s.jpg' border='1'></a></td></tr>";
}
echo "</table>";
}

if ($_GET['view'] == "s") {
echo authuser();

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

$_POST['search'] = strip_tags(htmlentities($_POST['search']));
$from = (($page * $max_results) - $max_results);

$results = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."games WHERE name LIKE '%" . $_POST['search'] . "%'")) or die(mysql_error());

echo "<title>".$sitename." :: ".$results." Search Results For - ".$_POST['search']."</title><table cellpadding='5' cellspacing='3' border='0' align='center'><tr><td align='center'><center>".$results." Results For :: ".$_POST['search']."</center><br><br></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."games WHERE name LIKE '%" . $_POST['search'] . "%'");
while($row = mysql_fetch_array($search)) {
		$n1 = "/".$_POST['search']."/";
		$n2 = "<b>".$_POST['search']."</b>";
		$name = preg_replace($n1, $n2, $row[name]);

		similar_text($_POST['search'], $row[name], $p);

		echo "<tr><td><a href='".$gamepart1.$row[id].fthrough($row[name], "").$gamepart2."'>".$name."</a></td><td><b>Relevance</b>: ".round(substr($p, 0, 4), 2)."%</td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$row[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_f.jpg' border='1' title='Favorite'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$row[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_p.jpg' border='1' title='Playing'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$row[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_t.jpg' border='1' title='Tracked'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$row[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$row[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_w.jpg' border='1' title='Wishlist'></a></td></tr>";
}
echo "</table>";
}

if (($_GET['view'] == "blogadd") && ($_GET['user'] == "")) {
session_start();
eval (" ?>" . headera() . " <?php ");
echo $tops;
//echo wysiwyg();
echo "<form action='index.php?load=elite&view=blogadd2' method='post'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Subject</b></td><td><input name='subject' type='text'></td></tr><tr><td><b>Text</b></td><td><textarea name='text' cols='25' rows='12'></textarea></td></tr><tr><td><img src='includes/captcha.php' style='border:1px solid #000000'></td><td><input type='text' name='captcha'></td></tr><tr><td><input type='submit' value='Add Entry'></td></tr></table></form>";
}

if (($_GET['view'] == "blogadd2") && ($_GET['user'] == "")) {
session_start();
eval (" ?>" . headera() . " <?php ");
echo $tops;
if (md5(strtoupper($_POST['captcha'])) != $_SESSION['captcha']) {
echo "Sorry but you put in the wrong CAPTCHA answer. Please go back and try again";
} else {
$_POST['text'] = preg_replace("/<br>\n/","\n",addslashes($_POST['text']));
$_POST['text'] = preg_replace("/<br \/>\n/","\n",addslashes($_POST['text']));
$_POST['text'] = preg_replace("/(\015\012)|(\015)|(\012)/","<br>\n",addslashes($_POST['text']));
$add = mysql_query("INSERT INTO ".$pre."blog VALUES ('null', '".addslashes(htmlentities($_POST['subject']))."', '".$_POST['text']."', '".$useridn."', '".time()."')");

if ($add == TRUE) {
echo "Blog entry added. <a href='index.php?load=elite&view=blog'>Go back</a>";
}
}
}

if (($_GET['view'] == "blog") && ($_GET['user'] == "")) {
echo "<br><center><a href='index.php?load=elite&view=blogadd'>Add Blog entry</a></center><br>";

$blog = "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\" width=\"75%\"><tr><td bgcolor='".$blog1."'>{name} - <i>{date}</i> <b><a href='javascript:awindow(\"index.php?load=elite&view=blogd&id={id}\", \"\", \"width=20,height=10,scroll=yes\")'>Delete</b></td></tr><tr><td bgcolor='".$blog2."'><p>{blog}</p></td></tr></table><br>";

$search = mysql_query("SELECT * FROM ".$pre."blog WHERE username = '".$useridn."' ORDER BY `date` DESC");
while($r = mysql_fetch_array($search)) {
$vate[0] = "{name}";
$vate[1] = "{blog}";
$vate[2] = "{username}";
$vate[3] = "{date}";
$vate[4] = "{id}";
$tate[0] = $r[name];
$tate[1] = stripslashes($r[blog]);
$tate[2] = $r[username];
$tate[3] = date($dformat, $r[date]);
$tate[4] = $r[id];
eval (" ?>" . str_replace($vate, $tate, stripslashes($blog)) . " <?php ");
}
}

if (($_GET['view'] == "blog") && ($_GET['user'])) {
echo "<br>";

$blog = "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\" width=\"75%\"><tr><td bgcolor='".$blog1."'>{name} - <i>{date}</i></td></tr><tr><td bgcolor='".$blog2."'><p>{blog}</p></td></tr></table><br>";

$search = mysql_query("SELECT * FROM ".$pre."blog WHERE username = '".$user_id."' ORDER BY `date` DESC");
while($r = mysql_fetch_array($search)) {
$vate[0] = "{name}";
$vate[1] = "{blog}";
$vate[2] = "{username}";
$vate[3] = "{date}";
$vate[4] = "{id}";
$tate[0] = $r[name];
$tate[1] = stripslashes($r[blog]);
$tate[2] = $r[username];
$tate[3] = date($dformat, $r[date]);
$tate[4] = $r[id];
eval (" ?>" . str_replace($vate, $tate, stripslashes($blog)) . " <?php ");
}
}

if (($_GET['view'] == "systems") && ($_GET['user'])) {
echo "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>System</b></td><td><b>Abbreviation</b></td><td><b>Users</b></td><td><b>Icon</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'systems' AND pid = '".$_GET['user']."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,abr,icon FROM ".$pre."systems WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'systems' AND game = '".$r[game]."'"));

echo "<tr><td><a href='index.php?sid=".$r[game]."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td><img src='".$sql[2]."'></td></tr>";
}

echo "</table>";
}

if (($_GET['view'] == "systems") && ($_GET['user'] == "")) {
echo authuser();

echo "<br><br><center><form action='index.php?load=elite&view=t' method='post'><b>Search for a system to add</b>&nbsp&nbsp<input type='text' name='search'>&nbsp&nbsp<input type='submit' value='Search'></center></form><br><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>System</b></td><td><b>Abbreviation</b></td><td><b>Users</b></td><td><b>Icon</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'systems' AND pid = '".$useridn."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,abr,icon FROM ".$pre."systems WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'systems' AND game = '".$r[game]."'"));

echo "<tr><td><a href='index.php?sid=".$r[game]."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td><img src='".$sql[2]."'></td><td><a href='javascript:awindow(\"index.php?load=elite&view=delete&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'>Delete</a></td></tr>";
}

echo "</table>";
}

if (($_GET['view'] == "wishlist") && ($_GET['user'])) {
echo "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Game</b></td><td><b>Genre</b></td><td><b>Users</b></td><td><b>Score</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'wishlist' AND pid = '".$_GET['user']."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,genre FROM ".$pre."games WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'wishlist' AND game = '".$r[game]."'"));

$searcha = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$r[game]."' AND cat = 'reviews' LIMIT 1");
$jh = mysql_num_rows($searcha);
if ($jh > "0") {
while($ra = mysql_fetch_array($searcha)) {

$sql3 = $ra[Overall];
}
} else {
$sql3 = "";
}

echo "<tr><td><a href='".$gamepart1.$r[game].$gamepart2."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td>".$sql3."</td>";

if ($_COOKIE[$pre."username"]) {
echo "<td><a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_f.jpg' border='1' title='Favorite'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_p.jpg' border='1' title='Playing'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_t.jpg' border='1' title='Tracked'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a></td>";
}
echo "</tr>";
}

echo "</table>";
}

if (($_GET['view'] == "wishlist") && ($_GET['user'] == "")) {
echo authuser();

echo "<br><br><center><form action='index.php?load=elite&view=s' method='post'><b>Search for a game to add</b>&nbsp&nbsp<input type='text' name='search'>&nbsp&nbsp<input type='submit' value='Search'></center></form><br><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Game</b></td><td><b>Genre</b></td><td><b>Users</b></td><td><b>Score</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'wishlist' AND pid = '".$useridn."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,genre FROM ".$pre."games WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'wishlist' AND game = '".$r[game]."'"));

$searcha = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$r[game]."' AND cat = 'reviews' LIMIT 1");
$jh = mysql_num_rows($searcha);
if ($jh > "0") {
while($ra = mysql_fetch_array($searcha)) {

$sql3 = $ra[Overall];
}
} else {
$sql3 = "";
}

echo "<tr><td><a href='".$gamepart1.$r[game].$gamepart2."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td>".$sql3."</td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_f.jpg' border='1' title='Favorite'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_p.jpg' border='1' title='Playing'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_t.jpg' border='1' title='Tracked'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=delete&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'>Delete</a></td></tr>";
}

echo "</table>";
}

if (($_GET['view'] == "collection") && ($_GET['user'])) {
echo "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Game</b></td><td><b>Genre</b></td><td><b>Users</b></td><td><b>Score</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'collection' AND pid = '".$_GET['user']."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,genre FROM ".$pre."games WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'collection' AND game = '".$r[game]."'"));

$searcha = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$r[game]."' AND cat = 'reviews' LIMIT 1");
$jh = mysql_num_rows($searcha);
if ($jh > "0") {
while($ra = mysql_fetch_array($searcha)) {

$sql3 = $ra[Overall];
}
} else {
$sql3 = "";
}

echo "<tr><td><a href='".$gamepart1.$r[game].$gamepart2."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td>".$sql3."</td>";
if ($_COOKIE[$pre."username"]) {
echo "<td><a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_f.jpg' border='1' title='Favorite'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_p.jpg' border='1' title='Playing'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_t.jpg' border='1' title='Tracked'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_w.jpg' border='1' title='Wishlist'></a></td>";
}
echo "</tr>";
}

echo "</table>";
}

if (($_GET['view'] == "collection") && ($_GET['user'] == "")) {
echo authuser();

echo "<br><br><center><form action='index.php?load=elite&view=s' method='post'><b>Search for a game to add</b>&nbsp&nbsp<input type='text' name='search'>&nbsp&nbsp<input type='submit' value='Search'></center></form><br><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Game</b></td><td><b>Genre</b></td><td><b>Users</b></td><td><b>Score</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'collection' AND pid = '".$useridn."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,genre FROM ".$pre."games WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'collection' AND game = '".$r[game]."'"));

$searcha = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$r[game]."' AND cat = 'reviews' LIMIT 1");
$jh = mysql_num_rows($searcha);
if ($jh > "0") {
while($ra = mysql_fetch_array($searcha)) {

$sql3 = $ra[Overall];
}
} else {
$sql3 = "";
}

echo "<tr><td><a href='".$gamepart1.$r[game].$gamepart2."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td>".$sql3."</td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_f.jpg' border='1' title='Favorite'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_p.jpg' border='1' title='Playing'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_t.jpg' border='1' title='Tracked'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_w.jpg' border='1' title='Wishlist'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=delete&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'>Delete</a></td></tr>";
}

echo "</table>";
}

if (($_GET['view'] == "tracked") && ($_GET['user'])) {
echo "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Game</b></td><td><b>Genre</b></td><td><b>Users</b></td><td><b>Score</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'tracked' AND pid = '".$_GET['user']."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,genre FROM ".$pre."games WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'tracked' AND game = '".$r[game]."'"));

$searcha = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$r[game]."' AND cat = 'reviews' LIMIT 1");
$jh = mysql_num_rows($searcha);
if ($jh > "0") {
while($ra = mysql_fetch_array($searcha)) {

$sql3 = $ra[Overall];
}
} else {
$sql3 = "";
}

echo "<tr><td><a href='".$gamepart1.$r[game].$gamepart2."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td>".$sql3."</td>";
if ($_COOKIE[$pre."username"]) {
echo "<td><a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_f.jpg' border='1' title='Favorite'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_p.jpg' border='1' title='Playing'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_w.jpg' border='1' title='Wishlist'></a></td>";
}
echo "</tr>";
}

echo "</table>";
}

if (($_GET['view'] == "tracked") && ($_GET['user'] == "")) {
echo authuser();

echo "<br><br><center><form action='index.php?load=elite&view=s' method='post'><b>Search for a game to add</b>&nbsp&nbsp<input type='text' name='search'>&nbsp&nbsp<input type='submit' value='Search'></center></form><br><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Game</b></td><td><b>Genre</b></td><td><b>Users</b></td><td><b>Score</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'tracked' AND pid = '".$useridn."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,genre FROM ".$pre."games WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'tracked' AND game = '".$r[game]."'"));

$searcha = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$r[game]."' AND cat = 'reviews' LIMIT 1");
$jh = mysql_num_rows($searcha);
if ($jh > "0") {
while($ra = mysql_fetch_array($searcha)) {

$sql3 = $ra[Overall];
}
} else {
$sql3 = "";
}

echo "<tr><td><a href='".$gamepart1.$r[game].$gamepart2."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td>".$sql3."</td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_f.jpg' border='1' title='Favorite'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_p.jpg' border='1' title='Playing'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_w.jpg' border='1' title='Wishlist'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=delete&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'>Delete</a></td></tr>";
}

echo "</table>";
}

if (($_GET['view'] == "playing") && ($_GET['user'])) {
echo "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Game</b></td><td><b>Genre</b></td><td><b>Users</b></td><td><b>Score</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'playing' AND pid = '".$_GET['user']."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,genre FROM ".$pre."games WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'playing' AND game = '".$r[game]."'"));

$searcha = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$r[game]."' AND cat = 'reviews' LIMIT 1");
$jh = mysql_num_rows($searcha);
if ($jh > "0") {
while($ra = mysql_fetch_array($searcha)) {

$sql3 = $ra[Overall];
}
} else {
$sql3 = "";
}

echo "<tr><td><a href='".$gamepart1.$r[game].$gamepart2."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td>".$sql3."</td>";
if ($_COOKIE[$pre."username"]) {
echo "<td><a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_f.jpg' border='1' title='Favorite'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_t.jpg' border='1' title='Tracked'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_w.jpg' border='1' title='Wishlist'></a></td>";
}
echo "</tr>";
}

echo "</table>";
}

if (($_GET['view'] == "playing") && ($_GET['user'] == "")) {
echo authuser();

echo "<br><br><center><form action='index.php?load=elite&view=s' method='post'><b>Search for a game to add</b>&nbsp&nbsp<input type='text' name='search'>&nbsp&nbsp<input type='submit' value='Search'></center></form><br><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Game</b></td><td><b>Genre</b></td><td><b>Users</b></td><td><b>Score</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'playing' AND pid = '".$useridn."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,genre FROM ".$pre."games WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'playing' AND game = '".$r[game]."'"));

$searcha = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$r[game]."' AND cat = 'reviews' LIMIT 1");
$jh = mysql_num_rows($searcha);
if ($jh > "0") {
while($ra = mysql_fetch_array($searcha)) {

$sql3 = $ra[Overall];
}
} else {
$sql3 = "";
}

echo "<tr><td><a href='".$gamepart1.$r[game].$gamepart2."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td>".$sql3."</td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_f.jpg' border='1' title='Favorite'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_t.jpg' border='1' title='Tracked'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_w.jpg' border='1' title='Wishlist'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=delete&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'>Delete</a></td></tr>";
}

echo "</table>";
}

if (($_GET['view'] == "favorites") && ($_GET['user'])) {
echo "<table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Game</b></td><td><b>Genre</b></td><td><b>Users</b></td><td><b>Score</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'favorites' AND pid = '".$_GET['user']."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,genre FROM ".$pre."games WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'favorites' AND game = '".$r[game]."'"));

$searcha = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$r[game]."' AND cat = 'reviews' LIMIT 1");
$jh = mysql_num_rows($searcha);
if ($jh > "0") {
while($ra = mysql_fetch_array($searcha)) {

$sql3 = $ra[Overall];
}
} else {
$sql3 = "";
}

echo "<tr><td><a href='".$gamepart1.$r[game].$gamepart2."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td>".$sql3."</td>";
if ($_COOKIE[$pre."username"]) {
echo "<td><a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_p.jpg' border='1' title='Playing'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_t.jpg' border='1' title='Tracked'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_w.jpg' border='1' title='Wishlist'></a></td>";
}
echo "</tr>";
}

echo "</table>";
}

if (($_GET['view'] == "favorites") && ($_GET['user'] == "")) {
echo authuser();

echo "<br><br><center><form action='index.php?load=elite&view=s' method='post'><b>Search for a game to add</b>&nbsp&nbsp<input type='text' name='search'>&nbsp&nbsp<input type='submit' value='Search'></center></form><br><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Game</b></td><td><b>Genre</b></td><td><b>Users</b></td><td><b>Score</b></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'favorites' AND pid = '".$useridn."' ORDER BY `id` DESC");
while($r = mysql_fetch_array($search)) {

$sql = mysql_fetch_row(mysql_query("SELECT name,genre FROM ".$pre."games WHERE id = '".$r[game]."'"));

$sql2 = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."elite WHERE type = 'favorites' AND game = '".$r[game]."'"));

$searcha = mysql_query("SELECT * FROM ".$pre."content WHERE games = '".$r[game]."' AND cat = 'reviews' LIMIT 1");
$jh = mysql_num_rows($searcha);
if ($jh > "0") {
while($ra = mysql_fetch_array($searcha)) {

$sql3 = $ra[Overall];
}
} else {
$sql3 = "";
}

echo "<tr><td><a href='".$gamepart1.$r[game].$gamepart2."'>".$sql[0]."</a></td><td>".$sql[1]."</td><td>".$sql2."</td><td>".$sql3."</td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_p.jpg' border='1' title='Playing'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_t.jpg' border='1' title='Tracked'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$r[game]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_w.jpg' border='1' title='Wishlist'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=delete&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'>Delete</a></td></tr>";
}

echo "</table>";
}


if (($_GET['view'] == "friendss") && ($_GET['user'] == "")) {
echo authuser();

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

$_POST['search'] = strip_tags(htmlentities($_POST['search']));
$from = (($page * $max_results) - $max_results);

$searca = mysql_query("SELECT * FROM ".$pre."profile WHERE username LIKE '%" . $_POST['search'] . "%'");
$results = mysql_num_rows($searca);

echo "<title>".$sitename." :: ".$results." Search Results For - ".$_POST['search']."</title><table cellpadding='5' cellspacing='3' border='0' align='center'><tr><td align='center'><center>".$results." Results For :: ".$_POST['search']."</center><br><br></td></tr>";

$search = mysql_query("SELECT * FROM ".$pre."profile WHERE username LIKE '%" . $_POST['search'] . "%'");
while($row = mysql_fetch_array($search)) {
if ($row[username] == $_COOKIE[$pre."username"]) {
} else {
		$n1 = "/".$_POST['search']."/";
		$n2 = "<b>".$_POST['search']."</b>";
		$name = preg_replace($n1, $n2, $row[username]);

		similar_text($_POST['search'], $row[username], $p);

		echo "<tr><td><a href='index.php?load=elite&user=".$row[id]."'>".$name."</a></td><td><b>Relevance</b>: ".round(substr($p, 0, 4), 2)."%</td><td><a href='javascript:awindow(\"index.php?load=elite&view=friendsver4&id=".$row[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_f2.jpg' border='1'></a></td></tr>";
}
}
echo "</table>";
}

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

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

echo "<table cellspacing=\"0\" cellpadding=\"1\" border=\"0\" valign=\"top\"><tr><td><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\"><tr><td><center><b>".$sta[0]."'s Friends</b></center></td></tr><tr>";

$qe = mysql_query("SELECT * FROM ".$pre."friends WHERE pid = '".$_GET['user']."' OR pid2 = '".$_GET['user']."' AND ver = 'yes' ORDER BY `id` DESC");

$ia = mysql_num_rows($qe);

for($i = 1; $r = mysql_fetch_assoc($qe); $i++) {

	$sql = mysql_query("SELECT username,avatar FROM ".$pre."profile WHERE id = '".$r[pid2]."'");
	$st = mysql_fetch_row($sql);

	$user = $st[0];

	if ($user == $_COOKIE[$pre."username"]) {
	} else {

	$page = @file_get_contents("$st[1]");
	if ($page == NULL) {
		$avatar = "<img src='".$siteurl."/a_images/noavatar.jpg' border='1'>";
	} else {
	$avatar = "<img src='".$st[1]."'";

	list($widtha, $heighta) = getimagesize($st[1]);

	if ($widtha > $avat1) {
	$avatar .= " width='".$avat1."'";
	}
	if ($heighta > $avat2) {
	$avatar .= " height='".$avat1."'";
	}

	$avatar .= " border='1'>";
	}

	echo "<td><a href='index.php?load=elite&user=".$r[pid2]."'><i>".$user."</i></a><br>".$avatar."</td>";

	if (($ia % 3) === 0) {
		echo "</tr><tr>";
	}
}
}
echo "</tr></table></td></tr></table>";
}

if (($_GET['view'] == "friends") && ($_GET['user'] == "")) {
echo authuser();

echo "<br><br><center><form action='index.php?load=elite&view=friendss' method='post'><b>Search for a member to add</b>&nbsp&nbsp<input type='text' name='search'>&nbsp&nbsp<input type='submit' value='Search'></center></form><br><table cellspacing=\"0\" cellpadding=\"1\" border=\"0\" valign=\"top\"><tr><td><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\"><tr><td><center><b>Current Friends</b></center></td></tr>";

$qe = mysql_query("SELECT * FROM ".$pre."friends WHERE pid = '".$useridn."' AND ver = 'yes' ORDER BY `id` DESC");

for($i = 1; $r = mysql_fetch_assoc($qe); $i++) {

	$sql = mysql_query("SELECT username,avatar FROM ".$pre."profile WHERE id = '".$r[pid2]."'");
	$st = mysql_fetch_row($sql);

	$user = $st[0];

	$page = @file_get_contents("$st[1]");
	if ($page == NULL) {
		$avatar = "<img src='".$siteurl."/a_images/noavatar.jpg' border='1'>";
	} else {
	$avatar = "<img src='".$st[1]."'";

	list($widtha, $heighta) = getimagesize($st[1]);

	if ($widtha > $avat1) {
	$avatar .= " width='".$avat1."'";
	}
	if ($heighta > $avat2) {
	$avatar .= " height='".$avat1."'";
	}

	$avatar .= " border='1'>";
	}

	echo "<tr><td><a href='index.php?load=elite&user=".$r[pid2]."'><i>".$user."</i></a><br>".$avatar."</td></tr>";
}

$qe = mysql_query("SELECT * FROM ".$pre."friends WHERE pid2 = '".$useridn."' AND ver = 'yes' ORDER BY `id` DESC");

for($i = 1; $r = mysql_fetch_assoc($qe); $i++) {

	$sql = mysql_query("SELECT username,avatar FROM ".$pre."profile WHERE id = '".$r[pid]."'");
	$st = mysql_fetch_row($sql);

	$user = $st[0];

	$page = @file_get_contents("$st[1]");
	if ($page == NULL) {
		$avatar = "<img src='".$siteurl."/a_images/noavatar.jpg' border='1'>";
	} else {
	$avatar = "<img src='".$st[1]."'";

	list($widtha, $heighta) = getimagesize($st[1]);

	if ($widtha > $avat1) {
	$avatar .= " width='".$avat1."'";
	}
	if ($heighta > $avat2) {
	$avatar .= " height='".$avat1."'";
	}

	$avatar .= " border='1'>";
	}

	echo "<tr><td><a href='index.php?load=elite&user=".$r[pid]."'><i>".$user."</i></a><br>".$avatar."</td></tr>";
}
echo "</table></td><td><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\"><tr><td><center><b>Incoming Requests</b></center></td></tr>";

$qe = mysql_query("SELECT * FROM ".$pre."friends WHERE pid2 = '".$useridn."' AND ver = 'no' OR ver = '' ORDER BY `id` DESC");

for($i = 1; $r = mysql_fetch_assoc($qe); $i++) {

	$sql = mysql_query("SELECT username,avatar FROM ".$pre."profile WHERE id = '".$r[pid]."'");
	$st = mysql_fetch_row($sql);

	$user = $st[0];

	$page = @file_get_contents("$st[1]");
	if ($page == NULL) {
		$avatar = "<img src='".$siteurl."/a_images/noavatar.jpg' border='1'>";
	} else {
	$avatar = "<img src='".$st[1]."'";

	list($widtha, $heighta) = getimagesize($st[1]);

	if ($widtha > $avat1) {
	$avatar .= " width='".$avat1."'";
	}
	if ($heighta > $avat2) {
	$avatar .= " height='".$avat1."'";
	}

	$avatar .= " border='1'>";
	}

	echo "<tr><td><a href='index.php?load=elite&user=".$r[pid]."'><i>".$user."</i></a><br>".$avatar."<br><center><b>[</b> <a href='javascript:awindow(\"index.php?load=elite&view=friendsver1&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'>Accept</a> <b>|</b> <a href='javascript:awindow(\"index.php?load=elite&view=friendsver2&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'>Decline</a> <b>]</b></center></td></tr>";
}

echo "</table></td><td><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\"><tr><td><center><b>Outgoing Requests</b></center></td></tr>";

$qe = mysql_query("SELECT * FROM ".$pre."friends WHERE pid = '".$useridn."' AND ver = 'no' OR ver = '' ORDER BY `id` DESC");

for($i = 1; $r = mysql_fetch_assoc($qe); $i++) {

	$sql = mysql_query("SELECT username,avatar FROM ".$pre."profile WHERE id = '".$r[pid2]."'");
	$st = mysql_fetch_row($sql);

	$user = $st[0];

	$page = @file_get_contents("$st[1]");
	if ($page == NULL) {
		$avatar = "<img src='".$siteurl."/a_images/noavatar.jpg' border='1'>";
	} else {
	$avatar = "<img src='".$st[1]."'";

	list($widtha, $heighta) = getimagesize($st[1]);

	if ($widtha > $avat1) {
	$avatar .= " width='".$avat1."'";
	}
	if ($heighta > $avat2) {
	$avatar .= " height='".$avat1."'";
	}

	$avatar .= " border='1'>";
	}

	echo "<tr><td><a href='index.php?load=elite&user=".$r[pid2]."'><i>".$user."</i></a><br>".$avatar."<br><center><b>[</b> <a href='javascript:awindow(\"index.php?load=elite&view=friendsver3&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'>Delete</a> <b>]</b></center></td></tr>";
}

echo "</table></td></tr></table>";
}

if ($_GET['view'] == "topgames") {
echo "<center><img src='".$siteurl."/a_images/top10.png' border='1'></center><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\">";
$qe = mysql_query("SELECT * FROM ".$pre."games ORDER BY `stats` DESC LIMIT 10");
for($i = 1; $r = mysql_fetch_assoc($qe); $i++) {
echo "<tr><td><b>".$i."</b></td><td><a href='index.php?gid=".$r[id]."'>".$r[name]."</a></td><td>".$r[genre]."</td>";

if ($_COOKIE[$pre."username"]) {echo "<td><a href='javascript:awindow(\"index.php?load=elite&view=elitef&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_f.jpg' border='1' title='Favorite'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitep&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_p.jpg' border='1' title='Playing'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitet&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_t.jpg' border='1' title='Tracked'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitec&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_c.jpg' border='1' title='Collection' alt='Collection'></a></td><td><a href='javascript:awindow(\"index.php?load=elite&view=elitew&id=".$r[id]."\", \"\", \"width=20,height=10,scroll=yes\")'><img src='".$siteurl."/a_images/elite_w.jpg' border='1' title='Wishlist'></a></td>";
}
echo "</tr>";
}
echo "</table>";
}
if (($_GET['view'] == "") && ($_GET['user'] == "")) {
echo authuser();
	$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]);
		$yahoo = stripslashes($row[yahoo]);
		$icq = stripslashes($row[icq]);
		$gtalk = stripslashes($row[gtalk]);
		$bday = explode("|", $row[birthday]);
	
		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=elite&view=update' method='post'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>E-mail</b></td><td><input type='text' name='email' value='".$email."'></td></tr><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>YIM</b></td><td><input type='text' name='yahoo' value='".$yahoo."'></td></tr><tr><td><b>ICQ</b></td><td><input type='text' name='icq' value='".$icq."'></td></tr><tr><td><b>Google Talk</b></td><td><input type='text' name='gtalk' value='".$gtalk."'></td></tr><tr><td><b>Birthday (m/d/yyyy)</b></td><td><select name='bday1'><option value=''></option>";
		
        if ($bday[0]) {
		echo "<option value='".$bday[0]."' selected>".$bday[0]."</option>";
		}

		echo "<option value='January'>January</option><option value='February'>February</option><option value='March'>March</option><option value='April'>April</option><option value='May'>May</option><option value='June'>June</option><option value='July'>July</option><option value='August'>August</option><option value='September'>September</option><option value='October'>October</option><option value='November'>November</option><option value='December'>December</option>";
		
		echo "</select>&nbsp;&nbsp;<select name='bday2'><option value=''></option>";

		for ($i = 1; $i <= 30; $i++) {
		if ($i == $bday[1]) {
		echo "<option value='".$i."' selected>".$i."</option>";
		} else {
		echo "<option value='".$i."'>".$i."</option>";
		}
		}

        echo "</select>&nbsp;&nbsp;<input type='text' name='bday3' value='".$bday[2]."' size='4' limit='4'></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\")'><b>View Current Avatar</b></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><br><center><b>Points to Spend:</b> ".points();
	}

	if ($_GET['view'] == "update") {
	echo authuser();
	$_POST["sig"] = addslashes($_POST["sig"]);

	$bday = $_POST["bday1"]."|".$_POST["bday2"]."|".$_POST["bday3"];

    if ($_POST["email"] == $email) {
	} else {
	$edit12 = sprintf("UPDATE ".$pre."users SET email = '".$_POST["email"]."' WHERE username = '%s' AND password = '%s'",
    mysql_real_escape_string($_COOKIE[$pre."username"]),
    mysql_real_escape_string($_COOKIE[$pre."password"]));
	$edit1 = mysql_query($edit12);
	}

    $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"]."', yahoo = '".$_POST["yahoo"]."', icq = '".$_POST["icq"]."', gtalk = '".$_POST["gtalk"]."', birthday = '".$bday."'";
	
	$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"]."' AND id = '".$useridn."'";

    $edit = mysql_query($edit2) or die(mysql_error());
   if ($edit == TRUE) {
	   echo "Your profile has been updated. <a href='".$elite1.$_COOKIE[$pre."username"].$elite2."'>Return</a>";
   }
	}

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