ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Controller.php
Go to the documentation of this file.
1<?php
2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
3
62{
63
64 // {{{ properties
65
71 var $auth = null;
72
77 var $login = null;
78
84 var $default = null;
85
92 var $autoRedirectBack = false;
93
94 // }}}
95 // {{{ Auth_Controller() [constructor]
96
107 function Auth_Controller(&$auth_obj, $login='login.php', $default='index.php', $accessList=array())
108 {
109 $this->auth =& $auth_obj;
110 $this->_loginPage = $login;
111 $this->_defaultPage = $default;
112 @session_start();
113 if (!empty($_GET['return']) && $_GET['return'] && !strstr($_GET['return'], $this->_loginPage)) {
114 $this->auth->setAuthData('returnUrl', $_GET['return']);
115 }
116
117 if(!empty($_GET['authstatus']) && $this->auth->status == '') {
118 $this->auth->status = $_GET['authstatus'];
119 }
120 }
121
122 // }}}
123 // {{{ setAutoRedirectBack()
124
132 function setAutoRedirectBack($flag = true)
133 {
134 $this->autoRedirectBack = $flag;
135 }
136
137 // }}}
138 // {{{ redirectBack()
139
145 function redirectBack()
146 {
147 // If redirectback go there
148 // else go to the default page
149
150 $returnUrl = $this->auth->getAuthData('returnUrl');
151 if(!$returnUrl) {
152 $returnUrl = $this->_defaultPage;
153 }
154
155 // Add some entropy to the return to make it unique
156 // avoind problems with cached pages and proxies
157 if(strpos($returnUrl, '?') === false) {
158 $returnUrl .= '?';
159 }
160 $returnUrl .= uniqid('');
161
162 // Track the auth status
163 if($this->auth->status != '') {
164 $url .= '&authstatus='.$this->auth->status;
165 }
166 header('Location:'.$returnUrl);
167 print("You could not be redirected to <a href=\"$returnUrl\">$returnUrl</a>");
168 }
169
170 // }}}
171 // {{{ redirectLogin()
172
180 function redirectLogin()
181 {
182 // Go to the login Page
183
184 // For Auth, put some check to avoid infinite redirects, this should at least exclude
185 // the login page
186
187 $url = $this->_loginPage;
188 if(strpos($url, '?') === false) {
189 $url .= '?';
190 }
191
192 if(!strstr($_SERVER['PHP_SELF'], $this->_loginPage)) {
193 $url .= 'return='.urlencode($_SERVER['PHP_SELF']);
194 }
195
196 // Track the auth status
197 if($this->auth->status != '') {
198 $url .= '&authstatus='.$this->auth->status;
199 }
200
201 header('Location:'.$url);
202 print("You could not be redirected to <a href=\"$url\">$url</a>");
203 }
204
205 // }}}
206 // {{{ start()
207
217 function start()
218 {
219 // Check the accessList here
220 // ACL should be a list of urls with allow/deny
221 // If allow set allowLogin to false
222 // Some wild card matching should be implemented ?,*
223 if(!strstr($_SERVER['PHP_SELF'], $this->_loginPage) && !$this->auth->checkAuth()) {
224 $this->redirectLogin();
225 } else {
226 $this->auth->start();
227 // Logged on and on login page
228 if(strstr($_SERVER['PHP_SELF'], $this->_loginPage) && $this->auth->checkAuth()){
229 $this->autoRedirectBack ?
230 $this->redirectBack() :
231 null ;
232 }
233 }
234
235
236 }
237
238 // }}}
239 // {{{ isAuthorised()
240
245 function isAuthorised()
246 {
247 return($this->auth->checkAuth());
248 }
249
250 // }}}
251 // {{{ checkAuth()
252
257 function checkAuth()
258 {
259 return($this->auth->checkAuth());
260 }
261
262 // }}}
263 // {{{ logout()
264
269 function logout()
270 {
271 return($this->auth->logout());
272 }
273
274 // }}}
275 // {{{ getUsername()
276
281 function getUsername()
282 {
283 return($this->auth->getUsername());
284 }
285
286 // }}}
287 // {{{ getStatus()
288
293 function getStatus()
294 {
295 return($this->auth->getStatus());
296 }
297
298 // }}}
299
300}
301
302?>
$_GET["client_id"]
redirectBack()
Redirects Back to the calling page.
Definition: Controller.php:145
logout()
Proxy call to auth.
Definition: Controller.php:269
setAutoRedirectBack($flag=true)
Enables auto redirection when login is done.
Definition: Controller.php:132
checkAuth()
Proxy call to auth.
Definition: Controller.php:257
start()
Starts the Auth Procedure.
Definition: Controller.php:217
getUsername()
Proxy call to auth.
Definition: Controller.php:281
isAuthorised()
Checks is the user is logged on.
Definition: Controller.php:245
getStatus()
Proxy call to auth.
Definition: Controller.php:293
redirectLogin()
Redirects to the login Page if not authorised.
Definition: Controller.php:180
Auth_Controller(&$auth_obj, $login='login.php', $default='index.php', $accessList=array())
Constructor.
Definition: Controller.php:107
if(! $in) print
$url
Definition: shib_logout.php:72
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']