TYPO3 CMS  TYPO3_6-2
FrontendBackendUserAuthentication.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend;
3 
20 
28 
34  public $formfield_uname = '';
35 
41  public $formfield_uident = '';
42 
48  public $formfield_chalvalue = '';
49 
55  public $writeStdLog = FALSE;
56 
62  public $writeAttemptLog = FALSE;
63 
69  public $extPageInTreeInfo = array();
70 
76  public $extAdmEnabled = FALSE;
77 
81  public $adminPanel = NULL;
82 
86  public $frontendEdit = NULL;
87 
91  public $extAdminConfig = array();
92 
98  public function initializeAdminPanel() {
99  $this->extAdminConfig = $this->getTSConfigProp('admPanel');
100  if (isset($this->extAdminConfig['enable.'])) {
101  foreach ($this->extAdminConfig['enable.'] as $value) {
102  if ($value) {
103  $this->adminPanel = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\View\\AdminPanelView');
104  $this->extAdmEnabled = TRUE;
105  break;
106  }
107  }
108  }
109  }
110 
116  public function initializeFrontendEdit() {
117  if (isset($this->extAdminConfig['enable.']) && $this->isFrontendEditingActive()) {
118  foreach ($this->extAdminConfig['enable.'] as $value) {
119  if ($value) {
120  if ($GLOBALS['TSFE'] instanceof \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController) {
121  // Grab the Page TSConfig property that determines which controller to use.
122  $pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
123  $controllerKey = isset($pageTSConfig['TSFE.']['frontendEditingController'])
124  ? $pageTSConfig['TSFE.']['frontendEditingController']
125  : 'default';
126  } else {
127  $controllerKey = 'default';
128  }
129  $controllerClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController'][$controllerKey];
130  if ($controllerClass) {
131  $this->frontendEdit = GeneralUtility::getUserObj($controllerClass, FALSE);
132  }
133  break;
134  }
135  }
136  }
137  }
138 
144  public function isFrontendEditingActive() {
145  return $this->extAdmEnabled && (
146  $this->adminPanel->isAdminModuleEnabled('edit') ||
147  $GLOBALS['TSFE']->displayEditIcons == 1 ||
148  $GLOBALS['TSFE']->displayFieldEditIcons == 1
149  );
150  }
151 
157  public function displayAdminPanel() {
158  return $this->adminPanel->display();
159  }
160 
166  public function isAdminPanelVisible() {
167  return $this->extAdmEnabled && !$this->extAdminConfig['hide'] && $GLOBALS['TSFE']->config['config']['admPanel'];
168  }
169 
170  /*****************************************************
171  *
172  * TSFE BE user Access Functions
173  *
174  ****************************************************/
182  // Check Hardcoded lock on BE
183  if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
184  return FALSE;
185  }
186  // Check IP
187  if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
188  $remoteAddress = GeneralUtility::getIndpEnv('REMOTE_ADDR');
189  if (!GeneralUtility::cmpIP($remoteAddress, $GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
190  return FALSE;
191  }
192  }
193  // Check SSL (https)
194  if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] && (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] !== 3) {
195  if (!GeneralUtility::getIndpEnv('TYPO3_SSL')) {
196  return FALSE;
197  }
198  }
199  // Finally a check from \TYPO3\CMS\Core\Authentication\BackendUserAuthentication::backendCheckLogin()
200  if ($this->isUserAllowedToLogin()) {
201  return TRUE;
202  } else {
203  return FALSE;
204  }
205  }
206 
217  public function extPageReadAccess($pageRec) {
218  return $this->isInWebMount($pageRec['uid']) && $this->doesUserHaveAccess($pageRec, 1);
219  }
220 
221  /*****************************************************
222  *
223  * TSFE BE user Access Functions
224  *
225  ****************************************************/
236  public function extGetTreeList($id, $depth, $begin = 0, $perms_clause) {
237  $depth = (int)$depth;
238  $begin = (int)$begin;
239  $id = (int)$id;
240  $theList = '';
241  if ($id && $depth > 0) {
242  $where = 'pid=' . $id . ' AND doktype IN (' . $GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes']
243  . ') AND deleted=0 AND ' . $perms_clause;
244  $res = $this->db->exec_SELECTquery('uid,title', 'pages', $where);
245  while (($row = $this->db->sql_fetch_assoc($res))) {
246  if ($begin <= 0) {
247  $theList .= $row['uid'] . ',';
248  $this->extPageInTreeInfo[] = array($row['uid'], htmlspecialchars($row['title'], $depth));
249  }
250  if ($depth > 1) {
251  $theList .= $this->extGetTreeList($row['uid'], $depth - 1, $begin - 1, $perms_clause);
252  }
253  }
254  $this->db->sql_free_result($res);
255  }
256  return $theList;
257  }
258 
265  public function extGetNumberOfCachedPages($pageId) {
267  $pageCache = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_pages');
268  $pageCacheEntries = $pageCache->getByTag('pageId_' . (int)$pageId);
269  return count($pageCacheEntries);
270  }
271 
272  /*****************************************************
273  *
274  * Localization handling
275  *
276  ****************************************************/
287  public function extGetLL($key) {
288  if (!is_array($GLOBALS['LOCAL_LANG'])) {
289  $this->getLanguageService()->includeLLFile('EXT:lang/locallang_tsfe.xlf');
290  if (!is_array($GLOBALS['LOCAL_LANG'])) {
291  $GLOBALS['LOCAL_LANG'] = array();
292  }
293  }
294  // Label string in the default backend output charset.
295  $labelStr = htmlspecialchars($this->getLanguageService()->getLL($key));
296  $labelStr = $this->getLanguageService()->csConvObj->utf8_to_entities($labelStr);
297  // Return the result:
298  return $labelStr;
299  }
300 
304  protected function getLanguageService() {
305  return $GLOBALS['LANG'];
306  }
307 
308 }
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]