1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
4
|
|
|
// |
5
|
|
|
// eTraxis - Records tracking web-based system |
6
|
|
|
// Copyright (C) 2005-2011 Artem Rodygin |
7
|
|
|
// |
8
|
|
|
// This program is free software: you can redistribute it and/or modify |
9
|
|
|
// it under the terms of the GNU General Public License as published by |
10
|
|
|
// the Free Software Foundation, either version 3 of the License, or |
11
|
|
|
// (at your option) any later version. |
12
|
|
|
// |
13
|
|
|
// This program is distributed in the hope that it will be useful, |
14
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
// GNU General Public License for more details. |
17
|
|
|
// |
18
|
|
|
// You should have received a copy of the GNU General Public License |
19
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
// |
21
|
|
|
//------------------------------------------------------------------------------ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @package eTraxis |
25
|
|
|
* @ignore |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
/**#@+ |
29
|
|
|
* Dependency. |
30
|
|
|
*/ |
31
|
|
|
require_once('../engine/engine.php'); |
32
|
|
|
require_once('../dbo/accounts.php'); |
33
|
|
|
/**#@-*/ |
34
|
|
|
|
35
|
|
|
@session_start(); |
36
|
|
|
|
37
|
|
|
if (get_user_level() != USER_LEVEL_GUEST) |
38
|
|
|
{ |
39
|
|
|
debug_write_log(DEBUG_NOTICE, 'User is already authorized.'); |
40
|
|
|
header('Location: ../records/index.php'); |
41
|
|
|
exit; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
// local JS functions |
45
|
|
|
|
46
|
|
|
$resTitle = get_js_resource(RES_ERROR_ID); |
47
|
|
|
$resOK = get_js_resource(RES_OK_ID); |
48
|
|
|
|
49
|
|
|
$uri = ustr2html(try_cookie(COOKIE_URI, '../records/index.php')); |
50
|
|
|
|
51
|
|
|
$xml = <<<JQUERY |
52
|
|
|
<script> |
53
|
|
|
|
54
|
|
|
function loginSuccess () |
55
|
|
|
{ |
56
|
|
|
window.open("{$uri}", "_parent"); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
function loginError (XMLHttpRequest) |
60
|
|
|
{ |
61
|
|
|
jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}"); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
</script> |
65
|
|
|
JQUERY; |
66
|
|
|
|
67
|
|
|
// generate contents |
68
|
|
|
|
69
|
|
|
$xml .= '<content>' |
70
|
|
|
. '<form name="loginform" action="login.php" success="loginSuccess" error="loginError">' |
71
|
|
|
. '<group>' |
72
|
|
|
. '<control name="username">' |
73
|
|
|
. '<label>' . get_html_resource(RES_USERNAME_ID) . '</label>' |
74
|
|
|
. '<editbox maxlen="' . MAX_ACCOUNT_USERNAME . '"/>' |
75
|
|
|
. '</control>' |
76
|
|
|
. '<control name="password">' |
77
|
|
|
. '<label>' . get_html_resource(RES_PASSWORD_ID) . '</label>' |
78
|
|
|
. '<passbox maxlen="' . MAX_ACCOUNT_PASSWORD . '"/>' |
79
|
|
|
. '</control>' |
80
|
|
|
. '</group>' |
81
|
|
|
. '<button default="true">' . get_html_resource(RES_OK_ID) . '</button>' |
82
|
|
|
. '</form>' |
83
|
|
|
. '</content>'; |
84
|
|
|
|
85
|
|
|
echo(xml2html($xml, get_html_resource(RES_LOGIN_ID))); |
86
|
|
|
|
87
|
|
|
?> |
|
|
|
|
88
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.