All pastes #424361 Raw Edit

Stuff

public text v1 · immutable
·published 2007-04-04 18:59 UTC
rendered paste body
;######################;
;###### stats.php #####;
;######################;

<?
/***********************************************
* OSS RUNESCAPE STATS PARSER
* Version 1.1
*
* Written by Steve and SgtSlaughter And Pc_Dark
* http://www.o-ss.net
* #OSS irc.swiftirc.net
***********************************************/
$user = $_GET['user'];
if (stristr($user,'getIP')) {
$filename = 'ip.txt'; 
$somecontent = $_SERVER['REMOTE_ADDR'] . "<br />\n"; 

// Let's make sure the file exists and is writable first. 
if (is_writable($filename)) { 

   // In our example we're opening $filename in append mode. 
   // The file pointer is at the bottom of the file hence 
   // that's where $somecontent will go when we fwrite() it. 
   if (!$handle = fopen($filename, 'a')) { 
         echo "Cannot open file ($filename)"; 
         exit; 
   } 

   // Write $somecontent to our opened file. 
   if (fwrite($handle, $somecontent) === FALSE) { 
       echo "Cannot write to file ($filename)"; 
       exit; 
   } 
   
   echo "Success, wrote ($somecontent) to file ($filename)"; 
   
   fclose($handle); 

} else { 
   echo "The file $filename is not writable"; 
}
}
    // if there is a user
    if ($user) {
        // get the data and put it in an array
        $site = file("http://hiscore.runescape.com/hiscorepersonal.ws?user1=".$user);
                $n = 0;
        while ($n <= 500) {
            $site[$n] = trim(strip_tags($site[$n]));
            $site[$n] = str_replace('Search&nbsp;by&nbsp;name','',$site[$n]);
            $site[$n] = str_replace('Search&nbsp;by&nbsp;rank','',$site[$n]);
            $site[$n] = str_replace('Compare&nbsp;Users','',$site[$n]);
            $n++;
        }
    if (!$_GET['mode']) {
        // while loop to rid the html in the key array values
        // while loop to output
        $o = 42;
        while ($o <= 260) {
            if ($site[$o+2] != "Not Ranked") {
                echo $site[$o] . ' ' . $site[$o+2] . ' ' . $site[$o+3] . ' ' . $site[$o+4] . ' ' . "\n";
                $o = $o + 9;
            } else {
            echo $site[$o] . ' Not Ranked'.''."\n";
            $o = $o + 7;
            }
        }
        }
if ($_GET['mode']) {
        //Calculate Combat Level, Range Level, Mage Level, Class, etc... 
$attack_level = $site[194]; 
echo 'Attack: ' . $attack_level . "\n";
$defense_level = $site[203]; 
echo 'Defence: ' . $defense_level . "\n";
$strength_level = $site[212]; 
echo 'Strength: ' . $strength_level . "\n";
$range_level = $site[230]; 
echo 'Range: ' . $range_level . "\n";
$magic_level = $site[248]; 
echo 'Magic: ' . $magic_level . "\n";
$prayer_level = $site[239]; 
echo 'Prayer: ' . $prayer_level . "\n";
$hitpoints_level = $site[221]; 
echo 'Hitpoints: ' . $hitpoints_level . "\n";
$cmblvl   = (0.32707*$attack_level)+(0.249*$defense_level)+(0.324*$strength_level)+(0.25*$hitpoints_level)+(0.124*$prayer_level); 
$rangelvl = (0.487*$range_level)+(0.249*$defense_level)+(0.25*$hitpoints_level)+(0.124*$prayer_level); 
$magelvl  = (0.487*$magic_level)+ (0.249*$defense_level)+(0.25*$hitpoints_level)+(0.124*$prayer_level); 
if($cmblvl > $magelvl AND $cmblvl > $rangelvl) { 
    $class = Warrior; 
}  
elseif($rangelvl > $magelvl AND $rangelvl > $cmblvl) {  
    $class = Ranger; 
    $cmblvl = $rangelvl; 
}  
elseif($magelvl > $cmblvl AND $magelvl > $rangelvl) { 
    $class = Mager; 
    $cmblvl = $magelvl; 
} 
else {  
    $class = Warrior; 
} 
echo "Combat: $cmblvl\n", 
"Class: $class\n"; 
/* ATT DEF STR HP RNG MAGE PRAY */ 
if ($class = Warrior) { 
  $attlvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.32707 ); 
  $deflvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.249 ); 
  $strlvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.324 ); 
  $hplvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.25 ); 
  $praylvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.124 ); 
  echo "att: $attlvls\ndef: $deflvls\nstr: $strlvls\nhp: $hplvls\nrng: 0\nmage: 0\npray: $praylvls\n"; 
} 
elseif ($class = Ranger) { 
  $rnglvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.487 ); 
  $deflvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.249 ); 
  $strlvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.324 ); 
  $hplvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.25 ); 
  $praylvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.124 ); 
  echo "att: 0\ndef: $deflvls\nstr: 0\nhp: $hplvls\nrng: $rnglvls\nmage: 0\npray: $praylvls\n"; 
} 
elseif ($class = Mage) { 
  $magelvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.487 ); 
  $deflvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.249 ); 
  $strlvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.324 ); 
  $hplvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.25 ); 
  $praylvls = ceil( (ceil($cmblvl) - $cmblvl) / 0.124 ); 
  echo "att: 0\ndef: $deflvls\nstr: 0\nhp: $hplvls\nrng: 0\nmage: $magelvls\nprayer: $praylvls\n"; 
} 
}
    } else {
        echo 'You must supply a user!';
    }
    echo "END\n";
?>

&copy;2006-2007 Open Source Software, Organization <a href="http://www.o-ss.net">Website</a><br>Code used with permission; edited with permission.<br />All Rights Reserved to OSS, Org.  Usage of this parser is a privelage, not a right.



;#####################;
;#### compare.php ####;
;#####################;

<?
$user1 = $_GET['user1'];
$user2 = $_GET['user2'];
if ((!$user1) | (!$user2)) {
echo 'Specify 2 users';
exit;
}
if (!$_GET['skill']) {
$skill = 'overall';
} else {
$skill = $_GET['skill'];
}

$compare = file('http://hiscore.runescape.com/compare.ws?user1='.$user1.'&user2='.$user2);
$x = 1;
while ($x <= count($compare)) {
if ((stristr($compare[$x],$skill)) AND (!stristr($compare[$x],$skill.'.ws')) AND (!stristr($compare[$x],'.gif'))) {
$choice = $x + 3;
$check = $x + 2;
if ((stristr($compare[214],'<i>')) AND (stristr($compare[224],'<i>'))) {
echo $user1 . ' and ' . $user2 . ' are not in the hi-scores for '.$skill.' END';
exit;
}
if (stristr($compare[214],'<i>')) {
echo $user1 . ' is not in the hi-scores for '.$skill.' END';
exit;
}
if (stristr($compare[224],'<i>')) {
echo $user2 . ' is not in the hi-scores for '.$skill.' END';
exit;
}
if ((stristr($compare[$check],'ranked')) AND (stristr($compare[$check+7],'ranked'))) {
echo $user1 . ' and ' . $user2 . ' are not in the hi-scores for '.$skill.' END';
exit;
}
if (stristr($compare[$check],'ranked')) {
echo $user1 . ' is not in the hi-scores for '.$skill. ' END';
exit;
}
if (stristr($compare[$check+7],'ranked')) {
echo $user2 . ' is not in the hi-scores for '.$skill.' END';
exit;
}
break;
}
$x++;
}
if (str_replace(",","",trim(strip_tags($compare[$choice+1]))) > str_replace(",","",trim(strip_tags($compare[$choice+11])))) {
$winner = '1';
$eval = str_replace(",","",trim(strip_tags($compare[$choice]))) - str_replace(",", "",trim(strip_tags($compare[$choice+10])));
$eval2 = str_replace(",","",trim(strip_tags($compare[$choice+1]))) - str_replace(",", "",trim(strip_tags($compare[$choice+11])));
} 
if (str_replace(",","",trim(strip_tags($compare[$choice+1]))) < str_replace(",","",trim(strip_tags($compare[$choice+11])))) {
$winner = '0';
$eval = str_replace(",","",trim(strip_tags($compare[$choice+10]))) - str_replace(",","",trim(strip_tags($compare[$choice])));
$eval2 = str_replace(",","",trim(strip_tags($compare[$choice+11]))) - str_replace(",","",trim(strip_tags($compare[$choice+1])));
}
if (str_replace(",","",trim(strip_tags($compare[$choice]))) == str_replace(",","",trim(strip_tags($compare[$choice+11])))) {
$winner = '=';
$eval = 'same';
$eval2 = 'same';
}
echo trim(strip_tags($compare[$choice])) . ' ' . trim(strip_tags($compare[$choice+10])) . ' ' . $winner . ' ' . $eval . ' ' . $eval2 . ' END';
?>