N-Bomb(Nerd) Posted December 25, 2008 Share Posted December 25, 2008 I have a php script I've made that creates a png image with stats on it that gets updated. However the forum I'm trying to use this in blocks the keyword ".php" within its image tags, therefore I couldn't use my script that I've made. I've seen people get around this though, but I'm not sure exactly how they did this. So pretty much I need to figure out a way to turn: http://www.SomeSite.Com/Image.php into something like : http://www.SomeSite.Com/Image.png but yet still have my script used for the .png image. I know this may seem confusing, if you need me to try and explain better please let me know. Thanks, Quote Link to comment Share on other sites More sharing options...
revraz Posted December 25, 2008 Share Posted December 25, 2008 You should be able to use AddType application/x-httpd-php .png in your .htaccess file on your server that hosts the image Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted December 25, 2008 Share Posted December 25, 2008 Keep in mind it would be best to isolate this .htaccess file in a subdirectory in which only the pngs you wish to be parsed for php are kept. If you add this to your main htdocs directory it will slow the image requests down because the server will be checking them for php code. Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted December 25, 2008 Author Share Posted December 25, 2008 You should be able to use AddType application/x-httpd-php .png in your .htaccess file on your server that hosts the image I'm not quite sure what you mean ??? Here's my code (image.php): <? $image = imagecreate(125, 125); imagecolorallocatealpha($image, 0, 0, 0, 127); $Color = imagecolorallocate($image, 32, 101, 138); imagestring($image, 2, 1, 0, 'This is my signature.', $Color); Header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?> Now by going to /image.php on my website you can see the image it creates. However is there an .htaccess or php hack I can use so that I'm able to use something like "/image.png" for a signature on a forum instead of "/image.php" because the keyword ".php" is blocked. This image is updated like every few minutes with new stats btw in case you didn't know. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 25, 2008 Share Posted December 25, 2008 Yes, I am aware that you are making a dynamic sig. You rename the image to image.png and put the entry I provided above in your .htaccess file. It will then parse the .png as PHP. Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted December 25, 2008 Author Share Posted December 25, 2008 Yes, I am aware that you are making a dynamic sig. You rename the image to image.png and put the entry I provided above in your .htaccess file. It will then parse the .png as PHP. I tried renaming the php file to image.png and using that .htaccess file and this is the output I got: Multiple Choices The document name you requested (/sig/image.png) could not be found on this server. However, we found documents with names similar to the one you requested. Available documents: * /sig/image.php (common basename) Then I would click the link "/sig/image.php" and it would take me to a different page that reads this: The document name you requested (/sig/image.php) could not be found on this server. However, we found documents with names similar to the one you requested. Available documents: * /sig/image.png (common basename) Please consider informing the owner of the referring page about the broken link. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 25, 2008 Share Posted December 25, 2008 Sounds like you are pointing to the wrong path.. file not found means just that. Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted December 25, 2008 Author Share Posted December 25, 2008 Sounds like you are pointing to the wrong path.. file not found means just that. Yeah I think I did mess up the path, but I just corrected the path problem. Now when I go to the url using the .png extention it wants me to download the file. I did in fact download the png image to look at it and it said no preview was available. So I tried to use my link with the .png extention on a forum to see if it worked there and no image came up. Before I changed the file to .png I checked it once with the .php and it worked just fine. Any suggestions? Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted December 25, 2008 Author Share Posted December 25, 2008 Also, I just opened the png file it asks me to download instead of just displaying it. I opened it using notepad and the whole php script was inside this png image, is that right? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 25, 2008 Share Posted December 25, 2008 I use a .jpg file http://bdcpaging.com/fsesig/mysig.jpg And here is my code for that file <?php Header ('Content-type: image/jpeg'); Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); Header('Pragma: no-cache'); $current = ""; $pilot = ''; function start_tag($parser, $name, $attribs) { global $current; $current = $name; } function end_tag($parser, $name) { global $current, $pilot; } function tag_contents($parser, $data) { global $current, $pilot; if ($current == "name") {$pilot[] = $data;} if ($current == "flights") {$pilot[] = $data;} if ($current == "miles") {$pilot[] = $data;} if ($current == "hours") {$pilot[] = $data;} } $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); xml_set_element_handler($parser, "start_tag", "end_tag"); xml_set_character_data_handler($parser, "tag_contents"); $document = file_get_contents("http://localhost.bdcpaging.com/xml/pilots.xml","r") or die("Error reading XML data."); xml_parse($parser, $document); xml_parser_free($parser); /* echo $pilot[0]; echo $pilot[2]; echo $pilot[4]; echo $pilot[6]; */ // create the image using your own background $image = imagecreatefromjpeg("FSESig.jpg"); // dimensions of the image used $img_width = 440; $img_height = 111; // set the colours $cool = imagecolorallocate($image, 81, 86, 96); $black = imagecolorallocate($image, 0, 0, 0); $white = imagecolorallocate($image, 255, 255, 255); $red = imagecolorallocate($image, 255, 0, 0); $grey = imagecolorallocate($image, 204, 204, 204); $green = imagecolorallocate($image, 206, 129, 18); $blue = imagecolorallocate($image, 0, 0, 255); // set the font and print text $font = '/home/users/web/b2031/pow.bdcpaging/htdocs/fsesig/arial.ttf'; // now i will create a line with font size 8, with no angle, 10 pixels to the right, and 17 pixels down ImageTTFText ($image, 8, 0, 10, 40, $black, $font, "Pilot... $pilot[0]"); ImageTTFText ($image, 8, 0, 10, 60, $black, $font, "Flights Flown... $pilot[2]"); ImageTTFText ($image, 8, 0, 10, 80, $black, $font, "Miles Flown... $pilot[4]"); ImageTTFText ($image, 8, 0, 10, 100, $black, $font, "Hours Flown... $pilot[6]"); // output and destroy imagepng($image); imagedestroy($image); ?> I use a XML feed for my data, but maybe you can spot what I'm doing different than what you are doing. Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted December 25, 2008 Author Share Posted December 25, 2008 I pretty much used the code that you just pasted, of course I took out the XML and changed the .htaccess instead of png I used jpg and it didn't work. When I go to it in my browser its asking me to download the image instead of displaying it. Could this be a problem with my php settings or my host then? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 25, 2008 Share Posted December 25, 2008 Do you have GD enabled? Quote Link to comment Share on other sites More sharing options...
N-Bomb(Nerd) Posted December 25, 2008 Author Share Posted December 25, 2008 Do you have GD enabled? I believe so.. ( look below ). So since I'm thinking that is enabled what would be left that would cause this then? gd GD Support enabled GD Version bundled (2.0.28 compatible) FreeType Support enabled FreeType Linkage with freetype GIF Read Support enabled GIF Create Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled XBM Support enabled Quote Link to comment Share on other sites More sharing options...
revraz Posted December 25, 2008 Share Posted December 25, 2008 What is the link to your image. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.