about summary refs log tree commit diff stats
path: root/central/trunk/changepassword.php
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2008-08-16 17:23:44 +0000
committerKelly Rauchenberger <fefferburbia@gmail.com>2008-08-16 17:23:44 +0000
commit3163329b8a8da24b8e388d4309f99cf2c6742a19 (patch)
tree772f685772b673b7515d70f219e0ea7a98ecc63c /central/trunk/changepassword.php
parent01669b5b3e38d4fd1138034458ad1e9339c8cf9c (diff)
downloadinstadisc-3163329b8a8da24b8e388d4309f99cf2c6742a19.tar.gz
instadisc-3163329b8a8da24b8e388d4309f99cf2c6742a19.tar.bz2
instadisc-3163329b8a8da24b8e388d4309f99cf2c6742a19.zip
Central: Added logout page
Also modified Change Password to lock out non logged-in users and to use the instaDisc_verifyUser() functions instead of inlining it. Refs #25
Diffstat (limited to 'central/trunk/changepassword.php')
-rw-r--r--central/trunk/changepassword.php69
1 files changed, 35 insertions, 34 deletions
diff --git a/central/trunk/changepassword.php b/central/trunk/changepassword.php index 84c7110..81fc5a7 100644 --- a/central/trunk/changepassword.php +++ b/central/trunk/changepassword.php
@@ -5,52 +5,53 @@
5include('includes/instadisc.php'); 5include('includes/instadisc.php');
6include('includes/template.php'); 6include('includes/template.php');
7 7
8if (!isset($_GET['submit'])) 8if (isset($_SESSION['username']))
9{ 9{
10 showForm('','','',array()); 10 if (!isset($_GET['submit']))
11} else {
12 $numOfErrors = 0;
13 $errors = array();
14
15 if ($_POST['old'] == '')
16 { 11 {
17 addError($numOfErrors, $errors, 'old', 'Old Password is a required field'); 12 showForm('','','',array());
18 } else { 13 } else {
19 $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($_SESSION['username']) . "\" AND password = \"" . mysql_real_escape_string(md5($_POST['old'])) . "\""; 14 $numOfErrors = 0;
20 $getuser2 = mysql_query($getuser); 15 $errors = array();
21 $getuser3 = mysql_fetch_array($getuser2);
22 16
23 if ($getuser3['password'] != md5($_POST['password'])) 17 if ($_POST['old'] == '')
24 { 18 {
25 addError($numOfErrors, $errors, 'old', 'Old password is not correct'); 19 addError($numOfErrors, $errors, 'old', 'Old Password is a required field');
20 } else {
21 if (!instaDisc_verifyUser($_SESSION['username'], $_POST['old'])
22 {
23 addError($numOfErrors, $errors, 'old', 'Old password is not correct');
24 }
26 } 25 }
27 }
28 26
29 if ($_POST['new'] == '') 27 if ($_POST['new'] == '')
30 { 28 {
31 addError($numOfErrors, $errors, 'new', 'New Password is a required field'); 29 addError($numOfErrors, $errors, 'new', 'New Password is a required field');
32 } 30 }
33 31
34 if ($_POST['confirm'] == '') 32 if ($_POST['confirm'] == '')
35 { 33 {
36 addError($numOfErrors, $errors, 'confirm', 'Confirm New Password is a required field'); 34 addError($numOfErrors, $errors, 'confirm', 'Confirm New Password is a required field');
37 } 35 }
38 36
39 if ($_POST['new'] != $_POST['confirm']) 37 if ($_POST['new'] != $_POST['confirm'])
40 { 38 {
41 addError($numOfErrors, $errors, 'confirm', 'Passwords do not match'); 39 addError($numOfErrors, $errors, 'confirm', 'Passwords do not match');
42 } 40 }
43 41
44 if ($numOfErrors > 0) 42 if ($numOfErrors > 0)
45 { 43 {
46 showForm($_POST['old'], $_POST['new'], $_POST['confirm'], $errors); 44 showForm($_POST['old'], $_POST['new'], $_POST['confirm'], $errors);
47 } else { 45 } else {
48 instaDisc_changePassword($_SESSION['username'], $_POST['new']); 46 instaDisc_changePassword($_SESSION['username'], $_POST['new']);
49 47
50 $template = new FITemplate('changedpassword'); 48 $template = new FITemplate('changedpassword');
51 $template->add('SITENAME', instaDisc_getConfig('siteName')); 49 $template->add('SITENAME', instaDisc_getConfig('siteName'));
52 $template->display(); 50 $template->display();
51 }
53 } 52 }
53} else {
54 header('Location: index.php');
54} 55}
55 56
56function showForm($old, $new, $confirm, $errors) 57function showForm($old, $new, $confirm, $errors)