about summary refs log tree commit diff stats
path: root/series/trunk/admin/login.php
diff options
context:
space:
mode:
Diffstat (limited to 'series/trunk/admin/login.php')
-rw-r--r--series/trunk/admin/login.php95
1 files changed, 0 insertions, 95 deletions
diff --git a/series/trunk/admin/login.php b/series/trunk/admin/login.php deleted file mode 100644 index fe394a1..0000000 --- a/series/trunk/admin/login.php +++ /dev/null
@@ -1,95 +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($_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
36function 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
64function 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
77function 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
89function addError(&$numOfErrors, &$errors, $field, $msg)
90{
91 $numOfErrors++;
92 $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg);
93}
94
95?>