rafiik18
Banned
- Dołączył
- Luty 6, 2011
- Posty
- 167
- Liczba reakcji
- 11
Jest to Highscores podobny do tego na riberi 

PHP:
<?PHP
$page = $_REQUEST['page'];
$add = array("query" => "", "vocation" => "", "promotion" => "");
$type = (int) $_GET['type'];
if(in_array($_GET['vocation'], array(1, 2, 3, 4)))
$add['vocation'] = (int) $_GET['vocation'];
if(in_array($_GET['promotion'], array(0, 1)))
$add['promotion'] = (int) $_GET['promotion'];
if(!empty($add['vocation']))
{
$add['query'] = " AND `vocation` = ".$add['vocation'];
if(!empty($add['promotion']))
$add['query'] .= " AND `promotion` = ".$add['promotion'];
}
function getTimeInSmartFormat($param)
{
$string;
$param = (int) $param;
if ($param >= 60*60)
$string .= (int) ($param / (60*60)) .' h ';
$string .= (int) ($param % (60*60) / 60) .' m';
return $string;
}
function coloured_value($valuein)
{
$value2 = $valuein;
while(strlen($value2) > 3)
{
$value .= '.'.substr($value2, -3, 3);
$value2 = substr($value2, 0, strlen($value2)-3);
}
$value = $value2.$value;
if($valuein > 0)
return '+'.$value.'';
elseif($valuein < 0)
return ''.$value.'';
else
return ''.$value.'';
}
///Ilosc profesji
$all = $SQL->query('SELECT COUNT(*) FROM `players` WHERE `vocation`>0;')->fetch();
$vocs = array();
foreach($SQL->query('SELECT `vocation`, COUNT(`id`) AS `count` FROM `players` GROUP BY `vocation`') as $entry)
$vocs[$entry['vocation']] = $entry['count'];
///Ilosc profesji
if((int) $_GET['vocation'] == 1)
$voc1 = $config['site']['lightborder'];
else
$voc1 = $config['site']['darkborder'];
$main_content .= "
<table style=\"width: 100%;\" cellpadding=\"4\" cellspacing=\"1\">
<tr style=\"background: ".$config['site']['vdarkborder']."; \" colspan=\"2\">
<td class=\"white\">
<B>Choose a profession</B>
<a href=\"?subtopic=highscores".($type >= 0 ? "&type=".$type : "")."\" style=\"padding: 5px 5px 7px 5px; margin: 5px 1px 0px 1px; background-color: ".((!(int) $_GET['vocation']) ? $config['site']['lightborder'] : $config['site']['darkborder'])."; color: #FFFFFF;\" title=\"".(int) $all[0]."\">All</a>
<a href=\"?subtopic=highscores".($type >= 0 ? "&type=".$type : "")."&vocation=1\" style=\"padding: 5px 5px 7px 5px; margin: 5px 1px 0px 1px; background-color: ".(((int) $_GET['vocation'] == 1) ? $config['site']['lightborder'] : $config['site']['darkborder'])."; color: #aaaaaa;\" title=\"".(int) $vocs[1]."\">Sorcerer</a>
<a href=\"?subtopic=highscores".($type >= 0 ? "&type=".$type : "")."&vocation=2\" style=\"padding: 5px 5px 7px 5px; margin: 5px 1px 0px 1px; background-color: ".(((int) $_GET['vocation'] == 2) ? $config['site']['lightborder'] : $config['site']['darkborder'])."; color: #aaaaaa;\" title=\"".(int) $vocs[2]."\">Druid</a>
<a href=\"?subtopic=highscores".($type >= 0 ? "&type=".$type : "")."&vocation=3\" style=\"padding: 5px 5px 7px 5px; margin: 5px 1px 0px 1px; background-color: ".(((int) $_GET['vocation'] == 3) ? $config['site']['lightborder'] : $config['site']['darkborder'])."; color: #aaaaaa;\" title=\"".(int) $vocs[3]."\">Paladin</a>
<a href=\"?subtopic=highscores".($type >= 0 ? "&type=".$type : "")."&vocation=4\" style=\"padding: 5px 5px 7px 5px; margin: 5px 1px 0px 1px; background-color: ".(((int) $_GET['vocation'] == 4) ? $config['site']['lightborder'] : $config['site']['darkborder'])."; color: #aaaaaa;\" title=\"".(int) $vocs[4]."\">Knight</a>
</td>
</tr>
</table>
";
$main_content .= "
<table style=\"width:100%;font-weight:bold;text-align:center;\" cellpadding=\"4\" cellspacing=\"1\">
<tr style=\"background:".$config['site']['vdarkborder'].";\">
<td colspan=\"3\" style=\"height:0px;\"></td>
</tr>
<TR><TD BGCOLOR=\"".$config['site']['vdarkborder']."\" ALIGN=center CLASS=white colspan=\"3\"><B>Skills</B></TD></TR>
<tr>
<td style=\"width:33%;\" BGCOLOR=\"".$config['site']['darkborder']."\"><a HREF=\"?subtopic=highscores&type=8".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >Experience</a></td>
<td style=\"width:33%;\" BGCOLOR=\"".$config['site']['darkborder']."\"><a HREF=\"?subtopic=highscores&type=9".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >Magic</a></td>
<td style=\"width:33%;\" BGCOLOR=\"".$config['site']['darkborder']."\"><a HREF=\"?subtopic=highscores&type=6".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >Shielding</a></td>
</tr>
<tr>
<td BGCOLOR=\"".$config['site']['lightborder']."\"><a HREF=\"?subtopic=highscores&type=5".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >Distance</a></td>
<td BGCOLOR=\"".$config['site']['lightborder']."\"><a HREF=\"?subtopic=highscores&type=2".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >Club</a></td>
<td BGCOLOR=\"".$config['site']['lightborder']."\"><a HREF=\"?subtopic=highscores&type=3".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" class=\"size_xs\">Sword</a></td>
</tr>
<tr>
<td BGCOLOR=\"".$config['site']['darkborder']."\"><a HREF=\"?subtopic=highscores&type=4".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >Axe</a></td>
<td BGCOLOR=\"".$config['site']['darkborder']."\"><a HREF=\"?subtopic=highscores&type=1".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >Fist</a></td>
<td BGCOLOR=\"".$config['site']['darkborder']."\"><a HREF=\"?subtopic=highscores&type=7".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >Fishing</a></td>
</tr>
</table>
<table BORDER=0 CELLPaDDING=\"4\" CELLSPaCING=\"1\" style=\"width:100%;font-weight:bold;text-align:center;\">
<TR><TD BGCOLOR=\"".$config['site']['vdarkborder']."\" ALIGN=center CLASS=white colspan=\"3\"><B>PowerGamers</B></TD></TR>
<tr>
<td style=\"width:33%;\" BGCOLOR=\"".$config['site']['darkborder']."\" width=\"50%\"><a HREF=\"?subtopic=highscores&type=10".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >Today</a></td>
<td style=\"width:33%;\" BGCOLOR=\"".$config['site']['darkborder']."\" width=\"50%\"><a HREF=\"?subtopic=highscores&type=11".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >1 Day</a></td>
</tr>
<tr>
<td style=\"width:33%;\" BGCOLOR=\"".$config['site']['lightborder']."\"><a HREF=\"?subtopic=highscores&type=12".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >3 Day</a></td>
<td style=\"width:33%;\" BGCOLOR=\"".$config['site']['lightborder']."\"><a HREF=\"?subtopic=highscores&type=13".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >7 Day</a></td>
</tr>
<TR><TD BGCOLOR=\"".$config['site']['vdarkborder']."\" ALIGN=center CLASS=white colspan=\"2\"><B>Online Time</B></TD></TR>
<tr>
<td style=\"width:33%;\" BGCOLOR=\"".$config['site']['darkborder']."\"><a HREF=\"?subtopic=highscores&type=14".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >Today</a></td>
<td style=\"width:33%;\" BGCOLOR=\"".$config['site']['darkborder']."\"><a HREF=\"?subtopic=highscores&type=15".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >All Time</a></td>
</tr>
<tr>
<td style=\"width:33%;\" BGCOLOR=\"".$config['site']['lightborder']."\"><a HREF=\"?subtopic=highscores&type=16".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >1 Day</a></td>
<td style=\"width:33%;\" BGCOLOR=\"".$config['site']['lightborder']."\"><a HREF=\"?subtopic=highscores&type=17".((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."\" >7 Day</a></td>
</tr>
</table>
";
$main_content .= "<br /><br /><table style=\"width: 100%;\" cellpadding=\"4\" cellspacing=\"1\">";
$offset = $page * 100;
if($type == 8 || !$type)
$highscore = $SQL->query("SELECT `name`, `level`, `vocation`, `promotion`, `experience`, `online` FROM `players` WHERE `group_id` <= 3 AND `name` NOT LIKE '%Sample'".($add['query'] ? $add['query'] : "")." ORDER BY `level` DESC LIMIT 101 OFFSET ".$offset);
elseif($type == 9)
$highscore = $SQL->query("SELECT `name`, `level`, `maglevel`, `vocation`, `promotion`, `manaspent`, `online` FROM `players` WHERE `group_id` <= 3 AND `name` NOT LIKE '%Sample'".($add['query'] ? $add['query'] : "")." ORDER BY `maglevel` DESC, `manaspent` DESC LIMIT 101 OFFSET ".$offset);
elseif($type == 10)
$highscore = $SQL->query("SELECT `name`, `level`, `vocation`, `promotion`, `experience`, `online` FROM `players` WHERE `group_id` <= 3 AND `name` NOT LIKE '%Sample'".($add['query'] ? $add['query'] : "")." ORDER BY `experience` DESC LIMIT 101 OFFSET ".$offset);
elseif($type == 11)
$highscore = $SQL->query("SELECT `name`, `level`, `vocation`, `promotion`, `experience`, `online`, `exphist1` FROM `players` WHERE `group_id` <= 3 AND `name` NOT LIKE '%Sample'".($add['query'] ? $add['query'] : "")." ORDER BY `exphist1` DESC LIMIT 101 OFFSET ".$offset);
elseif($type == 12)
$highscore = $SQL->query("SELECT `name`, `level`, `vocation`, `promotion`, `experience`, `online`, `exphist3` FROM `players` WHERE `group_id` <= 3 AND `name` NOT LIKE '%Sample'".($add['query'] ? $add['query'] : "")." ORDER BY `exphist3` DESC LIMIT 101 OFFSET ".$offset);
elseif($type == 13)
$highscore = $SQL->query("SELECT `name`, `level`, `vocation`, `promotion`, `experience`, `online`, `exphist7` FROM `players` WHERE `group_id` <= 3 AND `name` NOT LIKE '%Sample'".($add['query'] ? $add['query'] : "")." ORDER BY `exphist7` DESC LIMIT 101 OFFSET ".$offset);
elseif($type == 14)
$highscore = $SQL->query("SELECT `name`, `level`, `vocation`, `promotion`, `experience`, `online`, `onlinetimetoday` FROM `players` WHERE `group_id` <= 3 AND `name` NOT LIKE '%Sample'".($add['query'] ? $add['query'] : "")." ORDER BY `onlinetimetoday` DESC LIMIT 101 OFFSET ".$offset);
elseif($type == 15)
$highscore = $SQL->query("SELECT `name`, `level`, `vocation`, `promotion`, `experience`, `online`, `onlinetimeall` FROM `players` WHERE `group_id` <= 3 AND `name` NOT LIKE '%Sample'".($add['query'] ? $add['query'] : "")." ORDER BY `onlinetimeall` DESC LIMIT 101 OFFSET ".$offset);
elseif($type == 16)
$highscore = $SQL->query("SELECT `name`, `level`, `vocation`, `promotion`, `experience`, `online`, `onlinetime1` FROM `players` WHERE `group_id` <= 3 AND `name` NOT LIKE '%Sample'".($add['query'] ? $add['query'] : "")." ORDER BY `onlinetime1` DESC LIMIT 101 OFFSET ".$offset);
elseif($type == 17)
$highscore = $SQL->query("SELECT `name`, `level`, `vocation`, `promotion`, `experience`, `online`, `onlinetime7` FROM `players` WHERE `group_id` <= 3 AND `name` NOT LIKE '%Sample'".($add['query'] ? $add['query'] : "")." ORDER BY `onlinetime7` DESC LIMIT 101 OFFSET ".$offset);
else
$highscore = $SQL->query("SELECT `player_id`, `skillid`, `value`, `count` FROM `player_skills` WHERE `player_id` IN (SELECT `id` FROM `players` WHERE `group_id` <= 3 AND `name` NOT LIKE '%Sample'".($add['query'] ? $add['query'] : "").") AND `skillid` = ".(int) ($type - 1)." ORDER BY `value` DESC LIMIT 101 OFFSET ".$offset);
switch($type)
{
case 1:
$name = "Fist Fighting";
break;
case 2:
$name = "Club Fighting";
break;
case 3:
$name = "Sword Fighting";
break;
case 4:
$name = "Axe Fighting";
break;
case 5:
$name = "Distance Fighting";
break;
case 6:
$name = "Shielding";
break;
case 7:
$name = "Fishing";
break;
case 8:
$name = "Experience";
break;
case 9:
$name = "Magic Level";
break;
case 10:
$name = "PowerGamers - Today";
break;
case 11:
$name = "PowerGamers - 1 Days";
break;
case 12:
$name = "PowerGamers - 3 Days";
break;
case 13:
$name = "PowerGamers - 7 Days";
break;
case 14:
$name = "Online Time - Today";
break;
case 15:
$name = "Online Time - All Time";
break;
case 16:
$name = "Online Time - 1 Days";
break;
case 17:
$name = "Online Time - 7 Days";
break;
default:
$name = "Experience";
}
$main_content .= "<tr style=\"background: ".$config['site']['vdarkborder'].";\">
<td class=\"white\" colspan=\"4\" align=\"left\"><b>Ranking for <u>".$name."</u> on <u>".$config['server']['serverName']."</u></b></td>
";
$count = 0;
if($highscore->rowCount() > 0)
{
$main_content .= "<tr style=\"background: ".$config['site']['vdarkborder'].";\">
<td class=\"white\" align=\"center\"><b>#</b></td>
<td class=\"white\" align=\"center\"><b>Player</b></td>
";
if(in_array($type, array(1, 2, 3, 4, 5, 6, 7)))
$main_content .= "<td class=\"white\" align=\"center\"><b>Skill</b></td>";
elseif(in_array($type, array(8)) || !$type)
$main_content .= "
<td class=\"white\" align=\"center\"><b>Level</b></td>
<td class=\"white\" align=\"center\"><b>Points</b></td>
";
elseif(in_array($type, array(10, 11, 12, 13, 14, 15, 16, 17)))
$main_content .= "<td class=\"white\" align=\"center\"><b>#</b></td>";
else
$main_content .= "
<td class=\"white\" align=\"center\"><b>Level</b></td>
";
$main_content .= "</tr>";
foreach($highscore as $player)
{
if($count < 100)
{
if($player['online'] == 1)
$color = "green";
else
$color = "red";
if($type >= 1 && $type <= 7)
{
$tmp = new OTS_Player();
$tmp->load((int)$player['player_id']);
if($tmp->isLoaded())
{
$player['name'] = $tmp->getName();
$player['level'] = $tmp->getLevel();
$player['vocation'] = $tmp->getVocation();
$player['promotion'] = $tmp->getPromotion();
if($tmp->isOnline())
$player['status'] = "<font style=\"color: lime;\">Online</font>";
else
$player['status'] = "<font style=\"color: red;\">Offline</font>";
}
else
$player['name'] = "Fail'd @ loading.";
unset($tmp);
}
++$count;
$bgcolor = (is_int($count / 2) ? $config['site']['darkborder'] : $config['site']['lightborder']);
$main_content .= "<tr style=\"background: ".$bgcolor.";\">
<td style=\"text-align: center;\">".($offset + $count)."</td>
<td style=\"text-align: center;\"><a style=\"color: ".$color."\"; href=\"?subtopic=characters&name=".$player['name']."\">".$player['name']."</a><br /><small>Level ".$player['level'].", ".$vocation_name[1][$player['promotion']][$player['vocation']].", ".$config['server']['serverName']."</small></td>
";
if($type == 8 || empty($type))
$main_content .= "
<td style=\"text-align: center;\"><b>".$player['level']."</b></td>
<td width=\"10%\" style=\"text-align: center;\"><small><b>".$player['experience']."</b></td>
";
elseif($type == 9)
$main_content .= "<td style=\"text-align: center;\"><b>".$player['maglevel']."</b></td>";
elseif($type == 10)
{
$minus = $player['experience']-$player['exphist_lastexp'];
$main_content .= "<td style=\"text-align: center;\"><font color=\"".$color."\">".coloured_value($minus)."</font></td>";
}
elseif($type == 11)
$main_content .= "<td style=\"text-align: center;\"><font color=\"".$color."\">".coloured_value($player['exphist1'])."</font></td>";
elseif($type == 12)
$main_content .= "<td style=\"text-align: center;\"><font color=\"".$color."\">".coloured_value($player['exphist3'])."</font></td>";
elseif($type == 13)
$main_content .= "<td style=\"text-align: center;\"><font color=\"".$color."\">".coloured_value($player['exphist7'])."</font></td>";
elseif($type == 14)
$main_content .= "<td style=\"text-align: center;\"><font color=\"".$color."\">".getTimeInSmartFormat($player['onlinetimetoday'])."</font></td>";
elseif($type == 15)
$main_content .= "<td style=\"text-align: center;\"><font color=\"".$color."\">".getTimeInSmartFormat($player['onlinetimeall'])."</font></td>";
elseif($type == 16)
$main_content .= "<td style=\"text-align: center;\"><font color=\"".$color."\">".getTimeInSmartFormat($player['onlinetime1'])."</font></td>";
elseif($type == 17)
$main_content .= "<td style=\"text-align: center;\"><font color=\"".$color."\">".getTimeInSmartFormat($player['onlinetime7'])."</font></td>";
else
$main_content .= "<td style=\"text-align: center;\"><b>".$player['value']."</b></td>";
$main_content .= "</tr>";
}
else
$show_link_to_next_page = TRUE;
}
}
else
$main_content .= "<tr style=\"background: ".$config['site']['darkborder'].";\"><td class=\"whites\" align=\"center\">No highscore at the moment.</td></tr>";
$main_content .= "</table>";
$main_content .= '</TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%>';
//link to previous page if actual page isn't first
if($page > 0) {
$main_content .= "<TR><TD WIDTH=100% ALIGN=right VALIGN=bottom><A HREF=\"?subtopic=highscores".($type >= 0 ? "&type=".$type : "").((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."&page=".($page - 1)."\" CLASS=\"size_xxs\">Previous Page</A></TD></TR>";
}
//link to next page if any result will be on next page
if($show_link_to_next_page) {
$main_content .= "<TR><TD WIDTH=100% ALIGN=right VALIGN=bottom><A HREF=\"?subtopic=highscores".($type >= 0 ? "&type=".$type : "").((int) $_GET['vocation'] ? "&vocation=".(int) $_GET['vocation'] : "").((int) $_GET['promotion'] ? "&promotion=".(int) $_GET['promotion'] : "")."&page=".($page + 1)."\" CLASS=\"size_xxs\">Next Page</A></TD></TR>";
}
//end of page
$main_content .= '</TABLE></TD>';
?>