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