00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 class AjaxLogin {
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 public function login(array $parameters, TYPO3AJAX $ajaxObj) {
00046 if ($GLOBALS['BE_USER']->user['uid']) {
00047 $json = array('success' => TRUE);
00048 } else {
00049 $json = array('success' => FALSE);
00050 }
00051 $ajaxObj->addContent('login', $json);
00052 $ajaxObj->setContentFormat('json');
00053 }
00054
00055
00056
00057
00058
00059
00060
00061
00062 public function logout(array $parameters, TYPO3AJAX $ajaxObj) {
00063 $GLOBALS['BE_USER']->logoff();
00064 if($GLOBALS['BE_USER']->user['uid']) {
00065 $ajaxObj->addContent('logout', array('success' => FALSE));
00066 } else {
00067 $ajaxObj->addContent('logout', array('success' => TRUE));
00068 }
00069 $ajaxObj->setContentFormat('json');
00070 }
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 public function refreshLogin(array $parameters, TYPO3AJAX $ajaxObj) {
00081 $GLOBALS['BE_USER']->checkAuthentication();
00082 $ajaxObj->addContent('refresh', array('success' => TRUE));
00083 $ajaxObj->setContentFormat('json');
00084 }
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 function isTimedOut(array $parameters, TYPO3AJAX $ajaxObj) {
00095 if(is_object($GLOBALS['BE_USER'])) {
00096 $ajaxObj->setContentFormat('json');
00097 if (@is_file(PATH_typo3conf.'LOCK_BACKEND')) {
00098 $ajaxObj->addContent('login', array('timed_out' => FALSE, 'locked' => TRUE));
00099 $ajaxObj->setContentFormat('json');
00100 } else {
00101 $GLOBALS['BE_USER']->fetchUserSession(TRUE);
00102 $ses_tstamp = $GLOBALS['BE_USER']->user['ses_tstamp'];
00103 $timeout = $GLOBALS['BE_USER']->auth_timeout_field;
00104
00105
00106
00107 if ($GLOBALS['EXEC_TIME'] >= $ses_tstamp + $timeout - 120) {
00108 $ajaxObj->addContent('login', array('timed_out' => TRUE));
00109 } else {
00110 $ajaxObj->addContent('login', array('timed_out' => FALSE));
00111 }
00112 }
00113 } else {
00114 $ajaxObj->addContent('login', array('success' => FALSE, 'error' => 'No BE_USER object'));
00115 }
00116 }
00117
00118
00119
00120
00121
00122
00123
00124
00125 public function getChallenge(array $parameters, TYPO3AJAX $parent) {
00126 session_start();
00127
00128 $_SESSION['login_challenge'] = md5(uniqid('') . getmypid());
00129
00130 session_commit();
00131
00132 $parent->addContent('challenge', $_SESSION['login_challenge']);
00133 $parent->setContentFormat('json');
00134 }
00135 }
00136
00137 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.ajaxlogin.php']) {
00138 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.ajaxlogin.php']);
00139 }
00140
00141 ?>