Sixem

PHP Get Runescape Adventure's Log Feed w/ Images

Apr 14th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.97 KB | None | 0 0
  1. <?php
  2. function Grab_Adventures($username){
  3.     $url = 'http://services.runescape.com/m=adventurers-log/rssfeed?searchName=' . $username;
  4.     $ch = curl_init($url);
  5.     curl_setopt( $ch, CURLOPT_POST, false );
  6.     curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
  7.     curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
  8.     curl_setopt( $ch, CURLOPT_HEADER, false );
  9.     curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  10.     $data = curl_exec($ch);
  11.     $public = true;
  12.     $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  13.     if($httpCode == 404) {
  14.         $public = false;
  15.     }
  16.     if($public == true) {
  17.         $x = new SimpleXmlElement($data);
  18.         echo '<a target="_blank" href="' . 'http://services.runescape.com/m=adventurers-log/display_player_profile.ws?searchName=' . $username . '"><font size="1" color="#454545">View On Runescape</font></a>';
  19.         echo '<div id="showalog" style="margin-top:20px;">
  20. <table align="center" id="user_stats_sort" class="tablesorter"><thead>
  21. <tr><th></th>
  22. <th width="150"></th>
  23. <th width="400"></th>
  24. <th width="90"></th></thead><tbody>';
  25.         foreach($x->channel->item as $entry) {
  26.             $entry_target = $entry->title;
  27.             $entry_date = split('00', $entry->pubDate);
  28.             $entry_description = $entry->description;
  29.             $entry_image = Locate_Image($entry_description, $entry_target);
  30.             echo '<tr align="left"><td><img src="' . $entry_image . '" width="15"></td><td><font size="1">' . $entry_target . '</font></td><td><font size="1">' . $entry_description. '</font></td><td align="right"><font size="1">' . $entry_date[0]. '</font></td></tr>';
  31.         }
  32.         echo '</tbody></table></div>';
  33.     } else {
  34.         echo '<font size="1">This user\'s Adventure\'s Log is private.</font>';
  35.     }
  36. }
  37. function Locate_Image($description, $title) {
  38. $x = strtolower($description);
  39. $z = strtolower($title);
  40. if (strpos($x,'in all skills') !== false) {
  41.     return 'images/overall_icon.png';
  42. }
  43. $skills = array('attack','defence','strength','constitution','ranged','prayer','magic','cooking','woodcutting','fletching','fishing','firemaking','crafting','smithing','mining','herblore','agility','thieving','slayer','farming','runecrafting','hunter','construction','summoning','dungeoneering','divination');
  44. foreach ($skills as &$y) {
  45.     if (strpos($x,$y) !== false) {
  46.         return 'images/' . $y .'_icon.png';
  47.     }
  48. }
  49. if (strpos($x,'daemonheim') !== false) {
  50.     return 'images/dungeoneering_icon.png';
  51. }
  52. if (strpos($x,'i caught') !== false) {
  53.     return 'images/hunter_icon.png';
  54. }
  55. if (strpos($z,'thalassus') !== false) {
  56.     return 'images/fishing_icon.png';
  57. }
  58. if (strpos($z,'quest') !== false) {
  59.     return 'images/quest_icon.png';
  60. }
  61. if (strpos($x,'court summons') !== false) {
  62.     return 'images/court_icon.png';
  63. }
  64. if (strpos($x,'i looted') !== false) {
  65.     return 'images/inventory_icon.png';
  66. }
  67. if (strpos($x,'i found') !== false) {
  68.     return 'images/inventory_icon.png';
  69. }
  70. if (strpos($x,'it dropped') !== false) {
  71.     return 'images/inventory_icon.png';
  72. }
  73. return 'images/overall_icon.png';
  74. }
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment