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