/** * @see AdminToolsFunction::execute($data) */ public function execute($data) { parent::execute($data); $parameters = $data['parameters']['database.optimize']; $tables = WCF::getDB()->getTableNames(); $message = WCF::getLanguage()->get('wcf.acp.admintools.function.success', array('$functionName' => WCF::getLanguage()->get('wcf.acp.admintools.function.' . $data['functionName']))) . '<ul>'; if ($parameters['analyze']) { foreach ($tables as $table) { WCF::getDB()->sendQuery('ANALYZE TABLE ' . $table); } $message .= WCF::getLanguage()->get('wcf.acp.admintools.function.database.optimize.analyze.success', array('$tableCount' => count($tables))); } if ($parameters['optimize']) { foreach ($tables as $table) { WCF::getDB()->sendQuery('OPTIMIZE TABLE ' . $table); } $message .= WCF::getLanguage()->get('wcf.acp.admintools.function.database.optimize.optimize.success', array('$tableCount' => count($tables))); } if (!count($tables) || !$parameters['analyze'] && !$parameters['optimize']) { $this->setReturnMessage('error', WCF::getLanguage()->get('wcf.acp.admintools.function.database.optimize.analyze.error')); } else { $this->setReturnMessage('success', $message . '</ul>'); } $this->executed(); }
/** * @see AdminToolsFunction::execute($data) */ public function execute($data) { parent::execute($data); $parameters = $data['parameters']['cache.clearCache']; if ($parameters['clearWCFCache']) { WCF::getCache()->clear(WCF_DIR . 'cache', '*.php', true); } if ($parameters['clearStandaloneCache']) { $sql = "SELECT packageDir FROM wcf" . WCF_N . "_package WHERE packageID = " . PACKAGE_ID; $row = WCF::getDB()->getFirstRow($sql); WCF::getCache()->clear($row['packageDir'] . 'cache', '*.php', true); } if ($parameters['clearTemplateCache']) { require_once WCF_DIR . 'lib/system/template/ACPTemplate.class.php'; ACPTemplate::deleteCompiledACPTemplates(); Template::deleteCompiledTemplates(); } if ($parameters['clearLanguageCache']) { LanguageEditor::deleteLanguageFiles('*', '*', '*'); } if ($parameters['clearStandaloneOptions']) { Options::resetCache(); Options::resetFile(); } $this->executed(); }
/** * @see AdminToolsFunction::execute($data) */ public function execute($data) { parent::execute($data); $generalOptions = $data['parameters']['user.inactiveUsers.general']; // initalize the default condition to filter certain users $this->ignoreCondition = new ConditionBuilder(false); $this->ignoreCondition->add('user.userID NOT IN (' . $generalOptions['ignoredUserIDs'] . ')'); $this->ignoreCondition->add('user.userID NOT IN (SELECT userID FROM wcf' . WCF_N . '_user_to_groups WHERE groupID IN (' . $generalOptions['ignoredUsergroupIDs'] . '))'); $this->ignoreCondition->add('user.registrationDate < ' . (TIME_NOW - $generalOptions['periodOfGrace'] * 86400)); $this->handleUserDelete($generalOptions); if ($generalOptions['sendProtocol']) { $this->sendProtocol(); } $this->setReturnMessage('success', WCF::getLanguage()->get('wcf.acp.admintools.function.user.inactiveUsers.success', array('$countDeleted' => count($this->deletedInactiveUsers), '$countWarned' => count($this->warnedInactiveUsers)))); $this->executed(); }
/** * @see AdminToolsFunction::execute($data) */ public function execute($data) { parent::execute($data); $parameters = $data['parameters']['user.usergroupcopy']; if ($parameters['sourceGroup'] == $parameters['targetGroup']) { $this->setReturnMessage('error', WCF::getLanguage()->get('wcf.acp.admintools.function.' . $data['functionName'] . '.sourceEqualsTarget')); return; } $sql = "DELETE FROM wcf" . WCF_N . "_group_option_value\n\t\t\t\tWHERE groupID = " . $parameters['targetGroup']; WCF::getDB()->sendQuery($sql); $sql = "INSERT INTO wcf" . WCF_N . "_group_option_value\n (groupID, optionID, optionValue)\n \t\tSELECT " . $parameters['targetGroup'] . ", optionID, optionValue\n \t\tFROM wcf" . WCF_N . "_group_option_value\n \t\tWHERE groupID = " . $parameters['sourceGroup']; WCF::getDB()->sendQuery($sql); if ($parameters['copyUsers']) { $sql = "DELETE FROM wcf" . WCF_N . "_user_to_groups\n \tWHERE groupID = " . $parameters['targetGroup']; WCF::getDB()->sendQuery($sql); $sql = "INSERT INTO wcf" . WCF_N . "_user_to_groups\n (userID, groupID)\n \tSELECT userID, " . $parameters['targetGroup'] . "\n \tFROM wcf" . WCF_N . "_user_to_groups\n \tWHERE groupID = " . $parameters['sourceGroup']; WCF::getDB()->sendQuery($sql); } $this->executed(); }
/** * @see AdminToolsFunction::execute($data) */ public function execute($data) { parent::execute($data); $parameters = $data['parameters']['user.languagedefaults']; $condition = ''; if ($parameters['correctonly']) { $languages = array_keys(LanguageEditor::getLanguages()); foreach ($languages as $language) { if (!empty($condition)) { $condition .= ','; } $condition .= $language; } } $sql = "UPDATE wcf" . WCF_N . "_user\n\t\t\t\tSET languageID = " . $parameters['languageID'] . (!empty($condition) ? " WHERE languageID NOT IN(" . $condition . ")" : ""); WCF::getDB()->sendQuery($sql); $message = WCF::getLanguage()->get('wcf.acp.admintools.function.success', array('$functionName' => WCF::getLanguage()->get('wcf.acp.admintools.function.' . $data['functionName']))); $message .= WCF::getLanguage()->get('wcf.acp.admintools.function.' . $data['functionName'] . '.affectedUsers', array('$affectedUsers' => WCF::getDB()->getAffectedRows())); $this->setReturnMessage('success', $message); $this->executed(); }
/** * @see AdminToolsFunction::execute($data) */ public function execute($data) { parent::execute($data); $parameters = $data['parameters']['database.config']; $error = array(); $missingTables = array(); $wcfExistingTables = WCF::getDB()->getTableNames(); $wcfRequiredTables = $this->replaceWcfNumber($parameters['wcfNumber']); // Check dbHost if (empty($parameters['dbHost'])) { $error[] = WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorDbHostEmpty'); } // Check dbUser if (empty($parameters['dbUser'])) { $error[] = WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorDbUserEmpty'); } // Check dbPassword's if (empty($parameters['dbPassword1'])) { $error[] = WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorDbPassword1Empty'); } elseif (!empty($parameters['dbPassword1']) && empty($parameters['dbPassword2'])) { $error[] = WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorDbPassword2Empty'); } elseif ($parameters['dbPassword1'] != $parameters['dbPassword2']) { $error[] = WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorDbPasswordsUnequal'); } // Check dbName if (empty($parameters['dbName'])) { $error[] = WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorDbNameEmpty'); } // Check dbCharset if ($parameters['dbCharset'] == '0') { $error[] = WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorDbCharsetEmpty'); } // Check wcfNumber if (empty($parameters['wcfNumber']) || $parameters['wcfNumber'] == '0') { $error[] = WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorWcfNumberEmpty'); } elseif (!is_int($parameters['wcfNumber'])) { $error[] = WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorWcfNumberNOTint'); } // Check oldDbPassword if (empty($parameters['oldDbPassword'])) { $error[] = WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorOldDbPasswordEmpty'); } elseif ($parameters['oldDbPassword'] != $this->_configPassword) { $error[] = WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorOldDbPasswordUnequal'); } // If $error send message if (count($error)) { $this->setReturnMessage('error', '<ul>' . implode($error) . '</ul>'); } else { // Check connection $connect = @mysql_connect($parameters['dbHost'], $parameters['dbUser'], $parameters['dbPassword1'], true); if (!$connect && $parameters['checkConnect']) { $this->setReturnMessage('error', '<ul>' . WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorNoConnect') . '</ul>'); } elseif (!@mysql_select_db($parameters['dbName'], $connect) && $parameters['checkConnect']) { $this->setReturnMessage('error', '<ul>' . WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorNoDatabase') . '</ul>'); } else { if ($parameters['checkTables'] && $parameters['checkConnect']) { foreach ($wcfRequiredTables as $table) { if (@mysql_num_rows(@mysql_query("SHOW TABLES LIKE '" . $table . "'", $connect)) == 0) { $missingTables[] = $table; $this->availableNotTables .= '<li>' . $table . '</li>'; } } // Count not available tables if (count($missingTables)) { count($missingTables) == count($wcfRequiredTables) ? $this->setReturnMessage('error', '<ul>' . WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorTablesFailing') . '</ul>') : $this->setReturnMessage('error', '<ul>' . WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorTablesIncompleted', array('$availableTables' => $this->availableNotTables)) . '</ul>'); } } elseif (!@copy(WCF_DIR . 'config.inc.php', WCF_DIR . 'acp/backup/wcf_' . date('Y-m-d-H-i-s', $this->_time) . '_config.inc.php')) { $this->setReturnMessage('error', '<ul>' . WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorBackupFailed') . '</ul>'); } else { $file = "<?php\n"; $file .= "\$dbHost = '" . StringUtil::replace("'", "\\'", $parameters['dbHost']) . "';\n"; $file .= "\$dbUser = '******'", "\\'", $parameters['dbUser']) . "';\n"; $file .= "\$dbPassword = '******'", "\\'", $parameters['dbPassword1']) . "';\n"; $file .= "\$dbName = '" . StringUtil::replace("'", "\\'", $parameters['dbName']) . "';\n"; $file .= "\$dbCharset = '" . StringUtil::replace("'", "\\'", $parameters['dbCharset']) . "';\n"; $file .= "\$dbClass = '" . StringUtil::replace("'", "\\'", $this->_configClass) . "';\n"; $file .= "if (!defined('WCF_N')) define('WCF_N', " . $parameters['wcfNumber'] . ");\n?>"; if (!@file_put_contents(WCF_DIR . 'config.inc.php', $file)) { $this->setReturnMessage('error', '<ul>' . WCF::getLanguage()->get('wcf.acp.admintools.function.database.config.errorCanNOTWrite') . '</ul>'); } else { $this->executed(); } } } @mysql_close($connect); } }