Fork me on GitHub

You are here

Logical AND

Being only 10 minutes at work I already saved the day for a colleague. :)

I have installed a replacement server for the helpdesk website, and to make it a *little* more secure I set some restrictions in the php.ini file. E.g. I set the open_basedir retriction to a specific directory.

While the website is being migrated and tested there are a couple of PHP warnings that need to be fixed. For instance:

Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(..) is not within the allowed path(s): (/var/www/helpdesk) in /var/www/helpdesk/sitemap.php on line 264

Warning: is_file() [function.is-file]: open_basedir restriction in effect. File(..) is not within the allowed path(s): (/var/www/helpdesk) in /var/www/helpdesk/sitemap.php on line 267

Looking at the PHP code it was obvious:

$handle = opendir('.');
while ($file = readdir($handle)){
if( is_dir($file) && $file != "." && $file != ".." && !in_array($file, $excludedir)){...}
elseif( is_file($file) && $file != "$self" && array_key_exists(get_extension($file), $display) && !in_array($file, $excludefile)) {...}
}
Because opendir opens '..' and it isn't allowed, because of the open_basedir restriction, we get the two errors above.

Changing the code so that the is_dir and is_file function is called after the $file != "." && $file != ".." checks fixes the error.

 

 

Comments

Education is the part of everyone life and that would empower people to boost their knowledge to become a successful person. I really like your wonderful http://www.superiorpaper.net/ website with the thoughtful and informative article. Various people today using the advanced technology to boost their business product popularity.

Now we understand that you want quality for the money you spend for 1Z0-061 exam dumps. We guarantee quality 1Z0-061 practice exam with best results in your real 1Z0-061 exam. https://www.examsbuzz.com/

Add new comment