TYPO3 CMS  TYPO3_6-2
AjaxController.php
Go to the documentation of this file.
1 <?php
3 
22 
26  protected $unauthorized = 'unauthorized';
27 
31  protected $authenticationActions = array(
32  'extensionCompatibilityTester',
33  'uninstallExtension',
34  'clearCache',
35  'coreUpdateUpdateVersionMatrix',
36  'coreUpdateIsUpdateAvailable',
37  'coreUpdateCheckPreConditions',
38  'coreUpdateDownload',
39  'coreUpdateVerifyChecksum',
40  'coreUpdateUnpack',
41  'coreUpdateMove',
42  'coreUpdateActivate',
43  'folderStatus',
44  'environmentStatus'
45  );
46 
52  public function execute() {
53  $this->loadBaseExtensions();
54  $this->initializeObjectManager();
55  // Warning: Order of these methods is security relevant and interferes with different access
56  // conditions (new/existing installation). See the single method comments for details.
59  $this->initializeSession();
60  $this->checkSessionToken();
61  $this->checkSessionLifetime();
62  $this->checkLogin();
63  $this->dispatchAuthenticationActions();
64  }
65 
72  if (!$this->isInstallToolAvailable()) {
73  $this->output($this->unauthorized);
74  }
75  }
76 
82  protected function checkInstallToolPasswordNotSet() {
83  if (empty($GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword'])) {
84  $this->output($this->unauthorized);
85  }
86  }
87 
93  protected function checkLogin() {
94  if (!$this->session->isAuthorized()) {
95  $this->output($this->unauthorized);
96  } else {
97  $this->session->refreshSession();
98  }
99  }
100 
108  protected function handleSessionTokenCheck($tokenOk) {
109  if (!$tokenOk) {
110  $this->output($this->unauthorized);
111  }
112  }
113 
120  protected function handleSessionLifeTimeExpired() {
121  $this->output($this->unauthorized);
122  }
123 
130  protected function dispatchAuthenticationActions() {
131  $action = $this->getAction();
132  if ($action === '') {
133  $this->output('noAction');
134  }
135  $this->validateAuthenticationAction($action);
136  $actionClass = ucfirst($action);
138  $toolAction = $this->objectManager->get('TYPO3\\CMS\\Install\\Controller\\Action\\Ajax\\' . $actionClass);
139  if (!($toolAction instanceof Action\ActionInterface)) {
140  throw new Exception(
141  $action . ' does not implement ActionInterface',
142  1369474308
143  );
144  }
145  $toolAction->setController('ajax');
146  $toolAction->setAction($action);
147  $toolAction->setToken($this->generateTokenForAction($action));
148  $toolAction->setPostValues($this->getPostValues());
149  $this->output($toolAction->handle());
150  }
151 
158  protected function output($content = '') {
159  ob_clean();
160  header('Content-Type: application/json; charset=utf-8');
161  header('Cache-Control: no-cache, must-revalidate');
162  header('Pragma: no-cache');
163  echo $content;
164  die;
165  }
166 }
die
Definition: index.php:6
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]