Script not working, no errors, no access
Posted: Sat May 28, 2005 9:14 am
My signature image generation script stopped working some time ago. It works perfectly on my own local server, but I don't get any output at all on my remote server, it doesn't even show up in the access nor error logs generated by PHP. I've tried to find the problem which prevented it from working, but I don't have a clue after 2 hours of debugging. I've only found out what line it breaks on (tested every line by putting echoes).
Does anyone have a clue on why it wouldn't be working? $template is set to 'net_tpl_square.png' in the first lines, and the file exists and is located in the same folder as the script.
A huge thanks in advance.
Code: Select all
<?php
########## settings ##########
## note: both the template and the randomly selected mini-images must be saved as png-24
// filenames (and if needed, paths) for count- and templatefile
$template = 'net_tpl_square.png';
$count_file = 'count';
// location of randomly selected mini-images ( set it to '.' to have same directory)
$folder = 'img/';
// mini-images to randomly output (if you want to have all pngs in the folder, just use 'all'
$files = array (
'all'
#'pic1.png','pic2.png','pic3.png'
);
// font settings (use the absolute path, ie: C:\Windows\Fonts\Arial.ttf
$font = realpath ('./KROE0553.TTF');
$fsize = 6; // font size (width)
########## /settings ##########
########## read & update views ##########
// read from counter-file
$count = @file ($count_file);# or die ('could not load file');
// views-text
$views = ++$count[0];
// update views
$c_file = @fopen ($count_file, 'w');# or die ('could not open file for writing');
if ($c_file):
@fwrite ($c_file, $views);# or die ('could not update file');
@fclose ($c_file);
endif;
########## /read & update views ##########
########## /choose mini-image ##########
// should all pngs in the folder be used?
if ($files[0] == 'all') {
$files = array (); // empty files
if ($f_folder = opendir ($folder)): // open folder
while ($ofile = readdir ($f_folder)):
if ($ofile == '..' || $ofile == '.') continue;
$img_info = getimagesize ($folder.$ofile);
if ($img_info['mime'] == 'image/png')
$files[] = $folder.$ofile; // add to files
endwhile;
endif;
}
// pick a filename from list for displaying
$rnd_file = array_rand ($files);
########## /choose mini-image ##########
########## output final image ##########
// create images for template and mini
$output = imagecreatefrompng ($template);# or die ('could not load template-image'); ##<<<<< BREAKS HERE
$insert = imagecreatefrompng ($files[$rnd_file]);# or die ('could not load mini-image');
// merge the images together
imagecopy ($output,$insert,4,12,0,0,260,62);# or die ('could not insert mini-image');
// colors
$fc = imagecolorallocate ($output, 95, 97, 100); // foreground color
$bc = imagecolorallocate ($output, 250, 250, 250); // shadow color
// output views-string
imagettftext ($output, $fsize, 0, 229, 10, $bc, $font, $views);
imagettftext ($output, $fsize, 0, 228, 9, $fc, $font, $views);# or die ('could not echo views');
#### create the image ####
header ("Content-type: image/png");
#header ("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
#header ("Expires: ".gmdate("D, d M Y H:i:s", time() + 60*3)." GMT");
#header ("Pragma: no-cache");
imagepng ($output) or die ('could not create the image');
#### /create the image ####
########## /output final image ##########
?>A huge thanks in advance.