Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

admin/login.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: login.php 6389 2001-08-07 13:26:40Z jhe $
5 //
6 // Created on: <20-Sep-2000 13:32:11 ce>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezlog.php" );
30 // include_once( "classes/ezhttptool.php" );
31
32 $ini =& eZINI::instance( 'site.ini' );
33 $Language = $ini->variable( "eZUserMain", "Language" );
34
35 // include_once( "ezuser/classes/ezuser.php" );
36 // include_once( "ezuser/classes/ezusergroup.php" );
37 // include_once( "ezuser/classes/ezmodule.php" );
38 // include_once( "ezuser/classes/ezpermission.php" );
39 // include_once( "ezsession/classes/ezsession.php" );
40
41
42 // Template
43 $t = new eZTemplate( "kernel/ezuser/admin/" . $ini->variable( "eZUserMain", "AdminTemplateDir" ),
44 "kernel/ezuser/admin/" . "/intl", $Language, "login.php" );
45 $t->setAllStrings();
46
47 $t->set_file( array(
48 "login_tpl" => "login.tpl"
49 ) );
50
51 $t->set_block( "login_tpl", "error_message_tpl", "error_message" );
52 $t->set_block( "login_tpl", "max_message_tpl", "max_message" );
53
54 if ( isset( $Action ) && $Action == "login" )
55 {
56 $Username = $_POST['Username'];
57 $Password = $_POST['Password'];
58
59 $remoteAddress = $_SERVER['REMOTE_ADDR'];
60
61 $user = new eZUser();
62 $user = $user->validateUser( $_POST['Username'], $_POST['Password'] );
63
64 if ( ( $user ) && eZPermission::checkPermission( $user, "eZUser", "AdminLogin" ) )
65 {
66 if ( $user->get( $user->ID ) )
67 {
68 $logins = $user->getLogins( $user->ID );
69 $AllowSimultaneousLogins = $ini->variable( "eZUserMain", "SimultaneousLogins" );
70
71 if ( $AllowSimultaneousLogins == "disabled" )
72 {
73 $MaxLogins = "1";
74 }
75 else
76 {
77 $MaxLogins = $user->simultaneousLogins();
78 }
79
80 if ( ( $logins < $MaxLogins ) || ( $MaxLogins == 0 ) )
81 {
82 eZDebug::writeNotice( "Admin login: $Username from IP: $remoteAddress" );
83
84 eZUser::loginUser( $user );
85 if ( !isset( $RefererURL ) )
86 $RefererURL = "/";
87
88 // Show password change dialog, if admin is using default login
89 if ( $Username == "admin" && $Password == "publish" )
90 {
91 $RefererURL = "/user/passwordchange/";
92 }
93
94 eZHTTPTool::header( "Location: $RefererURL" );
95 exit();
96 }
97 else
98 {
99 eZPBLog::writeWarning( "Max limit reached: $Username from IP: $remoteAddress" );
100
101 $maxerror = true;
102 }
103 }
104 else
105 {
106 ezLog::writeError( "Couldn't receive admin information on : $Username from IP: $remoteAddress" );
107
108 $error = true;
109 }
110 }
111 else
112 {
113 eZPBLog::writeWarning( "Bad admin login: $Username from IP: $remoteAddress" );
114
115 $error = true;
116 }
117 }
118
119 if ( !isset( $RefererURL ) )
120 $RefererURL = $_SERVER['REQUEST_URI'];
121 if ( preg_match( "#^/user/login.*#", $RefererURL ) )
122 {
123 $RefererURL = "/";
124
125 }
126
127 $t->set_var( "referer_url", $RefererURL );
128
129 if ( isset( $Action ) && $Action == "logout" )
130 {
131 eZUser::logout();
132 eZHTTPTool::header( "Location: /" );
133 exit();
134 }
135
136 if ( isset( $error ) && $error )
137 {
138 $t->parse( "error_message", "error_message_tpl" );
139 }
140 else
141 {
142 $t->set_var( "error_message", "" );
143 }
144
145 if ( isset( $maxerror ) && $maxerror )
146 {
147 $t->parse( "max_message", "max_message_tpl" );
148 }
149 else
150 {
151 $t->set_var( "max_message", "" );
152 }
153
154 $t->set_var( "action_value", "login" );
155 $t->pparse( "output", "login_tpl" );
156
157 ?>
$t
$t
Definition: admin/login.php:43
$Language
$Language
Definition: admin/login.php:33
$ini
$ini
Definition: admin/login.php:32
$Password
$Password
Definition: admin/seti.php:21
eZDebug\writeNotice
static writeNotice( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:460
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZPBLog\writeWarning
static writeWarning( $warning)
Definition: ezpblog.php:177
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZTemplate
Definition: eztemplate.php:107
eZUser
Definition: ezuser.php:76
eZUser\logout
static logout()
Definition: ezuser.php:876
eZUser\loginUser
static loginUser(&$user)
Definition: ezuser.php:809
$Action
$Action
Definition: companysearch.php:80
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
exit
exit
Definition: folder.php:81
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.