Location: PHPKode > scripts > ezStats for Medal of Honor > classes.php
<?php
	/* SQL-Klasse */
	class ezSQL {
		private $debug;
		public $connected = false;
		
		protected function get_global_config($mode="all") {
			global $ezstats;
			
			if ($mode == "all") {
				return $ezstats;
			} elseif ($mode == "prefix") {
				return $ezstats['prefix'];
			}
		}
		
		protected function serialize_data($data) {
			/* Serialisiert Arrays für das Speichern in SQL-Db */
			if(is_array($data)) {
				$data = serialize($data);
				
				if(function_exists("mysql_real_escape_string")) {
					$data = mysql_real_escape_string($data);
				}
				else {
					$data = addslashes($data);
				}
				
				return $data;
			}
			else {
				return $data;
			}
		}
		
		public function __construct($mode="default") {
			$data = $this->get_global_config();
			$this->debug = $data['debug'];
			
			if ($mode == "default") {
				mysql_pconnect($data['host'], $data['user'], $data['pwd']) or die('ERROR: Can not connect to MySQL-Server');
				mysql_select_db($data['db']) or die('ERROR: Can not connect to database "'.$data['db'].'"');
			} elseif ($mode == "install") {
				if (@mysql_connect($data['host'], $data['user'], $data['pwd']) AND @mysql_select_db($data['db'])) {
					$result = $this->safe_query('SHOW TABLES');
					while ($row = mysql_fetch_array($result)){
						if ($row[0] == $data['prefix'].'settings') $this->connected = true;
					}
					
				}
			}
		}
		
		public function safe_query($query="") {
			if (stristr(str_replace(' ', '', $query), "unionselect")=== FALSE AND stristr(str_replace(' ', '', $query), "union(select")=== FALSE){
				if(empty($query)) return false;
				if($this->debug) {
					$result = mysql_query($query) or die('Query failed: '
					.'<br />errorno='.mysql_errno()
					.'<br />error='.mysql_error()
					.'<br />query='.$query);
				} else {
					$result = mysql_query($query) or die('Query failed!');
				}
				return $result;
			}
			else die('Query not executed');
		}
		
		public function reset_connection() {
			$data = $this->get_global_config();
			
			if ($data['cmsdb'] != "") {
				mysql_select_db($data['cmsdb']) or die('ERROR: Can not connect to database "'.$data['cmsdb'].'"');
			}
		}
	}
	
	
	/* CMS-Setting-Klasse */
	class ezCMS extends ezSQL {
		private $settings = Array(
			'011_standalone'	=> Array('headline'),
			'021_forum' 		=> Array('relpath'),
			'022_forum_smf'		=> Array('headline', 'relpath', 'curl'),
			'031_joomla15' 		=> Array('relpath'),
			'032_joomla15x' 	=> Array('relpath'),
			'033_joomla16x' 	=> Array('relpath'),
			'041_webspell40' 	=> Array('headline', 'relpath', 'cmsdb'),
			'042_webspell42' 	=> Array('headline', 'relpath', 'cmsdb'),
			'051_dzcp15x'		=> Array('headline', 'relpath', 'curl'),
			'052_dzcp153'		=> Array('headline', 'relpath', 'curl'),
			'061_phpnuke80'		=> Array('headline', 'relpath', 'curl'),
			'071_e107_07'		=> Array('headline', 'relpath', 'curl'),
			'081_ilch11'		=> Array('headline', 'relpath'),
			'091_wordpress29'	=> Array('relpath', 'curl'),
			'100_phpkit161'		=> Array('headline', 'relpath', 'curl'),
			'101_phpkit16'		=> Array('headline', 'relpath', 'curl'),
			'111_csphere2009'	=> Array('headline', 'relpath', 'curl'),
			'121_phpfusion7'	=> Array('headline', 'relpath', 'curl'),
			'131_ecp30'			=> Array('headline', 'relpath', 'curl'),
			'991_default_ajax' 	=> Array('relpath'),
			'992_default_curl'	=> Array('relpath', 'curl')
		);
		
		public function safe_cms_data($post) {
			$prefix = $this->get_global_config("prefix");
			$cms = $post['cms'];
			
			$datafields = $this->settings[$cms];
			$data = Array();
			
			foreach ($datafields as $datafield) {
				if (isset($post[$datafield])) {
					$data[$datafield] = $post[$datafield];
				}
			}
			$data = $this->serialize_data($data);
			
			$query = 'SELECT Data FROM '.$prefix.'cmsdata WHERE CMS = "'.$cms.'"';
			$result = $this->safe_query($query);
			
			if (mysql_num_rows($result)) {
				$query = 'UPDATE '.$prefix.'cmsdata SET Data = "'.$data.'" WHERE CMS = "'.$cms.'"';
			} else {
				$query = 'INSERT INTO '.$prefix.'cmsdata (CMS, Data) VALUES ("'.$cms.'", "'.$data.'")';
			}
			$this->safe_query($query);
		}
		
		public function load_cms_data($cms) {
			$prefix = $this->get_global_config("prefix");
			$datafields = $this->settings[$cms];
			
			$query = 'SELECT Data FROM '.$prefix.'cmsdata WHERE CMS = "'.$cms.'"';
			$result = $this->safe_query($query);
			
			$data = Array();
			
			if (mysql_num_rows($result)) {
				$row = mysql_fetch_assoc($result);
				$serialized_data = $row['Data'];
				$unserialized_data = unserialize($serialized_data);
			} else $unserialized_data = Array();
			
			foreach ($datafields as $datafield) {
				if (isset($unserialized_data[$datafield])) {
					$data[$datafield] = $unserialized_data[$datafield];
				} else {
					$data[$datafield] = "";
				}
			}
			
			return $data;
		}
	}
	
	
	/* Sprachmodul */
	class ezLocalization {
		public $data = array();
		public $language;
		private $default = "deutsch";
		private $folder = "language";
		private $templatefolder = "templates";
		
		public function __construct($data) {
			$this->language = $data['language'];
			$this->folder = $data['path'].$this->folder;
			$this->templatefolder = $data['path'].$this->templatefolder;
		}
		
		public function get_data($module, $add=false) {
			$module = str_replace(array('\\','/','.'), '', $module);
			
			if (file_exists($this->folder.'/'.$this->language.'/'.$module.'.php'))  {
				$file = $this->folder.'/'.$this->language.'/'.$module.'.php';
			}
			elseif (file_exists($this->folder.'/'.$this->default.'/'.$module.'.php'))  {
				$file = $this->folder.'/'.$this->default.'/'.$module.'.php';
			}
			elseif (file_exists('../'.$this->folder.'/'.$this->language.'/'.$module.'.php'))  {
				$file = '../'.$this->folder.'/'.$this->language.'/'.$module.'.php';
			}
			elseif (file_exists('../'.$this->folder.'/'.$this->default.'/'.$module.'.php'))  {
				$file = '../'.$this->folder.'/'.$this->default.'/'.$module.'.php';
			}
			else {
				return false;
			}
			
			
			if(isset($file)) {
				include $file;
				if(!$add) $this->data = array();
				
				foreach($language_array as $key => $val) {
					$this->data[$key] = $val;
				}
			}
			return true;
		}
		
		private function replace_wildcards($template) {
			foreach($this->data as $key => $val) {
				$template = str_replace('%'.$key.'%', $val, $template);
			}
			return $template;
		}
		
		public function get_template($template, $ext="html", $folder=false) {
			if ($folder) {
				$this->templatefolder = $folder;
			}

			return str_replace("\"", "\\\"", $this->replace_wildcards(file_get_contents($this->templatefolder."/".$template.".".$ext)));
		}
	}
	
	
	/* Sicherheits-Klasse */
	class ezSecure {
		public function __construct($prefix) {
			$this -> check_data($prefix);
			$this -> security_slashes($_GET);
			$this -> security_slashes($_POST);
			$this -> security_slashes($_COOKIE);
			/* $this -> unregister_globals(); */
		}
		
		private function check_data($prefix) {
			$request = strtolower(urldecode($_SERVER['QUERY_STRING']));
			$protarray = array("union","drop","select","into","where","update ","from","/*","set ",$prefix."user ",$prefix."user(",$prefix."user`",$prefix."user_groups","phpinfo","escapeshellarg","exec","fopen","fwrite","escapeshellcmd","passthru","proc_close","proc_get_status","proc_nice","proc_open","proc_terminate","shell_exec","system","telnet","ssh","cmd","mv","chmod","chdir","locate","killall","passwd","kill","script","bash","perl","mysql","~root",".history","~nobody","getenv");
			$check = str_replace($protarray, '*', $request);
			if ($request != $check) die("ERROR: Invalid request detected");
		}
		
		private function security_slashes(&$array) {
			foreach($array as $key => $value) {
				if(is_array($array[$key])) {
					$this -> security_slashes($array[$key]);
				}
				else {
					if(get_magic_quotes_gpc()) {
						$tmp = stripslashes($value);
					}
					else {
						$tmp = $value;
					}
					if(function_exists("mysql_real_escape_string")) {
						$array[$key] = mysql_real_escape_string($tmp);
					}
					else {
						$array[$key] = addslashes($tmp);
					}
					unset($tmp);
				}
			}
		}
		
		private function unregister_globals() {
			if(ini_get("register_globals") == "1") {
				$superglobals=array("_GET", "_POST", "_REQUEST", "_ENV", "_FILES", "_SESSION", "_COOKIES", "_SERVER");
				foreach($GLOBALS as $key => $value) {
					if(!in_array($key, $superglobals) && $key != "GLOBALS") {
						unset($GLOBALS[$key]);
					}
				}
				return true;
			}
			else {
				return true;
			}
		}      
	}
	
	
	/* Daten-Klasse */
	class ezData extends ezSQL {
		/* DATEN-WIEDERGABE */
		
		/* Ermittelt die Spieler-ID anhand des Spielernamens */
		public function get_player_id($name) {
			$prefix = $this->get_global_config("prefix");
			
			$query = 'SELECT ID FROM '.$prefix.'players WHERE name = "'.$name.'"';
			
			if (mysql_num_rows($this->safe_query($query))) {
				$result = mysql_fetch_assoc($this->safe_query($query));
				$id = $result['ID'];
				return $id;
			} else {
				return false;
			}
		}
		
		/* Ermittelt den Spielernamen anhand der Spieler-ID */
		public function get_player_name($id) {
			$prefix = $this->get_global_config("prefix");
			
			$query = 'SELECT name FROM '.$prefix.'players WHERE ID = "'.$id.'"';
			
			if (mysql_num_rows($this->safe_query($query))) {
				$result = mysql_fetch_assoc($this->safe_query($query));
				$name = $result['name'];
				return $name;
			} else {
				return false;
			}
		}
		
		/* Erstellt Array mit allen Spielernamen oder -IDs, wahlweise nur die mit vorhandenen Statsdaten */
		public function get_all_players($mode="all", $column="ID", $limit=9999, $sort="ASC") {
			$array = Array();
			$config = $this->get_global_config();
			
			$query = 'SELECT * FROM '.$config['prefix'].'players ORDER BY lastupdate '.$sort.' LIMIT 0, '.$limit;
			$result = $this->safe_query($query);
				
			while ($row = mysql_fetch_assoc($result)) {
				if ($row['name'] != $config['guest_dummy']) {
					if ($mode == "all") {
						$array[] = $row[$column];
					}
					else {
						$sql = 'SELECT time FROM '.$config['prefix'].'stats_default WHERE ID = "'.$row['ID'].'"';
						$check = mysql_fetch_assoc($this->safe_query($sql));
						
						if ($check['time']) {
							$array[] = $row[$column];
						}
					}
				}
			}
			return $array;
		}
		
		/* Gibt die gewünschten Statsdaten eines Spielers zurück */
		public function get_stats($id, $table) {
			$prefix = $this->get_global_config("prefix");
			
			if (!is_numeric($id)) {
				$query = 'SELECT ID FROM '.$prefix.'players WHERE name = "'.$id.'"';
				$result = mysql_fetch_assoc($this->safe_query($query));
				$id = $result['ID'];
			}
			
			$query = 'SELECT * FROM '.$prefix.'stats_'.$table.' WHERE ID = "'.$id.'"';
			$result = mysql_fetch_assoc($this->safe_query($query));
			
			/* In DB gespeicherte Array Deserialisieren */
			if (is_array($result)) {
				foreach ($result as $key => $value) {
					if (@unserialize($value)) {
						$result[$key] = unserialize($value);
					}
				}
			}
			
			return $result;
		}
		
		
		/* DATEN-AUFNAHME */
		
		/* Erstellt Array mit allen Spaltennamen einer Tabelle */
		public function show_columns_of_table($table) {
			$query = 'SHOW COLUMNS FROM '.$table;
			$result = $this->safe_query($query);
			
			$array = Array();
			while ($row = mysql_fetch_assoc($result)) {
				if ($row['Field'] != "ID") $array[] = $row['Field'];
			}
			return $array;
		}
		
		
		/* Laden der Stats-Daten von der API */
		public function load_from_api($names, $fields="general,rankings") {
			$config = $this->get_global_config();
			$url = 'http://api.mohstats.com/api/'.$config['system'];
			
			$ch = curl_init($url);
			if (is_array($names))  {
				$names_encoded = Array();
				foreach ($names as $name) {
					$names_encoded[] = urlencode($name); 
				}
				$names = implode(",", $names_encoded); 
			} else $names = urlencode($names);
			
			
			$postdata = 'players='.$names.'&fields='.$fields;
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
			$stats = curl_exec($ch);
			curl_close($ch);
			
			$stats = json_decode($stats, true);
			return $stats;
		}
		
		
		/* Security Slashes */
		private function security_slashes($value) {
			if (!is_array($value)) {
				if(function_exists("mysql_real_escape_string")) {
					$result = mysql_real_escape_string($value);
				}
				else {
					$result = addslashes($value);
				}
				return $result;
			} else return $value;
		}
		
		
		/* Schreibt die Statsdaten in die DB */
		private function write_stats_to_db($name, $stats, $type="default") {
			$config = $this->get_global_config();
			if ($type == "guest") {
				$id = $this->get_player_id($config['guest_dummy']);
			} else {
				$id = $this->get_player_id($name);
			}
			
			$columns = Array();
			$columns['stats_default'] = $this->show_columns_of_table($config['prefix'].'stats_default');
			$columns['stats_rankings'] = $this->show_columns_of_table($config['prefix'].'stats_rankings');
			
			foreach ($columns as $table => $array) {
				$query = 'REPLACE INTO '.$config['prefix'].$table.' (ID) VALUES ("'.$id.'")';
				$this->safe_query($query);
				
				foreach ($array as $desc) {
					if ($table == "stats_default") {
						$statsdata = $stats[$desc];
						$statsdata = $this->security_slashes($statsdata);
						if ($desc == "server") $statsdata = $this->serialize_data($statsdata);
					} else {
						$key = substr($table, 6);
						$statsdata = $stats[$key][$desc];
						$statsdata = $this->serialize_data($statsdata);
					}
					
					$query = 'UPDATE '.$config['prefix'].$table.' SET '.$desc.' = "'.$statsdata.'" WHERE ID = "'.$id.'"';
					$this->safe_query($query);
				}
			}
		}
		
		
		/* Schreibt Timestamp in die DB, wenn Spieler aktualisiert wurde */
		private function write_timestamp($name) {
			$prefix = $this->get_global_config("prefix");
			$query = 'UPDATE '.$prefix.'players SET lastupdate = "'.$_SERVER['REQUEST_TIME'].'" WHERE name = "'.$name.'"';
			$this->safe_query($query);
		}
		
		
		/* Update Stats-Daten (einzelner Spieler) */
		public function update_player($name, $type="default") {
			$stats = $this->load_from_api($name);
			
			if ($stats['found'] != 0) {
				$this->write_stats_to_db($name, $stats['players'][0], $type);
				$this->write_timestamp($name);
				return true;
			} else {
				return false;
			}
		}
		
		
		/* Update Stats-Daten (Spieler-Liste) */
		public function update_playerlist($array) {
			$stats = $this->load_from_api($array);
			$result = Array();
			
			if (isset($stats['players']) AND is_array($stats['players'])) {
				foreach ($stats['players'] as $player) {
					$this->write_stats_to_db($player['name'], $player);
					$this->write_timestamp($player['name']);
					$result[$player['name']] = true;
				}
			}
			
			if (isset($stats['players_unknown']) AND is_array($stats['players_unknown'])) {
				foreach ($stats['players_unknown'] as $player) {
					$this->write_timestamp($player['name']);
					$result[$player['name']] = false;
				}
			}
			
			if (isset($stats['players_nodata']) AND is_array($stats['players_nodata'])) {
				foreach ($stats['players_nodata'] as $player) {
					$this->write_timestamp($player['name']);
					$result[$player['name']] = false;
				}
			}
			return $result;
		}
	}
	
	
	/* Signaturen-Klasse */
	class ezImage extends ezSQL {
		private $image;
		public $settings = Array();
		
		
		public function __construct($settings) {
			$this->settings = $settings;
			$this->settings['global_settings'] = $this->get_global_config();
		}
		
		public function load_signature_settings() {
			$prefix = $this->settings['global_settings']['prefix'];
			$type = $this->settings['type'];
			
			$query = 'SELECT * FROM '.$prefix.'signatures WHERE signature_type = "'.$type.'"';
			$result = $this->safe_query($query);
			
			if (mysql_num_rows($result)) {
				$data = mysql_fetch_assoc($result);
				
				$query = 'SHOW COLUMNS FROM '.$prefix.'signatures';
				$result = $this->safe_query($query);
				$columns = Array();
				while ($row = mysql_fetch_assoc($result)) {
					$columns[] = $row['Field'];
				}
				
				foreach ($columns as $column) {
					$this->settings[$column] = $data[$column];
				}
			} else {
				$default = $this->settings['global_settings']['signatures'][$type];
				$query = '
					INSERT INTO '.$prefix.'signatures (
						signature_type,
						signature_width,
						signature_height,
						signature_pattern_filename,
						font_filename,
						font_size,
						background_alpha_start,
						background_alpha_end,
						background_offset
					) VALUES (
						"'.$default['signature_type'].'",
						"'.$default['signature_width'].'",
						"'.$default['signature_height'].'",
						"'.$default['signature_pattern_filename'].'",
						"'.$default['font_filename'].'",
						"'.$default['font_size'].'",
						"'.$default['background_alpha_start'].'",
						"'.$default['background_alpha_end'].'",
						"'.$default['background_offset'].'"
					)
				';
				$this->safe_query($query);
				$this->load_signature_settings();
			}
		}
		
		private function check_rgb_color($string) {
			$array = explode(",", $string);
			for ($i = 0; $i < 3; $i++) {
				if (isset($array[$i]) AND is_numeric($array[$i])) {
					if ($array[$i] >= 0 OR $array[$i] <= 127) {
						/* do nothing */
					} else {
						$array[$i] = 0;
					}
				} else {
					$array[$i] = 0;
				}
			}
			return $array;
		}
		
		
		private function create_background($width, $height, $path) {
			/* Variablen */
			$src = $path.$this->settings['signature_pattern_folder'].$this->settings['signature_pattern_filename'];
			$bg_color = $this->check_rgb_color($this->settings['background_color']);
			$alpha_start = $this->settings['background_alpha_start'];
			$alpha_end = $this->settings['background_alpha_end'];
			$offset = $this->settings['background_offset'];
			
			/* Erstellen des Bildes */
			$this->image = imagecreatetruecolor($width, $height);
			$pattern = imagecreatefrompng($src);
			imagecopyresampled($this->image, $pattern, 0, 0, 0, 0, $width, $height, $width, $height);
			
			/* Hintergrund-Verlauf erstellen */
			$alpha_step = ($alpha_end - $alpha_start) / ($width - $offset);
			for ($i = 0; $i < ($width - $offset); $i++) {
				$color = imagecolorallocatealpha($this->image, trim($bg_color[0]), trim($bg_color[1]), trim($bg_color[2]), ($i*$alpha_step)+$alpha_start);
				imageline($this->image, $i, 0, $i, $height, $color);
			}
		}
		
		private function create_rankicon($path, $type) {
			$rank = str_pad($this->settings['stats']['default']['rank'], 3, "0", STR_PAD_LEFT);
			$src = $path.$this->settings['rankicon_folder']."r".$rank.".png";
			
			if ($type == "max") {
				$width = 90;
				$x = 20;
				$y = 10;
			}
			
			if ($type == "med") {
				$width = 60;
				$x = 15;
				$y = 10;
			}
			
			if ($type == "min") {
				$width = 30;
				$x = 10;
				$y = 5;
			}
			
			$icon = imagecreatefrompng($src);
			imagecopyresampled($this->image, $icon, $x, $y, 0, 0, $width, $width, 128, 128);
		}
		
		private function create_text($path, $type) {
			/* Variablen */
			$font_file = $path.$this->settings['font_folder'].$this->settings['font_filename'];
			$size = $this->settings['font_size'];
			$color = $this->check_rgb_color($this->settings['font_color']);
			$stats = $this->settings['stats'];
			
			/* Farben anweisen */
			$font_color = imagecolorallocate($this->image, trim($color[0]), trim($color[1]), trim($color[2]));
			
			/* Erstellen des Textes */
			if ($type == "max") {
				$size1 = $size;
				$size2 = round($size * 1.5);
				$size3 = $size2 + 10;
				$size4 = $size3 + 25;
				$size5 = $size + 6;
				
				/* Name & Rang */
				$rankname = $this->settings['global_settings']["ranknames"][$stats['default']['rank']];
				$pos = imagefttext($this->image, $size2, 0, 130, ($size3), $font_color, $font_file, $stats['default']['name']);
				$pos = imagefttext($this->image, $size1, 0, ($pos[2] + 10), ($size3), $font_color, $font_file, $rankname);
				$x = 130;
				
				/* Label 1 */
				$pos = imagefttext($this->image, $size1, 0, $x, ($size4), $font_color, $font_file, "Score:");
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, "Kills:");
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, "Deaths:");
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, "Dogtags:");
				$x += 60;
				
				/* Werte 1 */
				$pos = imagefttext($this->image, $size1, 0, $x, ($size4), $font_color, $font_file, $stats['default']['score']);
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, $stats['default']['kills']);
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, $stats['default']['deaths']);
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, $stats['dogtags']['dogt_total']);
				$x += 90;
				
				/* Label 2 */
				$pos = imagefttext($this->image, $size1, 0, $x, ($size4), $font_color, $font_file, "SPM:");
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, "KPM:");
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, "KDR:");
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, "Time:");
				$x += 40;
				
				/* Werte 2 */
				$value = $stats['default']['time'];
				$time = Array(); $time['day'] = floor($value / 86400); $time['std'] = round(($value - $time['day']*86400) / 3600); 
				$time_string = sprintf('%dd %sh', $time['day'], str_pad($time['std'], 2, "0", STR_PAD_LEFT));
				
				$pos = imagefttext($this->image, $size1, 0, $x, ($size4), $font_color, $font_file, number_format(($stats['default']['score'] / ($stats['default']['time'] / 60)), 0, ".", " "));
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, number_format(($stats['default']['kills'] / ($stats['default']['time'] / 60)), 2, ".", " "));
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, number_format(($stats['default']['kills'] / $stats['default']['deaths']), 2, ".", " "));
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, $time_string);
			}
			
			if ($type == "med") {
				$size1 = $size;
				$size2 = round($size * 1.5);
				$size3 = $size2 + 10;
				$size4 = $size3 + 20;
				$size5 = $size + 6;
				
				/* Name & Rang */
				$rankname = $this->settings['global_settings']["ranknames"][$stats['default']['rank']];
				$pos = imagefttext($this->image, $size2, 0, 90, ($size3), $font_color, $font_file, $stats['default']['name']);
				$pos = imagefttext($this->image, $size1, 0, ($pos[2] + 10), ($size3), $font_color, $font_file, $rankname);
				$x = 90;
				
				/* Label 1 */
				$pos = imagefttext($this->image, $size1, 0, $x, ($size4), $font_color, $font_file, "Score:");
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, "Kills:");
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, "Dogtags:");
				$x += 55;
				
				/* Werte 1 */
				$pos = imagefttext($this->image, $size1, 0, $x, ($size4), $font_color, $font_file, $stats['default']['score']);
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, $stats['default']['kills']);
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, $stats['dogtags']['dogt_total']);
				$x += 70;
				
				/* Label 2 */
				$pos = imagefttext($this->image, $size1, 0, $x, ($size4), $font_color, $font_file, "SPM:");
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, "KPM:");
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, "KDR:");
				$x += 30;
				
				/* Werte 2 */
				$pos = imagefttext($this->image, $size1, 0, $x, ($size4), $font_color, $font_file, number_format(($stats['default']['score'] / ($stats['default']['time'] / 60)), 0, ".", " "));
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, number_format(($stats['default']['kills'] / ($stats['default']['time'] / 60)), 2, ".", " "));
				$pos = imagefttext($this->image, $size1, 0, $x, ($pos[1] + $size5), $font_color, $font_file, number_format(($stats['default']['kills'] / $stats['default']['deaths']), 2, ".", " "));
			}
			
			if ($type == "min") {
				$size1 = $size;
				$size2 = round($size * 1.4);
				$size3 = $size2 + 7;
				$size4 = $size3 + 15;
				
				/* Name & Rang */
				$rankname = $this->settings['global_settings']["ranknames"][$stats['default']['rank']];
				$pos = imagefttext($this->image, $size2, 0, 50, ($size3), $font_color, $font_file, $stats['default']['name']);
				$pos = imagefttext($this->image, $size1, 0, ($pos[2] + 10), ($size3), $font_color, $font_file, $rankname);
				$x = 50;
				
				/* Werte 1 */
				$pos = imagefttext($this->image, $size1, 0, $x, $size4, $font_color, $font_file, "SPM:");
				$pos = imagefttext($this->image, $size1, 0, $pos[2] + 5, $size4, $font_color, $font_file, number_format(($stats['default']['score'] / ($stats['default']['time'] / 60)), 0, ".", " "));
				$pos = imagefttext($this->image, $size1, 0, $pos[2] + 10, $size4, $font_color, $font_file, "KPM:");
				$pos = imagefttext($this->image, $size1, 0, $pos[2] + 5, $size4, $font_color, $font_file, number_format(($stats['default']['kills'] / ($stats['default']['time'] / 60)), 2, ".", " "));
				$pos = imagefttext($this->image, $size1, 0, $pos[2] + 10, $size4, $font_color, $font_file, "KDR:");
				$pos = imagefttext($this->image, $size1, 0, $pos[2] + 5, $size4, $font_color, $font_file, number_format(($stats['default']['kills'] / $stats['default']['deaths']), 2, ".", " "));
				
				
				
			}
		}
		
		private function create_picture($path, $type) {
			/* Variablen */
			$player = $this->settings['stats']['default']['ID'];
			$filename = $player."_".$type.".png";
			$filename = $this->settings['signature_folder'].$filename;
			$relpath = $this->settings['global_settings']['relpath'];
			
			/* Erstellen des Bildes */
			imagepng($this->image, $path.$filename);
			imagedestroy($this->image);
			return $relpath.$filename;
		}
		
		
		public function create_signature() {
			/* Variablen */
			$this->load_signature_settings();
			$type = $this->settings['signature_type'];
			$path = $this->settings['global_settings']['path'];
			$width = $this->settings['signature_width'];
			$height = $this->settings['signature_height'];
			
			$this->create_background($width, $height, $path);
			$this->create_rankicon($path, $type);
			$this->create_text($path, $type);
			
			return $this->create_picture($path, $type);
		}
	}
?>
Return current item: ezStats for Medal of Honor