diff --git a/admin/include/updates.class.php b/admin/include/updates.class.php index e8718779b..68e0ecc9c 100644 --- a/admin/include/updates.class.php +++ b/admin/include/updates.class.php @@ -65,6 +65,8 @@ class updates */ function get_piwigo_new_versions() { + global $conf; + $new_versions = array( 'piwigo.org-checked' => false, 'is_dev' => true, @@ -78,6 +80,7 @@ class updates $url = PHPWG_URL.'/download/all_versions.php'; $url.= '?rand='.md5(uniqid(rand(), true)); // Avoid server cache $url.= '&show_requirements'; + $url.= '&origin_hash='.sha1($conf['secret_key'].get_absolute_root_url()); if (@fetchRemote($url, $result) and $all_versions = @explode("\n", $result) @@ -134,6 +137,11 @@ class updates { global $conf; + if (!pwg_is_dbconf_writeable()) + { + return; + } + $new_versions = $this->get_piwigo_new_versions(); conf_update_param('update_notify_last_check', date('c')); diff --git a/include/functions.inc.php b/include/functions.inc.php index f66cb4083..c569819a3 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -1421,6 +1421,29 @@ SELECT param, value trigger_notify('load_conf', $condition); } +/** + * Is the config table currentable writeable? + * + * @since 14 + * + * @return boolean + */ +function pwg_is_dbconf_writeable() +{ + list($param, $value) = array('pwg_is_dbconf_writeable_'.generate_key(12), date('c').' '.generate_key(20)); + + conf_update_param($param, $value); + list($dbvalue) = pwg_db_fetch_row(pwg_query('SELECT value FROM '.CONFIG_TABLE.' WHERE param = \''.$param.'\'')); + + if ($dbvalue != $value) + { + return false; + } + + conf_delete_param($param); + return true; +} + /** * Add or update a config parameter *