1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85:
<?php
$plugin_is_filter = 5 | ADMIN_PLUGIN;
$plugin_description = gettext("Checks if there is a Zenphoto versions that is newer than the installed version.");
$plugin_author = "Stephen Billard (sbillard)";
$plugin_category = gettext('Admin');
$plugin_disable = (!class_exists('DOMDocument')) ? gettext('PHP <em>DOM Object Model</em> is required.') : false;
if (!$plugin_disable) {
if (OFFSET_PATH == 2) {
if (TEST_RELEASE) {
enableExtension('check_for_release', $plugin_is_filter);
}
} else {
$me = explode('?', getRequestURI());
if (basename(array_shift($me)) == 'admin.php') {
$v = getOption('last_update_version');
$last = getOption('last_update_check');
if (empty($last) || is_numeric($last)) {
if (time() > $last + 1728000) {
$v = checkForUpdate();
setOption('last_update_check', time());
setOption('last_update_version', $v);
if ($v) {
setOption('last_update_msg', '<a href="http://www.zenphoto.org" alt="' . gettext('Zenphoto download page') . '">' . gettext("A new version of Zenphoto version is available.") . '</a>');
}
}
}
if ($v) {
zp_register_filter('admin_note', 'admin_showupdate');
}
}
}
}
function checkForUpdate() {
$webVersion = false;
if (is_connected() && class_exists('DOMDocument')) {
require_once(dirname(__FILE__) . '/zenphoto_news/rsslib.php');
$recents = RSS_Retrieve("http://www.zenphoto.org/index.php?rss=news&category=changelog");
if ($recents) {
array_shift($recents);
$article = array_shift($recents);
$v = trim(str_replace('zenphoto-', '', basename($article['link'])));
$c = explode('-', ZENPHOTO_VERSION);
$c = array_shift($c);
if ($v && version_compare($c, $v, "<")) {
$webVersion = $v;
}
}
}
return $webVersion;
}
function admin_showupdate($tab, $subtab) {
?>
<div class="notebox">
<h2><a href="http://www.zenphoto.org" alt="<?php echo gettext('Zenphoto download page'); ?>"><?php echo gettext("A new version of Zenphoto version is available."); ?></a></h2>
</div>
<?php
setOption('last_update_check', time());
return $tab;
}
?>