note 107850 added to features.commandline.webserver

From: Date: Fri, 09 Mar 2012 15:40:32 +0000
Subject: note 107850 added to features.commandline.webserver
Groups: php.notes 
Request: Send a blank email to php-notes+get-186565@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 197.173.51.128 ---- Manual Page -- http://www.php.net/manual/en/features.commandline.webserver.php Edit -- https://master.php.net/note/edit/107850 Del: integrated -- https://master.php.net/note/delete/107850/integrated Del: useless -- https://master.php.net/note/delete/107850/useless Del: bad code -- https://master.php.net/note/delete/107850/bad+code Del: spam -- https://master.php.net/note/delete/107850/spam Del: non-english -- https://master.php.net/note/delete/107850/non-english Del: in docs -- https://master.php.net/note/delete/107850/in+docs Del: other reasons-- https://master.php.net/note/delete/107850 Reject -- https://master.php.net/note/reject/107850 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186565) next »