2
/* vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +----------------------------------------------------------------------+
5
// +----------------------------------------------------------------------+
6
// | Copyright (c) 2000-2009 WS Interactive |
7
// +----------------------------------------------------------------------+
8
// | Automne is subject to version 2.0 or above of the GPL license. |
9
// | The license text is bundled with this package in the file |
10
// | LICENSE-GPL, and is available through the world-wide-web at |
11
// | http://www.gnu.org/copyleft/gpl.html. |
12
// +----------------------------------------------------------------------+
13
// | Author: S�bastien Pauchet <sebastien.pauchet@ws-interactive.fr> |
14
// +----------------------------------------------------------------------+
16
// $Id: login.php,v 1.1.1.1 2008/11/26 17:12:05 sebastien Exp $
20
* Manages the login of users. Creates login window.
24
* @author S�bastien Pauchet <sebastien.pauchet@ws-interactive.fr>
27
require_once($_SERVER["DOCUMENT_ROOT"]."/cms_rc_frontend.php");
29
define("MESSAGE_PAGE_LOGIN", 54);
30
define("MESSAGE_PAGE_PASSWORD", 55);
31
define("MESSAGE_PAGE_REMEMBER_ME", 1218);
32
define("MESSAGE_BUTTON_VALIDATE", 56);
33
define("MESSAGE_BUTTON_CANCEL", 180);
34
define("MESSAGE_PAGE_TITLE", 51);
35
define("MESSAGE_ERROR_LOGIN_INCORRECT", 50);
36
define("MESSAGE_ERROR_TITLE", 301);
37
define("MESSAGE_PAGE_LOGIN_IN_PROGRESS", 302);
38
define("MESSAGE_PAGE_REQUIRED_FIELD", 1239);
39
define("MESSAGE_ERROR_REQUIRED_FIELD", 303);
40
define("MESSAGE_PAGE_USER_WELCOME", 314);
41
define("MESSAGE_PAGE_USER_NOVALIDATION", 1113);
42
define("MESSAGE_PAGE_USER_VALIDATIONS", 315);
44
//load language object
45
$language = CMS_languagesCatalog::getDefaultLanguage(true);
46
//load interface instance
47
$view = CMS_view::getInstance();
48
//var used to display error of login
52
switch (isset($_POST["cms_action"])) {
54
$permanent = isset($_POST["permanent"]) ? $_POST["permanent"] : 0;
55
$cms_context = new CMS_context($_POST["login"], $_POST["pass"], $permanent);
56
if (!$cms_context->hasError()) {
58
$_SESSION["cms_context"] = $cms_context;
59
$cms_user = $_SESSION["cms_context"]->getUser();
60
//launch the daily routine in case it's not in the cron
61
CMS_module_standard::processDailyRoutine();
62
$userSessionsInfos = CMS_context::getSessionInfos();
65
$welcome = $language->getJsMessage(MESSAGE_PAGE_USER_WELCOME, array($userSessionsInfos['fullname']));
66
if ($userSessionsInfos['hasValidations']) {
67
$welcome .= '<br /><br />'.(($userSessionsInfos['awaitingValidation']) ? $language->getJsMessage(MESSAGE_PAGE_USER_VALIDATIONS, array($userSessionsInfos['awaitingValidation'])) : $language->getJsMessage(MESSAGE_PAGE_USER_NOVALIDATION));
69
if (SYSTEM_DEBUG && $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
70
$welcome .= '<br /><br /><span class="atm-red">Attention, le debuggage est actif.</span> Pressez F2 pour voir la fen�tre de log.';
73
//then set context, remove login window and load Automne interface
76
Automne.context = '.sensitiveIO::jsonEncode($userSessionsInfos).';
77
//remove event closeAndBack on window
78
Ext.WindowMgr.get(\'loginWindow\').un(\'close\', Ext.WindowMgr.get(\'loginWindow\').closeAndBack);
79
//add event to load Automne interface after close
80
Ext.WindowMgr.get(\'loginWindow\').on(\'close\', Automne.load);
81
//display welcome message
82
Automne.message.show(\''.sensitiveIO::sanitizeJSString($welcome).'\');
83
if (Ext.Element.cache[\'loginField\']) {delete Ext.Element.cache[\'loginField\']};
86
$jscontent .= CMS_context::getJSLocales();
89
Ext.WindowMgr.get(\'loginWindow\').close();';
90
//eval content into parent
92
if (parent.Ext.Element.cache[\'loginField\']) {delete parent.Ext.Element.cache[\'loginField\']};
93
parent.eval(\''.sensitiveIO::sanitizeJSString($jscontent, true).'\');';
94
$view->addJavascript($jscontent);
95
$view->show(CMS_view::SHOW_HTML);
97
//display error login window on top of login form
99
parent.Automne.message.popup({
100
title: '{$language->getJsMessage(MESSAGE_ERROR_TITLE)}',
101
msg: '{$language->getJsMessage(MESSAGE_ERROR_LOGIN_INCORRECT)}',
102
buttons: Ext.MessageBox.OK,
103
icon: Ext.MessageBox.ERROR,
105
Ext.fly('loginField').dom.select();
111
// First attempt to obtain $_COOKIE information from domain
112
if ((!isset($_REQUEST["cms_action"]) || $_REQUEST["cms_action"] != 'logout') && CMS_context::autoLoginSucceeded()) {
113
$cms_user = $_SESSION["cms_context"]->getUser();
114
//launch the daily routine incase it's not in the cron
115
CMS_module_standard::processDailyRoutine();
116
//then set context and load Automne interface
117
$userSessionsInfos = CMS_context::getSessionInfos();
119
$welcome = $language->getJsMessage(MESSAGE_PAGE_USER_WELCOME, array($userSessionsInfos['fullname']));
120
if ($userSessionsInfos['hasValidations']) {
121
$welcome .= '<br /><br />'.(($userSessionsInfos['awaitingValidation']) ? $language->getJsMessage(MESSAGE_PAGE_USER_VALIDATIONS, array($userSessionsInfos['awaitingValidation'])) : $language->getJsMessage(MESSAGE_PAGE_USER_NOVALIDATION));
123
if (SYSTEM_DEBUG && $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
124
$welcome .= '<br /><br /><span class="atm-red">Attention, le debuggage est actif.</span> Pressez F2 pour voir la fen�tre de log.';
128
Automne.context = '.sensitiveIO::jsonEncode($userSessionsInfos).';
131
//display welcome message
132
Automne.message.show(\''.sensitiveIO::sanitizeJSString($welcome).'\');
135
$jscontent .= CMS_context::getJSLocales();
136
$view->addJavascript($jscontent);
137
$view->show(CMS_view::SHOW_RAW);
140
CMS_context::resetSessionCookies();
144
if (!isset($_GET['loginform'])) {
145
//Send Login form window
147
$applicationLabel = addcslashes(APPLICATION_LABEL, "'");
148
$htmlForm = '<iframe id="formframe" width="100%" height="100%" frameborder="0" src="'.$_SERVER['SCRIPT_NAME'].'?loginform=true"> </iframe>';
151
var loginWindow = new Ext.Window({
152
title: '{$language->getJsMessage(MESSAGE_PAGE_TITLE, array($applicationLabel))}',
154
iconCls: 'atm-pic-logo',
161
bodyStyle: 'padding:5px;',
162
buttonAlign:'center',
165
loginWindow.closeAndBack = function() {
166
document.location.replace('/');
168
loginWindow.on('close', loginWindow.closeAndBack);
172
$view->addJavascript($jscontent);
173
$view->show(CMS_view::SHOW_RAW);
176
//Send Login form frame window (in which login form is displayed)
177
$view->addJSFile('ext');
178
$view->addCSSFile('ext');
182
Ext.onReady(function() {
183
// turn on validation errors beside the field globally
184
Ext.form.Field.prototype.msgTarget = 'under';
185
var loginField = new Ext.form.TextField({
187
blankText: '{$language->getJsMessage(MESSAGE_PAGE_REQUIRED_FIELD)}',
188
applyTo: 'loginField'
190
var passField = new Ext.form.TextField({
192
inputType: 'password',
193
blankText: '{$language->getJsMessage(MESSAGE_PAGE_REQUIRED_FIELD)}',
196
var cancelButton = new Ext.Button({
197
text: '{$language->getJsMessage(MESSAGE_BUTTON_CANCEL)}',
198
handler: function() {if (parent) {parent.Ext.WindowMgr.get('loginWindow').close();}},
199
applyTo: 'cancelButton'
201
var submitButton = new Ext.Button({
202
text: '{$language->getJsMessage(MESSAGE_BUTTON_VALIDATE)}',
203
handler: function() {loginForm.doSubmit();},
204
applyTo: 'submitButton'
206
var loginForm = new Ext.form.BasicForm("loginForm", {
208
if (Ext.fly('loginField').dom.value && Ext.fly('passField').dom.value) {
209
this.getEl().dom.submit();
211
Ext.MessageBox.show({
212
title: '{$language->getJsMessage(MESSAGE_ERROR_TITLE)}',
213
msg: '{$language->getJsMessage(MESSAGE_ERROR_REQUIRED_FIELD)}',
214
buttons: Ext.MessageBox.OK,
215
icon: Ext.MessageBox.ERROR,
217
Ext.fly('loginField').dom.select();
224
var map = new Ext.KeyMap("loginForm", {
225
key: Ext.EventObject.ENTER,
226
fn: loginForm.doSubmit,
229
//put focus on the first login field
230
//if (Ext.get('loginField').dom.value){ alert('select');Ext.get('loginField').dom.select(); } else { alert('focus');Ext.get('loginField').focus();}
231
//display login error window if any
235
$view->addJavascript($jscontent);
238
<div class="x-panel x-form-label-left" style="width: 374px;">
239
<div class="x-panel-tl">
240
<div class="x-panel-tr">
241
<div class="x-panel-tc"></div>
244
<div class="x-panel-bwrap">
245
<div class="x-panel-ml">
246
<div class="x-panel-mr">
247
<div class="x-panel-mc">
248
<div style="width: 362px; height: 126px;" class="x-panel-body">
249
<form id="loginForm" class="x-form" method="post" action="login.php?loginform=true">
250
<input value="login" class="x-form-hidden x-form-field" size="20" autocomplete="on" name="cms_action" type="hidden" />
251
<div class="x-form-item" tabindex="-1">
252
<label for="loginField" style="width: 90px;" class="x-form-item-label">'.$language->getMessage(MESSAGE_PAGE_LOGIN).':</label>
253
<div class="x-form-element" style="padding-left: 95px;">
254
<input style="width: 240px;" class="x-form-text x-form-field" autocomplete="on" id="loginField" name="login" type="text" value="'.(isset($_POST['login']) ? htmlspecialchars($_POST['login']) : '').'" />
256
<div class="x-form-clear-left"></div>
258
<div class="x-form-item" tabindex="-1">
259
<label for="passField" style="width: 90px;" class="x-form-item-label">'.$language->getMessage(MESSAGE_PAGE_PASSWORD).':</label>
260
<div class="x-form-element" style="padding-left: 95px;">
261
<input style="width: 240px;" class="x-form-text x-form-field" autocomplete="on" id="passField" name="pass" type="password" value="'.(isset($_POST['pass']) ? htmlspecialchars($_POST['pass']) : '').'" />
263
<div class="x-form-clear-left"></div>
265
<div class="x-form-item" tabindex="-1">
266
<div class="x-form-element" style="padding-left: 95px;">
267
<label for="rememberField" class="x-form-item-label" style="width: 240px;">
268
<input value="1" class="x-form-checkbox x-form-field" size="20" autocomplete="on" id="rememberField" name="permanent" type="checkbox" />
269
'.$language->getMessage(MESSAGE_PAGE_REMEMBER_ME).'
272
<div class="x-form-clear-left"></div>
279
<div class="x-panel-bl">
280
<div class="x-panel-br">
281
<div class="x-panel-bc">
282
<div class="x-panel-footer">
283
<div class="x-panel-btns-ct">
284
<div class="x-panel-btns x-panel-btns-center" id="formsButton">
285
<table cellspacing="0">
288
<td class="x-panel-btn-td">
289
<div id="submitButton"></div>
291
<td class="x-panel-btn-td">
292
<div id="cancelButton"></div>
297
<div class="x-clear"></div>
307
$view->setContent($content);
308
$view->show(CMS_view::SHOW_HTML);
b'\\ No newline at end of file'