Code standards, fix base path at least for php includes and use single quotes more often
[busui.git] / include / common-auth.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
require $basePath.'lib/openid.php';
$openid = new LightOpenID($_SERVER['HTTP_HOST']);
 
function login()
{
 global $openid;
 if(!$openid->mode) {
    $openid->required = array('contact/email');
            $openid->identity = 'https://www.google.com/accounts/o8/id';
            header('Location: ' . $openid->authUrl());
 }
    } 
 
 
function auth()
 
{
  if ($_SESSION['authed'] == true) return true;
 global $openid;
  
  if($openid->mode) {
      $attr = $openid->getAttributes();
        if ($attr["contact/email"] != "maxious@gmail.com") {
            die("Access Denied");
             } else {
               $_SESSION['authed'] = true;
             }
        } else {
        login();
         } 
    }