Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle copy error in setup #577

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return sucess/error on copy

}

/**
* @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
Loading