zackcez Posted March 15, 2009 Share Posted March 15, 2009 Here's the code: /* Variables */ $search = str_replace("select", "", str_replace("union", "", mysql_real_escape_string($_GET['search']))); $user = str_replace("select", "", str_replace("union", "", mysql_real_escape_string($_GET['user']))); $compare = str_replace("select", "", str_replace("union", "", mysql_real_escape_string($_GET['with']))); $action = str_replace("select", "", str_replace("union", "", mysql_real_escape_string($_GET['action']))); $loggedgroupid = $vbulletin->userinfo['usergroupid']; //Logged in users vBulletin groupid $username = $vbulletin->userinfo['username']; //Logged in users vBulletin username $userid = $vbulletin->userinfo['userid']; //Logged in users vBulletin userid $overallRank = getRank($user, Total); //Gets the total level rank for indivial players $skillNames = array("Attack", "Defence", "Strength", "Hitpoints", "Range", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecrafting"); $miniGames = array("Kills", "Deaths"); foreach ($skillNames as $skill) { $PlayerRank[$skill] = getRank($user, $skill); } foreach ($skillNames as $skill) { $result = mysql_query("SELECT * FROM user WHERE username='$user'") or die(mysql_error()); $row = mysql_fetch_array($result); $PlayerXp[$skill] = number_format($row[$skill . "xp"]); } /* Functions */ function getRank($user, $skill) { if ($skill == 'Total') { $end = "Attackxp + Woodcuttingxp + Defencexp + Strengthxp + Hitpointsxp + Rangexp + Prayerxp + Magicxp + Cookingxp + Fletchingxp + Fishingxp + Firemakingxp + Craftingxp + Smithingxp + Miningxp + Herblorexp + Agilityxp + Thievingxp + Slayerxp + Farmingxp + Runecraftingxp"; } else if($skill == 'Kills' || $skill == 'Deaths') { $end = strtolower($skill); } else { $end = $skill . "xp"; } $rank = 1; $getRankQuery = mysql_query("SELECT * FROM user ORDER BY $end DESC") or die(mysql_error()); while ($rankData = mysql_fetch_array($getRankQuery)) { $groupQuery = mysql_query("SELECT * FROM usergroup WHERE usergroupid='" . $rankData['usergroupid'] . "'") or die(mysql_error()); $groupData = mysql_fetch_array($groupQuery); $endRank[$rankData['username']] = $rank++; } return number_format($endRank["$user"]); } function getPre($id) { $prefixQuery = mysql_query("SELECT * FROM usergroup WHERE usergroupid='$id'"); $groupPreData = mysql_fetch_array($prefixQuery); return $groupPreData['opentag']; } function getSuf($id) { $suffixQuery = mysql_query("SELECT * FROM usergroup WHERE usergroupid='$id'"); $groupSufData = mysql_fetch_array($suffixQuery); return $groupSufData['closetag']; } if(!$username){ echo "No Direct Access"; exit(); } switch ($action) { case user: /* Variables and Ints */ $result = mysql_query("SELECT * FROM user WHERE username='$user'") or die(mysql_error()); $row = mysql_fetch_array($result); $Totallvl = $row[Attacklvl] + $row[Defencelvl] + $row[Woodcuttinglvl] + $row[strengthlvl] + $row[Hitpointslvl] + $row[Rangelvl] + $row[Prayerlvl] + $row[Magiclvl] + $row[Cookinglvl] + $row[Fletchinglvl] + $row[Fishinglvl] + $row[Firemakinglvl] + $row[Craftinglvl] + $row[smithinglvl] + $row[Mininglvl] + $row[Herblorelvl] + $row[Agilitylvl] + $row[Thievinglvl] + $row[slayerlvl] + $row[Farminglvl] + $row[Runecraftinglvl]; $Totalxp = $row[Attackxp] + $row[Woodcuttingxp] + $row[Defencexp] + $row[strengthxp] + $row[Hitpointsxp] + $row[Rangexp] + $row[Prayerxp] + $row[Magicxp] + $row[Cookingxp] + $row[Fletchingxp] + $row[Fishingxp] + $row[Firemakingxp] + $row[Craftingxp] + $row[smithingxp] + $row[Miningxp] + $row[Herblorexp] + $row[Agilityxp] + $row[Thievingxp] + $row[slayerxp] + $row[Farmingxp] + $row[Runecraftingxp]; $TotalLevel = number_format($Totallvl); $TotalXP = number_format($Totalxp); if ($row['username'] == "") { echo"<center>Viewing User: INVALID</center>"; echo"<table class=\"tborder\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\"><tr align=\"center\"><td align=\"center\" class=\"tcat\" width=\"3%\">Skill</td><td align=\"center\" class=\"tcat\" width=\"18%\">Rank</td><td align=\"center\" class=\"tcat\" width=\"15%\">Level</td><td align=\"center\" class=\"tcat\" width=\"25%\">Xp</td></tr>"; echo"<tr align=\"center\"><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">Total</td><td class=\"alt2\" rowspan=\"22\" colspan=\"3\"><center>The data you've happened to 'stumble' upon doesn't match our databases nor any pages of our site; feel free to try again though.</center></td>"; foreach ($skillNames as $skill) { echo"<tr align=\"center\"><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">".$skill."</td>"; } echo"</table>"; } else { $pre = getPre($row['usergroupid']); $suf = getSuf($row['usergroupid']); $usernamer = $pre."".$row['username']."".$suf; if ($row['ServerOnline'] == '1') { $on_server = "<font color=\"green\">Online (World 1)</font>"; } elseif($row['ServerOnline'] == '2') { $on_server = "<font color=\"green\">Online (World 2)</font>"; } else { $on_server = "<font color=\"red\">Offline</font>"; } echo"<center>Viewing User: $usernamer | On Server: $on_server</center>"; echo"<table class=\"tborder\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\"><tr align=\"center\"><td align=\"center\" class=\"tcat\" width=\"3%\">Skill</td><td align=\"center\" class=\"tcat\" width=\"18%\">Rank</td><td align=\"center\" class=\"tcat\" width=\"15%\">Level</td><td align=\"center\" class=\"tcat\" width=\"25%\">Xp</td></tr>"; echo"<tr align=\"center\"><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">Total</td><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">$overallRank</td><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">$TotalLevel</td><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">$TotalXP</td>"; foreach ($skillNames as $skill) { echo"<tr align=\"center\"><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">".$skill."</td><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">" . $PlayerRank[$skill] . "</td><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">" . $row[$skill.'lvl'] . "</td><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">" . $PlayerXp[$skill] . "</td>"; } echo"<tr align=\"center\"><td align=\"center\" class=\"tcat\" width=\"3%\">Name</td><td align=\"center\" class=\"tcat\" width=\"18%\">Rank</td><td align=\"center\" class=\"tcat\" colspan=\"2\" width=\"15%\">Score</td></tr>"; foreach ($miniGames as $games) { $d = strtolower($games); echo"<tr align=\"center\"><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">".$games."</td><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">" . getRank($row['username'], $games) . "</td><td class=\"alt1\" colspan=\"2\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">" . $row[$d] . "</td>"; } echo"</table>"; unset($usernamer); unset($pre); unset($suf); } break; default: $perPage = 25; $data_Query = mysql_query("SELECT * FROM user"); $totalUsers = mysql_num_rows($data_Query); $totalPages = $totalUsers/$perPage; $totalPages = ceil($totalPages); $currentPage = str_replace("select", "", str_replace("union", "", mysql_real_escape_string($_GET['page']))); $m_stat = str_replace("select", "", str_replace("union", "", mysql_real_escape_string($_GET['stat']))); if((!$currentPage) || (is_numeric($currentPage) == false) || ($currentPage < 1) || ($currentPage > $totalPages)) { $currentPage = 1; } $limits = ($p - 1) * $max; $resultsLeft = ($currentPage - 1) * $perPage; $nextPage = $currentPage+1; $prevPage = $currentPage-1; $c = strtolower($m_stat); if(in_array($c, $skillNames) || in_array($m_stat, $skillNames)) { $stat = $m_stat.'xp'; $skill_name = $m_stat; $skill_lvl = $m_stat.'lvl'; } else if(in_array($c, $miniGames) || in_array($m_stat, $miniGames)) { $stat = $c; $skill_name = $m_stat; $skill_lvl = $m_stat; } else { $totalXP = $hsPlayerData[Attackxp] + $hsPlayerData[Woodcuttingxp] + $hsPlayerData[Defencexp] + $hsPlayerData[strengthxp] + $hsPlayerData[Hitpointsxp] + $hsPlayerData[Rangexp] + $hsPlayerData[Prayerxp] + $hsPlayerData[Magicxp] + $hsPlayerData[Cookingxp] + $hsPlayerData[Fletchingxp] + $row[Fishingxp] + $hsPlayerData[Firemakingxp] + $hsPlayerData[Craftingxp] + $hsPlayerData[smithingxp] + $hsPlayerData[Miningxp] + $hsPlayerData[Herblorexp] + $hsPlayerData[Agilityxp] + $hsPlayerData[Thievingxp] + $hsPlayerData[slayerxp] + $hsPlayerData[Farmingxp] + $hsPlayerData[Runecraftingxp] + $hsPlayerData[Hunterxp] + $hsPlayerData[Constructionxp] + $hsPlayerData[summoningxp]; $totalLevel = $hsPlayerData[Attacklvl] + $hsPlayerData[Defencelvl] + $hsPlayerData[Woodcuttinglvl] + $hsPlayerData[strengthlvl] + $hsPlayerData[Hitpointslvl] + $hsPlayerData[Rangelvl] + $hsPlayerData[Prayerlvl] + $hsPlayerData[Magiclvl] + $hsPlayerData[Cookinglvl] + $hsPlayerData[Fletchinglvl] + $hsPlayerData[Fishinglvl] + $hsPlayerData[Firemakinglvl] + $hsPlayerData[Craftinglvl] + $hsPlayerData[smithinglvl] + $hsPlayerData[Mininglvl] + $hsPlayerData[Herblorelvl] + $hsPlayerData[Agilitylvl] + $hsPlayerData[Thievinglvl] + $hsPlayerData[slayerlvl] + $hsPlayerData[Farminglvl] + $hsPlayerData[Runecraftinglvl] + $hsPlayerData[Hunterlvl] + $hsPlayerData[Constructionlvl] + $hsPlayerData[summoningxp]; $skill_name = Overall; $skill_lvl = $totalLevel; $stat = "Attackxp + Woodcuttingxp + Defencexp + Strengthxp + Hitpointsxp + Rangexp + Prayerxp + Magicxp + Cookingxp + Fletchingxp + Fishingxp + Firemakingxp + Craftingxp + Smithingxp + Miningxp + Herblorexp + Agilityxp + Thievingxp + Slayerxp + Farmingxp + Runecraftingxp + Hunterxp + Constructionxp + Summoningxp"; } switch ($skill_name) { case Kills: echo "<table class=\"tborder\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\"><tr align=\"center\"><td align=\"center\" class=\"tcat\" width=\"3%\">Rank</td><td align=\"center\" class=\"tcat\" width=\"18%\">User Name</td><td align=\"center\" class=\"tcat\" width=\"15%\">$skill_name</td></tr>"; break; case Deaths: echo "<table class=\"tborder\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\"><tr align=\"center\"><td align=\"center\" class=\"tcat\" width=\"3%\">Rank</td><td align=\"center\" class=\"tcat\" width=\"18%\">User Name</td><td align=\"center\" class=\"tcat\" width=\"15%\">$skill_name</td></tr>"; break; default: echo "<table class=\"tborder\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\"><tr align=\"center\"><td align=\"center\" class=\"tcat\" width=\"3%\">Rank</td><td align=\"center\" class=\"tcat\" width=\"18%\">User Name</td><td align=\"center\" class=\"tcat\" width=\"15%\">$skill_name Level</td><td align=\"center\" class=\"tcat\" width=\"25%\">$skill_name Experience</td></tr>"; break; } $i = ($currentPage - 1) * $perPage; $highscoresQuery = $db->query_read("SELECT * FROM user ORDER BY $stat DESC LIMIT ".$resultsLeft.",$perPage"); while ($hsPlayerData = $db->fetch_array($highscoresQuery)) { $pre = getPre($hsPlayerData['usergroupid']); $suf = getSuf($hsPlayerData['usergroupid']); $usernamer = $pre."".$hsPlayerData['username']."".$suf; if ($skill_name != Overall) { $full_skill = number_format($hsPlayerData[$skill_lvl]); $full_number = number_format($hsPlayerData[$stat]); } else if ($skill_name == Overall) { $totalXP = $hsPlayerData[Attackxp] + $hsPlayerData[Woodcuttingxp] + $hsPlayerData[Defencexp] + $hsPlayerData[strengthxp] + $hsPlayerData[Hitpointsxp] + $hsPlayerData[Rangexp] + $hsPlayerData[Prayerxp] + $hsPlayerData[Magicxp] + $hsPlayerData[Cookingxp] + $hsPlayerData[Fletchingxp] + $hsPlayerData[Fishingxp] + $hsPlayerData[Firemakingxp] + $hsPlayerData[Craftingxp] + $hsPlayerData[smithingxp] + $hsPlayerData[Miningxp] + $hsPlayerData[Herblorexp] + $hsPlayerData[Agilityxp] + $hsPlayerData[Thievingxp] + $hsPlayerData[slayerxp] + $hsPlayerData[Farmingxp] + $hsPlayerData[Runecraftingxp] + $hsPlayerData[Hunterxp] + $hsPlayerData[Constructionxp] + $hsPlayerData[summoningxp]; $totalLevel = $hsPlayerData[Attacklvl] + $hsPlayerData[Defencelvl] + $hsPlayerData[Woodcuttinglvl] + $hsPlayerData[strengthlvl] + $hsPlayerData[Hitpointslvl] + $hsPlayerData[Rangelvl] + $hsPlayerData[Prayerlvl] + $hsPlayerData[Magiclvl] + $hsPlayerData[Cookinglvl] + $hsPlayerData[Fletchinglvl] + $hsPlayerData[Fishinglvl] + $hsPlayerData[Firemakinglvl] + $hsPlayerData[Craftinglvl] + $hsPlayerData[smithinglvl] + $hsPlayerData[Mininglvl] + $hsPlayerData[Herblorelvl] + $hsPlayerData[Agilitylvl] + $hsPlayerData[Thievinglvl] + $hsPlayerData[slayerlvl] + $hsPlayerData[Farminglvl] + $hsPlayerData[Runecraftinglvl] + $hsPlayerData[Hunterlvl] + $hsPlayerData[Constructionlvl] + $hsPlayerData[summoninglvl]; $full_skill = number_format($totalLevel); $full_number = number_format($totalXP); } $i++; //Increases Rank Count After Each User if(in_array($skill_name, $miniGames) { echo"<tr align=\"center\"><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">$i</td>"; echo"<td class=\"alt1\" nowrap=\"nowrap\" width=\"15%\" align=\"left\"><a href=\"index.php?pageid=highscores&action=user&user=" . $hsPlayerData['username'] . "\">$usernamer</a></td>"; //Name echo"<td class=\"alt1\" nowrap=\"nowrap\" width=\"10%\" align=\"left\">$full_skill</td>"; } else { echo"<tr align=\"center\"><td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\" align=\"left\">$i</td>"; //Rank echo"<td class=\"alt1\" nowrap=\"nowrap\" width=\"15%\" align=\"left\"><a href=\"index.php?pageid=highscores&action=user&user=" . $hsPlayerData['username'] . "\">$usernamer</a></td>"; //Name echo"<td class=\"alt1\" nowrap=\"nowrap\" width=\"10%\" align=\"left\">$full_skill</td>"; //Level echo"<td class=\"alt1\" nowrap=\"nowrap\" width=\"15%\" align=\"left\">$full_number</td></tr>"; //XP } } $db->free_result($highscoresQuery); unset($hsPlayerData); echo"</table>"; echo"<div class=\"alt2 block_row\" id=\"visitor_message_tab_footer\">"; echo"<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">"; echo"<tr valign=\"bottom\"><td class=\"smallfont\" align=\"right\">"; echo"<div class=\"pagenav\" align=\"right\"><table class=\"tborder\" cellpadding=\"3\" cellspacing=\"1\" border=\"0\">"; echo"<tr>"; echo"<td class=\"vbmenu_control\" style=\"font-weight:normal\">Page $currentPage of $totalPages</td>"; $remSkill = "&stat=".$m_stat; if ($currentPage > 1) { $thePrev = $prevPage; echo"<td class=\"alt1\"><a class=\"smallfont\" href=\"index.php?pageid=highscores".$remSkill."&page=".$thePrev."\" title=\"Previous\"><</a></td>"; do { echo"<td class=\"alt1\"><a class=\"smallfont\" href=\"index.php?pageid=highscores".$remSkill."&page=".$thePrev."\" title=\"Current Results Showing Later\">$thePrev</a></td>"; $thePrev--; } while ($thePrev >= 1); } echo"<td class=\"alt2\"><span class=\"smallfont\" title=\"Showing ".$resultsLeft."\"><strong>$currentPage</strong></span></td>"; if ($nextPage <= $totalPages) { $theNext = $nextPage; do { echo"<td class=\"alt1\"><a class=\"smallfont\" href=\"index.php?pageid=highscores".$remSkill."&page=".$theNext."\" title=\"Current Results Showing Later\">$theNext</a></td>"; $theNext++; } while ($theNext <= $totalPages); echo"<td class=\"alt1\"><a class=\"smallfont\" href=\"index.php?pageid=highscores".$remSkill."&page=".$nextPage."\" title=\"Current Results Showing Later\">></a></td>"; } echo"<td class=\"vbmenu_control\" title=\"Go To\"><a name=\"PageNav\"></a></td>"; echo"</tr></table></td></tr></table></div></div>"; break; } Ik it's messy lol... Error: Parse error: syntax error, unexpected '{' in C:\www\vhosts\localhost\modules\highscores.php on line 162 Quote Link to comment https://forums.phpfreaks.com/topic/149529-solved-unexpected/ Share on other sites More sharing options...
shlumph Posted March 15, 2009 Share Posted March 15, 2009 Someone may kill you if you don't say where line 162 is Quote Link to comment https://forums.phpfreaks.com/topic/149529-solved-unexpected/#findComment-785277 Share on other sites More sharing options...
wildteen88 Posted March 15, 2009 Share Posted March 15, 2009 Line 162 should be if(in_array($skill_name, $miniGames)) { Quote Link to comment https://forums.phpfreaks.com/topic/149529-solved-unexpected/#findComment-785282 Share on other sites More sharing options...
Cosizzle Posted March 15, 2009 Share Posted March 15, 2009 Someone may kill you if you don't say where line 162 is 162 times over. Quote Link to comment https://forums.phpfreaks.com/topic/149529-solved-unexpected/#findComment-785288 Share on other sites More sharing options...
ram4nd Posted March 15, 2009 Share Posted March 15, 2009 if(in_array($skill_name, $miniGames) { Well you have ) missing there, try: if(in_array($skill_name, $miniGames)) { Quote Link to comment https://forums.phpfreaks.com/topic/149529-solved-unexpected/#findComment-785292 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.