Jump to content

Help with PHP GET


radian

Recommended Posts

Can any one help me with the code below? Would it be possible to stop directory transversals and only allow page requests from the pages directory?

 

So e.g. a user won't be able to change directory into the admin folder.

<?php

$p = $_GET['p'];
if ( !empty($p) && file_exists('./pages/' . $p . '.php') && stristr( $p, '.' ) == False ) )
{
   $file = './pages/' . $p . '.php';
}
else
{
   $file = './pages/default.php';
}

include $file;
?> 

Link to comment
https://forums.phpfreaks.com/topic/145476-help-with-php-get/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.