Código PHP:
<?php
FUNCTION all_stats ($user,$is_data_opened)
{
IF ($is_data_opened == FALSE)
{
$html = file('http://hiscore.runescape.com:80/aff/runescape/hiscorepersonal.cgi?username='.$user);
}
// Comprobamos que el usuario aparece en las tablas
$pos = strpos($html[4], "does not currently appear in the hiscores");
IF ($pos === FALSE)
{
$allstats = array();
//Lo primero que hacemos es inicializar el array the habilidades.
$categories[0]="Overall";
$categories[1]="Attack";
$categories[2]="Defence";
$categories[3]="Strength";
$categories[4]="Hitpoints";
$categories[5]="Ranged";
$categories[6]="Prayer";
$categories[7]="Magic";
$categories[8]="Cooking";
$categories[9]="Woodcutting";
$categories[10]="Fletching";
$categories[11]="Fishing";
$categories[12]="Firemaking";
$categories[13]="Crafting";
$categories[14]="Smithing";
$categories[15]="Mining";
$categories[16]="Herblore";
$categories[17]="Agility";
$categories[18]="Thieving";
$categories[19]="Runecrafting";
$l=0;
For ($i=0;$i<=19;$i++)
{
$position = 8+7*$i;
$stats[$i] = $html[$position];
//Buscamos si es entero, en tal caso buscamos a que habilidad pertenece el entero.
IF (strpos($stats[$i], "table cellspacing")===FALSE)
{
$position = $position-2;
DO
{
IF (strpos($html[$position], $categories[$l])!==FALSE)
{
$allstats[$categories[$l]] = $stats[$i];
echo "allstats[".$categories[$l]."] = ".$stats[$i].";<br>";
$valido = TRUE;
}
ELSE
{
$allstats[$categories[$l]] = "-";
}
$l=$l+1;
}
WHILE($valido==FALSE);
$valido = FALSE;
}
ELSE
{
$i=19;
}
}
//Mostramos las habilidades que queden con 1 guion
FOR ($i=$l;$i<=19;$i++)
{
$allstats[$categories[$i]] .= "-";
}
}
print_r(array_keys($allstats));
return $allstats;
}//fin funcion all_stats
all_stats(jcgx,FALSE);
print_r(array_keys($allstats));
IF ($allstats==ARRAY())
{
echo "ERROR: The user does not appear in the high score tables. Be sure it is spelled correctly.";
}
ELSE
{
echo $allstats[Overall];
}
?>