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