X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=www%2Findex.php;h=d88b3217651b2da70cb14326f55fb2658a026dbd;hb=ea0e53db8b5a264b6e231038815d2c350076d02a;hp=e181d08be794cd052681d5b53582bc9fc72a37c0;hpb=1a748a92f1782578b896c7dbfecb353587c49fe8;p=readifood.git diff --git a/www/index.php b/www/index.php index e181d08..d88b321 100644 --- a/www/index.php +++ b/www/index.php @@ -13,7 +13,8 @@ Propel::init("$propel_root/build/conf/$propel_project-conf.php"); set_include_path(join(PATH_SEPARATOR, array(join(DIRECTORY_SEPARATOR, array($propel_root, "build", "classes")), get_include_path()))); - $request = preg_replace('!^/branches/[^/]+/!', "", $_SERVER['SCRIPT_URL']); + $script_url = array_key_exists('SCRIPT_URL', $_SERVER) ? $_SERVER['SCRIPT_URL'] : $_SERVER['REDIRECT_URL']; + $request = preg_replace('!^/branches/[^/]+/!', "", $script_url); $request = preg_replace('!^/+!', "", $request); $request = preg_replace('!/+$!', "", $request); @@ -29,27 +30,35 @@ #echo "request: $request; module: $module; params: " . print_r($parameters, true); $http = (isset($_SERVER['HTTPS'])) ? "https" : "http"; - $username = $_SERVER['REMOTE_USER']; include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "constants.php"))); include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "functions.php"))); include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "session.php"))); + + $auth0_user = $auth0->getUser(); + if (isset($auth0_user)) $username = $auth0_user["sub"]; + else $username = null; + include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "header.php"))); - $q = new UserQuery; - $user = $q->findOneByUsername($username); - if (! $q->count()) { - echo "

$charity

\n"; - echo "

Not logged in!

\n"; - if ($_SERVER['REMOTE_USER']) echo "

User " . $_SERVER['REMOTE_USER'] . " needs an entry in the user table.

\n"; - } - else { - $user_id = $user->getContactId(); - $admin_level = $user->getAdmin(); - if ($module) { - echo "

$charity $module

\n"; - include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "$module.php"))); + + if ($username) { + $q = new UserQuery; + $user = $q->findOneByUsername($username); + if (! $q->count()) { + echo "

$charity

\n"; + echo "

Not logged in!

\n"; + echo "

User $username needs an entry in the user table.

\n"; } + else { + $user_id = $user->getContactId(); + $admin_level = $user->getAdmin(); + if ($module) { + echo "

$charity $module

\n"; + include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "$module.php"))); + } - #else include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "menu.php"))); - } + #else include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "menu.php"))); + } + } + else $auth0->login(); include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "footer.php"))); ?>