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
00056 class tx_sv_auth extends tx_sv_authbase {
00057
00058
00064 function getUser() {
00065 $user = false;
00066
00067 if ($this->login['status']=='login' AND $this->login['uident']) {
00068
00069 $user = $this->fetchUserRecord($this->login['uname']);
00070
00071 if(!is_array($user)) {
00072
00073 $this->writelog(255,3,3,2,
00074 "Login-attempt from %s (%s), username '%s' not found!!",
00075 Array($this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']));
00076 } else {
00077 if ($this->writeDevLog) t3lib_div::devLog('User found: '.t3lib_div::arrayToLogString($user, array($this->db_user['userid_column'],$this->db_user['username_column'])), 'tx_sv_auth');
00078 }
00079 }
00080 return $user;
00081 }
00082
00089 function authUser($user) {
00090 $OK = 100;
00091
00092 if ($this->login['uident'] && $this->login['uname']) {
00093
00094
00095 $OK = $this->compareUident($user, $this->login);
00096
00097 if(!$OK) {
00098
00099 if ($this->writeAttemptLog) {
00100 $this->writelog(255,3,3,1,
00101 "Login-attempt from %s (%s), username '%s', password not accepted!",
00102 Array($this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']));
00103 }
00104 if ($this->writeDevLog) t3lib_div::devLog('Password not accepted: '.$this->login['uident'], 'tx_sv_auth', 2);
00105 }
00106
00107
00108 if ($OK && $user['lockToDomain'] && $user['lockToDomain']!=$this->authInfo['HTTP_HOST']) {
00109
00110 if ($this->writeAttemptLog) {
00111 $this->writelog(255,3,3,1,
00112 "Login-attempt from %s (%s), username '%s', locked domain '%s' did not match '%s'!",
00113 Array($this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->db_user['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']));
00114 }
00115 $OK = false;
00116 }
00117 }
00118
00119 return $OK;
00120 }
00121
00129 function getGroups($user, $knownGroups) {
00130 global $TYPO3_CONF_VARS;
00131
00132 $groupDataArr = array();
00133
00134 if($this->mode=='getGroupsFE') {
00135
00136 $groups = array();
00137 if (is_array($user) && $user[$this->db_user['usergroup_column']]) {
00138 $groupList = $user[$this->db_user['usergroup_column']];
00139 $groups = array();
00140 $this->getSubGroups($groupList,'',$groups);
00141 }
00142
00143
00144 if (is_array($TYPO3_CONF_VARS['FE']['IPmaskMountGroups'])) {
00145 foreach($TYPO3_CONF_VARS['FE']['IPmaskMountGroups'] as $IPel) {
00146 if ($this->authInfo['REMOTE_ADDR'] && $IPel[0] && t3lib_div::cmpIP($this->authInfo['REMOTE_ADDR'],$IPel[0])) {$groups[]=intval($IPel[1]);}
00147 }
00148 }
00149
00150 $groups = array_unique($groups);
00151
00152 if (count($groups)) {
00153 $list = implode(',',$groups);
00154
00155 if ($this->writeDevLog) t3lib_div::devLog('Get usergroups with id: '.$list, 'tx_sv_auth');
00156
00157 $lockToDomain_SQL = ' AND (lockToDomain=\'\' OR lockToDomain=\''.$this->authInfo['HTTP_HOST'].'\')';
00158 if (!$this->authInfo['showHiddenRecords']) $hiddenP = 'AND hidden=0 ';
00159 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->db_groups['table'], 'deleted=0 '.$hiddenP.' AND uid IN ('.$list.')'.$lockToDomain_SQL);
00160 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00161 $groupDataArr[$row['uid']] = $row;
00162 }
00163 if ($res) $GLOBALS['TYPO3_DB']->sql_free_result($res);
00164
00165 } else {
00166 if ($this->writeDevLog) t3lib_div::devLog('No usergroups found.', 'tx_sv_auth', 2);
00167 }
00168 } elseif ($this->mode=='getGroupsBE') {
00169
00170 # Get the BE groups here
00171 # still needs to be implemented in t3lib_userauthgroup
00172 }
00173
00174 return $groupDataArr;
00175 }
00176
00186 function getSubGroups($grList, $idList='', &$groups) {
00187
00188
00189 $lockToDomain_SQL = ' AND (lockToDomain=\'\' OR lockToDomain=\''.$this->authInfo['HTTP_HOST'].'\')';
00190 if (!$this->authInfo['showHiddenRecords']) $hiddenP = 'AND hidden=0 ';
00191 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,subgroup', 'fe_groups', 'deleted=0 '.$hiddenP.' AND uid IN ('.$grList.')'.$lockToDomain_SQL);
00192
00193 $groupRows = array();
00194
00195
00196 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00197 if(!in_array($row['uid'], $groups)) { $groups[] = $row['uid']; }
00198 $groupRows[$row['uid']] = $row;
00199 }
00200
00201
00202 $include_staticArr = t3lib_div::intExplode(',', $grList);
00203 foreach($include_staticArr as $uid) {
00204
00205
00206 $row=$groupRows[$uid];
00207 if (is_array($row) && !t3lib_div::inList($idList,$uid)) {
00208
00209
00210 if (trim($row['subgroup'])) {
00211 $theList = implode(',',t3lib_div::intExplode(',',$row['subgroup']));
00212 $this->getSubGroups($theList, $idList.','.$uid, $groups);
00213 }
00214 }
00215 }
00216 }
00217 }
00218
00219
00220
00221 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sv/class.tx_sv_auth.php']) {
00222 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sv/class.tx_sv_auth.php']);
00223 }
00224 ?>