/** * Execute command * * @param InputInterface $input Input instance * @param OutputInterface $output Output instance * * @return int|null|void */ public function execute(InputInterface $input, OutputInterface $output) { // #################### // Init // #################### $basePath = $this->getApplication()->getConfigValue('config', 'www_base_path', '/var/www/'); $maxDepth = 3; $output->writeln('<h2>Clear TYPO3 cache</h2>'); if ($input->getArgument('path')) { $basePath = $input->getArgument('path'); } // #################### // Find and loop through TYPO3 instances // #################### foreach (Typo3Utility::getTypo3InstancePathList($basePath, $maxDepth) as $dirPath) { // Check if coreapi is installed if (!is_dir($dirPath . '/typo3conf/ext/coreapi/')) { $output->writeln('<p>EXT:coreapi is missing on ' . $dirPath . ', skipping</p>'); continue; } $params = array($dirPath . '/typo3/cli_dispatch.phpsh', 'coreapi', 'cache:clearallcaches'); $output->writeln('<p>Running clearcache command on ' . $dirPath . '</p>'); try { $command = new CommandBuilder('php'); $command->setArgumentList($params)->executeInteractive(); } catch (\Exception $e) { $output->writeln('<p-error> Failed with exception: ' . $e->getMessage() . '</p-error>'); } } return 0; }
/** * Execute command * * @param InputInterface $input Input instance * @param OutputInterface $output Output instance * * @return int|null|void */ public function execute(InputInterface $input, OutputInterface $output) { // #################### // Init // #################### $basePath = $this->getApplication()->getConfigValue('config', 'www_base_path', '/var/www/'); $maxDepth = 3; $enableInstaller = true; $basePath = Typo3Utility::guessBestTypo3BasePath($basePath, $input, 'path'); if ($input->getOption('remove')) { $enableInstaller = false; } // #################### // Find and loop through TYPO3 instances // #################### foreach (Typo3Utility::getTypo3InstancePathList($basePath, $maxDepth) as $dirPath) { $installFilePath = $dirPath . '/typo3conf/ENABLE_INSTALL_TOOL'; if ($enableInstaller) { // #################### // Enable installer // #################### // Check if install tool file is already there if (is_file($installFilePath)) { // Already existing, just update timestamp touch($installFilePath); $output->writeln('<comment>Already enabled on ' . $dirPath . '</comment>'); } else { // Not existing, create file touch($installFilePath); $output->writeln('<info>Enabled on ' . $dirPath . '</info>'); } } else { // #################### // Disable installer // #################### // Check if install tool file is already there if (is_file($installFilePath)) { // Remove installer file unlink($installFilePath); $output->writeln('<info>Disabled on ' . $dirPath . '</info>'); } else { $output->writeln('<comment>Not enabled on ' . $dirPath . '</comment>'); } } } return 0; }
/** * Execute command * * @param InputInterface $input Input instance * @param OutputInterface $output Output instance * * @return int|null|void */ public function execute(InputInterface $input, OutputInterface $output) { // #################### // Init // #################### $basePath = $this->getApplication()->getConfigValue('config', 'www_base_path', '/var/www/'); $maxDepth = 3; $basePath = Typo3Utility::guessBestTypo3BasePath($basePath, $input, 'path'); $versionFileList = array('/typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php' => '/define\\(\'TYPO3_version\',[\\s]*\'([^\']+)\'\\)/i', '/t3lib/config_default.php' => '/\\$TYPO_VERSION[\\s]*=[\\s]*\'([^\']+)\'/i'); // #################### // Find and loop through TYPO3 instances // #################### $typo3List = array(); foreach (Typo3Utility::getTypo3InstancePathList($basePath, $maxDepth) as $dirPath) { $typo3Version = null; $typo3Path = $dirPath; // Detect version (dirty way...) foreach ($versionFileList as $versionFile => $versionRegExp) { $versionFile = $dirPath . $versionFile; if (file_exists($versionFile)) { $tmp = file_get_contents($versionFile); if (preg_match($versionRegExp, $tmp, $matches)) { $typo3Version = $matches[1]; break; } } } if (strpos($typo3Version, '6') === 0) { // TYPO3 6.x $typo3Version = '<info>' . $typo3Version . '</info>'; } elseif (!empty($typo3Version)) { // TYPO3 4.x $typo3Version = '<comment>' . $typo3Version . '</comment>'; } else { // Unknown $typo3Version = '<error>unknown</error>'; } $typo3List[] = array($typo3Path, $typo3Version); } $table = new Table($output); $table->setHeaders(array('Path', 'Version')); foreach ($typo3List as $row) { $table->addRow(array_values($row)); } $table->render(); return 0; }
/** * Execute command * * @param InputInterface $input Input instance * @param OutputInterface $output Output instance * * @return int|null|void */ public function execute(InputInterface $input, OutputInterface $output) { // #################### // Init // #################### $basePath = $this->getApplication()->getConfigValue('config', 'www_base_path', '/var/www/'); $maxDepth = 3; $basePath = Typo3Utility::guessBestTypo3BasePath($basePath, $input, 'path'); // #################### // Find and loop through TYPO3 instances // #################### foreach (Typo3Utility::getTypo3InstancePathList($basePath, $maxDepth) as $dirPath) { $output->writeln('<info>Running TYPO3 scheduler on ' . $dirPath . '</info>'); try { $command = new CommandBuilder('php'); $command->addArgument('/typo3/cli_dispatch.phpsh')->addArgument('scheduler')->executeInteractive(); } catch (\Exception $e) { $output->writeln('<error>Failed TYPO3 scheduler on ' . $dirPath . '</error>'); } } return 0; }
/** * Execute command * * @param InputInterface $input Input instance * @param OutputInterface $output Output instance * * @return int|null|void */ public function execute(InputInterface $input, OutputInterface $output) { // ################## // Init // ################## $dbName = $input->getArgument('database'); $username = $input->getArgument('user'); $password = $input->getArgument('password'); $output->writeln('<h2>Injecting TYPO3 backend user</h2>'); // Set default user if not specified if (empty($username)) { $username = '******'; } // check username if (!preg_match('/^[-_a-zA-Z0-9\\.]+$/', $username)) { $output->writeln('<p-error>Invalid username</p-error>'); return 1; } $output->writeln('<p>Using user: "******"</p>'); // Set default password if not specified if (empty($password)) { $password = '******'; } $output->writeln('<p>Using pass: "******"</p>'); // ################## // Salting // ################## if ($input->getOption('plain')) { // Standard md5 $password = Typo3Utility::generatePassword($password, Typo3Utility::PASSWORD_TYPE_MD5); $this->output->writeln('<p>Generating plain (non salted) md5 password</p>'); } else { // Salted md5 $password = Typo3Utility::generatePassword($password, Typo3Utility::PASSWORD_TYPE_MD5_SALTED); $this->output->writeln('<p>Generating salted md5 password</p>'); } // ############## // Loop through databases // ############## if (empty($dbName)) { // ############## // All databases // ############## $databaseList = DatabaseConnection::databaseList(); $dbFound = false; foreach ($databaseList as $dbName) { // Check if database is TYPO3 instance $query = 'SELECT COUNT(*) as count FROM information_schema.tables WHERE table_schema = ' . DatabaseConnection::quote($dbName) . ' AND table_name = \'be_users\''; $isTypo3Database = DatabaseConnection::getOne($query); if ($isTypo3Database) { $this->setTypo3UserForDatabase($dbName, $username, $password); $dbFound = true; } } if (!$dbFound) { $output->writeln('<p-error>No valid TYPO3 database found</p-error>'); } } else { // ############## // One databases // ############## $this->setTypo3UserForDatabase($dbName, $username, $password); } return 0; }