diff options
Diffstat (limited to 'series/core/trunk/admin/login.php')
-rw-r--r-- | series/core/trunk/admin/login.php | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/series/core/trunk/admin/login.php b/series/core/trunk/admin/login.php new file mode 100644 index 0000000..fe394a1 --- /dev/null +++ b/series/core/trunk/admin/login.php | |||
@@ -0,0 +1,95 @@ | |||
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($_GET['submit'])) | ||
17 | { | ||
18 | showForm('','',array()); | ||
19 | } else { | ||
20 | $numOfErrors = 0; | ||
21 | $errors = array(); | ||
22 | |||
23 | if (instaDisc_verifyUser($_POST['username'], $_POST['password'])) | ||
24 | { | ||
25 | $_SESSION['username'] = $_POST['username']; | ||
26 | |||
27 | $template = new FITemplate('loggedin'); | ||
28 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
29 | $template->display(); | ||
30 | } else { | ||
31 | addError($numOfErrors, $errors, '', 'Account could not be found'); | ||
32 | showForm($_POST['username'], $_POST['password'], $errors); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | function showForm($username, $password, $errors) | ||
37 | { | ||
38 | $template = new FITemplate('login'); | ||
39 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
40 | |||
41 | if (isset($errors[1])) | ||
42 | { | ||
43 | $template->adds_block('ERROR', array('ex'=>'1')); | ||
44 | |||
45 | foreach ($errors as $name => $value) | ||
46 | { | ||
47 | $template->adds_block('ERRORS', array( 'NAME' => $name, | ||
48 | 'MSG' => $value['msg'])); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | $template->add('USERNAME_ERR', ifErrors($errors, 'username')); | ||
53 | $template->add('PASSWORD_ERR', ifErrors($errors, 'password')); | ||
54 | |||
55 | doErrors($template, $errors, 'username'); | ||
56 | doErrors($template, $errors, 'password'); | ||
57 | |||
58 | $template->add('USERNAME', $username); | ||
59 | $template->add('PASSWORD', $password); | ||
60 | |||
61 | $template->display(); | ||
62 | } | ||
63 | |||
64 | function ifErrors($errors, $id) | ||
65 | { | ||
66 | foreach ($errors as $name => $value) | ||
67 | { | ||
68 | if ($value['field'] == $id) | ||
69 | { | ||
70 | return ' error'; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | return ''; | ||
75 | } | ||
76 | |||
77 | function doErrors($template, $errors, $id) | ||
78 | { | ||
79 | foreach ($errors as $name => $value) | ||
80 | { | ||
81 | if ($value['field'] == $id) | ||
82 | { | ||
83 | $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name, | ||
84 | 'VALUE' => $value['msg'])); | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
90 | { | ||
91 | $numOfErrors++; | ||
92 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
93 | } | ||
94 | |||
95 | ?> | ||