-
Notifications
You must be signed in to change notification settings - Fork 10
/
kiosk.php
172 lines (145 loc) · 4.4 KB
/
kiosk.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
/**
* index.
*
*
*
* PHP version >= 5.0
*
* @package view
* @author Stefano Penge <steve@lynxlab.com>
* @author Maurizio "Graffio" Mazzoneschi <graffio@lynxlab.com>
* @author Vito Modena <vito@lynxlab.com>
* @copyright Copyright (c) 2009, Lynx s.r.l.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License v.2
* @link index
* @version 0.1
*/
/**
* Destroy session
*/
session_start();
session_unset();
session_destroy();
/**
* Base config file
*/
require_once realpath(dirname(__FILE__)).'/config_path.inc.php';
/**
* Clear node and layout variable in $_SESSION
* $_SESSION was destroyed, so we do not need to clear data in session.
*/
$allowedUsersAr = array(AMA_TYPE_VISITOR, AMA_TYPE_STUDENT,AMA_TYPE_TUTOR, AMA_TYPE_AUTHOR, AMA_TYPE_ADMIN);
/**
* Performs basic controls before entering this module
*/
require_once ROOT_DIR.'/include/module_init.inc.php';
$self = index;
include_once 'include/'.$self.'_functions.inc.php';
/**
* Negotiate login page language
*/
Translator::loadSupportedLanguagesInSession();
$supported_languages = Translator::getSupportedLanguages();
$login_page_language_code = Translator::negotiateLoginPageLanguage();
$_SESSION['sess_user_language'] = $login_page_language_code;
/**
* Track kiosk accesses
*/
$_SESSION['ada_access_from'] = ADA_KIOSK_ACCESS;
$_SESSION['ada_remote_address'] = $_SERVER['REMOTE_ADDR'];
/*
* Load news file
*/
$newsfile = 'news_'.$login_page_language_code.'.txt';
$infofile = 'info_'.$login_page_language_code.'.txt';
$helpfile = 'help_'.$login_page_language_code.'.txt';
/*
$infomsg = '';
$newsmsg = '';
$hlpmsg = '';
*/
if ($newsmsg == ''){
$newsfile = $root_dir."/browsing/".$newsfile; // txt files in ada browsing directory
if ($fid = @fopen($newsfile,'r')){
while (!feof($fid))
$newsmsg .= fread($fid,4096);
fclose($fid);
} else {
$newsmsg = translateFN("File news non trovato");
}
}
if ($hlpmsg == ''){
$helpfile = $root_dir."/browsing/".$helpfile; // txt files in ada browsing directory
if ($fid = @fopen($helpfile,'r')){
while (!feof($fid))
$hlpmsg .= fread($fid,4096);
fclose($fid);
} else {
$hlpmsg = translateFN("File help non trovato");
}
}
if ($infomsg == ''){
$infofile = $root_dir."/browsing/".$infofile; // txt files in ada browsing directory
if ($fid = @fopen($infofile,'r')){
while (!feof($fid))
$infomsg .= fread($fid,4096);
fclose($fid);
} else {
$infomsg = translateFN("File info non trovato");
}
}
/**
* Perform login
*/
if(isset($p_login)) {
$username = DataValidator::validate_username($p_username);
$password = DataValidator::validate_password($p_password, $p_password);
if($username !== FALSE && $password !== FALSE) {
$userObj = MultiPort::loginUser($username, $password);
//User has correctly logged in
if($userObj instanceof ADALoggableUser){
$_SESSION['sess_user_language'] = $p_selected_language;
$_SESSION['sess_id_user'] = $userObj->getId();
$GLOBALS['sess_id_user'] = $userObj->getId();
$_SESSION['sess_id_user_type'] = $userObj->getType();
$GLOBALS['sess_id_user_type'] = $userObj->getType();
$_SESSION['sess_userObj'] = $userObj;
$user_default_tester = $userObj->getDefaultTester();
if($user_default_tester !== NULL) {
$_SESSION['sess_selected_tester'] = $user_default_tester;
}
header('Location:'.$userObj->getHomePage());
exit();
}
else {
// Utente non loggato perché coppia username password non corretta
$login_error_message = translateFN("Username e/o password non valide");
}
}
else {
// Utente non loggato perche' informazioni in username e password non valide
// es. campi vuoti o contenenti caratteri non consentiti.
$login_error_message = translateFN("Username e/o password non valide");
}
}
/**
* Show login page
*/
$form_action = HTTP_ROOT_DIR .'/kiosk.php';
$login = UserModuleHtmlLib::loginForm($form_action, $supported_languages,$login_page_language_code, $login_error_message);
$message = CDOMElement::create('div');
if(isset($_GET['message'])) {
$message->addChild(new CText($_GET['message']));
}
$content_dataAr = array(
'form' => $login->getHtml(),
'text' => $newsmsg,
'help' => $hlpmsg,
'message' => $message->getHtml()
);
/**
* Sends data to the rendering engine
*/
ARE::render($layout_dataAr,$content_dataAr);
?>