Automad
 All Classes Functions Variables Pages
install.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  * As part of the GUI, this file is only to be included via the GUI class.
43  * The installer creates a file called "accounts.txt" to be installed in /config.
44  */
45 
46 
47 if ($_POST) {
48 
49  if ($_POST['username'] && $_POST['password1'] && ($_POST['password1'] === $_POST['password2'])) {
50 
51  $accounts = array();
52  $accounts[$_POST['username']] = $this->passwordHash($_POST['password1']);
53 
54  // Download accounts.php
55  header('Expires: -1');
56  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
57  header('Pragma: public');
58  header('Content-Type: application/octet-stream');
59  header('Content-Transfer-Encoding: binary');
60  header('Content-Disposition: attachment; filename=' . basename(AM_FILE_ACCOUNTS));
61  ob_end_flush();
62  echo $this->accountsGeneratePHP($accounts);
63  die;
64 
65  } else {
66 
67  $error = $this->tb['error_form'];
68 
69  }
70 
71 }
72 
73 
74 $this->guiTitle = $this->guiTitle . ' / ' . $this->tb['install_title'];
75 $this->element('header');
76 
77 
78 ?>
79 
80  <div class="column content">
81  <div class="inner">
82  <div class="alert alert-info"><?php echo $this->tb['install_help']; ?></div>
83  <?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 } ?>
84  <form role="form" method="post">
85  <div class="form-group">
86  <label for="username"><?php echo $this->tb['sys_user_add_name']; ?></label>
87  <input id="username" class="form-control" type="text" name="username" required />
88  </div>
89  <div class="form-group">
90  <label for="password1"><?php echo $this->tb['sys_user_add_password']; ?></label>
91  <input id="password1" class="form-control" type="password" name="password1" required />
92  </div>
93  <div class="form-group">
94  <label for="password2"><?php echo $this->tb['sys_user_add_repeat']; ?></label>
95  <input id="password2" class="form-control" type="password" name="password2" required />
96  </div>
97  <br />
98  <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-save"></span> <?php echo $this->tb['btn_accounts_file']; ?></button>
99  </form>
100  </div>
101  </div>
102 
103 <?php
104 
105 
106 $this->element('footer');
107 
108 
109 ?>