TYPO3 CMS  TYPO3_7-6
FrontendBackendUserAuthentication.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
26 {
32  public $formfield_uname = '';
33 
39  public $formfield_uident = '';
40 
46  public $writeStdLog = false;
47 
53  public $writeAttemptLog = false;
54 
60  public $extPageInTreeInfo = [];
61 
67  public $extAdmEnabled = false;
68 
72  public $adminPanel = null;
73 
77  public $frontendEdit = null;
78 
82  public $extAdminConfig = [];
83 
89  public function initializeAdminPanel()
90  {
91  $this->extAdminConfig = $this->getTSConfigProp('admPanel');
92  if (isset($this->extAdminConfig['enable.'])) {
93  foreach ($this->extAdminConfig['enable.'] as $value) {
94  if ($value) {
95  $this->adminPanel = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\View\AdminPanelView::class);
96  $this->extAdmEnabled = true;
97  break;
98  }
99  }
100  }
101  }
102 
108  public function initializeFrontendEdit()
109  {
110  if (isset($this->extAdminConfig['enable.']) && $this->isFrontendEditingActive()) {
111  foreach ($this->extAdminConfig['enable.'] as $value) {
112  if ($value) {
113  if ($GLOBALS['TSFE'] instanceof \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController) {
114  // Grab the Page TSConfig property that determines which controller to use.
115  $pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
116  $controllerKey = isset($pageTSConfig['TSFE.']['frontendEditingController'])
117  ? $pageTSConfig['TSFE.']['frontendEditingController']
118  : 'default';
119  } else {
120  $controllerKey = 'default';
121  }
122  $controllerClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController'][$controllerKey];
123  if ($controllerClass) {
124  $this->frontendEdit = GeneralUtility::getUserObj($controllerClass);
125  }
126  break;
127  }
128  }
129  }
130  }
131 
137  public function isFrontendEditingActive()
138  {
139  return $this->extAdmEnabled && (
140  $this->adminPanel->isAdminModuleEnabled('edit') ||
141  $GLOBALS['TSFE']->displayEditIcons == 1 ||
142  $GLOBALS['TSFE']->displayFieldEditIcons == 1
143  );
144  }
145 
151  public function displayAdminPanel()
152  {
153  return $this->adminPanel->display();
154  }
155 
161  public function isAdminPanelVisible()
162  {
163  return $this->extAdmEnabled && !$this->extAdminConfig['hide'] && $GLOBALS['TSFE']->config['config']['admPanel'];
164  }
165 
166  /*****************************************************
167  *
168  * TSFE BE user Access Functions
169  *
170  ****************************************************/
178  {
179  // Check Hardcoded lock on BE
180  if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
181  return false;
182  }
183  // Check IP
184  if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
185  $remoteAddress = GeneralUtility::getIndpEnv('REMOTE_ADDR');
186  if (!GeneralUtility::cmpIP($remoteAddress, $GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
187  return false;
188  }
189  }
190  // Check SSL (https)
191  if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] && !GeneralUtility::getIndpEnv('TYPO3_SSL')) {
192  return false;
193  }
194  // Finally a check from \TYPO3\CMS\Core\Authentication\BackendUserAuthentication::backendCheckLogin()
195  if ($this->isUserAllowedToLogin()) {
196  return true;
197  } else {
198  return false;
199  }
200  }
201 
212  public function extPageReadAccess($pageRec)
213  {
214  return $this->isInWebMount($pageRec['uid']) && $this->doesUserHaveAccess($pageRec, 1);
215  }
216 
217  /*****************************************************
218  *
219  * TSFE BE user Access Functions
220  *
221  ****************************************************/
232  public function extGetTreeList($id, $depth, $begin = 0, $perms_clause)
233  {
234  $depth = (int)$depth;
235  $begin = (int)$begin;
236  $id = (int)$id;
237  $theList = '';
238  if ($id && $depth > 0) {
239  $where = 'pid=' . $id . ' AND doktype IN (' . $GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes']
240  . ') AND deleted=0 AND ' . $perms_clause;
241  $res = $this->db->exec_SELECTquery('uid,title', 'pages', $where);
242  while (($row = $this->db->sql_fetch_assoc($res))) {
243  if ($begin <= 0) {
244  $theList .= $row['uid'] . ',';
245  $this->extPageInTreeInfo[] = [$row['uid'], htmlspecialchars($row['title'], $depth)];
246  }
247  if ($depth > 1) {
248  $theList .= $this->extGetTreeList($row['uid'], $depth - 1, $begin - 1, $perms_clause);
249  }
250  }
251  $this->db->sql_free_result($res);
252  }
253  return $theList;
254  }
255 
262  public function extGetNumberOfCachedPages($pageId)
263  {
265  $pageCache = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('cache_pages');
266  $pageCacheEntries = $pageCache->getByTag('pageId_' . (int)$pageId);
267  return count($pageCacheEntries);
268  }
269 
270  /*****************************************************
271  *
272  * Localization handling
273  *
274  ****************************************************/
285  public function extGetLL($key)
286  {
287  if (!is_array($GLOBALS['LOCAL_LANG'])) {
288  $this->getLanguageService()->includeLLFile('EXT:lang/locallang_tsfe.xlf');
289  if (!is_array($GLOBALS['LOCAL_LANG'])) {
290  $GLOBALS['LOCAL_LANG'] = [];
291  }
292  }
293  // Return the label string in the default backend output charset.
294  return htmlspecialchars($this->getLanguageService()->getLL($key));
295  }
296 
300  protected function getLanguageService()
301  {
302  return $GLOBALS['LANG'];
303  }
304 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']