R8kit Posted September 11, 2011 Share Posted September 11, 2011 Hey everyone, I am trying to secure php includes and I wrote the following lines: <?php $dir=scandir('.'); if (in_array('copyright.php',$dir)) { include('copyright.php'); } else { echo 'That page could not be found'; } ?> Is this code secure enough, can anyone help me improve it? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/246933-securing-php-includes/ Share on other sites More sharing options...
Pandemikk Posted September 11, 2011 Share Posted September 11, 2011 http://php.net/manual/en/function.file-exists.php <?php $filename = '/path/to/copyright.php'; if (file_exists($filename)) { include('copyright.php'); } else { echo "The file $filename does not exist"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/246933-securing-php-includes/#findComment-1268164 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.