PHAS Intranet Site (secure.phas.ubc.ca)

Date: 2013-03-12

Note: The dark-green font indicates recent updates concerned with improving the security of the site.

Site Overview

Site Mechanics

  1. All executable PHP files begin with something like:
    <?php
    require_once ("/wwws/functions.php");
    $user=sessbegin();                      // are they logged in (session started)?
    require_once ("auth.php");
    auth($user);                            // are they allowed to see this page?
    require_once ("/wwws/default.php");
    $mainitem = "Forms";
    phasbegin();                            // show site-wide banner and navigation
    // begin content --------------------------------------------------------------------
     
  2. , and end with something like:
    // end content --------------------------------------------------------------------
    phasend();
    ?>

  3. The call to sessbegin() ensures that the user is authenticated.  It will redirect to login.php if not.

  4. The local auth.php scripts ensure that the user is allowed to run the scripts in each directory.
    They define the local auth($user) functions which:
    Eg.
    function auth($user) {
    // function to determine whether this user is allowed to see a page
    // in this directory.  Calls "allow" function with right parameters.
    // If result is false, redirects to rejection page
       require_once('/wwws/functions.php');
       require_once('db_connect.php');

       if ( isset($user) ) {
    // the parameters passed to allow function are specific to this directory
          #if ( ! allow('gradstudents',$user) ) {
            if ( ! is_GradAdmin($user)) ) {
            // not allowed - redirect to rejection page
           $redirect_url = "/reject.php";
           header ("Location: $redirect_url");
          }
       } else {    // not logged in yet - redirect to Login page
          $redirect_url = "/login.php";
          header ("Location: $redirect_url");
       }
    }  // if didn't get redirected then return and continue

  5. The calls to phasbegin() and phasend() provide the site-wide look and feel elements.
    The $mainitem variable controls which button is highlighted in the navigation bar.

Files in DocumentRoot - /var/www/shtml (aka /wwws)


Files in /usr/local/lib/php

  1. Session Management
  2. db_connect.php (Database Access)
  3. db_access.php (Application Access)
  4. form_validation.php (Input Validation) - 2012-12-10

To-Do List