PHP Image

For the discussion of Perl, Python, Ruby, and PHP and other interpreted languages.

PHP Image

Post by hagman9 on Tue Aug 26, 2008 9:54 am
([msg=10493]see PHP Image[/msg])

I was just browsing around HackThisSite when I came across the quoteheader.php file. It really intrigues me because you have it linked to the main page using an image tag, but its a php file and it can also be linked to using BBCode [img] tags.

Code: Select all
<img src="/images/quoteheader.php" alt="Header Fill" width="780"  />

Image

I've been trying to work on duplicating it, since you could add your own code in quoteheader.php to do whatever you want, but have came up empty so far. It would be really nice if someone could explain to me how this is done or at least give their opinion on how to do it.
hagman9
New User
New User
 
Posts: 3
Joined: Fri Jul 18, 2008 11:04 am
Blog: View Blog (0)


Re: PHP Image

Post by BhaaL on Tue Aug 26, 2008 11:12 am
([msg=10496]see Re: PHP Image[/msg])

Theres two ways to go.

One is simply forwarding to the file:
Code: Select all
<?php
$randomFileName = generateRandomImageFileName();
header('Location: /my/image/folder/' . $randomFileName);
?>


The other is generating the image using GD, and sending it as output (also works for the first one, if you want to keep the filenames secret):
Code: Select all
<?php
header('Content-type: image/jpeg');
//send image stuff here, imagejpeg() or similar. also works:
readfile('/my/image/folder/' . $randomFileName);
?>
BhaaL
Poster
Poster
 
Posts: 270
Joined: Sun Apr 13, 2008 11:16 am
Blog: View Blog (0)


Re: PHP Image

Post by hagman9 on Tue Aug 26, 2008 8:50 pm
([msg=10527]see Re: PHP Image[/msg])

I think you misunderstood me. I'm not trying to make a random image generator, im trying to get a php file able to be opened through [img] tags.
hagman9
New User
New User
 
Posts: 3
Joined: Fri Jul 18, 2008 11:04 am
Blog: View Blog (0)


Re: PHP Image

Post by mutants_r_us_guild on Tue Aug 26, 2008 9:09 pm
([msg=10528]see Re: PHP Image[/msg])

it wont OPEN but it will execute... if you had a page named logout.php and you put it in img tags... it would silently log you out. This is used for CSRF. It will only show an image if the page has an image output.
Image
Image
Image
User avatar
mutants_r_us_guild
Poster
Poster
 
Posts: 246
Joined: Fri May 30, 2008 7:56 pm
Blog: View Blog (0)


Re: PHP Image

Post by BhaaL on Wed Aug 27, 2008 11:06 am
([msg=10549]see Re: PHP Image[/msg])

hagman9 wrote:I think you misunderstood me. I'm not trying to make a random image generator, im trying to get a php file able to be opened through [img] tags.

Ah well, thats a setting in your-board-software-here. Most have an option to allow/disallow dynamic image (those with .php) in order to avoid CSRF and other stuff like mutant just pointed out.
BhaaL
Poster
Poster
 
Posts: 270
Joined: Sun Apr 13, 2008 11:16 am
Blog: View Blog (0)


Re: PHP Image

Post by leonidas_heaven on Mon Sep 08, 2008 8:46 am
([msg=11195]see Re: PHP Image[/msg])

I just want to ask that can any one tell me the link to download PHP which have GD already included in it..
Challenges are not meant to be taken easily,rather they are meant to be taken Seriously
leonidas_heaven
Experienced User
Experienced User
 
Posts: 66
Joined: Sun Jun 01, 2008 5:20 am
Location: Uttarakhand,India
Blog: View Blog (0)


Re: PHP Image

Post by BhaaL on Mon Sep 08, 2008 11:48 am
([msg=11202]see Re: PHP Image[/msg])

For windows, you may want to look into XAMPP from www.apachefriends.org. It includes the latest Apache2, the (almost) latest PHP5 with most useful libraries and the latest version of MySQL, together with phpMyAdmin prepackaged and preconfigured for standard use.

For *nix, you may want to look into your package manager. Apt-based systems (Debian, *ubuntu, some others) got php5-gd, Emerge (Gentoo, Sabayon) has a similar package, aswell as Slackware (same as Debian, also php5-gd iirc). From Binary, look at http://php.net/gd
BhaaL
Poster
Poster
 
Posts: 270
Joined: Sun Apr 13, 2008 11:16 am
Blog: View Blog (0)


Re: PHP Image

Post by Dr_Phil on Tue Sep 09, 2008 2:45 pm
([msg=11268]see Re: PHP Image[/msg])

BhaaL wrote:
hagman9 wrote:I think you misunderstood me. I'm not trying to make a random image generator, im trying to get a php file able to be opened through [img] tags.

Ah well, thats a setting in your-board-software-here. Most have an option to allow/disallow dynamic image (those with .php) in order to avoid CSRF and other stuff like mutant just pointed out.


This maybe is a stupid question, but can't you link to logout.gif and then tell your PHP to parse gif files as they was php files?
Dr_Phil
Poster
Poster
 
Posts: 171
Joined: Mon Sep 01, 2008 12:36 pm
Blog: View Blog (0)


Re: PHP Image

Post by Rijnzael on Tue Sep 09, 2008 10:02 pm
([msg=11299]see Re: PHP Image[/msg])

That's accomplished using configuration directives for the web server in question in either httpd.conf, or if the directive is allowed, in the .htaccess file for the applicable directory. I believe the line goes something like 'AddHandler application/x-httpd-php .gif', though there are other variations that work depending on the version of apache and the php module in question.
Rijnzael
Poster
Poster
 
Posts: 164
Joined: Sun Apr 13, 2008 10:12 am
Location: 128.0.0.0/8
Blog: View Blog (0)


Re: PHP Image

Post by leonidas_heaven on Wed Sep 10, 2008 1:11 am
([msg=11308]see Re: PHP Image[/msg])

Thanks, Bhaal that version of PHP was the one i was searching from many days..and Btw you are great as always..Thanks
Challenges are not meant to be taken easily,rather they are meant to be taken Seriously
leonidas_heaven
Experienced User
Experienced User
 
Posts: 66
Joined: Sun Jun 01, 2008 5:20 am
Location: Uttarakhand,India
Blog: View Blog (0)



Return to Interpreted Languages

Who is online

Users browsing this forum: No registered users and 0 guests