TYPO3 CMS  TYPO3_7-6
AdminCommand.php
Go to the documentation of this file.
1 <?php
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 
21 {
25  public $adminModules = [
26  'setBElock' => 'Set the Backend Lock',
27  'clearBElock' => 'Clears the Backend Lock',
28  'msg' => 1
29  ];
30 
34  public function __construct()
35  {
36  // Running parent class constructor
37  parent::__construct();
38  // Adding options to help archive:
39  $this->cli_options[] = ['--redirect=[URL]', 'For toolkey "setBElock": The URL to which the redirection will occur.'];
40  // Setting help texts:
41  $this->cli_help['name'] = 'lowlevel_admin -- Various functions for administration and maintenance of TYPO3 from the command line';
42  $this->cli_help['synopsis'] = 'toolkey ###OPTIONS###';
43  $this->cli_help['description'] = 'The \'toolkey\' keywords are:
44 
45  ' . implode('
46  ', array_keys($this->adminModules));
47  $this->cli_help['examples'] = '/.../cli_dispatch.phpsh lowlevel_admin setBElock --redirect=http://url_which_explains_why.com/';
48  $this->cli_help['author'] = 'Kasper Skaarhoej, (c) 2009';
49  }
50 
51  /**************************
52  *
53  * CLI functionality
54  *
55  *************************/
62  public function cli_main($argv)
63  {
64  // Force user to admin state and set workspace to "Live":
65  $GLOBALS['BE_USER']->user['admin'] = 1;
66  $GLOBALS['BE_USER']->setWorkspace(0);
67  // Print help
68  $analysisType = (string)$this->cli_args['_DEFAULT'][1];
69  if (!$analysisType) {
70  $this->cli_validateArgs();
71  $this->cli_help();
72  die;
73  }
74  // Analysis type:
75  switch ((string)$analysisType) {
76  case 'setBElock':
77  if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
78  $this->cli_echo('A lockfile already exists. Overwriting it...
79 ');
80  }
81  $lockFileContent = $this->cli_argValue('--redirect');
82  \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_typo3conf . 'LOCK_BACKEND', $lockFileContent);
83  $this->cli_echo('Wrote lock-file to \'' . PATH_typo3conf . 'LOCK_BACKEND\' with content \'' . $lockFileContent . '\'');
84  break;
85  case 'clearBElock':
86  if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
87  unlink(PATH_typo3conf . 'LOCK_BACKEND');
88  if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
89  $this->cli_echo('ERROR: Could not remove lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\'!!
90 ', 1);
91  } else {
92  $this->cli_echo('Removed lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\'
93 ');
94  }
95  } else {
96  $this->cli_echo('No lock file \'' . PATH_typo3conf . 'LOCK_BACKEND\' was found; hence no lock can be removed.\'
97 ');
98  }
99  break;
100  default:
101  $this->cli_echo('Unknown toolkey, \'' . $analysisType . '\'');
102  }
103  $this->cli_echo(LF);
104  }
105 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static writeFile($file, $content, $changePermissions=false)