All pastes #440365 Raw Edit

Untitled

public text v1 · immutable
·published 2007-04-14 23:49 UTC
rendered paste body
<?php
error_reporting(E_ALL);

/* cURL Function */
function lookupUser($rsuser) {
  $hsurl = 'http://hiscore.runescape.com/hiscorepersonal.ws';
  $hsurl .= '?user1=' . $rsuser;
  $curl = curl_init(); // Initialize the CURL session
  curl_setopt($curl , CURLOPT_URL , $hsurl); // Set the URL for CURL transfer
  curl_setopt($curl , CURLOPT_VERBOSE , 1); // Output VERBOSE information, Write to STDERR
  curl_setopt($curl , CURLOPT_HEADER , 0); // Don't return the Header in the string
  $file = curl_exec($curl); // Perform the CURL session
  curl_close($curl); // Close the CURL session
  return $file;
}

/* Mid Function */
function mid($inputstr,$delimeterLeft,$delimeterRight) {
  $posLeft  = stripos($inputstr,$delimeterLeft)+1;
  $posRight = stripos($inputstr,$delimeterRight,$posLeft+1);
  return substr($inputstr,$posLeft,$posRight-$posLeft);
}

/* XML Function */
function makeHSXML($username) {
  $hspage=lookupUser('Zanithsrevel');
  $xmlf = '<?xml version="1.0" encoding="ISO-8859-1"?>';
  $xmlf .= "\n";
  $xmlf .= '<user name="' . $username . '">';
  $xmlf .= "\n";
  for ($i=0; $i<=23; $i++) {
    $hspars[$i]=mid($hspage, '?table=' . $i, '</tr>');
  }
  foreach ($hspars as $hsbd) {
    $xmlf .= '<' . trim(mid($hsbd, ">", "</a>")) . '>';
    $xmlf .= "\n";
    $plodehs=explode("\n",$hsbd);
    $xmlf .= '<rank>' . trim(substr(mid($plodehs[3], '<td align="right">', '</td>'), 17)) . 

'</rank>';
    $xmlf .= "\n";
    $xmlf .= '<level>' . trim(substr(mid($plodehs[4], '<td align="right">', '</td>'), 17)) 

. '</level>';
    $xmlf .= "\n";
    $xmlf .= '<exp>' . trim(substr(mid($plodehs[5], '<td align="right">', '</td>'), 17)) . 

'</exp>';
    $xmlf .= "\n";
    $xmlf .= '</' . trim(mid($hsbd, ">", "</a>")) . '>';
    $xmlf .= "\n";
  }
  $xmlf .= '</user>';
  return $xmlf;
}
echo makeHSXML('Zanithsrevel');
?>