As most of you will have realized (I got many many 'complaints' recently), the image I used in my sig for the post count has been broken for a while. It's not that the link points to a nonexistent location: the PHP code that creates it is just not working.
Here's the code (which worked until a while ago):
<?php
// find posts...
// line 1224
// start making image
//creates a image handle
$file_name= 'http://scratch.mit.edu/forums/viewtopic.php?id=34152&p=1';
$scratchpage = file_get_contents("http://scratch.mit.edu/forums/viewtopic.php?id=34152&p=1");
$start = stripos($scratchpage,'<dd><a href="search.php?action=show_user&user_id=53856">Posts</a>: ');
$end = stripos($scratchpage,'</dd>',$start);
$posts = strip_tags(substr($scratchpage,$start + 67,$end - $start - 20));
// start
$img = imagecreatefrompng ( "bg.png" );
//choose a bg color, u can play with the rgb values
$background = imagecolorallocate( $img,232, 0, 135 );
//chooses the text color
$text_colour = imagecolorallocate( $img, 146, 208, 80 );
$colour2 = imagecolorallocate( $img, 0, 102, 0 );
//sets the thickness/bolness of the line
imagesetthickness ( $img, 3 );
//draws a line params are (imgres,x1,y1,x2,y2,color)
imageline( $img, 20, 130, 165, 130, $text_colour );
//pulls the value passed in the URL
$text = 'Posts';
// place the font file in the same dir level as the php file
$font = 'font.ttf';
//this function sets the font size, places to the co-ords
imagettftext($img, 12, 0, 6, 15, $colour2, $font, $text);
//places another text with smaller size
imagettftext($img, 13, 0, 15, 35, $text_colour, $font, $posts);
//alerts the browser abt the type of content i.e. png image
header( 'Content-type: image/png' );
//now creates the image
imagepng( $img );
//destroys used resources
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $img );
?>To all PHP coders, is there maybe a PHP version update of which I'm not aware of that obsoleted the above code? Or is it just my server, and I should maybe move the image to a different one?
I would appreciate some help. Thanks,
LS97
Oh, and I put this in AT because it is somewhat related to Scratch (it's about my sig) and it's obviously advanced.
Offline
Comment out the line "header( 'Content-type: image/png' );" temporarily and see if there are any PHP errors in the output.
Offline
It's on line 1222 according to my source.
Offline
scimonster wrote:
It's on line 1222 according to my source.
The only thing I saw with 1222 lines was notepad decompiled into assembly code. What do you mean by 1222?
Offline
LS97 wrote:
scimonster wrote:
It's on line 1222 according to my source.
The only thing I saw with 1222 lines was notepad decompiled into assembly code. What do you mean by 1222?
Too big to post whole code, but in Firefox, it shows that on line 1222 of the source.
Offline
scimonster wrote:
LS97 wrote:
scimonster wrote:
It's on line 1222 according to my source.
The only thing I saw with 1222 lines was notepad decompiled into assembly code. What do you mean by 1222?
Too big to post whole code, but in Firefox, it shows that on line 1222 of the source.
Hmm..
Offline
Of course, 000webhost had to have a problem with its servers now...
Offline
Firefox wrote:
The image “http://mod-share.webuda.com/imgs/posts/image.php” cannot be displayed, because it contains errors.
See my post.
Offline
Could not find/open font in <b>/home/a2956315/public_html/imgs/posts/image.php</b> on line <b>42</b><br />
this line is the problem:
// place the font file in the same dir level as the php file $font = 'font.ttf';
the font "font.ttf" is causing the error
Last edited by TRocket (2011-06-17 03:00:57)
Offline
ok, thanks! i think PHP now changed the file not found to a fatal error...
Offline
And here we go, I got it working!
I used realpath('font.ttf') since I found out that ImageTTFText() only works with full paths.
Offline
Closed by request of topic owner
Offline