Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sun Jul 31, 2011 8:20 pm 
Offline
Junior Member

Joined: Sun Jul 31, 2011 5:03 pm
Posts: 49
Website: http://www.clubpenguincheatsy.com/
AOL: thefiame12
Location: GA
I used to use a script to change the text on an image via update form.

It worked perfectly at first while I was on a shared host with all modules pre-installed.

I moved to a vps where I had to install everything myself and now the script no longer works.

The php page is able to be displayed but when I update, the text does not show up like it used to.

Here is an example of the page on the shared host that still works: http://nyanpuffle.com/auntarctic/ Password is 1234

Here is an example of the page on the vps that does not work: http://www.clubpenguincheatsy.com/cptra ... untarctic/ Password is 1234

Here is a copy of the coding used:

Code:
<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>


The VPS is ran on Ubuntu and I have PHP,MYSQL, and Apache installed.


Top
   
 Post subject:
PostPosted: Sun Jul 31, 2011 11:57 pm 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
Make sure the GD and FreeType libraries are both installed. Most distributions have these in separate packages from the main PHP package. Be sure the font file you want to use is present.

Also, seems like the interpretation of the font file parameter has changed over time, so your script may need tweaking to account for this.


Top
   
 Post subject:
PostPosted: Mon Aug 01, 2011 1:39 am 
Offline
Junior Member

Joined: Sun Jul 31, 2011 5:03 pm
Posts: 49
Website: http://www.clubpenguincheatsy.com/
AOL: thefiame12
Location: GA
Everything is installed and enabled I believe.

Here is the new script:

Code:
<?php 
error_reporting(E_ALL); //Change to 0 when live
header("Cache-Control: no-cache, must-revalidate"); //remind the browser not to cache the image
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tracker</title>
</head>

<body bgcolor="#4b7bb2">
<font face="arial">
<center>
<?php
$password=''; //pre-set thos vars
$status='';
$server='';
$room='';

if(isset($_POST['submit'])){
    $password = $_POST['password'];
    if($password == "1234"){
        $status = $_POST['status'];
        $server = $_POST['server'];
        $room = $_POST['room'];

        $im = imagecreatefrompng("in.png");
        $colour = imagecolorallocate($im, 255, 255, 255);
        $font = 'BurbankBigRegular-Bold.ttf'; //

        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);
        imagepng($im,'out.png');
        imagedestroy($im);
        $result="<b> Updated! </b>";
    }else{
        $result="<p><b>Incorrect Password!</b></p>";
    }
}

echo (isset($result))?$result:'';
?>

<form action="" method="POST" />
<p>Password: <input type="password"  name="password" value="<?php echo htmlentities($password); ?>"/></p>

<p>Status: <select name="status">
<option value="">Select...</option>
<?php
echo "<option value=\"Online\""; if($status=='Online'){ echo" selected=\"selected\"";} echo"> Online</option>\n";
echo "<option value=\"Offline\""; if($status=='Offline'){ echo" selected=\"selected\"";} echo"> Offline</option>\n";
echo "<option value=\"Tracking...\""; if($status=='Tracking...'){ echo" selected=\"selected\"";} echo"> Tracking</option>\n";
?>
</select>
</p>

<p>Server: <input type="text" name="server" value="<?php echo htmlentities($server); ?>"/></p>
<p>Room: <input type="text" name="room" value="<?php echo htmlentities($room); ?>"/></p>
<p><input type="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>


Page: http://www.clubpenguincheatsy.com/cptra ... untarctic/
Pass is 1234

Text still doesn't update

Also, here is my PHP info:
http://www.clubpenguincheatsy.com/cptra ... c/test.php


Top
   
 Post subject:
PostPosted: Mon Aug 01, 2011 11:06 am 
Offline
Junior Member

Joined: Sun Jul 31, 2011 5:03 pm
Posts: 49
Website: http://www.clubpenguincheatsy.com/
AOL: thefiame12
Location: GA
When I load the script directly using:

Code:
<?php header('Content-Type: image/png'); $im = imagecreatefrompng(dirname(__FILE__)."/in.png"); $colour = imagecolorallocate($im, 255, 255, 255); $font = dirname(__FILE__).'/BurbankBigRegular-Bold.ttf'; imagettftext($im, 20, 0, 100, 68, $colour, $font, 'Testing'); imagepng($im); imagedestroy($im);


clubpenguincheatsy.com/cptrackers/auntarctic/testing.php

The text updates.

But when I use the other script in my previous post using the update forms, nothing happens.


Top
   
 Post subject:
PostPosted: Mon Aug 01, 2011 12:25 pm 
Offline
Senior Member

Joined: Sat Nov 27, 2010 8:21 pm
Posts: 63
Check permissions in out.png. It's probably not writable by your webserver.


Top
   
 Post subject:
PostPosted: Mon Aug 01, 2011 4:41 pm 
Offline
Junior Member

Joined: Sun Jul 31, 2011 5:03 pm
Posts: 49
Website: http://www.clubpenguincheatsy.com/
AOL: thefiame12
Location: GA
Well it wasn't writable, but setting the permissions to 777 didn't seem to help either.

EDIT:
Weird, after trying the permissions changes on another image. The text updated, but not the correct way. It removed the text that was already on the image but didn't replace it with the text I typed in the update form.


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 10:10 am 
Offline
Junior Member

Joined: Sun Jul 31, 2011 5:03 pm
Posts: 49
Website: http://www.clubpenguincheatsy.com/
AOL: thefiame12
Location: GA
This is the latest reply I've gotten:

Quote:
Im very sorry but I cannot help, your code and my answerer is the very basic usage of GD, ive had alook at your phpinfo and at first glance it looks ok but can only see that your version of GD is 1.2.42 this maybe the problem as the latest version is 1.5.4 libpng.org/pub/png/libpng.html like other's have said make sure you permissions are correct. if your apache handlers are DSO mode change it too suPHP if you can so your script is not run as (nobody) but as your hosting username then chmod 0755 for folders & 0644 for files, apart from that I have no idea whats wrong. sorry


Any help on what he meant by this?


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 11:14 am 
Offline
Senior Member

Joined: Thu May 21, 2009 3:19 am
Posts: 336
Make sure that the directory where out.png is writable by the user PHP runs as.


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 11:20 am 
Offline
Junior Member

Joined: Sun Jul 31, 2011 5:03 pm
Posts: 49
Website: http://www.clubpenguincheatsy.com/
AOL: thefiame12
Location: GA
Yes I set the directory permissions to 777 to test it, nothing.

Would the fact that I had the same directory and images on my old server be a problem? All I did was move the databases and file directories when I moved my site.

Could there be some type of cached DB query that would cause the image not to update?


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 2:47 pm 
Offline
Junior Member

Joined: Sun Jul 31, 2011 5:03 pm
Posts: 49
Website: http://www.clubpenguincheatsy.com/
AOL: thefiame12
Location: GA
Any help on this?


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 2:53 pm 
Offline
Senior Member

Joined: Thu May 21, 2009 3:19 am
Posts: 336
Try changing ownership of the directory(s) and file like you did in your other thread.


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 2:59 pm 
Offline
Junior Member

Joined: Sun Jul 31, 2011 5:03 pm
Posts: 49
Website: http://www.clubpenguincheatsy.com/
AOL: thefiame12
Location: GA
Yeah just tried that. Didn't seem to work either. I'm starting to think I'm gonna need a new script.

It's just weird, because it works when I render the image directly.

Just won't let me update it with the forms.


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 3:06 pm 
Offline
Senior Member

Joined: Thu May 21, 2009 3:19 am
Posts: 336
That to me, still points to a permissions issue. You are logged in as root. There is nothing to stop you from doing anything. PHP/Apache is running as www-data. That user doesn't have access to everything on the system. Make sure that the www-data user can perform the actions you're trying to do.

I don't know if this is best practice (or if it'll work), but you could try switching to the www-data user.

Since you're already logged in as root, just enter:
su www-data

And you'll be typing commands on the command line as if you were the www-data user. Then try to render the image directly as you were before.


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 3:15 pm 
Offline
Junior Member

Joined: Sun Jul 31, 2011 5:03 pm
Posts: 49
Website: http://www.clubpenguincheatsy.com/
AOL: thefiame12
Location: GA
Ugh, that seemed like it would work. Text still not changing.


Top
   
 Post subject:
PostPosted: Tue Aug 02, 2011 6:32 pm 
Offline
Junior Member

Joined: Sun Jul 31, 2011 5:03 pm
Posts: 49
Website: http://www.clubpenguincheatsy.com/
AOL: thefiame12
Location: GA
I got this from error report:

Warning: imagettftext(): Could not find/open font in /var/www/cptrackers/auntarctic/index.php on line 34 Warning: imagettftext(): Could not find/open font in /var/www/cptrackers/auntarctic/index.php on line 35 Warning: imagettftext(): Could not find/open font in /var/www/cptrackers/auntarctic/index.php on line 36


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group