Jump to content

Problem with php-gd (long) [solved]


Recommended Posts

I have a php-gd script to output an image:

 

http://omarserenity.com/end.php

 

and, to use it in my sig, I named it end.png and added this in my .htaccess file:

 

<Files end.png>

ForceType application/x-php

</Files>

 

I also tried:

ForceType application/x-httpd-php

 

When I try to view the image here:

http://omarserenity.com/end.png

 

I get:

The image "http://omarserenity.com/end.png" cannot be displayed, because it contains errors

 

I have restarted apache each time I edited my .htaccess file. The image here: http://omarserenity.com/end.php is exactly the same script as end.png and end.php works fine. The end.png script worked perfectly in MDV 2005 LE.

 

[root@desktop html]# (rpm -qa | grep apache) && (rpm -qa | grep php)
apache-mod_perl-2.0.54_2.0.1-6mdk
apache-doc-2.0.54-2mdk
apache-mod_php-2.0.54_5.0.4-4mdk
apache-conf-2.0.54-12mdk
apache-mpm-prefork-2.0.54-13mdk
apache-mod_log_data-2.0.54_0.0.3-2mdk
apache-base-2.0.54-13mdk
apache-modules-2.0.54-13mdk
php5-cgi-5.0.3-8mdk
php-ctype-5.0.4-1mdk
php-sysvshm-5.0.4-1mdk
php-dbase-5.0.4-1mdk
php-posix-5.0.4-1mdk
php-gettext-5.0.4-1mdk
php-session-5.0.4-1mdk
php-xml-5.0.4-1mdk
php-pear-5.0.4-14mdk
libc-client-php0-2004e-1.1.20060mdk
php-cgi-5.0.4-9.1.20060mdk
php-yp-5.0.4-1mdk
php-fileinfo-5.0.4_0.2-1mdk
php-filepro-5.0.4-1mdk
php-manual-en-5.0.4-1mdk
apache-mod_php-2.0.54_5.0.4-4mdk
php5-cli-5.0.3-8mdk
php-ini-5.0.4-4mdk
php-gd-5.0.4-1mdk
php-xmlrpc-5.0.4-1mdk
php-pear-HTML_Common-1.2.2-1mdk
php-cli-5.0.4-9.1.20060mdk
php-sysvsem-5.0.4-1mdk
php-dba-5.0.4-1mdk
php-mysql-5.0.4-1mdk
php-pcre-5.0.4-1mdk
php-recode-5.0.4-1mdk
php-exif-5.0.4-1.1.20060mdk
php-pear-4.3.10-3mdk
php-pear-HTML_Common-1.2.1-4mdk
php-ftp-5.0.4-1mdk
php-tokenizer-5.0.4-1mdk
php-dbx-5.0.4-1mdk
php-ming-5.0.4-1mdk
libphp5_common5-5.0.4-9.1.20060mdk

 

Any ideas?

 

Edit: Here's the script:

<?php

/*
Copyright 2005 Steve Scrimpshire

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

$timestring = "22 December 2012";
$something = strtotime("$timestring");
$end = $something - time();
$days = round((($end/60)/60)/24);
$years = floor($days/365);
$dayz = fmod($days,365);
if ($years == 1){
  $yrs = "year";
  }
if ($years >= 2){
  $yrs = "years";
  }
if ($dayz == 1){
  $daze = "day";
 }
if ($dayz >= 2){
  $daze = "days";
 }

Header ("Content-type: image/png");
Header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
Header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
Header("Pragma: no-cache");

$img = @ImageCreate(389,15);
$font = '/home/omar/.fonts/VeraSeBd.ttf';
$bg = ImageColorAllocate($img, 23, 137, 45);
imagecolortransparent ($img,$bg);
$text_color = ImageColorAllocate ($img, 36, 25, 223);
$title_color = ImageColorAllocate ($img, 0, 0, 205);
imagestring($img,3,0,0,"Only $days more shopping days until the end of the world.",$text_color);
ImagePNG($img);
ImageDestroy($img);
?>

Edited by Steve Scrimpshire
Link to comment
Share on other sites

Apache was not parsing my .htaccess file because in /etc/httpd/conf/httpd.conf there was still a line

AllowOverride None

for /var/www/html and that overrode the

AllowOverride All in /etc/httpd/conf/commonhttpd.conf.

 

Edit: FWIW, the line in .htaccess has to be:

 

ForceType application/x-httpd-php

Edited by Steve Scrimpshire
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...