Kullanımı;
PHP Kod:
echo mapresim("de_dust2");
PHP Fonksiyonu :
PHP Kod:
function mapresim($map){
//Map Resim Başlangıç
stream_context_set_default(
array(
'http' => array(
'method' => 'HEAD',
'header' => "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.79 Safari/537.1\r\n"
)
)
);
$banner = "http://image.gametracker.com/images/maps/160x120/cs/".strtolower($map).".jpg";
$banner = htmlentities($banner);
$banner = str_replace("​", "", $banner);
$banner = str_replace("\xE2\x80\x8C", "", $banner);
$mapyok = 'http://image.www.gametracker.com/images/maps/160x120/nomap.jpg';
$header_response = get_headers($banner, 1);
if(preg_match_all('/(404|Not|Found)/', $header_response[0])) {
$cikti = 'map resmi bulunamadi!';
}
else {
$cikti = $banner;
}
return $cikti;
}
test.php
Kod:
<?php
function mapresim($map){
//Map Resim Başlangıç
stream_context_set_default(
array(
'http' => array(
'method' => 'HEAD',
'header' => "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.79 Safari/537.1\r\n"
)
)
);
$banner = "http://image.gametracker.com/images/maps/160x120/cs/".strtolower($map).".jpg";
$banner = htmlentities($banner);
$banner = str_replace("&#8203;", "", $banner);
$banner = str_replace("\xE2\x80\x8C", "", $banner);
$mapyok = 'http://image.www.gametracker.com/images/maps/160x120/nomap.jpg';
$header_response = get_headers($banner, 1);
if(preg_match_all('/(404|Not|Found)/', $header_response[0])) {
$cikti = 'Map Resmi Bulunamadi';
}
else {
$cikti = $banner;
}
return $cikti;
}
?>
<img src="<?php echo mapresim("de_dust2");?>">