| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#10 (permalink) |
|
Surpass Fan
Excelling Contributor
Joined in Jan 2004
Lives in Clinton, Massachusetts
Hosted on Serenity x.x.40.51
994 posts
Gave thanks: 0
Thanked 0 times
|
I just quickly browsed through the posts and I didn't know you posted that link, otherwise I wouldn't have made my post. Sorry!
![]() |
|
|
|
|
|
#11 (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 thought about using the switch/case method, but sometimes I don't want to edit my script.php file to accomodate a newly created file.
Is there another way around this where I could use my original script? I also want the: ?x=folder/file Is there a safe way to not allow ?x=../file
__________________
When I get sad, I stop being sad, and be AWESOME instead. True story.
|
|
|
|
|
|
#12 (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
|
Oh guys, I've seen another way to do this. Could you check it out:
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);
}
?>
__________________
When I get sad, I stop being sad, and be AWESOME instead. True story.
|
|
|
|
|
|
#13 (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
|
Quote:
EDIT: In fact, that's what the code she had does anyway...so it prevents use of files other than PHP... As for this: Quote:
Code:
if(preg_match("#^../(.+?)#", $x)) {include "illegal.php";} else {include "$x.php";}
__________________
Me: TeeJay Server: Sync (Statistics) Site: technoized.com (Statistics) chown -R us ./base Last edited by TJ09; July 31st, 2004 at 10:07 PM.. Reason: Add to post |
||
|
|
|
|
|
#14 (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
|
Have you guys taken a look at my new code? It's two posts above this.
__________________
When I get sad, I stop being sad, and be AWESOME instead. True story.
|
|
|
|
|
|
#15 (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
|
I don't think that code would prevent ../, just non-alphanumeric characters.
__________________
Me: TeeJay Server: Sync (Statistics) Site: technoized.com (Statistics) chown -R us ./base |
|
|
|
|
|
#17 (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
|
I guess, but your script allows . to be in the $x variable.
Now that I look at it, it prevents use of all directories, since / isn't allowed.
__________________
Me: TeeJay Server: Sync (Statistics) Site: technoized.com (Statistics) chown -R us ./base |
|
|
|
|
|
#18 (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
|
Cool so do you think it is okay to use? I guess I just have to give up on using ?x=folder/file
?x=file should be sufficient.
__________________
When I get sad, I stop being sad, and be AWESOME instead. True story.
|
|
|
|