PHP Below the Root - Part 2

In the last part I discussed the file structure. Everything will come from one main script, (i.e. index.php)

that script will have the minimum of code, everything else will be fed from deeper libraries.

index.php

session_start();
ini_set('display_errors', 1);
 
// define base wanda path, below web root
 
$home = $_SERVER['SCRIPT_FILENAME'];
$loc = explode('/',$home);
 
define('WANDA_BASE', implode('/',array_slice($loc,0,-2)).'/');
 
// Hand over to the page handler
require WANDA_BASE.'wanda/inc/pagelib.php';

Thats it. What it does is define the path WANDA_BASE to below web root, then goes and includes the pagelib.php file, which partly includes much of what is needed to get around in the directories.

pagelib.php part 1

//define directory constants
 
// home page
    define('WANDA_INDEX', $home);
 
// above root libraries
    define('WANDA_LIB', implode('/',array_slice($loc,0,-1)).'/wanda2/');
 
// above root icon images
    define('WANDA_ICON', 'wanda2/icon/');
 
// above root images
    define('WANDA_IMAGE', 'wanda2/image/');
 
// below root apps folder
    define('WANDA_APPS', WANDA_BASE.'wanda/app/');
 
// below root includes (function libraries) folder
    define('WANDA_INC', WANDA_BASE.'wanda/inc/');
 
// System configurations folder (db settings, etc.
    define('WANDA_CONF', WANDA_BASE.'wanda/conf/');

Where to go from here?

so to call different programs we will need to have a system to have the core script make available or access the programs that will not be browser accessible.

The big challenge was figuring out where to go from here. I've devised three modes:

  • Nothing specified - goes to a menu or log in screen.
  • Direct call to a page pre-set for direct access i.e: index.pho?do=claendar - these would be pages that do not require an access restriction, nor are dependent on data from other pages. Note the name such as “calendar” does not have anything to do with the path or the script name… more on that later.
  • Go to a page called by another page - these pages are from a list pre-generated by the menu or another page withn the system - only available when made available. The third mode actually works in two different ways:
    • Go to a series of sub pages in a chain of pages, and upon completion be able to return to the previous calling page (i.e. search → information → edit → sub-element search → confirm then be able to go back again…)
    • Or go to a report page - this would be a page not part of a chain of pages, but does not affect the chain in progress - like the direct page option but only accessible via the calling page. such as a pre-filled form or something that opens in a new window or tab. There could be a case of it having its own input form so it needs to have a semi static listing on the page list.

next

Next up I will go about highlighting some of the page access magic.

~~LINKBACK~~ ~~DISCUSSION~~

Last modified:: 2020/11/22 08:55
   
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International