about summary refs log tree commit diff stats
path: root/series/trunk/admin/chpwd.php
diff options
context:
space:
mode:
Diffstat (limited to 'series/trunk/admin/chpwd.php')
-rw-r--r--series/trunk/admin/chpwd.php134
1 files changed, 0 insertions, 134 deletions
diff --git a/series/trunk/admin/chpwd.php b/series/trunk/admin/chpwd.php deleted file mode 100644 index 12eff53..0000000 --- a/series/trunk/admin/chpwd.php +++ /dev/null
@@ -1,134 +0,0 @@
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 */
14require_once('includes/instadisc.php');
15
16if (!isset($_SESSION['username']))
17{
18 header('Location: index.php');
19 exit;
20}
21
22if (isset($_SESSION['username']))
23{
24 if (!isset($_GET['submit']))
25 {
26 showForm('','','',array());
27 } else {
28 $numOfErrors = 0;
29 $errors = array();
30
31 if ($_POST['old'] == '')
32 {
33 addError($numOfErrors, $errors, 'old', 'Old Password is a required field');
34 } else {
35 if (!instaDisc_verifyUser($_SESSION['username'], $_POST['old']))
36 {
37 addError($numOfErrors, $errors, 'old', 'Old password is not correct');
38 }
39 }
40
41 if ($_POST['new'] == '')
42 {
43 addError($numOfErrors, $errors, 'new', 'New Password is a required field');
44 }
45
46 if ($_POST['confirm'] == '')
47 {
48 addError($numOfErrors, $errors, 'confirm', 'Confirm New Password is a required field');
49 }
50
51 if ($_POST['new'] != $_POST['confirm'])
52 {
53 addError($numOfErrors, $errors, 'confirm', 'Passwords do not match');
54 }
55
56 if ($numOfErrors > 0)
57 {
58 showForm($_POST['old'], $_POST['new'], $_POST['confirm'], $errors);
59 } else {
60 instaDisc_changePassword($_SESSION['username'], $_POST['new']);
61
62 $template = new FITemplate('changedpassword');
63 $template->add('SITENAME', instaDisc_getConfig('siteName'));
64 $template->display();
65 }
66 }
67} else {
68 header('Location: index.php');
69 exit;
70}
71
72function showForm($old, $new, $confirm, $errors)
73{
74 $template = new FITemplate('changepassword');
75 $template->add('SITENAME', instaDisc_getConfig('siteName'));
76
77 if (isset($errors[1]))
78 {
79 $template->adds_block('ERROR', array('ex'=>'1'));
80
81 foreach ($errors as $name => $value)
82 {
83 $template->adds_block('ERRORS', array( 'NAME' => $name,
84 'MSG' => $value['msg']));
85 }
86 }
87
88 $template->add('OLD_ERR', ifErrors($errors, 'old'));
89 $template->add('NEW_ERR', ifErrors($errors, 'new'));
90 $template->add('CONFIRM_ERR', ifErrors($errors, 'confirm'));
91
92 doErrors($template, $errors, 'old');
93 doErrors($template, $errors, 'new');
94 doErrors($template, $errors, 'confirm');
95
96 $template->add('OLD', $old);
97 $template->add('NEW', $new);
98 $template->add('CONFIRM', $confirm);
99
100 $template->display();
101}
102
103function ifErrors($errors, $id)
104{
105 foreach ($errors as $name => $value)
106 {
107 if ($value['field'] == $id)
108 {
109 return ' error';
110 }
111 }
112
113 return '';
114}
115
116function doErrors($template, $errors, $id)
117{
118 foreach ($errors as $name => $value)
119 {
120 if ($value['field'] == $id)
121 {
122 $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name,
123 'VALUE' => $value['msg']));
124 }
125 }
126}
127
128function addError(&$numOfErrors, &$errors, $field, $msg)
129{
130 $numOfErrors++;
131 $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg);
132}
133
134?>