From 5ec7d4b23062c1d760cf5479d1192ca2fbe5cfd5 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 28 Oct 2024 12:28:09 +0100 Subject: [PATCH 1/2] Handle copy error in setup --- lang/de_de.lang | 1 + lang/en_gb.lang | 1 + lib/yrewrite/yrewrite.php | 20 +++++++++++++++++++- pages/setup.php | 7 +++++-- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lang/de_de.lang b/lang/de_de.lang index 40bc63f..3d4e8d3 100644 --- a/lang/de_de.lang +++ b/lang/de_de.lang @@ -114,6 +114,7 @@ yrewrite_index_noindex = Indexierung verbieten / nicht in Sitemap anzeigen (NoIn yrewrite_index_noindex_follow = Indexierung verbieten und Links folgen / nicht in Sitemap anzeigen (NoIndex) yrewrite_htaccess_hasbeenset = .htaccess-Datei wurde gesetzt/ersetzt +yrewrite_htaccess_not_copied = .htaccess-Datei konnte nicht kopiert werden yrewrite_htaccess_set = .htaccess-Datei setzen yrewrite_htaccess_info = Um YRewrite in Betrieb zu nehmen, wird eine .htaccess-Datei im Root-Ordner erstellt. Ist eine andere .htaccess-Datei bereits vorhanden, wird diese ersetzt. Bitte ggf. die .htaccess-Datei vorher sichern. diff --git a/lang/en_gb.lang b/lang/en_gb.lang index 46c7d5d..62440b7 100644 --- a/lang/en_gb.lang +++ b/lang/en_gb.lang @@ -113,6 +113,7 @@ yrewrite_index_noindex = do not allow Search Engine to index page / do not displ yrewrite_index_noindex_follow = do not allow Search Engine to index page and follow its links / do not display in Sitemap (NoIndex) yrewrite_htaccess_hasbeenset = .htaccess file has been created or overwritten +yrewrite_htaccess_not_copied = .htaccess file could not be written. yrewrite_htaccess_set = Set .htaccess file yrewrite_htaccess_info = A .htaccess file is required in the root directory to run YRewrite. I there is a .htaccess file already, it will be overwritten (can not be undone). diff --git a/lib/yrewrite/yrewrite.php b/lib/yrewrite/yrewrite.php index 6bbfee7..4db0043 100644 --- a/lib/yrewrite/yrewrite.php +++ b/lib/yrewrite/yrewrite.php @@ -536,6 +536,9 @@ public static function generateConfig() } } + /** + * @return void + */ public static function readConfig() { if (!file_exists(self::$configfile)) { @@ -544,6 +547,9 @@ public static function readConfig() include self::$configfile; } + /** + * @return void + */ public static function readPathFile() { if (!file_exists(self::$pathfile)) { @@ -552,11 +558,17 @@ public static function readPathFile() self::$paths = rex_file::getCache(self::$pathfile); } + /** + * @return bool + */ public static function copyHtaccess() { - rex_file::copy(rex_path::addon('yrewrite', 'setup/.htaccess'), rex_path::frontend('.htaccess')); + return rex_file::copy(rex_path::addon('yrewrite', 'setup/.htaccess'), rex_path::frontend('.htaccess')); } + /** + * @return bool + */ public static function isHttps() { if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO']) { @@ -570,6 +582,9 @@ public static function deleteCache() rex_package::require('yrewrite')->clearCache(); } + /** + * @return string + */ public static function getFullPath($link = '') { $domain = self::getHost(); @@ -581,6 +596,9 @@ public static function getFullPath($link = '') return $http . $domain . $subfolder . $link; } + /** + * @return string + */ public static function getHost() { if (isset($_SERVER['HTTP_X_FORWARDED_SERVER'])) { diff --git a/pages/setup.php b/pages/setup.php index 626282e..4564a9b 100644 --- a/pages/setup.php +++ b/pages/setup.php @@ -19,8 +19,11 @@ echo rex_view::error(rex_i18n::msg('csrf_token_invalid')); } else { if ('htaccess' == $func) { - rex_yrewrite::copyHtaccess(); - echo rex_view::success($this->i18n('htaccess_hasbeenset')); + if (rex_yrewrite::copyHtaccess()) { + echo rex_view::success($this->i18n('htaccess_hasbeenset')); + } else { + echo rex_view::error($this->i18n('htaccess_not_copied')); + } } } } From ff8dbef4d932770fb1762813b209f37e6074c9fd Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 28 Oct 2024 12:29:23 +0100 Subject: [PATCH 2/2] Update en_gb.lang --- lang/en_gb.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en_gb.lang b/lang/en_gb.lang index 62440b7..7e1f637 100644 --- a/lang/en_gb.lang +++ b/lang/en_gb.lang @@ -113,7 +113,7 @@ yrewrite_index_noindex = do not allow Search Engine to index page / do not displ yrewrite_index_noindex_follow = do not allow Search Engine to index page and follow its links / do not display in Sitemap (NoIndex) yrewrite_htaccess_hasbeenset = .htaccess file has been created or overwritten -yrewrite_htaccess_not_copied = .htaccess file could not be written. +yrewrite_htaccess_not_copied = .htaccess file could not be written yrewrite_htaccess_set = Set .htaccess file yrewrite_htaccess_info = A .htaccess file is required in the root directory to run YRewrite. I there is a .htaccess file already, it will be overwritten (can not be undone).