Lighttpd conf file added for lighttpd webservers
[atbbs.git] / restore_id.php
blobe82494ffd2b37b8321ef8cff129769728d46d39a
1 <?php
2 require('includes/header.php');
3 update_activity('restore_id');
4 $page_title = 'Restore ID';
5 $onload_javascript = 'focusId(\'memorable_name\')';
7 // If an ID card was uploaded...
8 if(isset($_POST['do_upload']))
10 list($uid, $password) = file($_FILES['id_card']['tmp_name'], FILE_IGNORE_NEW_LINES);
12 // ... or an ID and password was inputted...
13 else if(!empty($_POST['UID']) && !empty($_POST['password']))
15 $uid = $_POST['UID'];
16 $password = $_POST['password'];
18 // ...or a link from a recovery e-mail is being used...
19 else if(!empty($_GET['UID']) && !empty($_GET['password']))
21 $uid = $_GET['UID'];
22 $password = $_GET['password'];
24 // ... or a memorable name was inputted ...
25 else if(!empty($_POST['memorable_name']))
27 $stmt = $link->prepare('SELECT user_settings.uid, users.password FROM user_settings INNER JOIN users ON user_settings.uid = users.uid WHERE LOWER(user_settings.memorable_name) = LOWER(?) AND user_settings.memorable_password = ?');
28 $stmt->bind_param('ss', $_POST['memorable_name'], $_POST['memorable_password']);
29 $stmt->execute();
30 $stmt->bind_result($uid, $password);
31 $stmt->fetch();
32 $stmt->close();
34 if(empty($uid))
36 add_error('Your memorable information was incorrect.');
40 if(!empty($uid))
42 $stmt = $link->prepare('SELECT password FROM users WHERE uid = ?');
43 $stmt->bind_param('s', $uid);
44 $stmt->execute();
45 $stmt->bind_result($db_password);
46 $stmt->fetch();
47 $stmt->close();
49 if(empty($db_password))
51 add_error('There is no such UID.');
53 else if($password != $db_password)
55 add_error('Incorrect password.');
57 else {
58 $_SESSION['UID'] = $uid;
59 $_SESSION['ID_activated'] = true;
60 setcookie('UID', $uid, $_SERVER['REQUEST_TIME'] + 315569260, '/');
61 setcookie('password', $password, $_SERVER['REQUEST_TIME'] + 315569260, '/');
63 $stmt = $link->prepare('SELECT spoiler_mode, topics_mode, ostrich_mode, snippet_length FROM user_settings WHERE uid = ?');
64 $stmt->bind_param('s', $uid);
65 $stmt->execute();
66 $stmt->bind_result($user_config['spoiler_mode'], $user_config['topics_mode'], $user_config['ostrich_mode'], $user_config['snippet_length']);
67 $stmt->fetch();
68 $stmt->close();
70 foreach($user_config as $key => $value)
72 if($value != 0)
74 setcookie($key, $value, $_SERVER['REQUEST_TIME'] + 315569260, '/');
78 $_SESSION['notice'] = 'Welcome back.';
79 header('Location: ' . DOMAIN);
80 exit;
81 // Get settings, etc.
85 print_errors();
89 <p>Your internal ID can be restored in a number of ways. If none of these work, you may be able to <a href="/recover_ID_by_email">recover your ID by e-mail</a>.
91 <p>Here are your options:</p>
93 <fieldset>
94 <legend>Input memorable name and password</legend>
96 <p>Memorable information can be set from the <a href="/dashboard">dashboard</a></p>
98 <form action="" method="post">
99 <div class="row">
100 <label for="memorable_name">Memorable name</label>
101 <input type="text" id="memorable_name" name="memorable_name" maxlength="100" />
102 </div>
103 <div class="row">
104 <label for="memorable_password">Memorable password</label>
105 <input type="password" id="memorable_password" name="memorable_password" />
106 </div>
107 <div class="row">
108 <input type="submit" value="Restore" />
109 </div>
110 </form>
112 </fieldset>
114 <fieldset>
115 <legend>Input UID and password</legend>
117 <p>Your internal ID and password are automatically set upon creation of your ID. They are available from the <a href="/back_up_ID">back up</a> page.</p>
119 <form action="" method="post">
120 <div class="row">
121 <label for="UID">Internal ID</label>
122 <input type="text" id="UID" name="UID" size="23" maxlength="23" />
123 </div>
124 <div class="row">
125 <label for="password">Internal password</label>
126 <input type="password" id="password" name="password" size="32" maxlength="32" />
127 </div>
128 <div class="row">
129 <input type="submit" value="Restore" />
130 </div>
131 </form>
133 </fieldset>
135 <fieldset>
136 <legend>Upload ID card</legend>
138 <p>If you have an <a href="/generate_ID_card">ID card</a>, upload it here.</p>
140 <form enctype="multipart/form-data" action="" method="post">
141 <div class="row">
142 <input name="id_card" type="file" />
143 </div>
144 <div class="row">
145 <input name="do_upload" type="submit" value="Upload and restore" />
146 </div>
147 </form>
149 </fieldset>
151 <?php
152 require('includes/footer.php');