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. 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/246933-securing-php-includes/#findComment-1268164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.