| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#19 (permalink) |
|
SurPerson
On a golden path...
Joined in Jul 2004
Lives in front of my laptop
Hosted on Sync
437 posts
Gave thanks: 0
Thanked 1 Time in 1 Post
|
You could allow x=folder/file with the following modification to your code, as long as neither has a "." in it:
Code:
<?php
$x = $_GET['x'];
if(eregi("[a-z0-9\-_/]+", $x, $regs)) {
$dir = "includes/";
$ext = ".php";
if(file_exists($dir . $x . $ext)) {
include($dir . $x . $ext);
} else {
include($dir . "notfound" . $ext);
}
} else {
include($dir . "illegal" . $ext);
}
?>
__________________
Me: TeeJay Server: Sync (Statistics) Site: technoized.com (Statistics) chown -R us ./base Last edited by TJ09; July 31st, 2004 at 11:15 PM.. Reason: Forgot [/code] tag |
|
|
|
|
|
#20 (permalink) |
|
L'Awesome Advocate
Super #1
Joined in May 2004
Lives in .au
Hosted on Mango
2,423 posts
Gave thanks: 1
Thanked 5 times
|
Ah I see, looks good. I'll just have to make sure there is no period in the file or folder name.
Thanks for all the help guys.
__________________
When I get sad, I stop being sad, and be AWESOME instead. True story.
|
|
|
|
|
|
#21 (permalink) |
|
L'Awesome Advocate
Super #1
Joined in May 2004
Lives in .au
Hosted on Mango
2,423 posts
Gave thanks: 1
Thanked 5 times
|
I've tried both version but the script still seems to allow ?x=../file
How do I prevent that?
__________________
When I get sad, I stop being sad, and be AWESOME instead. True story.
|
|
|
|
|
|
#22 (permalink) |
|
L'Awesome Advocate
Super #1
Joined in May 2004
Lives in .au
Hosted on Mango
2,423 posts
Gave thanks: 1
Thanked 5 times
|
Wait got it working. Just gave up, no use of periods or slashes. Sucks being a PHP newb.
Code:
<?php
$x = $_GET['x'];
$dir = "includes/";
$ext = ".php";
if(eregi("^[_a-z0-9-]", $x)) {
if(file_exists($dir . $x . $ext)) {
include($dir . $x . $ext);
} else {
include($dir . "notfound" . $ext);
}
} elseif(!$x) {
include($dir . "main" . $ext);
} else {
include($dir . "error" . $ext);
}
?>
__________________
When I get sad, I stop being sad, and be AWESOME instead. True story.
|
|
|
|