Commit 158f1ca7 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add some sanity checks to the warnings on the admin home page


Remove log_environ calls for those warnings from ensure_sanity, so they don't appear on every page
Move all the admin warnings into a single function
Display warnings on the home page after the redirect from a successful site upgrade

Change-Id: I63f732ab9c0047ed70919eb6948c4fbf5d759b4b
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent e7299ba2
......@@ -94,28 +94,7 @@ if (isset($register)) {
$smarty->assign('closed', $closed);
$smarty->assign('closeform', $closeform);
// site warnings for the admin to consider
$warnings = array();
// Check if the host returns a usable value for the timezone identifier %z
$tz_count = preg_match("/\+[0-9]{4}/", strftime("%z"));
if ($tz_count == 0 || $tz_count == FALSE) {
$warnings[] = get_string('timezoneidentifierunusable', 'error');
}
// Check file upload settings.
$postmax = ini_get('post_max_size');
$uploadmax = ini_get('upload_max_filesize');
$realpostmax = get_real_size($postmax);
$realuploadmax = get_real_size($uploadmax);
if ($realpostmax && $realpostmax < $realuploadmax) {
$warnings[] = get_string('postmaxlessthanuploadmax', 'error', $postmax, $uploadmax, $postmax);
}
else if ($realpostmax && $realpostmax < 9000000) {
$warnings[] = get_string('smallpostmaxsize', 'error', $postmax, $postmax);
}
$smarty->assign('warnings', $warnings);
$smarty->assign('warnings', site_warnings());
$smarty->display('admin/index.tpl');
......
......@@ -33,6 +33,9 @@ require(dirname(dirname(__FILE__)).'/init.php');
require(get_config('libroot') . 'upgrade.php');
if (param_integer('finished', 0)) {
foreach (site_warnings() as $w) {
$SESSION->add_error_msg($w);
}
if ($missing = check_installed_plugins()) {
$message = get_string('installedpluginsmissing', 'admin') . ': ';
$message .= join(', ', $missing) . '.';
......
......@@ -86,7 +86,6 @@ function ensure_sanity() {
// register globals workaround
if (ini_get_bool('register_globals')) {
log_environ(get_string('registerglobals', 'error'));
$massivearray = array_keys(array_merge($_POST, $_GET, $_COOKIE, $_SERVER, $_REQUEST, $_FILES));
foreach ($massivearray as $tounset) {
unset($GLOBALS[$tounset]);
......@@ -95,7 +94,6 @@ function ensure_sanity() {
// magic_quotes_gpc workaround
if (!defined('CRON') && ini_get_bool('magic_quotes_gpc')) {
log_environ(get_string('magicquotesgpc', 'error'));
function stripslashes_deep($value) {
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
......@@ -118,13 +116,11 @@ function ensure_sanity() {
if (ini_get_bool('magic_quotes_runtime')) {
// Turn of magic_quotes_runtime. Anyone with this on deserves a slap in the face
set_magic_quotes_runtime(0);
log_environ(get_string('magicquotesruntime', 'error'));
}
if (ini_get_bool('magic_quotes_sybase')) {
// See above comment re. magic_quotes_runtime
@ini_set('magic_quotes_sybase', 0);
log_environ(get_string('magicquotessybase', 'error'));
}
if (ini_get_bool('safe_mode')) {
......
......@@ -1116,3 +1116,43 @@ function activate_plugin_submit(Pieform $form, $values) {
$SESSION->add_ok_msg(get_string('plugin' . (($values['enable']) ? 'enabled' : 'disabled')));
redirect('/admin/extensions/plugins.php');
}
// site warnings for the admin to consider
function site_warnings() {
$warnings = array();
// Warn about nasty php settings that Mahara can still sort of deal with.
if (ini_get_bool('register_globals')) {
$warnings[] = get_string('registerglobals', 'error');
}
if (!defined('CRON') && ini_get_bool('magic_quotes_gpc')) {
$warnings[] = get_string('magicquotesgpc', 'error');
}
if (ini_get_bool('magic_quotes_runtime')) {
$warnings[] = get_string('magicquotesruntime', 'error');
}
if (ini_get_bool('magic_quotes_sybase')) {
$warnings[] = get_string('magicquotessybase', 'error');
}
// Check if the host returns a usable value for the timezone identifier %z
$tz_count = preg_match("/\+[0-9]{4}/", strftime("%z"));
if ($tz_count == 0 || $tz_count == FALSE) {
$warnings[] = get_string('timezoneidentifierunusable', 'error');
}
// Check file upload settings.
$postmax = ini_get('post_max_size');
$uploadmax = ini_get('upload_max_filesize');
$realpostmax = get_real_size($postmax);
$realuploadmax = get_real_size($uploadmax);
if ($realpostmax && $realpostmax < $realuploadmax) {
$warnings[] = get_string('postmaxlessthanuploadmax', 'error', $postmax, $uploadmax, $postmax);
}
else if ($realpostmax && $realpostmax < 9000000) {
$warnings[] = get_string('smallpostmaxsize', 'error', $postmax, $postmax);
}
return $warnings;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment