• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Small PHP editing needed.

Lucenzo

The Way You Move :)
Joined
Jan 29, 2011
Messages
363
Reaction score
14
Location
UK
Heya, I'm on a good start with my first project, which is kind of hard to edit alot of things on my own without basic knowlegde over PHP.


So i got a small favour to ask, editing Highscore page for Gesior Acc Maker.

What exactly is needed to be done is this,

http://www13.speedy*****malware.localhost/files/26722491/download/highscore.png

highscore png

To proper nice looking, like this one.

http://www13.speedy*****malware.localhost/files/26722532/download/high2.png

high2 png


And here is the file to be edited.

highscores php

Thanks in Advance.
 
Code:
<?PHP
$list = $_REQUEST['list'];
$page = $_REQUEST['page'];
if(!is_numeric($page)) $page = 0;
else $page = max(0, min(5, $page));

switch($list)
{
	case 'fist':
		$id = 0;
		$name = 'Fist Fighting';
		break;
	case 'club':
		$id = 1;
		$name = 'Club Fighting';
		break;
	case 'sword':
		$id = 2;
		$name = 'Sword Fighting';
		break;
	case 'axe':
		$id = 3;
		$name = 'Axe Fighting';
		break;
	case 'distance':
		$id = 4;
		$name = 'Distance Fighting';
		break;
	case 'shield':
		$id = 5;
		$name = 'Shielding';
		break;
	case 'fishing':
		$id = 6;
		$name = 'Fishing';
		break;
	case 'magic':
		$name = 'Magic Level';
		break;
	default:
		$name = 'Level';
		$list = 'experience';
		break;
}

$f = 'highscores-'.$list.'-'.$page.'.tmp';
if(file_exists($f) && filemtime($f) > (time() - 180))
	$main_content .= file_get_contents($f);
else {
$offset = $page * 50;
if(isset($id))
	$skills = $SQL->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.group_id < 4 AND players.id = player_skills.player_id AND player_skills.skillid = '.$id.' ORDER BY value DESC, count DESC LIMIT 50 OFFSET '.$offset);
elseif($list == "magic")
	$skills = $SQL->query('SELECT name,online,maglevel,level,vocation,promotion FROM players WHERE players.group_id < 4 ORDER BY maglevel DESC, manaspent DESC LIMIT 50 OFFSET '.$offset);
elseif($list == "experience")
	$skills = $SQL->query('SELECT name,online,level,experience,vocation,promotion FROM players WHERE players.group_id < 4 ORDER BY level DESC, experience DESC LIMIT 50 OFFSET '.$offset);

$main_content .= '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>&nbsp;</td><td><center><h2>Ranking for '.$name.' on '.$config['server']['serverName'].'</h2></center><br/>';
$main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%"><tr><td width="100%" align="right" valign="top">';
if($page > 0)
$links .= '<a href="?subtopic=highscores&amp;list='.$list.'">Top</a> | <a href="?subtopic=highscores&amp;list='.$list.($page != 1 ? '&amp;page='.($page-1) : '').'">Rank '.(($page-1)*50+1).'-'.(($page)*50).'</a>';
if($page < 5)
$links .= ($page==0 ? '' : ' | ').'<a href="?subtopic=highscores&amp;list='.$list.'&amp;page='.($page+1).'">Rank '.(($page+1)*50+1).'-'.(($page+2)*50).'</a></td>';
$main_content .= $links.'</tr></table>';
	$main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td width="3%" class="white"><b>Rank</b></td><td width="75%" class="white"><b>Name</b></td><td width="15%" class="white"><b>Level</b></td>';
if($list == 'experience')
	$main_content .= '<td class="white"><b>Points</b></td>';
$main_content .= '</tr>';
foreach($skills as $skill) {
	if($list == 'magic')
		$skill['value'] = $skill['maglevel'];
	elseif($list == 'experience')
		$skill['value'] = $skill['level'];
	$i++;
	$main_content .= '<tr bgcolor="'.$config['site'][(is_int($i / 2)) ? 'lightborder' : 'darkborder'].'"><td>'.($offset + $i).'</td><td><a href="?subtopic=characters&amp;name='.urlencode($skill['name']).'">'.($skill['online']>0 ? '<font color="green">'.$skill['name'].'</font>' : '<font color="red">'.$skill['name'].'</font>').'</a><br/><small>'.$skill['level'].' '.$vocation_name[0][$skill['promotion']][$skill['vocation']].'</small></td><td>'.$skill['value'].'</td>';
	if($list == 'experience')
		$main_content .= '<td>'.$skill['experience'].'</td>';
	$main_content .= '</tr>';
}
$main_content .= '</table><table border="0" cellpadding="4" cellspacing="1" width="100%"><tr><td align="right" valign="top">'.$links.'</tr></table></td><td width="3%">&nbsp;</td><td width="100" valign="top" align="right"><table style="border:1px solid grey;width:135px" bgcolor="'.$config['site']['lightborder'].'" cellpadding="4" cellspacing="1"><tr bgcolor="'.$config['site']['darkborder'].'"><td><span style="font-size:10px;color:#625536">&raquo; Highscore Type</span></td></tr><tr bgcolor="'.$config['site']['lightborder'].'"><td>';

$i=0;
foreach(array('experience'=>'Level','magic'=>'Magic Level','fist'=>'Fist','club'=>'Club','sword'=>'Sword','axe'=>'Axe','distance'=>'Distance','shield'=>'Shielding','fishing'=>'Fishing') as $k => $v) {
	$i++;
	$main_content .= '<span style="font-size:10px;color:#625536">'.$i.'.</span> <a href="?subtopic=highscores&amp;list='.$k.'"><span  style="text-decoration:underline;font-weight:100;color:#493421;font-size:10px">'.$v.'</span></a><br/>';
}
$main_content .= '</td></tr></table></td><td>&nbsp;</td></tr></table>';
file_put_contents($f, $main_content);
}
?>
If you want underline to disappear when hovering the links, you have to edit your basic.css; or use this script (which has longer output):
Code:
<?PHP
$list = $_REQUEST['list'];
$page = $_REQUEST['page'];
if(!is_numeric($page)) $page = 0;
else $page = max(0, min(5, $page));

switch($list)
{
	case 'fist':
		$id = 0;
		$name = 'Fist Fighting';
		break;
	case 'club':
		$id = 1;
		$name = 'Club Fighting';
		break;
	case 'sword':
		$id = 2;
		$name = 'Sword Fighting';
		break;
	case 'axe':
		$id = 3;
		$name = 'Axe Fighting';
		break;
	case 'distance':
		$id = 4;
		$name = 'Distance Fighting';
		break;
	case 'shield':
		$id = 5;
		$name = 'Shielding';
		break;
	case 'fishing':
		$id = 6;
		$name = 'Fishing';
		break;
	case 'magic':
		$name = 'Magic Level';
		break;
	default:
		$name = 'Level';
		$list = 'experience';
		break;
}

$f = 'highscores-'.$list.'-'.$page.'.tmp';
if(file_exists($f) && filemtime($f) > (time() - 180))
	$main_content .= file_get_contents($f);
else {
$offset = $page * 50;
if(isset($id))
	$skills = $SQL->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.group_id < 4 AND players.id = player_skills.player_id AND player_skills.skillid = '.$id.' ORDER BY value DESC, count DESC LIMIT 50 OFFSET '.$offset);
elseif($list == "magic")
	$skills = $SQL->query('SELECT name,online,maglevel,level,vocation,promotion FROM players WHERE players.group_id < 4 ORDER BY maglevel DESC, manaspent DESC LIMIT 50 OFFSET '.$offset);
elseif($list == "experience")
	$skills = $SQL->query('SELECT name,online,level,experience,vocation,promotion FROM players WHERE players.group_id < 4 ORDER BY level DESC, experience DESC LIMIT 50 OFFSET '.$offset);

$main_content .= '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>&nbsp;</td><td><center><h2>Ranking for '.$name.' on '.$config['server']['serverName'].'</h2></center><br/>';
$main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%"><tr><td width="100%" align="right" valign="top">';
if($page > 0)
$links .= '<a href="?subtopic=highscores&amp;list='.$list.'">Top</a> | <a href="?subtopic=highscores&amp;list='.$list.($page != 1 ? '&amp;page='.($page-1) : '').'">Rank '.(($page-1)*50+1).'-'.(($page)*50).'</a>';
if($page < 5)
$links .= ($page==0 ? '' : ' | ').'<a href="?subtopic=highscores&amp;list='.$list.'&amp;page='.($page+1).'">Rank '.(($page+1)*50+1).'-'.(($page+2)*50).'</a></td>';
$main_content .= $links.'</tr></table>';
	$main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td width="3%" class="white"><b>Rank</b></td><td width="75%" class="white"><b>Name</b></td><td width="15%" class="white"><b>Level</b></td>';
if($list == 'experience')
	$main_content .= '<td class="white"><b>Points</b></td>';
$main_content .= '</tr>';
foreach($skills as $skill) {
	if($list == 'magic')
		$skill['value'] = $skill['maglevel'];
	elseif($list == 'experience')
		$skill['value'] = $skill['level'];
	$i++;
	$main_content .= '<tr bgcolor="'.$config['site'][(is_int($i / 2)) ? 'lightborder' : 'darkborder'].'"><td>'.($offset + $i).'</td><td><a href="?subtopic=characters&amp;name='.urlencode($skill['name']).'">'.($skill['online']>0 ? '<font color="green">'.$skill['name'].'</font>' : '<font color="red">'.$skill['name'].'</font>').'</a><br/><small>'.$skill['level'].' '.$vocation_name[0][$skill['promotion']][$skill['vocation']].'</small></td><td>'.$skill['value'].'</td>';
	if($list == 'experience')
		$main_content .= '<td>'.$skill['experience'].'</td>';
	$main_content .= '</tr>';
}
$main_content .= '</table><table border="0" cellpadding="4" cellspacing="1" width="100%"><tr><td align="right" valign="top">'.$links.'</tr></table></td><td width="3%">&nbsp;</td><td width="100" valign="top" align="right"><table style="border:1px solid grey;width:135px" bgcolor="'.$config['site']['lightborder'].'" cellpadding="4" cellspacing="1"><tr bgcolor="'.$config['site']['darkborder'].'"><td><span style="font-size:10px;color:#625536">&raquo; Highscore Type</span></td></tr><tr bgcolor="'.$config['site']['lightborder'].'"><td>';

$i=0;
foreach(array('experience'=>'Level','magic'=>'Magic Level','fist'=>'Fist','club'=>'Club','sword'=>'Sword','axe'=>'Axe','distance'=>'Distance','shield'=>'Shielding','fishing'=>'Fishing') as $k => $v) {
	$i++;
	$main_content .= '<span style="font-size:10px;color:#625536">'.$i.'.</span> <a style="{text-decoration:underline;font-weight:100;color:#493421;font-size:10px};" onmouseover="this.style.textDecoration = \'none\'" onmouseout="this.style.textDecoration = \'underline\'" href="?subtopic=highscores&amp;list='.$k.'">'.$v.'</a><br/>';
}
$main_content .= '</td></tr></table></td><td>&nbsp;</td></tr></table>';
file_put_contents($f, $main_content);
}
?>
 
Last edited:
It might work, but that doesn't mean it's made the optimal way.
No, it's just my perfectionism that's killing me.
 
Back
Top