<?php

function displayError($message) {
    $error = $message;
    include("login.inc");
    exit(0);
}

function doIncludes() {
    /**
     * Require the OpenID consumer code.
     */
    require_once "consumer.inc";

    /**
     * Require the "file store" module, which we'll need to store
     * OpenID information.
     */
    require_once "filestore.inc";

    /**
     * Require the Simple Registration extension API.
     */
    require_once "sreg.inc";

    /**
     * Require the PAPE extension module.
     */
    require_once "pape.inc";
}

doIncludes();

global $pape_policy_uris;
$pape_policy_uris = array(
			  PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
			  PAPE_AUTH_MULTI_FACTOR,
			  PAPE_AUTH_PHISHING_RESISTANT
			  );

function &getStore() {
    /**
     * This is where the example will store its OpenID information.
     * You should change this path if you want the example store to be
     * created elsewhere.  After you're done playing with the example
     * script, you'll have to remove this directory manually.
     */
    $store_path = "/tmp";

    if (!file_exists($store_path) &&
        !mkdir($store_path)) {
        print "Could not create the FileStore directory '$store_path'. ".
            " Please check the effective permissions.";
        exit(0);
    }

    return new Auth_OpenID_FileStore($store_path);
}

function &getConsumer() {
    /**
     * Create a consumer object using the store object created
     * earlier.
     */
    $store = getStore();
    return new Auth_OpenID_Consumer($store);
}

function getReturnTo() {
    return sprintf("https://%s%s/",
                   $_SERVER['SERVER_NAME'],
                   dirname($_SERVER['PHP_SELF']));
}

function getTrustRoot() {
    return sprintf("https://%s%s/",
                   $_SERVER['SERVER_NAME'],
                   dirname($_SERVER['PHP_SELF']));
}

?>