Jump to content

calculator gone wrong... HELP!!


gaogier

Recommended Posts

Hello

 

I have a script, which is a calculator. This script still calculates all my data with no question.

 

The script got data from another site. Using this data, the script would calculate what would be needed to get to the next level, decided what level by the user.

 

I have a guide, if you wanted, i could reply with it.

 

To be honest, i think it may be better if the script would be remade, only one problem though, I dont understand php. where could i find a someone who would help me write the script? Basically a volunteer.

 

Please reply, even if you think this is stupid, it all helps.

Link to comment
Share on other sites

the script is for an mmorpg

 

The script gets data form the hiscores, then adds it to the calculator (dose not work)

 

Then, the script calculates your data, and the target level, and tells you how many of everything you want. (works fine)

 

Here is a link http://runehints.com/calculate.php?action=enter_name&skill=cooking&members=no

 

Just enter, gaogier... you see the error. the company that made the game, changed how the hiscores work (to make it easier) but I have been confused for about 2 years...

Link to comment
Share on other sites

as thebadbad said, you'd have to pay someone to write the script or ask specific questions about how to make it (start with googling what you want to do).. we don't write full scripts for people here (for free).

 

 

I dont want the script to be rewritten, i want it working...

 

whats on lines 135-140 of calculator .php?

 

 

Lines, 135-140 is harder than i thought.

 

 

Here is all the code...

 

<?php
# All Calculator - calculate.php
# Orignally created on 28 December 2004 remade using RS Hiscores on 9 June 2005
# Created by Joseph Jeffery of DSIBaN Designs
//This page functions as every calculator
//set page headers
include ('diffhead.inc');

class score_table
{
var $page;	
var $parser;
var $scoretable;
function score_table ($page, $parser)
{
	$this->page = $page;
	$this->parser = $parser;
	$this->scoretable = array();
}
function load_table ()
{
	if (($page = $this->page->load_page()) === false)
	{
		return false;
	}
	if (($scores = $this->parser->parse_page($page)) === false)
	{
		return false;
	}
	$this->scoretable = $scores;
	$this->convert_int($this->page->get_int_list());
	return true;
}
function convert_int ($list)
{
	foreach ($list as $colum)
	{
		foreach ($this->scoretable[$colum] as $key => $value)
		{
			$this->scoretable[$colum][$key] = intval($value);
		}
	}
}
function get_row ($n)
{
	if ($n < 0 || $n >= count($this->scoretable[$this->page->get_name_colum()]))
	{
		return false;
	}		
	$array = array();
	foreach ($this->scoretable as $key => $value)
	{
		$array[$key] = $value[$n];
	}		
	return $array;
}
function search_row ($colum, $search)
{
	if (!isset($this->scoretable[$colum]))
	{
		return false;
	}		
	$search = str_replace(' ', '_', $search);
	foreach($this->scoretable[$colum] as $key => $value)
	{
		if (strcasecmp(str_replace(' ', '_', $value), $search) == 0)
		{
			return $this->get_row($key);
		}
	}
	return false;
}
function get_names ()
{
	return array_values($this->scoretable[$this->page->get_name_colum()]);
}
function get_size ()
{
	return count($this->scoretable[$this->page->get_name_colum()]);
}
function get_colums ()
{
	return array_keys($this->scoretable);
}

}

class hiscore_page
{
var $url;
function hiscore_page ($url)
{
	$this->url = $url;
}
function load_page ()
{
	if (($page = file_get_contents($this->url)) === false)
	{
		return false;
	}

	return $page;
}
function get_name_colum ()
{
	return 'Name';
}
function get_int_list ()
{
	return array('Rank', 'Level', 'XP');
}

}

class personal_page extends hiscore_page
{
function personal_page ($name)
{
	parent::hiscore_page('http://hiscore.runescape.com/hiscorepersonal.ws?user1=' .

		strtolower(str_replace(' ', '_', $name)));
}

function get_name_colum ()
{
	return 'Skill';
}

}

class personal_parser
{
function parse_page ($page)
{		
	if (!preg_match('/<table><tr><td.*><b>Skill.*<\/table>/Us', $page, $table))
	{
		if (!preg_match('/the user .* does not currently appear in the hiscores/i', $page))
		{
			trigger_error('Unable to parse as RuneScape hiscore page', E_USER_WARNING);
		}
		return false;
	}
	$table = preg_replace('/<td>(<img .* \/>| )<\/td>|<a .*>|<\/a>/Us', '', $table[0]);
	preg_match('/<tr>(.*)<\/tr>/Us', $table, $match);		
	$colums = array();
	$skills = array();
	while (preg_match('/<td .*><b>(.*)<\/b><\/td>/Us', $match[1], $search))
	{	$colums[] = $search[1];
		$skills[$search[1]] = array();
		$match[1] = str_replace($search[0], '', $match[1]);		
	}
	$table = str_replace($match[0], '', $table);
	$table = preg_replace('/[^a-zA-Z0-9<>\/]/', '', $table);		
	$row = 0;
	while (preg_match('/<tr>(.*)<\/tr>/Us', $table, $skill))
	{
		$col = 0;
		while (preg_match('/<td.*>(.*)<\/td>/Us', $skill[1], $search))
		{
			$skills[$colums[$col++]][$row] = $search[1];
			$skill[1] = substr_replace($skill[1], '', strpos($skill[1], $search[0]), strlen($search[0]));
		}
		$table = substr_replace($table, '', strpos($table, $skill[0]), strlen($skill[0]));
		$row += 1;
	}		
	return $skills;	
}	
}

function enter_name(){
$skill = $_GET['skill'];
$mem = $_GET['members'];
echo '<form action="'.$_SERVER['PHP_SELF'].'?action=calculator&skill='.$skill.'&members='.$mem.'" method="post">
<p>Runescape name:  <input type="text" name="rsname" class="text" value="" /></p>
<input type="submit" class="text" value="Grab XP" onMouseOver="this.style.cursor=\'hand\';"/>
</form><br />
';

}


function calculator(){
$rsname = $_POST['rsname'];

$scorepage = new score_table(new personal_page($rsname), new personal_parser());

if ($scorepage->load_table() === false)
{	
	$skill = $_GET['skill'];
	$message = '<br /><table width=98% bgcolor=#faf5f4 class=logfail align=center><tr>
							<td width=40><img src=images/exclamation.gif></td>
							<td align=left>
							<B>Nothing found</B> <BR>
							Sorry but we couldn\'t find you in the hiscores. If you aren\'t in the hiscores just use the form below to do it manually
							<BR />
							</table>';		
	$xp = "0";
	$levl ="0";
}else{
	$skill = $_GET['skill'];

	if (($row = $scorepage->search_row('Skill', $skill)) === false)
	{
		$check = "1";
		$xp = "0";
		$levl ="0";
		$message = '<br /><table width=98% bgcolor=#faf5f4 class=logfail align=center><tr>
							<td width=40><img src=images/exclamation.gif></td>
							<td align=left>
							<B>Nothing found</B> <BR>
							Sorry but we couldn\'t find you in the hiscores for '.$skill.'. If you aren\'t in the hiscores for '.$skill.' just use the form below to do it manually
							<BR />
							</table>';
	}else{
		$levl = $row['Level'];
		$xp = $row['XP'];
	}
}
$skill2 = ucwords($skill);
$mem = $_GET['members'];
echo '<font face=verdana size=2 color=#3FC7C9><b>'.$skill2.'</b></font><br />'.$message.'<br />'; ?>
<br />
<form action="<?php echo $_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=level&members='.$mem.'&showmembers=0'; ?>" method="post">
	<table border="0" class="calcinput">
	<tr><td>Current Xp:</td><td> <input type="text" name="cxp" class="text" value="<?php if ($xp != "0") { echo $xp; } ?>" /></td></tr> 
	<tr><td>Current Level:</td><td><input type="text" class="text" value="<?php if ($levl != "0") { echo $levl; } ?>" <?php if($xp != "0") {echo 'disabled="true" name="lev" /><input type="hidden" name="lev" value="'.$levl.'"'; }else{ echo 'name="lev"';} ?> /></td></tr> 
	<tr><td>Desired Level:</td><td> <SELECT name="lvl" class="text"><OPTION value=0 selected>--------------------------</OPTION><OPTION value=0 >Level 1 - 0 xp</OPTION> <OPTION value=83>Level 2 - 83 xp</OPTION> <OPTION value=174>Level 3 - 174 xp</OPTION> <OPTION value=276>Level 4 - 276 xp</OPTION> <OPTION value=388>Level 5 - 388 xp</OPTION> <OPTION value=512>Level 6 - 512 xp</OPTION> <OPTION value=650>Level 7 - 650 xp</OPTION> <OPTION value=801>Level 8 - 801 xp</OPTION> <OPTION value=969>Level 9 - 969 xp</OPTION> <OPTION value=1154>Level 10 - 1,154 xp</OPTION> <OPTION value=1358>Level 11 - 1,358 xp</OPTION> <OPTION value=1584>Level 12 - 1,584 xp</OPTION> <OPTION value=1833>Level 13 - 1,833 xp</OPTION> <OPTION value=2107>Level 14 - 2,107 xp</OPTION> <OPTION value=2411>Level 15 - 2,411 xp</OPTION> <OPTION value=2746>Level 16 - 2,746 xp</OPTION> <OPTION value=3115>Level 17 - 3,115 xp</OPTION> <OPTION value=3523>Level 18 - 3,523 xp</OPTION> <OPTION value=3973>Level 19 - 3,973 xp</OPTION> <OPTION value=4470>Level 20 - 4,470 xp</OPTION> <OPTION value=5018>Level 21 - 5,018 xp</OPTION> <OPTION value=5624>Level 22 - 5,624 xp</OPTION> <OPTION value=6291>Level 23 - 6,291 xp</OPTION> <OPTION value=7028>Level 24 - 7,028 xp</OPTION> <OPTION value=7842>Level 25 - 7,842 xp</OPTION> <OPTION value=8740>Level 26 - 8,740 xp</OPTION> <OPTION value=9730>Level 27 - 9,730 xp</OPTION> <OPTION value=10824>Level 28 - 10,824 xp</OPTION> <OPTION value=12031>Level 29 - 12,031 xp</OPTION> <OPTION value=13364>Level 30 - 13,364 xp</OPTION> <OPTION value=14833>Level 31 - 14,833 xp</OPTION> <OPTION value=16456>Level 32 - 16,456 xp</OPTION> <OPTION value=18249>Level 33 - 18,249 xp</OPTION> <OPTION value=20224>Level 34 - 20,224 xp</OPTION> <OPTION value=22406>Level 35 - 22,406 xp</OPTION> <OPTION value=24815>Level 36 - 24,815 xp</OPTION> <OPTION value=27473>Level 37 - 27,473 xp</OPTION> <OPTION value=30408>Level 38 - 30,408 xp</OPTION> <OPTION value=33648>Level 39 - 33,648 xp</OPTION> <OPTION value=37224>Level 40 - 37,224 xp</OPTION> <OPTION value=41171>Level 41 - 41,171 xp</OPTION> <OPTION value=45529>Level 42 - 45,529 xp</OPTION> <OPTION value=50339>Level 43 - 50,339 xp</OPTION> <OPTION value=55649>Level 44 - 55,649 xp</OPTION> <OPTION value=61512>Level 45 - 61,512 xp</OPTION> <OPTION value=67983>Level 46 - 67,983 xp</OPTION> <OPTION value=75127>Level 47 - 75,127 xp</OPTION> <OPTION value=83014>Level 48 - 83,014 xp</OPTION> <OPTION value=91720>Level 49 - 91,720 xp</OPTION> <OPTION value=101333>Level 50 - 101,333 xp</OPTION> <OPTION value=111945>Level 51 - 111,945 xp</OPTION> <OPTION value=123660>Level 52 - 123,660 xp</OPTION> <OPTION value=136549>Level 53 - 136,549 xp</OPTION> <OPTION value=150872>Level 54 - 150,872 xp</OPTION> <OPTION value=166636>Level 55 - 166,636 xp</OPTION> <OPTION value=184040>Level 56 - 184,040 xp</OPTION> <OPTION value=203254>Level 57 - 203,254 xp</OPTION> <OPTION value=224466>Level 58 - 224,466 xp</OPTION> <OPTION value=247886>Level 59 - 247,886 xp</OPTION> <OPTION value=273742>Level 60 - 273,742 xp</OPTION> <OPTION value=302288>Level 61 - 302,288 xp</OPTION> <OPTION value=333804>Level 62 - 333,804 xp</OPTION> <OPTION value=368559>Level 63 - 368,559 xp</OPTION> <OPTION value=407015>Level 64 - 407,015 xp</OPTION> <OPTION value=449428>Level 65 - 449,428 xp</OPTION> <OPTION value=496254>Level 66 - 496,254 xp</OPTION> <OPTION value=547953>Level 67 - 547,953 xp</OPTION> <OPTION value=605032>Level 68 - 605,032 xp</OPTION> <OPTION value=668051>Level 69 - 668,051 xp</OPTION> <OPTION value=737627>Level 70 - 737,627 xp</OPTION> <OPTION value=814445>Level 71 - 814,445 xp</OPTION> <OPTION value=899257>Level 72 - 899,257 xp</OPTION> <OPTION value=992895>Level 73 - 992,895 xp</OPTION> <OPTION value=1096278>Level 74 - 109,6278 xp</OPTION> <OPTION value=1210421>Level 75 - 121,0421 xp</OPTION> <OPTION value=1336443>Level 76 - 133,6443 xp</OPTION> <OPTION value=1475581>Level 77 - 147,5581 xp</OPTION> <OPTION value=1629200>Level 78 - 1,629,200 xp</OPTION> <OPTION value=1798808>Level 79 - 1,798,808 xp</OPTION> <OPTION value=1986068>Level 80 - 1,986,068 xp</OPTION> <OPTION value=2192818>Level 81 - 2,192,818 xp</OPTION> <OPTION value=2421087>Level 82 - 2,421,087 xp</OPTION> <OPTION value=2673114>Level 83 - 2,673,114 xp</OPTION> <OPTION value=2951373>Level 84 - 2,951,373 xp</OPTION> <OPTION value=3258594>Level 85 - 3,258,594 xp</OPTION> <OPTION value=3597792>Level 86 - 3,597,792 xp</OPTION> <OPTION value=3972294>Level 87 - 3,972,294 xp</OPTION> <OPTION value=4385776>Level 88 - 4,385,776 xp</OPTION> <OPTION value=4842295>Level 89 - 4,842,295 xp</OPTION> <OPTION value=5346332>Level 90 - 5,346,332 xp</OPTION> <OPTION value=5902831>Level 91 - 5,902,831 xp</OPTION> <OPTION value=6517253>Level 92 - 6,517,253 xp</OPTION> <OPTION value=7195629>Level 93 - 7,195,629 xp</OPTION> <OPTION value=7944614>Level 94 - 7,944,614 xp</OPTION> <OPTION value=8771558>Level 95 - 8,771,558 xp</OPTION> <OPTION value=9684577>Level 96 - 9,684,577 xp</OPTION> <OPTION value=10692629>Level 97 - 10,692,629 xp</OPTION> <OPTION value=11805606>Level 98 - 11,805,606 xp</OPTION> <OPTION value=13034431>Level 99 - 13,034,431 xp</OPTION></SELECT></td></tr> 
	<?php
		if ($mem == "yes"){
		echo '<tr><td>Show members items?:</td><td> <input name="showmembers" type="checkbox" disabled="true" value="yes" checked></td></tr> ';
		}else{
		echo '<tr><td>Hide members items?:</td><td> <input name="showmembers" type="checkbox" value="no"></td></tr> ';
		}		
	?>		
	<tr><td><input type="submit" class="text" value="Calculate" onMouseOver="this.style.cursor='hand';"/></td><td>
	<input type="reset" class="text" value="Reset" onMouseOver="this.style.cursor='hand';"/></td></tr> 
	</table>
</form>
<?php 
}
function calculate(){
$lvl = $_POST['lvl'];
$cxp = $_POST['cxp']; 
$lev = $_POST['lev'];
$xpn = $lvl - $cxp;  
if ($xpn == ""){
	$xpn = $_GET['xpn'];
}
if ($lev == ""){
	$lev = $_GET['lev'];
}
$show = $_GET['showmembers'];
if ($show == "0"){
$show = $_POST['showmembers'];
}
switch($_GET['skill']) {

	case 'firemaking':
		$skill = "fire";
		$item = "Log";
		break;
	case 'runecrafting':
		$skill = "rune";
		$item = "Rune";
		break;
	case 'ranging':
		$skill = "range";
		$item = "Monster";
		break;
	case 'herblore':
		$skill = "herb";
		$item = "Herb/Potion";
		break;
	case 'fishing':
		$skill = "fish";
		$item = "Fish";
		break;
	case 'cooking':
		$skill = "cook";
		$item = "Food";
		break;
   case 'woodcutting':
		$skill = "wood";
		$item = "Log";
		break;
	case 'agility':
		$skill = "agility";
		$item = "Course";
		break;
	case 'slayer':
		$skill = "slayer";
		$item = "monster";
		break;
	case 'farming':
		$skill = "farming";
		$item = "Seed/Action";
		break;
	case 'fletching':
		$skill = "fletching";
		$item = "Item";
		break;
	case 'magic':
		$skill = "magic";
		$item = "Spell";
		break;
	case 'mining':
		$skill = "mining";
		$item = "Ore";
		break;
	case 'smithing':
		$skill = "smithing";
		$item = "Bar";
		break;
	case 'thieving':
		$skill = "thieving";
		$item = "Chest/Stall/Pickpocket";
		break;
	case 'fighting':
		$skill = "fighting";
		$item = "Monster";
		break;
	case 'crafting':
		$skill = "crafting";
		$item = "Item";
		break;
	case 'prayer':
		$skill = "prayer";
		$item = "Bones";
		break;	
	default:
	   $skill = $_GET['skill'];
	   $item = "Item";
}
$mem = $_GET['members'];	
echo'
	<table>
	<tr><td class="calc"><font class="small"><a href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=level&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Level needed</a></td><td class="calc"><font class="small"><a href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=item&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">'.$item.'</a></td><td class="calc"><font class="small"><a href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=xp&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Experience given</a></td><td class="calc"><font class="small"><a href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=xp&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Number of times</a></td><td class="calc"><font class="small"><a href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=members&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Members?</a></td>';		
	require_once ('../mysql_connect.php');//connect to db		
	$by = $_GET['orderby'];
	if ($mem == "no"){
	if ($show == "no"){
	$mess = '<a href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=level&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers=no">Click here to show members items</a>';
	$n_query = 'SELECT * FROM `'.$skill.'calc` WHERE `members`="0" ORDER BY `'.$by.'` ASC';
	}else{
	$mess = '<a href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=level&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers=yes">Click here to hide members items</a>';
	$n_query = 'SELECT * FROM `'.$skill.'calc` ORDER BY `'.$by.'` ASC';
	}		
	}else{
	$n_query = 'SELECT * FROM `'.$skill.'calc` ORDER BY `'.$by.'` ASC';
	}
	 	$n_result = mysql_query ($n_query);
		while ($n_row = mysql_fetch_assoc($n_result)) {
		$level = $n_row['level'];  
		$course = $n_row['item'];
		$xpg = $n_row['xp'];

		$tot1 = $xpn / $xpg;
		$tot = sprintf('%.0f', $tot1);
		$members1 = $n_row['members'];
		if ($members1 == "1"){
		$members = "Yes";
		$bg2 = "#000029";
		}else{
		$members = "No";
		$bg2 = "#000000";
		}
		if ($lev < $level){
		$bg = "#990000";
		}else{
		$bg = "#006600";
		}		
	echo '<tr><td class="calc" bgcolor="'.$bg.'"onMouseOver="this.style.backgroundColor=\'#71828A\'" onMouseOut=this.style.backgroundColor="'.$bg.'"><font class="small2">'.$level.'</td><td class="calc" onMouseOver="this.style.backgroundColor=\'#71828A\'" onMouseOut=this.style.backgroundColor="#000000"><font class="small2">'.$course.'</td><td class="calc" onMouseOver="this.style.backgroundColor=\'#71828A\'" onMouseOut=this.style.backgroundColor="#000000"><font class="small2">'.$xpg.'</td><td class="calc" onMouseOver="this.style.backgroundColor=\'#71828A\'" onMouseOut=this.style.backgroundColor="#000000"><font class="small2">'.$tot.'</td><td class="calc" bgcolor="'.$bg2.'" onMouseOver="this.style.backgroundColor=\'#71828A\'" onMouseOut=this.style.backgroundColor="'.$bg2.'"><font class="small2">'.$members.'</td>';
	}
	echo'
	</table><br />
	';
}
switch($_GET['action']) {

    case 'calculate':
        calculate();
        break;
    case 'calculator':
        calculator();
        break;
   case 'enter_name':
        enter_name();
        break;
    default:
       enter_name();
}
include ('difffooter.inc');
?>

 

 

 

Here is the part that I think is the problem...

 

{
	return array('Rank', 'Level', 'XP');
}

}

class personal_page extends hiscore_page
{
function personal_page ($name)
{
	parent::hiscore_page('http://hiscore.runescape.com/hiscorepersonal.ws?user1=' .

		strtolower(str_replace(' ', '_', $name)));
}

function get_name_colum ()

 

 

The URL is old, it should not work. http://hiscore.runescape.com/hiscorepersonal.ws?user1=

 

This should be the New URL http://hiscore.runescape.com/index_lite.ws?player=

 

I hope that helps...

Link to comment
Share on other sites

Its not that i dont want to learn, i cant learn... (never been good with php)

 

I got books, on php...

 

I just want the script fixed, yes, but I am willing to do this. I just have no idea what i need to do... Its like, a completely different language.

 

So, what do i need to learn to get the script fixed?

Link to comment
Share on other sites

I mean, what part of php, do i need to learn to get this working.

 

I know this seems like im a lame guy, who cant be bothered to learn php. Well, its not i cant be bothered, its just i have alot on my plate now.

 

Dose anyone know where i can find someone who would be willing to do this for free? (to build up his portfolio)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.