fixed the qrcode creation dialog
[ga4php.git] / authserver / www / index.php
1 <?php 
2
3 require_once("user_actions.php");
4
5 // first check for a token retreival
6 if(isset($_REQUEST["gettoken"])) {
7         $username = $_REQUEST["username"];
8         $otkid = $_REQUEST["otkid"];
9         $users = $myAC->getUsers();
10         $realname = "";
11         $otk = "";
12         foreach($users as $user) {
13                 if($user["username"] == $username) {
14                         $realname = $user["realname"];
15                         $otk = $user["otk"];
16                 }
17         }
18         
19         if($realname == "") $realname = $username;
20         if($otk == "") {
21 ?>
22 <html>
23 Hello <?php echo $realname?>, we're sorry, but your One Time Key has<br>
24 already been picked up or you dont currently have a token. If you believe<br>
25 this in error, please contact the site admin immediately as it could mean<br>
26 your key has been compromised.<br>
27 </html>
28 <?php
29         exit(0); 
30         }
31         
32         if($otk != $otkid) {
33 ?>
34 <html>
35 Hello <?php echo $realname?>, we're sorry, but your One Time Key ID is not
36 the correct one, the URL you have been sent may be in error, please check with the site admin
37 </html>
38 <?php   
39         }
40         
41         // now actually pick up the key
42         if(isset($_REQUEST["ready"])) {
43 ?>
44 <html>
45 Hello <?php echo $realname?>, welcome to the One Time Key retreival site. Here is your<br>
46 One Time Key. Do not save this anywhere as it will compromise your account<br>
47 <li> Point your phones camera at the screen
48 <li> Watch the display until it locks onto the code
49 <li> Once the code has been scanned, the phone should return to the Google Authenticator with a 6 digit number presented, or a "get code" button.<br><hr>
50 <img src="?action=actuallygettoken&username=<?php echo $username?>&otkid=<?php echo $otkid ?>"><br>
51
52 Once you have the key, you may try logging into the user site <a href="index.php">here</a>
53 </html>
54 <?php 
55         } else {
56 ?>
57 <html>
58 Hello <?php echo $realname?>, welcome to the One Time Key retreival site. Before we present<br>
59 your key, you must have your phone ready to accept it as the key can only be presented once.<br>
60 If your phone is not ready to accept the key, the key needs to be regenerated, so only proceed<br>
61 if you phone is on, you have clicked on "scan account barcode" and the phone is ready to<br>
62 scan the code.<br>
63 <br>
64 If you are ready to proceed, click <a href="index.php?gettoken&username=<?php echo $username?>&ready=true&otkid=<?php echo $otkid?>">here</a>.
65 </html>
66 <?php 
67         }
68         exit(0);
69 }
70
71
72 ?>
73 <html>
74 <h1>Welcome to the GAAS User Site</h1>
75 <?php
76 if(isset($_REQUEST["message"])) {
77         echo "<font color=\"green\">".$_REQUEST["message"]."</font>";
78
79 if(isset($_REQUEST["error"])) {
80         echo "<font color=\"red\">".$_REQUEST["error"]."</font>";
81
82
83 if(!$loggedin) {
84 ?>
85 <form method="post" action="?action=login">
86 Username: <input type="text" name="username"><br>
87 Token Code: <input type="text" name="tokencode"><br>
88 <input type="submit" value="Login">
89 </form>
90 </html>
91 <?php
92         exit(0); 
93 } else {
94 ?>
95
96 Welcome, you have successfully logged into the<br>
97 user site, but there is no content here to view.<br>
98 Later, this site will be where you might resync your<br>
99 token or change pin codes and the like<br>
100 </html>
101
102 <hr><a href="?action=logout">Logout</a>
103
104 <?php 
105 }
106 ?>
107