cleaner behaviour for data directory check

Show a properly translated message.
This commit is contained in:
Andreas Gohr 2021-01-11 17:16:30 +01:00
parent 052e1c84e6
commit d3f829c2e8
4 changed files with 22 additions and 12 deletions

View File

@ -84,8 +84,7 @@ class Admin extends Ui {
if(substr($conf['savedir'], 0, 2) !== './') return;
$img = DOKU_URL . $conf['savedir'] .
'/dont-panic-if-you-see-this-in-your-logs-it-means-your-directory-permissions-are-correct.png';
echo '<a style="border:none; float:right;" id="security__check"
href="http://www.dokuwiki.org/security#web_access_security" data-src="' . $img . '"></a>';
echo '<div id="security__check" data-src="' . $img . '"></div>';
}
/**

View File

@ -171,6 +171,7 @@ $lang['js']['media_done_btn'] = 'Done';
$lang['js']['media_drop'] = 'Drop files here to upload';
$lang['js']['media_cancel'] = 'remove';
$lang['js']['media_overwrt'] = 'Overwrite existing files';
$lang['js']['data_insecure'] = 'WARNING: It seems your data directory is not properly secured. Please read about <a href="https://www.dokuwiki.org/security#web_access_security">Web Access Security in DokuWiki</a>.';
$lang['rssfailed'] = 'An error occurred while fetching this feed: ';
$lang['nothingfound'] = 'Nothing was found.';

View File

@ -215,25 +215,26 @@ var dw_behaviour = {
* avoids overeager security bans (see #3363)
*/
securityCheck: function () {
var $checkA = jQuery('#security__check');
if (!$checkA.length) return;
if (sessionStorage.getItem('security-check')) {
var $checkDiv = jQuery('#security__check');
if (!$checkDiv.length) return;
if (sessionStorage.getItem('dw-security-check:' + DOKU_BASE)) {
// check was already executed successfully
$checkA.remove();
$checkDiv.remove();
return;
}
var img = new Image(347, 63);
var img = new Image();
img.onerror = function () {
// successful check will not be repeated during session
$checkA.remove();
sessionStorage.setItem('security-check', true);
$checkDiv.remove();
sessionStorage.setItem('dw-security-check:' + DOKU_BASE, true);
}
img.onload = function () {
// check failed, display the image
$checkA.html(img);
// check failed, display a warning message
$checkDiv.html(LANG.data_insecure);
$checkDiv.addClass('error');
}
img.src = $checkA.data('src');
img.src = $checkDiv.data('src');
}
};

View File

@ -61,4 +61,13 @@
clear: right;
float: left;
}
/* data directory security check */
#security__check {
float: right;
max-width: 20em;
}
[dir=rtl] & #admin__version {
float: left;
}
}