diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-28 21:40:47 +0000 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-28 21:40:47 +0000 |
| commit | fb1b67b6922a20fdc3538dd6ae4659dfc1d8d7d2 (patch) | |
| tree | 9ad7b7c72f451fd5bdcb2c33a6586c586309ab10 /central/trunk/changepassword.php | |
| parent | 9d6ed35e4faa192ea734bfc353a6be65b977a6e6 (diff) | |
| download | instadisc-fb1b67b6922a20fdc3538dd6ae4659dfc1d8d7d2.tar.gz instadisc-fb1b67b6922a20fdc3538dd6ae4659dfc1d8d7d2.tar.bz2 instadisc-fb1b67b6922a20fdc3538dd6ae4659dfc1d8d7d2.zip | |
Central: Removed UI
Refs #63
Diffstat (limited to 'central/trunk/changepassword.php')
| -rw-r--r-- | central/trunk/changepassword.php | 119 |
1 files changed, 0 insertions, 119 deletions
| diff --git a/central/trunk/changepassword.php b/central/trunk/changepassword.php deleted file mode 100644 index 1b92666..0000000 --- a/central/trunk/changepassword.php +++ /dev/null | |||
| @@ -1,119 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* InstaDisc Server - A Four Island Project */ | ||
| 4 | |||
| 5 | include('includes/instadisc.php'); | ||
| 6 | include('includes/template.php'); | ||
| 7 | |||
| 8 | if (isset($_SESSION['username'])) | ||
| 9 | { | ||
| 10 | if (!isset($_GET['submit'])) | ||
| 11 | { | ||
| 12 | showForm('','','',array()); | ||
| 13 | } else { | ||
| 14 | $numOfErrors = 0; | ||
| 15 | $errors = array(); | ||
| 16 | |||
| 17 | if ($_POST['old'] == '') | ||
| 18 | { | ||
| 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 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | if ($_POST['new'] == '') | ||
| 28 | { | ||
| 29 | addError($numOfErrors, $errors, 'new', 'New Password is a required field'); | ||
| 30 | } | ||
| 31 | |||
| 32 | if ($_POST['confirm'] == '') | ||
| 33 | { | ||
| 34 | addError($numOfErrors, $errors, 'confirm', 'Confirm New Password is a required field'); | ||
| 35 | } | ||
| 36 | |||
| 37 | if ($_POST['new'] != $_POST['confirm']) | ||
| 38 | { | ||
| 39 | addError($numOfErrors, $errors, 'confirm', 'Passwords do not match'); | ||
| 40 | } | ||
| 41 | |||
| 42 | if ($numOfErrors > 0) | ||
| 43 | { | ||
| 44 | showForm($_POST['old'], $_POST['new'], $_POST['confirm'], $errors); | ||
| 45 | } else { | ||
| 46 | instaDisc_changePassword($_SESSION['username'], $_POST['new']); | ||
| 47 | |||
| 48 | $template = new FITemplate('changedpassword'); | ||
| 49 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 50 | $template->display(); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } else { | ||
| 54 | header('Location: index.php'); | ||
| 55 | } | ||
| 56 | |||
| 57 | function showForm($old, $new, $confirm, $errors) | ||
| 58 | { | ||
| 59 | $template = new FITemplate('changepassword'); | ||
| 60 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 61 | |||
| 62 | if (isset($errors[1])) | ||
| 63 | { | ||
| 64 | $template->adds_block('ERROR', array('ex'=>'1')); | ||
| 65 | |||
| 66 | foreach ($errors as $name => $value) | ||
| 67 | { | ||
| 68 | $template->adds_block('ERRORS', array( 'NAME' => $name, | ||
| 69 | 'MSG' => $value['msg'])); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | $template->add('OLD_ERR', ifErrors($errors, 'old')); | ||
| 74 | $template->add('NEW_ERR', ifErrors($errors, 'new')); | ||
| 75 | $template->add('CONFIRM_ERR', ifErrors($errors, 'confirm')); | ||
| 76 | |||
| 77 | doErrors($template, $errors, 'old'); | ||
| 78 | doErrors($template, $errors, 'new'); | ||
| 79 | doErrors($template, $errors, 'confirm'); | ||
| 80 | |||
| 81 | $template->add('OLD', $old); | ||
| 82 | $template->add('NEW', $new); | ||
| 83 | $template->add('CONFIRM', $confirm); | ||
| 84 | |||
| 85 | $template->display(); | ||
| 86 | } | ||
| 87 | |||
| 88 | function ifErrors($errors, $id) | ||
| 89 | { | ||
| 90 | foreach ($errors as $name => $value) | ||
| 91 | { | ||
| 92 | if ($value['field'] == $id) | ||
| 93 | { | ||
| 94 | return ' error'; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | return ''; | ||
| 99 | } | ||
| 100 | |||
| 101 | function doErrors($template, $errors, $id) | ||
| 102 | { | ||
| 103 | foreach ($errors as $name => $value) | ||
| 104 | { | ||
| 105 | if ($value['field'] == $id) | ||
| 106 | { | ||
| 107 | $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name, | ||
| 108 | 'VALUE' => $value['msg'])); | ||
| 109 | } | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
| 114 | { | ||
| 115 | $numOfErrors++; | ||
| 116 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
| 117 | } | ||
| 118 | |||
| 119 | ?> | ||
