$map = imagecreatefrompng("images/maps/".$serv['server_map'].".png");
imagecopyresized($img, $map, 38, 84, 0, 0, 16, 12, 32, 24);
Если изображения не загружено в папку, то ни чего не показывает.
Како поставить заглушку, допустим если он не нашел изображение, автоматом выдавал допустим noimages.png
?
Спустя 1 минута, 50 секунд (28.09.2011 - 18:57) Winston написал(а):
Вот так можно
if(file_exists("images/maps/".$serv['server_map'].".png"))
{
$map = imagecreatefrompng("images/maps/".$serv['server_map'].".png");
imagecopyresized($img, $map, 38, 84, 0, 0, 16, 12, 32, 24);
}
else
echo "<img src='noimage.png' />";
Спустя 5 минут, 22 секунды (28.09.2011 - 19:02) 715kg написал(а):
Спасибо, но не работает.
Спустя 6 минут, 33 секунды (28.09.2011 - 19:09) walerus написал(а):
Цитата (715kg @ 28.09.2011 - 16:02) |
Спасибо, но не работает. |
Что значит не работает? Нотис выдается или что ?, работать должно.
Спустя 1 час, 20 минут, 40 секунд (28.09.2011 - 20:30) 715kg написал(а):
Картинка с инфой просто не открывается. Вот весь код как я сделал
<?php
require_once "maincore.php";
$id=$_GET['id'];
$q = dbquery("SELECT * FROM ".DB_SERVERS." WHERE server_id = ".$id."");
$serv=dbarray_fetch($q);
$status="Ofline";
if($serv['server_status']==1)$status="Online";
if(isset($_GET['bigbanner']))
{
header ("Content-type: image/png");
$img = imagecreatefrompng('images/banners/monitor2.png');
$server_full=floor(($serv['server_players'] / $serv['server_maxplayers']) * 100);
$data=htmlcolor($img,"CC9900");
$z=htmlcolor($img,"339900");
$ip=htmlcolor($img,"FFCC33");
$text_color=htmlcolor($img,"F68E56");
$green=htmlcolor($img,"00FF00");
//imagestring($img, 4, 5, 4, "Name:", $z);
if(file_exists("images/maps/".$serv['server_map'].".png"))
{
$map = imagecreatefrompng("images/maps/".$serv['server_map'].".png");
imagecopyresized($img, $map, 60, 150, 0, 0, 16, 12, 32, 24);
}
else
echo "<img src='/images/maps/default.png' />";
imagestring($img, 2, 2, 90, $serv['server_name'], $data);
//imagestring($img, 4, 10, 57, "IP:", $z);
imagestring($img, 20, 420, 10, $status, $green);
imagestring($img, 2, 40, 60, $serv['server_ip'], $data);
//imagestring($img, 3, 220, 50, "Map", $z);
imagestring($img, 2, 220, 60, $serv['server_map'], $data);
//imagestring($img, 3, 350, 47, "Players", $z);
imagestring($img, 2, 360, 60, $serv['server_players']."/".$serv['server_maxplayers'], $data);
imagestring($img, 2, 400, 70, "Server Full ".$server_full. "%", $data);
imagepng($img);
imagedestroy($img);
}
//функция для русского текста
function iso2uni ($isoline)
{
$isoline = convert_cyr_string($isoline, "w", "k");
$isoline = convert_cyr_string($isoline, "k", "i");
for ($i=0; $i < strlen($isoline); $i++)
{
$thischar=substr($isoline,$i,1);
$charcode=ord($thischar);
$uniline.=($charcode>175) ? "&#".(1040+($charcode-176)). ";" : $thischar;
}
return $uniline;
}
function unicode($str)
{
$cyrillic = array("А","Б","В","Г","Д","Е","Ж","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ъ","Ы","Ь","Э","Ю","Я","а","б","в","г","д","е","ж","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч","ш","щ","ъ","ы","ь","э","ю","я","Ё","ё");
$unicode = array("А","Б","В","Г","Д","Е","Ж","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ъ","Ы","Ь","Э","Ю","Я","а","б","в","г","д","е","ж","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч","ш","щ","ъ","ы","ь","э","ю","я","Ё","ё");
return str_replace($cyrillic, $unicode, $str);
}
?>