return ['validationResult' => $smtp->testConnection()];
}
- /**
- * Validates the "generateRewriteRules" action
- * @throws \wcf\system\exception\AJAXException
- */
public function validateGenerateRewriteRules() {
WCF::getSession()->checkPermissions(['admin.configuration.canEditOption']);
-
- if (!FileUtil::isApacheModule()) {
- throw new AJAXException(WCF::getLanguage()->get('wcf.acp.rewrite.error.notApache'));
- }
}
/**
* @return string
*/
public function generateRewriteRules() {
- $output = '';
-
- foreach ($this->fetchRewriteRules() as $path => $content) {
- $output .= <<<SNIPPET
-<span class="inlineCode">{$path}</span>
-<pre>{$content}</pre>
-<br>
-SNIPPET;
-
- }
-
- return $output;
+ return WCF::getTPL()->fetch('__optionRewriteRulesOutput', 'wcf', [
+ 'rewriteRules' => $this->fetchRewriteRules(),
+ ]);
}
/**
* Returns an array with rewrite rules per necessary directory/file
* Applications in sub-directories of another application will be mapped to the top one
*
- * @return string[]
+ * @return string[][]
*/
protected function fetchRewriteRules() {
- $dirs = $rules = [];
+ $dirs = [];
+ $rules = [
+ 'apache' => [],
+ ];
foreach (ApplicationHandler::getInstance()->getApplications() as $app) {
$test = $app->getPackage()->getAbsolutePackageDir();
$insert = true;
krsort($domainPaths);
foreach ($domainPaths as $domainPath => $value) {
- $path = FileUtil::removeTrailingSlash(substr($value, strlen($dir)));
- $snippet = <<<SNIPPET
+ $htaccess = "{$dir}.htaccess";
+ if (empty($rules['apache'][$htaccess])) {
+ $path = FileUtil::removeTrailingSlash(substr($value, strlen($dir)));
+ $rules['apache'][$htaccess] = <<<SNIPPET
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/{$path}(.*)$ {$path}/index.php?$1 [L,QSA]
SNIPPET;
- $rules[$dir . '.htaccess'] = (!empty($rules[$dir . '.htaccess']) ? $rules[$dir . '.htaccess'] . "\n \n " : '') . $snippet;
+ }
}
}
<item name="wcf.acp.rescueMode.username.notAuthorized"><![CDATA[Diese Benutzer ist nicht berechtigt die Konfiguration zu verändern.]]></item>
</category>
<category name="wcf.acp.rewrite">
- <item name="wcf.acp.rewrite"><![CDATA[Rewrite-Regeln (Apache)]]></item>
+ <item name="wcf.acp.rewrite"><![CDATA[Rewrite-Regeln]]></item>
+ <item name="wcf.acp.rewrite.apache"><![CDATA[Apache (.htaccess)]]></item>
<item name="wcf.acp.rewrite.generate"><![CDATA[Rewrite-Regeln generieren]]></item>
<item name="wcf.acp.rewrite.description"><![CDATA[Generiert die Inhalte der benötigten .htaccess-Dateien und gibt sie aus. Beachte{if !LANGUAGE_USE_INFORMAL_VARIANT}n Sie{/if} bitte, dass die benötigten Regeln bei speziellen Server-Konfigurationen abweichen können.]]></item>
- <item name="wcf.acp.rewrite.error.notApache"><![CDATA[Der Webserver konnte nicht als Apache identifiziert werden. Diese Funktion unterstützt ausschließlich Rewrite-Regeln für Apache.]]></item>
</category>
<category name="wcf.acp.search">
<item name="wcf.acp.search.noResults"><![CDATA[Keine Treffer]]></item>
<item name="wcf.acp.rescueMode.username.notAuthorized"><![CDATA[This user is not authorized to manage installed apps.]]></item>
</category>
<category name="wcf.acp.rewrite">
- <item name="wcf.acp.rewrite"><![CDATA[Rewrite Rules (Apache)]]></item>
+ <item name="wcf.acp.rewrite"><![CDATA[Rewrite Rules]]></item>
+ <item name="wcf.acp.rewrite.apache"><![CDATA[Apache (.htaccess)]]></item>
<item name="wcf.acp.rewrite.generate"><![CDATA[Generate Rewrite-Rules]]></item>
<item name="wcf.acp.rewrite.description"><![CDATA[Generates the rewrite rules for necessary .htaccess-files. Please keep in mind, that you might have to provide different rules for special webserver configurations.]]></item>
- <item name="wcf.acp.rewrite.error.notApache"><![CDATA[Your webserver could not be identified as Apache. This function supports rewrite rules for Apache only.]]></item>
</category>
<category name="wcf.acp.search">
<item name="wcf.acp.search.noResults"><![CDATA[No results]]></item>