Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html xmlns="http://www.w3.org/1999/xhtml" lang="pl" >
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <head>
- <title>GE Extractor</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <script type="text/javascript">
- function myFocus(element) {
- if (element.value == element.defaultValue) {
- element.value = '';
- }
- }
- function myBlur(element) {
- if (element.value == '') {
- element.value = element.defaultValue;
- }
- }
- </script>
- <style type="text/css">
- .error {
- color:#FF0000;
- font-weight:bold;
- }
- small {
- color:#666666;
- }
- .parsedItemIconUrl {
- float:left;
- }
- </style>
- </head>
- <body>
- <form name="myForm" action="" method="post" id="myForm">
- <table cellpadding="2" border="1">
- <tr>
- <td width="250" rowspan="3" valign="top">
- <?php
- function transformHTML($string)
- {
- $string = trim($string);
- $string = utf8_decode($string);
- $string = htmlentities($string, ENT_NOQUOTES);
- $string = str_replace("#", "#", $string);
- $string = str_replace("%", "%", $string);
- return $string;
- }
- function get_string_between($string, $start, $end){
- $string = " ".$string;
- $ini = strpos($string,$start);
- if ($ini == 0) return "";
- $ini += strlen($start);
- $len = strpos($string,$end,$ini) - $ini;
- return substr($string,$ini,$len);
- }
- function echoObjectIdStuff($objectId) {
- $error_A = "<p><small class=error>Error #1: Give the ID!</small></p>";
- $error_B = "<p><small class=error>Error #2: Item ID " . $objectId . " not found</small></p>";
- $lines = file('http://services.runescape.com/m=itemdb_rs/viewitem.ws?obj=' . $objectId);
- foreach ($lines as $line_num => $line) {
- $lineCrawl = htmlspecialchars($line);
- $StringSum = "$StringSum$lineCrawl";
- }
- $parsedGuidePrice = get_string_between($StringSum, "Current guide price", "Today");
- $parsedItemName = get_string_between($StringSum, "<title>", " - Grand Exchange - RuneScape</title>");
- $parsedItemIconUrl = get_string_between($StringSum, '<meta property="og:image" content="', '" />');
- $guideprice = preg_replace("/[^\.kbm0-9]/", "", $parsedGuidePrice);
- if (strpos($guideprice,'k') !== false) {
- $guideprice = preg_replace("/[^0-9]/", "", $parsedGuidePrice);
- $guideprice *= 100;
- } else if (strpos($guideprice,'m') !== false) {
- $guideprice = preg_replace("/[^0-9]/", "", $parsedGuidePrice);
- $guideprice *= 100000;
- } else if (strpos($guideprice,'b') !== false) {
- $guideprice = preg_replace("/[^0-9]/", "", $parsedGuidePrice);
- $guideprice *= 100000000;
- } if ($guideprice == "") {
- echo $error_B;
- } else {
- echo "<img src='" . $parsedItemIconUrl . "' class='parsedItemIconUrl'>";
- echo "<br>";
- echo "<br>";
- echo "<strong>" . $parsedItemName . "</strong>: " . $guideprice;
- echo "<br>";
- echo "<small>(Item ID: " . $objectId . ")</small><br><br>";
- }
- }
- if($_POST['submit']) {
- $objectId = transformHTML($_POST['objectId']);
- $objectRange = transformHTML($_POST['objectRange']);
- $objectRange += $objectId - 1;
- for($i = $objectId; $i <= $objectRange; $i++) {
- echoObjectIdStuff($i);
- }
- }
- ?>
- </td>
- <td width="79">Item ID:</td>
- <td width="260"><input name="objectId" value="Type the ID here" onfocus="myFocus(this);" onblur="myBlur(this);" /></td>
- <td width="79"><input type="submit" name="submit" alt="Get yesterday's averge market price" title="Get yesterday's averge market price" /></td>
- </tr>
- <tr valign="top">
- <td>Range:</td>
- <td><input name="objectRange" value="1" onfocus="myFocus(this);" onblur="myBlur(this);" /></td>
- <td> </td>
- </tr>
- <tr valign="top">
- <td> </td>
- <td>
- <small>ex. Gold Bar ID = 2357<br />
- ex. Range = 9 with ID 1038 is: 1038, 1039, ... 1047</small>
- </td>
- <td><input value="Reset" type="button" name="reset" alt="Reset the form" title="Reset the form" onclick="javascript:window.location = '';" /></td>
- </tr>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement