diff --git a/include/admin/overview.inc.php b/include/admin/overview.inc.php
index 4954df1d..6f221354 100644
--- a/include/admin/overview.inc.php
+++ b/include/admin/overview.inc.php
@@ -23,6 +23,12 @@ switch($serendipity['POST']['adminAction']) {
$data['error_publish'] = $success;
}
break;
+ case 'updateCheckDisable':
+ if ( !serendipity_checkFormToken() || !serendipity_checkPermission('blogConfiguration') ) {
+ break;
+ }
+ serendipity_set_config_var('updateCheck', false);
+ break;
}
@@ -40,6 +46,7 @@ $data['backend_frontpage_display'] = $output['more'];
$data['curVersion'] = serendipity_getCurrentVersion();
$data['usedVersion'] = $serendipity['version'];
+$data['updateCheck'] = $serendipity['updateCheck'];
$data['update'] = version_compare($data['usedVersion'], $data['curVersion'], '<');
diff --git a/include/functions_installer.inc.php b/include/functions_installer.inc.php
index 28170ccf..e993dd4e 100644
--- a/include/functions_installer.inc.php
+++ b/include/functions_installer.inc.php
@@ -1196,21 +1196,44 @@ function serendipity_verifyFTPChecksums() {
return $badsums;
}
+
+/**
+ * Check https://raw.github.com/s9y/Serendipity/master/docs/RELEASE for the newest available version
+ *
+ * If the file is not fetch- or parseable (behind a proxy, malformed by Garvin), this will return -1
+ * */
function serendipity_getCurrentVersion() {
- $updateURL = 'https://raw.github.com/s9y/Serendipity/master/docs/RELEASE';
-
- $file = fopen($updateURL, 'r');
- if (!$file) {
- return;
+ global $serendipity;
+ if ($serendipity['updateCheck'] != "stable" && $serendipity['updateCheck'] != "beta") {
+ return -1;
}
+ $updateURL = 'https://raw.github.com/s9y/Serendipity/master/docs/RELEASE';
+ $context = stream_context_create( array('http'=>array('timeout' => 5.0)) );
- while (!feof($file)) {
- $line = fgets($file);
+ $file = @file_get_contents($updateURL, false, $context);
- if (preg_match('/stable:(.+$)/', $line, $match)) {
- return $match[1];
+ if ( ! $file) {
+ if (function_exists('curl_init')) {
+ $ch = curl_init($updateURL);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_TIMEOUT, "5");
+ $file = curl_exec($ch);
+ curl_close($ch);
}
}
+
+ if ($file) {
+ if ($serendipity['updateCheck'] == "stable") {
+ if (preg_match('/^stable:(.+)\b/', $file, $match)) {
+ return $match[1];
+ }
+ } else {
+ if (preg_match('/^beta:(.+)\b/', $file, $match)) {
+ return $match[1];
+ }
+ }
+ }
+ return -1;
}
/* vim: set sts=4 ts=4 sw=4 expandtab : */
diff --git a/include/tpl/config_local.inc.php b/include/tpl/config_local.inc.php
index e7ed6196..ac3cb1ef 100644
--- a/include/tpl/config_local.inc.php
+++ b/include/tpl/config_local.inc.php
@@ -398,6 +398,12 @@
'type' => 'bool',
'default' => false,
'permission' => 'blogConfiguration'),
+ array('var' => 'updateCheck',
+ 'title' => UPDATE_NOTIFICATION,
+ 'description' => "Show the update notification in the Dashboard, and for which channel?", # i18n
+ 'type' => 'list',
+ 'default' => array('stable' => 'stable', 'beta' => 'beta', 'false' => NO ), # i18n
+ 'permission' => 'blogConfiguration'),
));
$res['display'] =
diff --git a/templates/2k11/admin/overview.inc.tpl b/templates/2k11/admin/overview.inc.tpl
index 09e4cfc0..6620b96d 100644
--- a/templates/2k11/admin/overview.inc.tpl
+++ b/templates/2k11/admin/overview.inc.tpl
@@ -11,12 +11,25 @@
{$CONST.PUBLISH_ERROR}: {$error_publish}
{/if}
- {if $update}
-
- {$CONST.UPDATE_NOTIFICATION}
+ {if $updateCheck == "stable" || $updateCheck == "beta" }
+ {if $curVersion == -1}
+
+ {$CONST.UPDATE_NOTIFICATION}
- {$CONST.NEW_VERSION_AVAILABLE} {$curVersion}
-
+ Check for new Serendipity version failed {* i18n *}
+
+
+ {else if $update}
+
+ {$CONST.UPDATE_NOTIFICATION}
+
+ {$CONST.NEW_VERSION_AVAILABLE} {$curVersion}
+
+ {/if}
{/if}