note 107850 deleted from features.commandline.webserver by danbrown

From: Date: Wed, 04 Apr 2012 15:40:39 +0000
Subject: note 107850 deleted from features.commandline.webserver by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-186967@lists.php.net to get a copy of this message
Note Submitter: Stefano F. Rausch ---- The router example from Ralph Schindler's mail http://news.php.net/php.internals/53870: didn't work for me. I had to make some minimal changes: <?php /* OR if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"])) */ if ( is_file( $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'] ) ) { // if ( !preg_match( '/^\/folder\/path\/to\/deny\/access\/to\//', $_SERVER['REQUEST_URI'] ) && is_file( $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'] ) ) { return false; // access granted } else { require_once 'access/secured/folder/path/error.handler.php'; } ?> I had to swap the __DIR__ constant to be able to put the error.handler.php file wherever I want it. In my case it is located in the access/secured/folder too :) Furthermore I had to swap the file_exists function call. Reason: this function doesn't distinguish files from folders and hence a check of a generic request e.g. http://test.web.site/ did not trigger error.handler.php as expected. Now everything is fine. Last but not least I wanted to try to "block" a specific folder for obvious reasons. It works like a charm. HTTP requests are blocked and include / require directives have full access.

« previous php.notes (#186967) next »