root/trunk/redirectors/login.php

Revision 291, 3.1 kB (checked in by hannes, 3 years ago)

establishing a global warnings array to store and display (choke) warnings

Line 
1 <?php
2
3 /**
4  * Package: Spam Board 5
5  * File: redirectors/login.php
6  * Description: called by the login form; checks user identity
7  *
8  * Copyright (C) 2007, 2009 Hannes Schueller
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as
12  * published by the Free Software Foundation, version 3 of the
13  * License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program (see LICENCE). If not,
22  * see <http://www.gnu.org/licenses/>.
23  **/
24
25 // since this is not called from /index.php, get the necessary includes
26 require('../includes/config/settings.php');
27
28 // load classes on demand
29 function __autoload($class) {
30     global $SETTINGS;
31     if (is_file($SETTINGS['fspath'] . 'classes/pages/' . $class . '.php')) {
32         require_once($SETTINGS['fspath'] . 'classes/pages/' . $class . '.php');
33     } elseif (is_file($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php')) {
34         require_once($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php');
35     } else { die('Class ' . $class . ' not found.'); }
36 }
37
38 // initialize global warnings array
39 $WARNINGS = Array();
40
41 // import version number
42 require_once($SETTINGS['fspath'] . 'includes/config/version.php');
43 // bots definition
44 require_once($SETTINGS['fspath'] . 'includes/config/bots.php');
45 // crypto module
46 require($SETTINGS['fspath'] . 'includes/config/crypt.php');
47 // load formatting functions
48 $F = new Format();
49 require($SETTINGS['fspath'] . 'includes/lang/' . $SETTINGS['language'] . '.php');
50 require($SETTINGS['fspath'] . 'includes/input.php');
51 // open database connection
52 $C = new Connection();
53 Member::session();
54 if (isset($_SESSION['lang']) && $_SESSION['lang'] != '') {
55     // override global language setting by user setting
56     include($SETTINGS['fspath'] . 'includes/lang/' . $_SESSION['lang'] . '.php');
57 }
58
59 if (Page::checkLogins()) {
60
61     // check if user has permission; required: write; independent from id
62     if (Member::checkRights('Login', 'w')) {
63         // permission granted
64         // try authenticating member
65         if (Member::authenticate($INPUT['user'], $INPUT['password'])) {
66             if (!isset($INPUT['remember'])) {
67                 $INPUT['remember'] = 'n';
68             }
69             if (isset($INPUT['admin'])) {
70                 Member::login($INPUT['user'], $INPUT['remember'], $INPUT['admin']);
71             } else {
72                 Member::login($INPUT['user'], $INPUT['remember']);
73             }
74             // close database connection
75             $C = NULL;
76             // handle refering page
77             if (strpos($_SESSION['page_ref2'], '?') === FALSE) {
78                 $ref = $_SESSION['page_ref2'] . '?';
79             } else {
80                 $ref = $_SESSION['page_ref2'];
81             }
82             // do forward
83             header('Location: ' . $SETTINGS['webpath'] . $ref . '&' . strip_tags(SID));
84             // in case something went wrong with redirecting, display message at least
85             print($LANG['login_success']);
86         } else {
87             // login failed
88             print($LANG['error_userpassword']);
89         }
90     } else {
91         print($LANG['error_permission_denied']);
92     }
93
94 }
95
96 ?>
Note: See TracBrowser for help on using the browser.