Ist zwar schon komplett oben, aber bitte:
PHP
<?php
$mysqlhost = "localhost"; // Host des MySQL-Servers - Host of you MySQL-Server
$mysqluser = "buh"; // Benutzername des MySQL-Servers - Loginname for the MySQL-Server
$mysqlpasswd = "muh"; // Passwort des MySQL-Servers - Password for the MySQL-Server
$mysqldbname = "mamstats"; // Datenbank des MySQL-Servers - Database of the MySQL-Server
$ip = "192.168.1.4";
$port = "28960"; // Port deines Gameservers - You gameserver's port
$timeout = "0.5"; // Maximale Verbindungzeit zum Gameserver in Sekunden - Maximum connection time to the gameserver
$bildname = "Signatur.png"; // Hintergrund-Bild - Background-Image
$font_file = "./bankgthd.ttf"; // Sonstige Schriftart - Other font
$font_file2 = "./Battlev2bi.ttf"; // Überschrift (Nick) Schriftart - headline (nickname) font
/*
Don't Change something after these lines except you know what you are doing!
Ändere ab hier nichts mehr außer du weißt was du machst!
*/
mysql_connect($mysqlhost, $mysqluser, $mysqlpasswd);
mysql_select_db($mysqldbname);
header("Content-type: image/png");
$userid = addslashes($_GET["user"]);
$hm = mysql_query("SELECT user FROM mam01_nicks WHERE nick = '".$userid."'");
$ha = mysql_fetch_array($hm);
$as = mysql_query("SELECT * FROM mam01_user WHERE id = '".$ha["user"]."'");
$user = mysql_fetch_array($as);
function textstroke($img,$text,$posx,$posy,$textcolor,$font,$size,$strokecolor,$angle,$dick,$d3,$dicks)
{
for($i=0;$i<$dicks;$i++)
{
imagettftext($img, $size, $angle, $posx + $dick, $posy+$i, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx - $dick, $posy+$i, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx, $posy + $dick+$i, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx, $posy - $dick+$i, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx + $dick, $posy - $dick+$i, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx + $dick, $posy + $dick+$i, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx - $dick, $posy - $dick+$i, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx - $dick, $posy + $dick+$i, $strokecolor, $font,$text);
}
imagettftext($img, $size, $angle, $posx + $dick, $posy, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx - $dick, $posy, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx, $posy + $dick, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx, $posy - $dick, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx + $dick, $posy - $dick, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx + $dick, $posy + $dick, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx - $dick, $posy - $dick, $strokecolor, $font,$text);
imagettftext($img, $size, $angle, $posx - $dick, $posy + $dick, $strokecolor, $font,$text);
for($i=0;$i<$dicks;$i++)
{
imagettftext($img, $size, $angle, $posx, $posy+$i, $d3, $font,$text);
}
imagettftext($img, $size, $angle, $posx, $posy, $textcolor, $font,$text);
}
$pic = ImageCreateFromPNG($bildname);
$weiss = ImageColorAllocate($pic, 255, 255, 255);
$black = ImageColorAllocate($pic, 50, 50, 50);
$gray = ImageColorAllocate($pic, 125, 125, 125);
$green = ImageColorAllocate($pic, 0, 255, 0);
$font_height = ImageFontHeight(10);
$font_width = ImageFontWidth(10);
$image_height = ImageSY($pic);
$image_width = ImageSX($pic);
$userid = addslashes($_GET["user"]);
$online = false;
$con = fsockopen("udp://$ip", $port, $errno, $errstr, 3);
if ($con)
{
fwrite($con, "\xFF\xFF\xFF\xFFgetstatus\x00");
stream_set_timeout($con, (int) $timeout, ($timeout - ((int) $timeout)) * 100000);
$start = microtime(true);
$s = "";
do {
$s .= substr(fread($con, 9999), 10);
$info = stream_get_meta_data($con);
if (!isset($end)) {
$end = microtime(true);
}
}
while(!$info["timed_out"]) ;
if (empty($s))
{
} else {
$ping = round(($end - $start) * 1000) . " ms";
list($dummy, $dvarslist, $playerlist) = explode("\n", $s, 3);
$playerlist = explode("\n", $playerlist);
array_pop($playerlist);
$players = array();
foreach ($playerlist as $value) {
list($score, $pingp, $name) = explode(" ", $value, 3);
$players[] = array(
"name" => htmlspecialchars(trimcolor(substr($name, 1, -1))),
"score" => $score,
"ping" => $pingp
);
}
$playerlist = "";
foreach ($players as $value) {
if(strtolower($value["name"]) == strtolower($userid))
{
$online = true;
$score = $value["score"];
}
}
}
}
function trimcolor($name) {
return preg_replace('|\^.|', '', $name);
}
if($online)
{
textstroke($pic,"ONLINE score:".$score,220,148,$green,$font_file2,10,$black,0,1,$gray,1);
}
textstroke($pic,$userid,3,21,$weiss,$font_file2,20,$black,0,1,$gray,5);
textstroke($pic,"Kills: ".$user["kills"],5,40,$weiss,$font_file,14,$black,0,1,$gray,3);
textstroke($pic,"Deaths: ".$user["deaths"],5,65,$weiss,$font_file,14,$black,0,1,$gray,3);
textstroke($pic,"Headshots: ".$user["headshots"],5,90,$weiss,$font_file,14,$black,0,1,$gray,3);
textstroke($pic,"Rate: ".round($user["kills"]/$user["deaths"],2),5,115,$weiss,$font_file,14,$black,0,1,$gray,3);
ImagePNG($pic);
ImageDestroy($pic)
?>
Alles anzeigen