Directory guards

A _guard.php in a directory decides, for every page below it, whether the request may see the page - before any _inits.php or page PHP runs. Access control follows the file tree: put one in admin/ and every page there is protected, with no list of routes to keep in step.

The guard of this manual's guarded/ directory:

<?php

// The pages in this directory open only to a request that says ?pass=yes.

return padRequest ( 'pass' ) === 'yes';

?>

This request did not say ?pass=yes, so the included page stays empty:

PHP
HTML
fragments/directory_guards_1.pad
Result
<p>Included: [{page 'guarded/secret'}]</p>

Included: []