ev5unleash Posted June 8, 2008 Share Posted June 8, 2008 I was talking to my friend (noob php coder) and I asked him if he knew the code so people could go to (ex. /index.php?request=games) instead of doing /games/index.php. He have me this code <?php $request = $_GET["request"]; include("homepage/".$request); ?> I checked my site with some people and found the problem with the script. Anyway, does anyone have any alternative? That won't exploit my server Link to comment https://forums.phpfreaks.com/topic/109310-getting-page-with-out-exploiting-my-server/ Share on other sites More sharing options...
Minase Posted June 8, 2008 Share Posted June 8, 2008 simple use on index.php a php script <?php if ($_GET['request'] == "games") { include files / HEADER OR ANYTHING ELSE GOES HERE; } ?> lets say you want to include 1.txt <?php if ($_GET['request'] == "games") { include("1.txt"); } ?> Link to comment https://forums.phpfreaks.com/topic/109310-getting-page-with-out-exploiting-my-server/#findComment-560716 Share on other sites More sharing options...
rarebit Posted June 8, 2008 Share Posted June 8, 2008 it technically works, but this part: include("homepage/".$request); needs cleaning, for instance some malicious cracker could put in a funny url, it'd be better to use a taken and look it up, e.g. index.html?request=xyz, then check for xyz and if you have a reference then substitute for a filename: $request = $_GET["request"]; if(strcmp($request,"userbob")==0) { include("homepage/bob.php"); } or check the file exists, etc... Link to comment https://forums.phpfreaks.com/topic/109310-getting-page-with-out-exploiting-my-server/#findComment-560721 Share on other sites More sharing options...
ev5unleash Posted June 8, 2008 Author Share Posted June 8, 2008 That was just an example, I need alittle bit more detail. I want the folder /homepage I want to be able to do something like /index.php?hp=welcome.html It would redirect to /homepage/welcome.html Link to comment https://forums.phpfreaks.com/topic/109310-getting-page-with-out-exploiting-my-server/#findComment-560729 Share on other sites More sharing options...
ev5unleash Posted June 8, 2008 Author Share Posted June 8, 2008 Sorry, I still need i clearer example. Had to bump this one. Link to comment https://forums.phpfreaks.com/topic/109310-getting-page-with-out-exploiting-my-server/#findComment-560741 Share on other sites More sharing options...
Minase Posted June 8, 2008 Share Posted June 8, 2008 if my example wasnt clear enough i dont know what can be Link to comment https://forums.phpfreaks.com/topic/109310-getting-page-with-out-exploiting-my-server/#findComment-560771 Share on other sites More sharing options...
ev5unleash Posted June 8, 2008 Author Share Posted June 8, 2008 I get it now thanks Link to comment https://forums.phpfreaks.com/topic/109310-getting-page-with-out-exploiting-my-server/#findComment-560781 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.