Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Run .jpg extension as .php
Old 06-06-2009, 05:09 PM Run .jpg extension as .php
Guerrilla's Avatar
Ultra Talker

Posts: 424
Trades: -1
Hey Guys,

I want my php code to run with the file type extension of .jpg.

By this i mean I save my php script with a jpg extension.

I have added this code to my .htaccess file

Code:
<Files spacer.jpg>
ForceType application/x-httpd-php
</Files>
But it didn't work. Is the code right? I wonder if my host could be blocking this perhaps?

Any help would be greatly appreciated.

Thanks,

G
__________________
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
Guerrilla is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-06-2009, 07:37 PM Re: Run .jpg extension as .php
alex021's Avatar
Super Talker

Posts: 118
Name: Alex
Trades: 0
This sort of thing is usually used for hacking websites, I don't think you should be looking into such things
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
---
Please login or register to view this content. Registration is FREE
---
Please login or register to view this content. Registration is FREE
alex021 is offline
Reply With Quote
View Public Profile
 
Old 06-06-2009, 08:41 PM Re: Run .jpg extension as .php
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Code:
AddType
Google it to get the answer.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 06-08-2009, 03:29 PM Re: Run .jpg extension as .php
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
Here's something I often use, just throw it in the .php file you want to act like a .jpg.
PHP Code:
<?php header('Content-Type: image/jpeg'); ?>
I don't know if it will work in your specific case, though.
__________________
if($stevej == "helpful") { $talkupation += $user_power; }
stevej is offline
Reply With Quote
View Public Profile
 
Old 06-08-2009, 04:14 PM Re: Run .jpg extension as .php
Guerrilla's Avatar
Ultra Talker

Posts: 424
Trades: -1
Quote:
Originally Posted by alex021 View Post
This sort of thing is usually used for hacking websites, I don't think you should be looking into such things
Thanks for chiming in but I think you don't know what you are talking about.
__________________
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
Guerrilla is offline
Reply With Quote
View Public Profile
 
Old 06-09-2009, 04:45 AM Re: Run .jpg extension as .php
alex021's Avatar
Super Talker

Posts: 118
Name: Alex
Trades: 0
Quote:
Originally Posted by Guerrilla View Post
Thanks for chiming in but I think you don't know what you are talking about.

Trust me I do as one of my websites was hacked this way the php code in jpg file and htaccess file was used to run it and append virus to each page
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
---
Please login or register to view this content. Registration is FREE
---
Please login or register to view this content. Registration is FREE
alex021 is offline
Reply With Quote
View Public Profile
 
Old 06-09-2009, 06:02 AM Re: Run .jpg extension as .php
Guerrilla's Avatar
Ultra Talker

Posts: 424
Trades: -1
Quote:
Originally Posted by alex021 View Post
Trust me I do as one of my websites was hacked this way the php code in jpg file and htaccess file was used to run it and append virus to each page
Your site must have aready been compromised if they were able to upload their own .htaccess file.
__________________
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
Guerrilla is offline
Reply With Quote
View Public Profile
 
Old 06-09-2009, 08:19 AM Re: Run .jpg extension as .php
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Quote:
Originally Posted by alex021 View Post
Trust me I do as one of my websites was hacked this way the php code in jpg file and htaccess file was used to run it and append virus to each page
Sounds like a permissions problem, not anything do do with .jpg being used for PHP. Any file format could have been used, .jpg was just a convenient hiding place. Almost all hacks like this come from someone else on your shared server, so if your file or directory permissions are not strict enough, it is possible for others to change your directories or even upload and change files.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 06-12-2009, 11:35 AM Re: Run .jpg extension as .php
anderswc's Avatar
Super Talker

Posts: 132
Name: Will Anderson
Location: Terre Haute, IN
Trades: 0
If I were you, I'd redirect my jpg requests to a php script, rather than trying to get apache to interpret jpg files as php.
__________________
Will Anderson

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
anderswc is offline
Reply With Quote
View Public Profile Visit anderswc's homepage!
 
Old 06-12-2009, 12:54 PM Re: Run .jpg extension as .php
Novice Talker

Posts: 7
Trades: 0
A simple way to achieve what you desire is to use a directory.

Make a directory image.jpg and inside it, have your index.php generate the image

For example:
http://www.fakeexamplesite.com/image.jpg/index.php

could be used in html as http://www.fakeexamplesite.com/image.jpg

The index.php needs to send image headers and return an image, im assuming you know how to do that as you only asked the question about executing php scripts with the jpg extension

edit: This is all assuming you want to actually return an image, not ust have your regular php scripts named .jpg, in which case ignore this post

Last edited by LSS1; 06-12-2009 at 12:56 PM..
LSS1 is offline
Reply With Quote
View Public Profile
 
Old 06-12-2009, 03:18 PM Re: Run .jpg extension as .php
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
No, none of you are understanding his question or providing the correct/easiest answer. The "real" solution can be used for easy hacking/spreading malware so I'm not going to post it but its a single line in a .htaccess file.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 06-13-2009, 08:40 PM Re: Run .jpg extension as .php
Novice Talker

Posts: 6
Name: adam greenberg
Location: Va. Beach Va.
Trades: 0
what about html to php
__________________
Go to
Please login or register to view this content. Registration is FREE
for Computer financing, No credit check, Finance a Computer Today, Ooh if you go to my page and try to exit see what happens and if you like it let me know and i will hook u up
agreenberg is offline
Reply With Quote
View Public Profile Visit agreenberg's homepage!
 
Old 06-20-2009, 10:56 AM Re: Run .jpg extension as .php
Guerrilla's Avatar
Ultra Talker

Posts: 424
Trades: -1
my problem is when i do it I end up changing every .jpg file to run as php. I just want to make it happen for 1 file or 1 directory.
__________________
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
Guerrilla is offline
Reply With Quote
View Public Profile
 
Old 06-20-2009, 02:26 PM Re: Run .jpg extension as .php
Defies a Status

Posts: 1,606
Trades: 0
Quote:
Originally Posted by Guerrilla View Post
my problem is when i do it I end up changing every .jpg file to run as php. I just want to make it happen for 1 file or 1 directory.

Place the .htaccess only in that directory. Only that directory and the children ones will be affected.

Then be sure no one else can upload to that directory.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 06-20-2009, 02:42 PM Re: Run .jpg extension as .php
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Yes, but your still failing to tell him how this can be done. Its done with the .htacces code from one of my earlier post. The reason as to why I didn't post the entire code is because this can be used to hack user's machines.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 06-20-2009, 04:07 PM Re: Run .jpg extension as .php
The PHP Professor

Posts: 340
Name: Alex
Location: Behind You
Trades: 0
Well, can you at least replace the in-secure parts of the script as var1, var2, var3 instead of the actual things? This may better help us understand exactly what you are looking for.
__________________
Go Kirby! <(" . "<) (^" . "^) (>" . ")> Talkupation!
microcolt is offline
Reply With Quote
View Public Profile Visit microcolt's homepage!
 
Old 06-20-2009, 04:46 PM Re: Run .jpg extension as .php
Defies a Status

Posts: 1,606
Trades: 0
Quote:
Originally Posted by Decaf View Post
Yes, but your still failing to tell him how this can be done. Its done with the .htacces code from one of my earlier post. The reason as to why I didn't post the entire code is because this can be used to hack user's machines.

His latest post implied that he knew how to do it sitewide and I chose to tell him how to do it in one directory.

Like you I think doing it very risky and have no desire for some newbie to screw up a server using what I post.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Run .jpg extension as .php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.01801 seconds with 12 queries