<?php
/*
__++====Runescape Highscorescript 1.0====++__
This class gets every lvl 30+ stat from any player, it can check level, exp and place in highscores.
I also build in a function to check how much exp someone is from a certain level.

Getskill function($player,$skill,$mode)
$player = The runescape name of the player you want the stat from
$skill = The skill you want the stat from
$mode = 0 or empty to get level, 1 to get exp, 2 to get place in highscores

Expleft function
$currentexp = the current exp of the player
$goal = the lvl you want to calculate for how much exp it is from current amount of exp.

If you have any questions, mail me: t e u n e b o o n [@] g m a i l {dot} com
*/
class highscores {
	function getskill($player,$skill,$mode) {
		$skills = array("Overall","Attack","Defence","Strenght","Hitpoints","Ranged","Prayer","Magic","Cooking","Woodcutting","Fletching","Fishing","Firemaking","Crafting","Smithing","Mining","Herblore","Agility","Thieving","Slayer","Farming","Runecrafting","Hunter","Construction");
		$link = "http://hiscore.runescape.com/index_lite.ws?player=".$player;
		$contents = nl2br(file_get_contents($link));
		$contents = str_replace('<br />',',',$contents);
		$contents = str_replace('-1','1000000+',$contents);
		$stats = explode(',',$contents);
		$nrskill = array_search($skill,$skills);
		if($nrskill !== FALSE) {
			switch ($mode) {
				case 0;
					return $stats[($nrskill*3)+1];
					break;
				case 1;
					return $stats[($nrskill*3)+2];
					break;
				case 2;
					return $stats[$nrskill*3];
					break;
				default;
					return $stats[($nrskill*3)+1];
					break;
			}
		} else {
			return "Unknown skill";
		}
	}
	function expleft($currentexp,$goal) {
		$a=0;
		for($b=1; $x<$goal; $b++) {
			$a += floor($b+300*pow(2, ($b/7)));
		}
		$expneeded = floor($a/4);
		$expleft = $expneeded-$currentexp;
		return $expleft;
	}
}
/*
Example:
$example = new highscores;
$exphunter = $example->getskill("zezima","Magic",1);
echo $example->expleft($exphunter,99);
*/
?>