duanduan8439 2013-06-13 06:28
浏览 40

PHP GD图像显示本地主机但不在服务器上

I've always worked localhost on MAMP (PHP Version 5.4.10). I uploaded the EXACT same file onto a server I purchased running LAMP (PHP Version 5.4.15-1~lucid+1). I opened the file localhost and the image loaded fine and correct. I uploaded the exact files onto the server and I get the broken image image. My code:

    <?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once('query.class.php');
$Server = new MinecraftServerStatus($IP = '69.65.42.155', $Port = 30465, $Timeout = 1);

 header('content-type: image/png');

$image = imagecreatefrompng('http://192.34.58.24/cfgd/images/o_image1.png');

$dark_grey = imagecolorallocate($image, 102, 102, 102);
$white = imagecolorallocate($image, 255, 255, 255);
$red = imagecolorallocate($image, 255, 0, 0);
$green = imagecolorallocate($image, 0, 255, 0);

$font_path = 'Brixton';

$title = 'Knightsrp';
if($Port != 25565){
    $dip = $IP.':'.$Port;
}
else{
    $dip = $IP;
}

if($Server->Get('online')){
    $status = 'Online';
    $players = $Server->Get('numplayers').' / '.$Server->Get('maxplayers');
}
else{
    $status = 'Offline';
}

imagettftext($image, 30, 0, 10, 35, $white, $font_path, $title);
if($status == 'Online'){imagettftext($image, 20, 0, 5, 87, $green, $font_path, $status);}else{imagettftext($image, 20, 0, 5, 87, $red, $font_path, $status);}
if($status == 'Online'){imagettftext($image, 20, 0, 550, 87, $white, $font_path, $players);}
imagettftext($image, 20, 0, 350, 20, $white, $font_path, $dip);

imagepng($image);

imagedestroy($image);
?>

You can find the php class I use here: https://github.com/NoxNebula/Minecraft-Server-Status

  • 写回答

1条回答 默认 最新

  • douang4294 2013-06-13 21:53
    关注

    I added

    putenv('GDFONTPATH=' . realpath('.'));
    

    Before

    imagettftext($image, 30, 0, 10, 35, $white, $font_path, $title);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来