/    Sign up×
Community /Pin to ProfileBookmark

Can’t Explain in Title.

First off, thanks to [URL=”http://www.webdeveloper.com/forum/member.php?u=29608″]stephan.gerlach[/URL] for the script. =].


—–

Thanks for opening this, even though I have a rather vague title.

Anyways, here’s my predicament: I’m making a tool for players of the MMORPG [URL=”www.runescape.com”]RuneScape[/URL] that would let them lookup their hiscores, and see how much XP they need from where they are to the next skill level.

[URL=”http://hiscore.runescape.com/hiscorepersonal.ws?user1=%27itstruikou”]Here’s[/URL] an example of what the hiscores look like. [URL=”http://xpcontest.freehostia.com/action.php?username=Itstruikou&submit=Look+Up”]Here’s[/URL] that same page on my website. As you can see, the “XP to next level” isn’t really…there.

Here’s my coding:

Index.php

[code=php]
<!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221; &#8220;http://www.w3.org/ TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;>
<html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221; xml:lang=&#8221;en&#8221; lang=&#8221;en&#8221;>
<head>
<meta http-equiv=&#8221;content-type&#8221; content=&#8221;text/html; charset=iso-8859-1&#8221; />
<title>Look Up…</title>
</head>
<body>

<font size=+2><u>Look Up…</u></font><br>
<form action=”action.php” method=”get”>
Username: <input name=”username” type=”text”/>

<input name=”submit” type=”submit” value=”Look Up”/>
</form>

</body>
</html>

[/code]

Action.php

[code=php]
<?php $username=$_REQUEST[‘username’]; ?>

<html>
<head>
<title>Stats for <?php echo $username; ?></title>
</head>

<body>

<center>

<h1>Stats for <?php echo $username; ?></h1>
<a href=”index.php”>Return to Index</a>

<?php

function getCode ($user) {
$code = file_get_contents(‘http://hiscore.runescape.com/hiscorepersonal.ws?user1=’.$user);

$start = strpos($code,”Minigames”);
$code = substr($code,0,$start);

$start = strpos($code,'<table class=”table_back” style=”margin-bottom:5px” id=”mini_player”>’);
$code = substr($code,$start);

$start = strpos($code,'<br style=”clear:both” />’);
$code = substr($code,0,$start);

$string = $code;
$patterns[0] = ‘/class=”.*”/’;
$patterns[1] = ‘/align=”center”/’;
$patterns[2] = ‘/<a.*”>/’;
$patterns[3] = ‘/</a>/’;
$patterns[4] = ‘/<img >/’;
$replacements[0] = ”;
$replacements[1] = ”;
$replacements[2] = ”;
$replacements[3] = ”;
$replacements[4] = ”;

$code = preg_replace($patterns, $replacements, $string);
$code = str_replace(“n”,”,$code);
$code = str_replace(” “,”,$code);
$code = str_replace(“</tr>”,”</tr>n”,$code);
$code = str_replace(“<tr>”,”n<tr>”,$code);

$pattern = ‘|<tr><td></td><td>(.*)</td><td>(.*)</td><td>(.*)</td><td>(.*)</td></tr>|’;
preg_match_all($pattern,$code,$arr);

return $arr;
}

$array = getCode($username);
$value = ‘-‘;

echo ‘<table border=”1″ width=”50%” length=”100%”><tr><th>Skill</th><th>Rank</th><th>Level</th><th>XP</th><th>XP to Next Level</th><tr>’;

for($i=0; $i<count($array[1]); $i++) {
echo ‘<text align=”center”><tr><td>’.$array[1][$i].'</td><td>’.$array[2][$i].'</td><td>’.$array[3][$i].'</td><td>’.$array[4][$i].'</td><td>’.$value.'</td></tr></text>’;
}

echo ‘</table>’;
?>

</center>

</body>
</html>[/code]

I’m completely stuck, though. [URL=”http://www.tip.it/runescape/?page=xp_table.htm”]Here’s[/URL] a list of the Skill Levels and their corresponding XP point values. Again, here’s the [URL=”http://xpcontest.freehostia.com/action.php?username=Itstruikou&submit=Look+Up”]site [/URL]in action.

If anyone could point me in the right direction, or give any constructive input, I’d greatly appreciate it. If you think you can help, but just need a little clarification as to what I’m doing, please post!

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@tfk11Oct 05.2008 — Do you have permission from runescape.com to republish their content?
×

Success!

Help @Andrew_Hucks spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...