This repository was archived by the owner on Nov 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
144 lines (126 loc) · 4.46 KB
/
index.php
File metadata and controls
144 lines (126 loc) · 4.46 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
# Move these to index.php config file?
$loginConnName = '127.0.0.1:27017';
$loginDBName = 'slideatlas';
# Logging in with Google $accounts requires setting special identity, so this example shows how to do it.
require 'protected/openid.php';
@$databaseId = $_REQUEST['database'];
@$passwd = $_REQUEST['passwd'];
$openid = new LightOpenID('ayodhya:82');
# First see if OpenID login is called
if(!$openid->mode)
{
if(isset($_REQUEST['login']))
{
$openid->identity = 'https://www.google.com/accounts/o8/id';
$openid->required = array('namePerson/friendly', 'contact/email'); $openid->optional = array('namePerson/first');
// Send the user to authorizing application
header('Location: ' . $openid->authUrl());
return;
}
}
elseif($openid->mode != 'cancel')
{
$arr = $openid->getAttributes();
if($openid->validate())
{
session_destroy();
session_start();
$_SESSION['name'] = $arr['contact/email'];
$_SESSION['start'] = time();
$_SESSION['last_activity'] = time();
$_SESSION['book'] = 'bev1';
$_SESSION['copyright'] = "Copyright © 2011, Charles Palmer, Beverly
Faulkner-Jones and Su-jean Seo. All rights reserved";
$_SESSION['auth'] = 'admin';
header("location:session-index.php");
return;
}
}
# Check for categorical logins
if(isset($databaseId) && isset($passwd))
{
$loginConn = new Mongo('mongodb://' . $loginConnName);
$loginDBColl = $loginConn->selectDB($loginDBName)->selectCollection('databases');
$loginDBDoc = $loginDBColl->findOne(array('_id' => new MongoId($databaseId)));
if(!is_null($loginDBDoc))
{
if($passwd == $loginDBDoc['studentpasswd'] || $passwd == $loginDBDoc['adminpasswd'])
{
session_start();
$_SESSION['host'] = $loginDBDoc['host'];
$_SESSION['book'] = $loginDBDoc['dbname'];
$_SESSION['copyright'] = $loginDBDoc['copyright'];
$_SESSION['auth'] = ($passwd == $loginDBDoc['adminpasswd']) ? 'admin' : 'student';
header("location:session-index.php");
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Slide Atlas</title>
<script src="libs/jquery/jquery-1.7.2.min.js"></script>
<script src="libs/jquery.mobile/jquery.mobile-1.1.0.min.js"></script>
<link rel="stylesheet" href="libs/jquery.mobile/jquery.mobile-1.1.0.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="favicon.ico">
<script src="libs/index.js"></script>
<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<!-- Index pages -->
<div data-role="page">
<!-- Header -->
<div data-role="header" data-position='fixed' data-tap-toggle="false">
<h1>Slide Atlas</h1>
</div>
<!-- Content -->
<div data-role="content">
<p>This website is supported on multiple devices including iPad, iPhone and the latest desktop browsers</p>
<form action="index.php" data-ajax="false" method="post">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<legend>Please choose your affiliation:</legend>
<?php
$loginConn = new Mongo('mongodb://' . $loginConnName);
$loginDBColl = $loginConn->selectDB($loginDBName)->selectCollection('databases');
foreach ($loginDBColl->find() as $loginDBDoc)
{
echo '<input type="radio" name="database" id="' , $loginDBDoc['_id'], '" value="' , $loginDBDoc['_id'] , '">', "\n";
echo '<label for="' , $loginDBDoc['_id'] , '">' , $loginDBDoc['label'] , '</label>', "\n";
}
?>
</fieldset>
</div>
<div data-role="fieldcontain">
<label for="password">Password:</label>
<input type="password" name="passwd" id="password" value="">
</div>
<div data-role="fieldcontain" class="btn-container">
<button type="submit" data-inline="true" data-theme="a">Submit</button>
</div>
</form>
<!-- login
Or authenticate using :
<form action="?login" method="post" data-ajax="false">
<center>
<button data-theme="a" data-inline="true" data-ajax="false">Google</button>
</center>
</form>
-->
<div>
<p>Or authenticate using :</p>
<div class="btn-container">
<a data-role="button" data-theme="a" data-inline="true" data-ajax="false" href="facebook_module.php">Facebook</a>
</div>
</div>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>