--- a/lib/common.inc.php
+++ b/lib/common.inc.php
@@ -8,6 +8,41 @@
if (!$conn) {
die("A database error occurred.\n");
+}
+
+define('ROOT' , pathinfo(__FILE__, PATHINFO_DIRNAME));
+if (strstr($_SERVER['PHP_SELF'], "labs/")) {
+ $basePath = "../";
+}
+
+require ROOT . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'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() {
+ global $openid;
+ if ($_SESSION['authed'] == true) {
+ return true;
+ }
+
+ if ($openid->mode) {
+ $attr = $openid->getAttributes();
+ if ($attr['contact/email'] != 'maxious@gmail.com') {
+ die('Access Denied');
+ } else {
+ $_SESSION['authed'] = true;
+ }
+ } else {
+ login();
+ }
}
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -104,14 +139,14 @@
@import "media/css/demo_table.css";
-
+