diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-10 21:06:49 +0000 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-10 21:06:49 +0000 |
| commit | 44c3bc48b5db7b3dc6517d2b073a55af5d4b52db (patch) | |
| tree | a48f63061f3cfe5427ce1bc313147cf6be0e739a /series/trunk/admin/chpwd.php | |
| parent | a9a796498285358e7a2f1fde5043e4015de5db70 (diff) | |
| download | instadisc-44c3bc48b5db7b3dc6517d2b073a55af5d4b52db.tar.gz instadisc-44c3bc48b5db7b3dc6517d2b073a55af5d4b52db.tar.bz2 instadisc-44c3bc48b5db7b3dc6517d2b073a55af5d4b52db.zip | |
Series: Moved around directory structure
Refs #55
Diffstat (limited to 'series/trunk/admin/chpwd.php')
| -rw-r--r-- | series/trunk/admin/chpwd.php | 132 |
1 files changed, 132 insertions, 0 deletions
| diff --git a/series/trunk/admin/chpwd.php b/series/trunk/admin/chpwd.php new file mode 100644 index 0000000..2f5368d --- /dev/null +++ b/series/trunk/admin/chpwd.php | |||
| @@ -0,0 +1,132 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* InstaDisc Series - A Four Island Project */ | ||
| 4 | |||
| 5 | /** | ||
| 6 | * require_once() is used to ensure | ||
| 7 | * the ACP files are being called by | ||
| 8 | * admin.php instead of their actual | ||
| 9 | * locations admin/. | ||
| 10 | * The _once() part ensures no problem | ||
| 11 | * arises as includes/instadisc.php has | ||
| 12 | * already been included from admin.php | ||
| 13 | */ | ||
| 14 | require_once('includes/instadisc.php'); | ||
| 15 | |||
| 16 | if (!isset($_SESSION['username'])) | ||
| 17 | { | ||
| 18 | header('Location: index.php'); | ||
| 19 | } | ||
| 20 | |||
| 21 | if (isset($_SESSION['username'])) | ||
| 22 | { | ||
| 23 | if (!isset($_GET['submit'])) | ||
| 24 | { | ||
| 25 | showForm('','','',array()); | ||
| 26 | } else { | ||
| 27 | $numOfErrors = 0; | ||
| 28 | $errors = array(); | ||
| 29 | |||
| 30 | if ($_POST['old'] == '') | ||
| 31 | { | ||
| 32 | addError($numOfErrors, $errors, 'old', 'Old Password is a required field'); | ||
| 33 | } else { | ||
| 34 | if (!instaDisc_verifyUser($_SESSION['username'], $_POST['old'])) | ||
| 35 | { | ||
| 36 | addError($numOfErrors, $errors, 'old', 'Old password is not correct'); | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | if ($_POST['new'] == '') | ||
| 41 | { | ||
| 42 | addError($numOfErrors, $errors, 'new', 'New Password is a required field'); | ||
| 43 | } | ||
| 44 | |||
| 45 | if ($_POST['confirm'] == '') | ||
| 46 | { | ||
| 47 | addError($numOfErrors, $errors, 'confirm', 'Confirm New Password is a required field'); | ||
| 48 | } | ||
| 49 | |||
| 50 | if ($_POST['new'] != $_POST['confirm']) | ||
| 51 | { | ||
| 52 | addError($numOfErrors, $errors, 'confirm', 'Passwords do not match'); | ||
| 53 | } | ||
| 54 | |||
| 55 | if ($numOfErrors > 0) | ||
| 56 | { | ||
| 57 | showForm($_POST['old'], $_POST['new'], $_POST['confirm'], $errors); | ||
| 58 | } else { | ||
| 59 | instaDisc_changePassword( $_POST['new']); | ||
| 60 | |||
| 61 | $template = new FITemplate('changedpassword'); | ||
| 62 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 63 | $template->display(); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } else { | ||
| 67 | header('Location: index.php'); | ||
| 68 | } | ||
| 69 | |||
| 70 | function showForm($old, $new, $confirm, $errors) | ||
| 71 | { | ||
| 72 | $template = new FITemplate('changepassword'); | ||
| 73 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 74 | |||
| 75 | if (isset($errors[1])) | ||
| 76 | { | ||
| 77 | $template->adds_block('ERROR', array('ex'=>'1')); | ||
| 78 | |||
| 79 | foreach ($errors as $name => $value) | ||
| 80 | { | ||
| 81 | $template->adds_block('ERRORS', array( 'NAME' => $name, | ||
| 82 | 'MSG' => $value['msg'])); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | $template->add('OLD_ERR', ifErrors($errors, 'old')); | ||
| 87 | $template->add('NEW_ERR', ifErrors($errors, 'new')); | ||
| 88 | $template->add('CONFIRM_ERR', ifErrors($errors, 'confirm')); | ||
| 89 | |||
| 90 | doErrors($template, $errors, 'old'); | ||
| 91 | doErrors($template, $errors, 'new'); | ||
| 92 | doErrors($template, $errors, 'confirm'); | ||
| 93 | |||
| 94 | $template->add('OLD', $old); | ||
| 95 | $template->add('NEW', $new); | ||
| 96 | $template->add('CONFIRM', $confirm); | ||
| 97 | |||
| 98 | $template->display(); | ||
| 99 | } | ||
| 100 | |||
| 101 | function ifErrors($errors, $id) | ||
| 102 | { | ||
| 103 | foreach ($errors as $name => $value) | ||
| 104 | { | ||
| 105 | if ($value['field'] == $id) | ||
| 106 | { | ||
| 107 | return ' error'; | ||
| 108 | } | ||
| 109 | } | ||
| 110 | |||
| 111 | return ''; | ||
| 112 | } | ||
| 113 | |||
| 114 | function doErrors($template, $errors, $id) | ||
| 115 | { | ||
| 116 | foreach ($errors as $name => $value) | ||
| 117 | { | ||
| 118 | if ($value['field'] == $id) | ||
| 119 | { | ||
| 120 | $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name, | ||
| 121 | 'VALUE' => $value['msg'])); | ||
| 122 | } | ||
| 123 | } | ||
| 124 | } | ||
| 125 | |||
| 126 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
| 127 | { | ||
| 128 | $numOfErrors++; | ||
| 129 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
| 130 | } | ||
| 131 | |||
| 132 | ?> | ||
