Skip to content

Commit

Permalink
Handle copy error in setup
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Oct 28, 2024
1 parent 4115749 commit 5ec7d4b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
20 changes: 19 additions & 1 deletion lib/yrewrite/yrewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,9 @@ public static function generateConfig()
}
}

/**
* @return void
*/
public static function readConfig()
{
if (!file_exists(self::$configfile)) {
Expand All @@ -544,6 +547,9 @@ public static function readConfig()
include self::$configfile;
}

/**
* @return void
*/
public static function readPathFile()
{
if (!file_exists(self::$pathfile)) {
Expand All @@ -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']) {
Expand All @@ -570,6 +582,9 @@ public static function deleteCache()
rex_package::require('yrewrite')->clearCache();
}

/**
* @return string
*/
public static function getFullPath($link = '')
{
$domain = self::getHost();
Expand All @@ -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'])) {
Expand Down
7 changes: 5 additions & 2 deletions pages/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}
}
}
Expand Down

0 comments on commit 5ec7d4b

Please sign in to comment.