summaryrefslogtreecommitdiff
path: root/shell/login.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-11-27 11:22:36 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-11-27 11:22:36 -0500
commit3d6790614bb0dc776e02a95835e5c274263d1d1a (patch)
treeaad032777fccb7fbdc80551a6f89f4bb4845a510 /shell/login.php
parent66c84cedfb411ad6ca0508d9f45d6d33c8ad474d (diff)
This zip file was identified as ltshell-3.zip
Diffstat (limited to 'shell/login.php')
-rw-r--r--shell/login.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/shell/login.php b/shell/login.php
new file mode 100644
index 0000000..eff6eca
--- /dev/null
+++ b/shell/login.php
@@ -0,0 +1,59 @@
+<?php if (!isset($LTS)) { die(); }
+
+// BEGIN AUTH CODE /////////////////////////////////////////////////////////////
+global $auth_html;
+include_once('lightopenid.php');
+@session_start();
+if ( isset($_SESSION['user']) && ($_SESSION['user']!='') ) {
+ // someone is already logged in
+ if ( isset($_GET['openid_mode']) && ($_GET['openid_mode']=='logout') ) {
+ // logout
+ $auth_html.='<p>'.$_SESSION['user'].' is now logged out</p>';
+ $_SESSION['user']='';
+ } else {
+ $auth_html.='
+ <p>Currently logged in as '.$_SESSION['user'].'.</p>
+ <form action="" method="get">
+ <input type="hidden" name="openid_mode" value="logout" />
+ <input type="submit" value="Log Out" />
+ </form>
+ ';
+ }
+} else {
+ // not already logged in
+ try {
+ if(!isset($_GET['openid_mode'])) {
+ if(isset($_POST['openid_identifier'])) {
+ $openid = new LightOpenID;
+ $openid->identity = $_POST['openid_identifier'];
+ header('Location: ' . $openid->authUrl());
+ }
+ $auth_html.='
+ <form action="" method="post">
+ OpenID: <input type="text" name="openid_identifier" /> <input type="submit" value="Submit" />
+ </form>
+ ';
+ } elseif($_GET['openid_mode'] == 'cancel') {
+ $auth_html.='<p>User has canceled authentication!</p>';
+ } else {
+ $openid = new LightOpenID;
+ if ($openid->validate()) {
+ // is logged in
+ global $users;
+ include_once('passwd.php');
+ if (in_array($openid->identity,$users)) {
+ $_SESSION['user']=$openid->identity;
+ $auth_html.='<p>Welcome, '.$_SESSION['user'].'!</p>';
+ } else {
+ $auth_html.='<p>Authentication was successful, but '.$openid->identity.' is not an authorized user.</p>';
+ }
+ } else {
+ // is not logged in
+ $auth_html.='<p>User '.$openid->identity.' is not logged in </p>';
+ }
+ }
+ } catch(ErrorException $e) {
+ $auth_html.=$e->getMessage();
+ }
+}
+// END AUTH CODE ///////////////////////////////////////////////////////////////