[2242] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
| 5 | // +-----------------------------------------------------------------------+ |
---|
| 6 | // | file : $Id: plugins_update.php 2245 2008-03-03 12:50:54Z rvelices $ |
---|
| 7 | // | last update : $Date: 2008-03-03 12:50:54 +0000 (Mon, 03 Mar 2008) $ |
---|
| 8 | // | last modifier : $Author: rvelices $ |
---|
| 9 | // | revision : $Revision: 2245 $ |
---|
| 10 | // +-----------------------------------------------------------------------+ |
---|
| 11 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 12 | // | it under the terms of the GNU General Public License as published by | |
---|
| 13 | // | the Free Software Foundation | |
---|
| 14 | // | | |
---|
| 15 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 16 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 17 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 18 | // | General Public License for more details. | |
---|
| 19 | // | | |
---|
| 20 | // | You should have received a copy of the GNU General Public License | |
---|
| 21 | // | along with this program; if not, write to the Free Software | |
---|
| 22 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 23 | // | USA. | |
---|
| 24 | // +-----------------------------------------------------------------------+ |
---|
| 25 | |
---|
| 26 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
| 27 | { |
---|
| 28 | die ("Hacking attempt!"); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | $template->set_filenames(array('plugins' => 'admin/plugins_update.tpl')); |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | //-----------------------------------------------------------automatic upgrade |
---|
| 35 | if (isset($_GET['upgrade']) and isset($_GET['plugin']) and !is_adviser()) |
---|
| 36 | { |
---|
[2243] | 37 | include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); |
---|
[2242] | 38 | |
---|
[2243] | 39 | $upgrade_status = extract_plugin_files('upgrade', |
---|
| 40 | $_GET['upgrade'], |
---|
| 41 | $_GET['plugin']); |
---|
[2242] | 42 | |
---|
[2243] | 43 | $my_base_url .= isset($_GET['reactivate']) ? '&action=activate' : ''; |
---|
[2242] | 44 | |
---|
[2243] | 45 | redirect($my_base_url.'&plugin='.$_GET['plugin'].'&upgradestatus='.$upgrade_status); |
---|
[2242] | 46 | } |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | //--------------------------------------------------------------upgrade result |
---|
| 50 | if (isset($_GET['upgradestatus']) and isset($_GET['plugin'])) |
---|
| 51 | { |
---|
[2243] | 52 | switch ($_GET['upgradestatus']) |
---|
| 53 | { |
---|
| 54 | case 'ok': |
---|
| 55 | array_push($page['infos'], |
---|
[2242] | 56 | sprintf(l10n('plugins_upgrade_ok'), |
---|
| 57 | $fs_plugins[$_GET['plugin']]['name'])); |
---|
[2243] | 58 | break; |
---|
[2242] | 59 | |
---|
[2243] | 60 | case 'temp_path_error': |
---|
[2245] | 61 | array_push($page['errors'], l10n('plugins_temp_path_error')); |
---|
[2243] | 62 | break; |
---|
[2245] | 63 | |
---|
[2243] | 64 | case 'dl_archive_error': |
---|
[2245] | 65 | array_push($page['errors'], l10n('plugins_dl_archive_error')); |
---|
[2243] | 66 | break; |
---|
[2242] | 67 | |
---|
[2243] | 68 | case 'archive_error': |
---|
[2245] | 69 | array_push($page['errors'], l10n('plugins_archive_error')); |
---|
[2243] | 70 | break; |
---|
[2242] | 71 | |
---|
[2243] | 72 | default: |
---|
| 73 | array_push($page['errors'], |
---|
[2242] | 74 | sprintf(l10n('plugins_extract_error'), |
---|
[2245] | 75 | $_GET['upgradestatus'])); |
---|
[2243] | 76 | } |
---|
[2242] | 77 | } |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | // +-----------------------------------------------------------------------+ |
---|
| 81 | // | start template output | |
---|
| 82 | // +-----------------------------------------------------------------------+ |
---|
[2245] | 83 | $plugins_infos = check_server_plugins($fs_plugins); |
---|
[2242] | 84 | |
---|
| 85 | if ($plugins_infos !== false) |
---|
| 86 | { |
---|
[2243] | 87 | foreach($fs_plugins as $plugin_id => $fs_plugin) |
---|
| 88 | { |
---|
| 89 | if (isset($fs_plugin['extension']) |
---|
[2242] | 90 | and isset($plugins_infos[$fs_plugin['extension']])) |
---|
[2243] | 91 | { |
---|
| 92 | $plugin_info = $plugins_infos[$fs_plugin['extension']]; |
---|
[2245] | 93 | |
---|
[2243] | 94 | $ext_desc = nl2br(htmlspecialchars(strip_tags( |
---|
[2242] | 95 | utf8_encode($plugin_info['ext_description'])))); |
---|
[2245] | 96 | |
---|
[2243] | 97 | $ver_desc = sprintf(l10n('plugins_description'), |
---|
| 98 | $plugin_info['version'], |
---|
| 99 | date('Y-m-d', $plugin_info['date']), |
---|
| 100 | nl2br(htmlspecialchars(strip_tags( |
---|
[2242] | 101 | utf8_encode($plugin_info['description']))))); |
---|
[2245] | 102 | |
---|
[2243] | 103 | if ($plugin_info['version'] == $fs_plugin['version']) |
---|
| 104 | { |
---|
| 105 | // Plugin is up to date |
---|
| 106 | $template->append('plugins_uptodate', |
---|
| 107 | array('URL' => $fs_plugin['uri'], |
---|
| 108 | 'NAME' => $fs_plugin['name'], |
---|
| 109 | 'EXT_DESC' => $ext_desc, |
---|
| 110 | 'VERSION' => $fs_plugin['version'], |
---|
| 111 | 'VER_DESC' => $ver_desc)); |
---|
| 112 | } |
---|
| 113 | else |
---|
| 114 | { |
---|
| 115 | // Plugin need upgrade |
---|
| 116 | $url_auto_update = htmlentities($my_base_url) |
---|
| 117 | . '&plugin=' . $plugin_id |
---|
| 118 | . ( |
---|
[2245] | 119 | (isset($db_plugins_by_id[$plugin_id]) |
---|
| 120 | and $db_plugins_by_id[$plugin_id]['state'] == 'active') ? |
---|
[2242] | 121 | '&action=deactivate' : '' |
---|
| 122 | ) |
---|
[2243] | 123 | . '&upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension'] |
---|
| 124 | . '%2Frevision-' . $plugin_info['id_revision'] |
---|
[2242] | 125 | . '%2F' . $plugin_info['url']; |
---|
[2245] | 126 | |
---|
[2243] | 127 | $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension'] |
---|
| 128 | . '/revision-' . $plugin_info['id_revision'] |
---|
| 129 | . '/' . $plugin_info['url']; |
---|
[2245] | 130 | |
---|
[2243] | 131 | $template->append('plugins_not_uptodate', |
---|
| 132 | array('EXT_NAME' => $fs_plugin['name'], |
---|
| 133 | 'EXT_URL' => $fs_plugin['uri'], |
---|
| 134 | 'EXT_DESC' => $ext_desc, |
---|
| 135 | 'VERSION' => $fs_plugin['version'], |
---|
| 136 | 'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['id_revision'], |
---|
| 137 | 'NEW_VERSION' => $plugin_info['version'], |
---|
| 138 | 'NEW_VER_DESC' => $ver_desc, |
---|
| 139 | 'URL_UPDATE' => $url_auto_update, |
---|
| 140 | 'URL_DOWNLOAD' => $url_download)); |
---|
| 141 | } |
---|
| 142 | } |
---|
[2245] | 143 | else |
---|
[2243] | 144 | { |
---|
| 145 | // Can't check plugin |
---|
| 146 | $template->append('plugins_cant_check', |
---|
| 147 | array('NAME' => $fs_plugin['name'], |
---|
| 148 | 'VERSION' => $fs_plugin['version'])); |
---|
| 149 | } |
---|
| 150 | } |
---|
[2242] | 151 | } |
---|
| 152 | else |
---|
| 153 | { |
---|
[2243] | 154 | array_push($page['errors'], l10n('plugins_server_error')); |
---|
[2242] | 155 | } |
---|
| 156 | |
---|
| 157 | ?> |
---|