General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 30th, 2003, 05:34 PM
jmweb jmweb is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 3 jmweb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
help with include, very simple.

fixed

Last edited by jmweb : September 30th, 2003 at 08:16 PM.

Reply With Quote
  #2  
Old September 30th, 2003, 06:58 PM
Ben Ben is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Grand Rapids, MI
Posts: 1 Ben User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Ben Send a message via AIM to Ben Send a message via Yahoo to Ben
PHP Code:
 $photos $HTTP_GET_VARS['photos'];
include(
'/home/gibson/public_html/rocket/images/$photos/'

Reply With Quote
  #3  
Old September 30th, 2003, 07:16 PM
jmweb jmweb is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 3 jmweb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks

Last edited by jmweb : September 30th, 2003 at 07:20 PM.

Reply With Quote
  #4  
Old September 30th, 2003, 07:46 PM
jmweb jmweb is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 3 jmweb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
can anyone help?

Reply With Quote
  #5  
Old October 1st, 2003, 08:18 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Try concatenating your variable instead of posting it inline.:

PHP Code:
 $photos $HTTP_GET_VARS['photos'];
include(
"/home/gibson/www/rocket/images/" $photos "/"); 


Also, the single quotes are probably causing a problem, as they cause $photos to be read as a string literal. In the error messages you last posted, there appear to be spaces in the path as well. Try changing your single quotes to double quotes, and consider also using the dot operator to concatenate the variable between string values (that may just be my personal coding style and probably doesn't really gain you anything besides readability).

Consider also validating $photos to make sure I can't pass something to your query string like:

Code:
&photos=../../../../../etc/passwd


and get access to sensitive files.

Reply With Quote
  #6  
Old October 6th, 2003, 10:04 PM
mutus mutus is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 6 mutus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
yeah double quotes would fix it
PHP Code:
 $photos $HTTP_GET_VARS['photos']; 
include(
"/home/gibson/www/rocket/images/$photos/"

or use what dhouston gave (but stick to single quotes if you concatenate).

BY ALL MEANS validate that query string value before you use it to include any files. That is a huge security issue! Preferably you should compare it to an array of acceptable values, and either use a default or kill the script if the value is not what you expected.

Reply With Quote
  #7  
Old October 7th, 2003, 09:13 AM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
or

PHP Code:
include("/home/gibson/www/rocket/images/{$HTTP_GET_VARS['photos']}/"
__________________
-- Jason

Reply With Quote
  #8  
Old October 7th, 2003, 01:25 PM
mwichmann4 mwichmann4 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 81 mwichmann4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 27 sec
Reputation Power: 6
One thing

Make sure you have given that folder write permissions.

Reply With Quote
  #9  
Old October 7th, 2003, 03:01 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Why would you want to give the folder write permission if all you're doing is reading images from it?

Reply With Quote
  #10  
Old October 7th, 2003, 04:20 PM
mwichmann4 mwichmann4 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 81 mwichmann4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 27 sec
Reputation Power: 6
oops good point did not read it all the way

I get that kind of error when i am trying to write something to a directory that does not allow that. Sorry, ya if you are only reading then it does not matter.

Reply With Quote
  #11  
Old October 7th, 2003, 09:51 PM
mutus mutus is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 6 mutus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP Code:
include("/home/gibson/www/rocket/images/{$HTTP_GET_VARS['photos']}/"

Please do not use that line of code in any script. That is text book non-secure PHP code. Never accept any unchecked user input.... especially to include a file on your network.

Some reading material...

http://us4.php.net/manual/en/security.variables.php

http://us4.php.net/manual/en/security.filesystem.php

Reply With Quote
  #12  
Old October 7th, 2003, 10:06 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
mutus, there are many ways to do that same thing. do you think setting $photos = to http_get_vars is more secure? nope

Reply With Quote
  #13  
Old October 7th, 2003, 10:34 PM
mutus mutus is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 6 mutus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry there was no offense meant...

If you read above to my first post you'll see that I made a point that the inputted value should be validated. ie. whatever value is held by $photos

That line of code you posted appears to plug the GET value in unvalidated. That's my objection. Of course there are multiple ways to assembe strings... maybe you were assuming that the value was already validated and just offering an alternative way to write the code.

Going by what I suggested... yes putting the GET value into $photos and validating it against an array of acceptable choices is MUCH more secure than stuffing the raw GET value into an include statement.

But maybe you were assuming that the GET value was already deemed safe before that line of code... my apologies if so . I Wasn't trying to make a problem.

Reply With Quote
  #14  
Old October 7th, 2003, 10:45 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
no problem.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Get Vars being a pain, simple question.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |