Example #1
0
/**
 * Validate client
 *
 * Displays the login page if the client is not validated.
 */
function validate_client()
{
    global $conf;
    if ($conf['authenticate_user'] && (!isset($_SESSION['client']['userdbo']) || $_SESSION['client']['userdbo']->getType() == "Client")) {
        $_GET['page'] = $conf['login_page'];
        $_GET['no_headers'] = 1;
        $class = get_page_class($_GET['page']);
        require_once BASE_PATH . $conf['pages'][$class]['class_file'];
    }
    // Client is valid
    return true;
}
Example #2
0
/**
 * Get Page Object
 *
 * Instantiates a Page object for the request page provided by the
 * 'page' parameter in the URL.
 *
 * @param array $conf Configuration data
 * @param object $smarty Smarty template object
 * @return Page A reference to the page object.  If the page parameter is invalid, null is returned.
 */
function &get_page_object($conf, $smarty)
{
    if (!isset($_GET['page'])) {
        // No page parameter is provided, set to home page
        $_GET['page'] = $conf['home_page'];
    }
    // Find the requested Page object
    $requested_page_name = $_GET['page'];
    $page_class = get_page_class($requested_page_name);
    // Verify the requested page was found
    if ($page_class == null) {
        throw new SWException("Could not find the requested page name: " . $requested_page_name);
    }
    // Instantiate an object for the requested page and return as a reference
    $page_obj = new $page_class();
    // Set the class name - workaround for PHP 5 get_class behavior.
    $page_obj->class_name = $page_class;
    $page_obj->load($conf, $smarty);
    if ($page_obj->isDisabled()) {
        throw new SWException("This page has been disabled");
    }
    if (method_exists($page_obj, 'init')) {
        // init() function takes on the role of a contructor for Page objects
        $page_obj->init();
    }
    // Remove any page data from the session of Pages other than this one
    foreach ($conf['pages'] as $page_class_name => $page_conf) {
        if ($page_conf['name'] != $requested_page_name) {
            // Not data for this page - remove from session
            unset($_SESSION[$page_conf['name']]);
        }
    }
    return $page_obj;
}