Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so dont bother with any of their useless mail servers here and just use oauth login instead. Thank the nice Russians for causing that. :)
Paste
Pasted by Kerrrr ( 16 years ago )
<?php
/*
Hej NeonMaster, ansvarsfullt av en webbhost att kolla innehållet i användares phpfiler.
Eftersom att du undrar är masterservern dpmaster.deathmask.net, iofs skulle du ha sett det om du kollar lite längre ned i filen.
*/
ini_set('display_errors',1);
error_reporting(E_ALL);
$font = 'fonts/Cantarell.ttf';
$fonts = array(1 => 'fonts/Cantarell.ttf', # cantarell
2 => 'fonts/Cantarell-Bold.ttf', # Cantarell bold
3 => 'fonts/Cantarell-Oblique.ttf', # Cantarell oblique
4 => 'fonts/PT_Sans.ttf', # PT Sans
5 => 'fonts/PT_Sans_Narrow.ttf', # PT Sans Narrow
6 => 'fonts/PT_Sans_Italic.ttf', # PT Sans Italic
7 => 'fonts/PT_Sans_Caption.ttf', # PT Sans Caption
8 => 'fonts/PT_Sans_Bold.ttf', # PT Sans Captio
9 => 'fonts/Sansation_Regular.ttf', # Sansation Regular
10 => 'fonts/Sansation_Light.ttf', # Sansation Light
11 => 'fonts/Sansation_Bold.ttf', # Sansation Bold
);
require_once 'xml2array.php';
# Check if ip is provided
if (!isset($_GET['s']) or empty($_GET['s'])) {
# If not, show doc.php
require_once 'doc.php';
# END
}
# If we have a server...
else {
# ... create a variable for the ip.
$server = $_GET['s'];
# And check if we have a port aswell
if (!isset($_GET['p']) or empty($_GET['p'])) {
# If not, assign 26000
$port = "26000";
}
else {
# Else get the provided one
$port = $_GET['p'];
}
# Retrieve data
$data = simplexml_load_file("http://dpmaster.deathmask.net/?game=nexuiz&xml=1&nocolors=0&xmlcarets=1&server;=$server:$port");
#
if (isset($_GET['showplayers']) and !empty($_GET['showplayers'])) {
$showplayers = true;
}
else
{
$showplayers = false;
}
if ($showplayers)
{
# Create the image instance
$im = imagecreatetruecolor(300, 95 + 15 * sizeof($data->server->players->player));
}
else
{
$im = imagecreatetruecolor(300, 95);
}
# Saveeee alphaaaaa
imagesavealpha($im, true);
# Check if there is any background parameter
if (isset($_GET['bg']) and !empty($_GET['bg'])) {
# IF it is, split the value into an array
$bg = explode(',',$_GET['bg'],3);
# Create an color out of the RGB value recieved
$bg = imagecolorallocate($im, $bg[0], $bg[1], $bg[2]);
# And write the background
imagefilledrectangle($im, 0, 0, 300, 95, $bg);
}
# If there's no background, make it transparent
else {
$trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $trans_colour);
}
# Check if we have a font id provided and if its a number
if (isset($_GET['font']) and !empty($_GET['font']) and is_numeric($_GET['font']))
{
# If there is a font id, check i the font really exists
if (array_key_exists($_GET['font'],$fonts)) {
# if it does, set the font to the value
$font = $fonts[$_GET['font']];
} # no need for else since $font is present from before
}# no need for else since $font is present from before
# Time for the font colors.
# Check if we have a main font color
if (isset($_GET['fc']) and !empty($_GET['fc'])) {
$fc = explode(',',$_GET['fc'],3);
}
# if not, set it to black
else {
$fc = array(0,0,0);
}
# Create the main font color variable
$maintext = imagecolorallocate($im, $fc[0], $fc[1], $fc[2]); # main Font color
if (isset($_GET['namec']) and !empty($_GET['namec'])) {
# Explode the rgb value
$namec = explode(',',$_GET['namec'],3);
# Make a color var
$namec = imagecolorallocate($im, $namec[0], $namec[1], $namec[2]); # main Font color
}
else {
# if not specified, use the same as $maintext
$namec = $maintext;
}
if (isset($_GET['hostc']) and !empty($_GET['hostc'])) {
# Explode the rgb value
$hostc = explode(',',$_GET['hostc'],3);
$hostc = imagecolorallocate($im, $hostc[0], $hostc[1], $hostc[2]); # main Font color
}
else {
$hostc = $maintext;
}
if (isset($_GET['playerc']) and !empty($_GET['playerc'])) {
# Explode the rgb value
$playerc = explode(',',$_GET['playerc'],3);
$playerc = imagecolorallocate($im, $playerc[0], $playerc[1], $playerc[2]); # main Font color
}
else {
$playerc = $maintext;
}
if (isset($_GET['mapc']) and !empty($_GET['mapc'])) {
# Explode the rgb value
$mapc = explode(',',$_GET['mapc'],3);
$mapc = imagecolorallocate($im, $mapc[0], $mapc[1], $mapc[2]); # main Font color
}
else {
$mapc = $maintext;
}
if (isset($_GET['typec']) and !empty($_GET['typec'])) {
# Explode the rgb value
$typec = explode(',',$_GET['typec'],3);
$typec = imagecolorallocate($im, $typec[0], $typec[1], $typec[2]); # main Font color
}
else {
$typec = $maintext;
}
# All colors done
# If there is an error, outputs the error
if (isset($data->server->error))
{
imagefttext($im, 10, 0, 10, 20, $text, $font, "Server is offline or does not exist.nDetails: ".$data->server->error); # server name
}
# All went fine, output data
else
{
imagefttext($im, 10, 0, 10, 20, $namec, $font, $data->server->name); # server name
imagefttext($im, 9, 0, 10, 40, $hostc, $font, "Hostname: ".$data->server->hostname); # server hostname
imagefttext($im, 9, 0, 10, 55, $playerc, $font, "Players: ".$data->server->numplayers." / ".$data->server->maxplayers); # server players
imagefttext($im, 9, 0, 10, 70, $mapc, $font, "Current map: ".$data->server->map); # server map
$qcstats = explode(':',$data->server->rules->rule[5]);
imagefttext($im, 9, 0, 10, 85, $typec, $font, "Gametype: ".$qcstats[0]); # server gametype
if ($showplayers)
{
$nextpos = 100;
for($i = 0; $i < sizeof($data->server->players->player); ++$i)
{
$name = $data->server->players->player[$i]->name;
$name = ereg_replace("^[0-9]", "", $name);
$name = ereg_replace("^x..", "", $name);
$score = $data->server->players->player[$i]->score;
imagefttext($im, 9, 0, 10, $nextpos, $typec, $font, $name." score: ".$score);
$nextpos = $nextpos + 15;
}
}
}
// Output image to the browser
header('Content-Type: image/png');
header("Expires: Mon, 01 Jul 2003 00:00:00 GMT"); // Past date
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Consitnuously modified
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // NO CACHE
imagepng($im);
imagedestroy($im);
}
?>
Revise this Paste