*/ /** * Core functions for administration * * @author Kasper Skårhøj * @package TYPO3 * @subpackage tx_lowlevel */ class tx_lowlevel_admin_core extends t3lib_cli { var $adminModules = array( 'setBElock' => 'Set the Backend Lock', 'clearBElock' => 'Clears the Backend Lock', 'msg' => 1 ); /** * Constructor * * @return void */ function __construct() { // Running parent class constructor parent::__construct(); // Adding options to help archive: $this->cli_options[] = array('--redirect=[URL]', 'For toolkey "setBElock": The URL to which the redirection will occur.'); // Setting help texts: $this->cli_help['name'] = 'lowlevel_admin -- Various functions for administration and maintenance of TYPO3 from the command line'; $this->cli_help['synopsis'] = 'toolkey ###OPTIONS###'; $this->cli_help['description'] = "The 'toolkey' keywords are:\n\n ".implode("\n ", array_keys($this->adminModules)); $this->cli_help['examples'] = "/.../cli_dispatch.phpsh lowlevel_admin setBElock --redirect=http://url_which_explains_why.com/"; $this->cli_help['author'] = "Kasper Skaarhoej, (c) 2009"; } /************************** * * CLI functionality * *************************/ /** * CLI engine * * @param array Command line arguments * @return string */ function cli_main($argv) { // Force user to admin state and set workspace to "Live": $GLOBALS['BE_USER']->user['admin'] = 1; $GLOBALS['BE_USER']->setWorkspace(0); // Print help $analysisType = (string)$this->cli_args['_DEFAULT'][1]; if (!$analysisType) { $this->cli_validateArgs(); $this->cli_help(); exit; } // Analysis type: switch((string)$analysisType) { case 'setBElock': if (@is_file(PATH_typo3conf.'LOCK_BACKEND')) { $this->cli_echo("A lockfile already exists. Overwriting it... \n"); } $lockFileContent = $this->cli_argValue('--redirect'); t3lib_div::writeFile(PATH_typo3conf.'LOCK_BACKEND', $lockFileContent); $this->cli_echo("Wrote lock-file to '".PATH_typo3conf."LOCK_BACKEND' with content '".$lockFileContent."'"); break; case 'clearBElock': if (@is_file(PATH_typo3conf.'LOCK_BACKEND')) { unlink(PATH_typo3conf.'LOCK_BACKEND'); if (@is_file(PATH_typo3conf.'LOCK_BACKEND') ) { $this->cli_echo("ERROR: Could not remove lock file '".PATH_typo3conf."LOCK_BACKEND'!!\n", 1); } else { $this->cli_echo("Removed lock file '".PATH_typo3conf."LOCK_BACKEND'\n"); } } else { $this->cli_echo("No lock file '".PATH_typo3conf."LOCK_BACKEND' was found; hence no lock can be removed.'\n"); } break; default: $this->cli_echo("Unknown toolkey, '".$analysisType."'"); break; } $this->cli_echo(LF); } } ?>