【发布时间】:2011-07-31 23:43:23
【问题描述】:
我曾经使用脚本通过更新表单来更改图像上的文本。
当我在预先安装了所有模块的共享主机上时,它一开始工作得很好。
我搬到了一个 vps,我必须自己安装所有东西,现在脚本不再工作了。
php页面可以显示,但是当我更新时,文本不像以前那样显示了。
以下是共享主机上仍然有效的页面示例: http://nyanpuffle.com/auntarctic/密码是1234
以下是 vps 上无法正常工作的页面示例: http://www.clubpenguincheatsy.com/cptrackers/auntarctic/密码是1234
这里是使用的编码的副本:
<TITLE>Tracker</TITLE>
<body bgcolor="#4b7bb2">
<font face="arial">
<center>
<?php
$submit = $_POST['submit']; // Gets If It has been Submitted
if($submit){ // If submitted do this.
$password = $_POST['password']; // Get the password they submitted
$status = $_POST['status']; // Get the status they submitted
$server = $_POST['server']; // Get the server they submitted
$room = $_POST['room']; // Get the room they submitted
//Now We Secure it.
if($password == "1234"){
//Now We Generate the image and stuff.
$im = imagecreatefrompng("in.png");
// Make RGB Colour For Writing
$colour = imagecolorallocate($im, 255, 255, 255); // I want mine in red(This is black). So I am just
//Gonna find out the rgb code
$font = 'BurbankBigRegular-Bold.ttf'; //
//This ^ Is our font, It has to be the exact name and in the right folder.
//Draw Text
imagettftext($im, 20, 0, 100, 68, $colour, $font, $status);
imagettftext($im, 20, 0, 95, 95, $colour, $font, $server);
imagettftext($im, 20, 0, 85, 127, $colour, $font, $room);
//Create Image
imagepng($im,'out.png');
// Destroy - Save Server Resources
imagedestroy($im);
echo "<b> Updated! </b>";
}else
{
echo "<p><b>Incorrect Password!</b></p>";
}
}
//This form remebers what they put, so they dont have to keep typing it in.
// $_SERVER['PHP_SELF'] Means Get this document to submit to.
// If you know html this will be familiar.
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" />
<p>Password: <input type="password" name="password" id="password" value="<?php echo $_POST['password']; ?>"/></p>
<p>Status: <select name="status"> <option value="">Select...</option>
<option value="Online"> Online</option>
<option value="Offline"> Offline</option>
<option value="Tracking..."> Tracking</option>
</select>
</p>
<p>Server: <input type="text" id="server" name="server" value="<?php echo $_POST['server']; ?>"/></p>
<p>Room: <input type="text" id="room" name="room" value="<?php echo $_POST['room']; ?>"/></p>
<p><input type="submit" id="submit" name="submit"/></p>
</form>
<p>Tracker:</p>
<p><img src="out.png" alt="Tracker" /></P>
<a href="http://ClubPenguincheatsy.com/cptrackers"s>Back to Tracker Dashbaord</a>
</center>
VPS 在 Ubuntu 上运行,我安装了 PHP、MYSQL 和 Apache。
【问题讨论】:
-
能否在调用 out.php 时尝试缓存保护机制?切换到 "/> 后,你能更新一下事情的表现吗?
-
我把显示的img源改成上面的代码,还是没有显示文字。
-
主要问题是文本不再出现在新主机上
-
能不能调整代码直接渲染PNG,去掉周围的HTML(别忘了把header content-type扔到最上面)?关键是要确保没有发生奇怪的 PHP 错误。
-
这很奇怪,因为确切的编码工作在共享主机上(由 fatcow 托管)但是当我尝试在 VPS 上使用它时,文本没有更新。
标签: php image text dynamic tracker