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';
?>
FALSE - or anything that is not true: NULL,
0, '' - refuses the page with 403 Forbidden. Returning
TRUE, or no return at all, lets the request through to the next guard down._lib files, so a guard can call the application's functions and read the session
and request variables - and $padPage, to decide per page.padRedirect ( 'login' ).This request did not say ?pass=yes, so the included page stays empty:
|
PHP |
HTML fragments/directory_guards_1.pad |
Result |
|---|---|---|
|
Included: [] |