Compare commits
7 Commits
60f74c3247
...
2de6bfb149
Author | SHA1 | Date |
---|---|---|
Fred Tempez | 2de6bfb149 | |
Fred Tempez | 25d1556210 | |
Fred Tempez | ae71326bd0 | |
Fred Tempez | f567d7645d | |
Fred Tempez | 02766515c5 | |
fredtempez | 01dd64f3e1 | |
fredtempez | cc8dcce9e3 |
|
@ -32,5 +32,4 @@ Options -Indexes
|
||||||
Options -MultiViews
|
Options -MultiViews
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
|
||||||
# Attention, surtout ne rien modifier ci-dessous !
|
# URL rewriting (ne pas supprimer ce commentaire !)
|
||||||
# URL rewriting
|
|
|
@ -263,11 +263,15 @@ class helper {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function checkRewrite() {
|
public static function checkRewrite() {
|
||||||
if(self::$rewriteStatus === null) {
|
// N'interroge que le serveur Apache
|
||||||
|
if (strpos($_SERVER["SERVER_SOFTWARE"], 'Apache') > 0) {
|
||||||
|
self::$rewriteStatus === false;
|
||||||
|
} elseif(self::$rewriteStatus === null) {
|
||||||
// Ouvre et scinde le fichier .htaccess
|
// Ouvre et scinde le fichier .htaccess
|
||||||
$htaccess = explode('# URL rewriting', file_get_contents('.htaccess'));
|
$htaccess = explode('# URL rewriting', file_get_contents('.htaccess'));
|
||||||
// Retourne un boolean en fonction du contenu de la partie réservée à l'URL rewriting
|
// Retourne un boolean en fonction du contenu de la partie réservée à l'URL rewriting
|
||||||
self::$rewriteStatus = (empty($htaccess[1]) === false);
|
//self::$rewriteStatus = (empty($htaccess[1]) === false);
|
||||||
|
self::$rewriteStatus = (strpos($htaccess[1], 'RewriteEngine on') > 0) ? true : false;
|
||||||
}
|
}
|
||||||
return self::$rewriteStatus;
|
return self::$rewriteStatus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,6 @@ class common {
|
||||||
]);;
|
]);;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Import version 9
|
// Import version 9
|
||||||
if (file_exists(self::DATA_DIR . 'core.json') === true &&
|
if (file_exists(self::DATA_DIR . 'core.json') === true &&
|
||||||
$this->getData(['core','dataVersion']) < 10000) {
|
$this->getData(['core','dataVersion']) < 10000) {
|
||||||
|
|
|
@ -547,17 +547,21 @@ class config extends common {
|
||||||
AND helper::checkRewrite() === false
|
AND helper::checkRewrite() === false
|
||||||
) {
|
) {
|
||||||
// Ajout des lignes dans le .htaccess
|
// Ajout des lignes dans le .htaccess
|
||||||
file_put_contents(
|
$fileContent = file_get_contents('.htaccess');
|
||||||
'.htaccess',
|
$rewriteData = PHP_EOL .
|
||||||
PHP_EOL .
|
'# URL rewriting' . PHP_EOL .
|
||||||
'<IfModule mod_rewrite.c>' . PHP_EOL .
|
'<IfModule mod_rewrite.c>' . PHP_EOL .
|
||||||
"\tRewriteEngine on" . PHP_EOL .
|
"\tRewriteEngine on" . PHP_EOL .
|
||||||
"\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL .
|
"\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL .
|
||||||
"\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL .
|
"\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL .
|
||||||
"\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL .
|
"\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL .
|
||||||
"\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL .
|
"\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL .
|
||||||
'</IfModule>',
|
'</IfModule>'. PHP_EOL .
|
||||||
FILE_APPEND
|
'# URL rewriting' . PHP_EOL ;
|
||||||
|
$fileContent = str_replace('# URL rewriting', $rewriteData, $fileContent);
|
||||||
|
file_put_contents(
|
||||||
|
'.htaccess',
|
||||||
|
$fileContent
|
||||||
);
|
);
|
||||||
// Change le statut de la réécriture d'URL (pour le helper::baseUrl() de la redirection)
|
// Change le statut de la réécriture d'URL (pour le helper::baseUrl() de la redirection)
|
||||||
helper::$rewriteStatus = true;
|
helper::$rewriteStatus = true;
|
||||||
|
@ -568,8 +572,13 @@ class config extends common {
|
||||||
AND helper::checkRewrite()
|
AND helper::checkRewrite()
|
||||||
) {
|
) {
|
||||||
// Suppression des lignes dans le .htaccess
|
// Suppression des lignes dans le .htaccess
|
||||||
$htaccess = explode('# URL rewriting', file_get_contents('.htaccess'));
|
$fileContent = file_get_contents('.htaccess');
|
||||||
file_put_contents('.htaccess', $htaccess[0] . '# URL rewriting');
|
$fileContent = explode('# URL rewriting', $fileContent);
|
||||||
|
$fileContent = $fileContent[0] . '# URL rewriting' . $fileContent[2];
|
||||||
|
file_put_contents(
|
||||||
|
'.htaccess',
|
||||||
|
$fileContent
|
||||||
|
);
|
||||||
// Change le statut de la réécriture d'URL (pour le helper::baseUrl() de la redirection)
|
// Change le statut de la réécriture d'URL (pour le helper::baseUrl() de la redirection)
|
||||||
helper::$rewriteStatus = false;
|
helper::$rewriteStatus = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,9 +42,10 @@
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col6">
|
<div class="col6">
|
||||||
<?php echo template::checkbox('configRewrite', true, 'URL intelligentes', [
|
<?php echo template::checkbox('configRewrite', true, 'Apache URL intelligentes', [
|
||||||
'checked' => helper::checkRewrite(),
|
'checked' => helper::checkRewrite(),
|
||||||
'help' => 'Supprime ? dans les URL et redirige sur le protocole HTTPS.'
|
'help' => 'Supprime le point d\'interrogation dans les URL, l\'option est indisponible avec les autres serveurs Web',
|
||||||
|
'disabled' => strpos($_SERVER["SERVER_SOFTWARE"], 'Apache') > 0 ? true : false
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -252,19 +252,23 @@ class install extends common {
|
||||||
$success = true;
|
$success = true;
|
||||||
$rewrite = $this->getInput('data');
|
$rewrite = $this->getInput('data');
|
||||||
// Réécriture d'URL
|
// Réécriture d'URL
|
||||||
if ($rewrite === "true") {
|
if ($rewrite === "true") { // Ajout des lignes dans le .htaccess
|
||||||
$success = (file_put_contents(
|
$fileContent = file_get_contents('.htaccess');
|
||||||
'.htaccess',
|
$rewriteData = PHP_EOL .
|
||||||
PHP_EOL .
|
'# URL rewriting' . PHP_EOL .
|
||||||
'<IfModule mod_rewrite.c>' . PHP_EOL .
|
'<IfModule mod_rewrite.c>' . PHP_EOL .
|
||||||
"\tRewriteEngine on" . PHP_EOL .
|
"\tRewriteEngine on" . PHP_EOL .
|
||||||
"\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL .
|
"\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL .
|
||||||
"\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL .
|
"\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL .
|
||||||
"\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL .
|
"\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL .
|
||||||
"\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL .
|
"\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL .
|
||||||
'</IfModule>',
|
'</IfModule>'. PHP_EOL .
|
||||||
FILE_APPEND
|
'# URL rewriting' . PHP_EOL ;
|
||||||
) !== false);
|
$fileContent = str_replace('# URL rewriting', $rewriteData, $fileContent);
|
||||||
|
file_put_contents(
|
||||||
|
'.htaccess',
|
||||||
|
$fileContent
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// Recopie htaccess
|
// Recopie htaccess
|
||||||
if ($this->getData(['config','autoUpdateHtaccess']) &&
|
if ($this->getData(['config','autoUpdateHtaccess']) &&
|
||||||
|
|
Loading…
Reference in New Issue