Automad
 All Classes Functions Variables Pages
login.php
1 <?php
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  * AUTOMAD
29  *
30  * Copyright (c) 2014 by Marc Anton Dahmen
31  * http://marcdahmen.de
32  *
33  * Licensed under the MIT license.
34  * http://automad.org/license
35  */
36 
37 
38 defined('AUTOMAD') or die('Direct access not permitted!');
39 
40 
41 /*
42  * The GUI Login Page. As part of the GUI, this file is only to be included via the GUI class.
43  */
44 
45 
46 if ($_POST) {
47 
48  $username = $_POST['username'];
49  $password = $_POST['password'];
50  $accounts = $this->accountsGetArray();
51 
52  if (isset($accounts[$username]) && $this->passwordVerified($password, $accounts[$username])) {
53 
54  session_regenerate_id(true);
55  $_SESSION['username'] = $username;
56  header('Location: ' . $_SERVER['REQUEST_URI']);
57  die;
58 
59  } else {
60 
61  $error = $this->tb['error_login'];
62 
63  }
64 
65 }
66 
67 
68 $this->guiTitle = $this->guiTitle . ' / ' . $this->tb['login_title'];
69 $this->element('header');
70 
71 
72 ?>
73 
74  <div class="column content">
75  <div class="inner">
76  <?php if (isset($error)) { ?><div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><?php echo $error; ?></div><?php } ?>
77  <form role="form" method="post">
78  <div class="form-group">
79  <label for="username">Username</label>
80  <input id="username" class="form-control" type="text" name="username" />
81  </div>
82  <div class="form-group">
83  <label for="password">Password</label>
84  <input id="password" class="form-control" type="password" name="password" />
85  </div>
86  <br />
87  <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-arrow-right"></span> <?php echo $this->tb['btn_login']; ?></button>
88  </form>
89  </div>
90  </div>
91 
92 <?php
93 
94 
95 $this->element('footer');
96 
97 
98 ?>