| 1 | <?php |
|---|
| 2 | // +-----------------------------------------------------------------------+ |
|---|
| 3 | // | PhpWebGallery - a PHP based picture gallery | |
|---|
| 4 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
|---|
| 5 | // +-----------------------------------------------------------------------+ |
|---|
| 6 | // | file : $Id$ |
|---|
| 7 | // | last update : $Date$ |
|---|
| 8 | // | last modifier : $Author$ |
|---|
| 9 | // | revision : $Revision$ |
|---|
| 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 | { |
|---|
| 37 | include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); |
|---|
| 38 | |
|---|
| 39 | $upgrade_status = extract_plugin_files('upgrade', |
|---|
| 40 | $_GET['upgrade'], |
|---|
| 41 | $_GET['plugin']); |
|---|
| 42 | |
|---|
| 43 | $my_base_url .= isset($_GET['reactivate']) ? '&action=activate' : ''; |
|---|
| 44 | |
|---|
| 45 | redirect($my_base_url.'&plugin='.$_GET['plugin'].'&upgradestatus='.$upgrade_status); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | //--------------------------------------------------------------upgrade result |
|---|
| 50 | if (isset($_GET['upgradestatus']) and isset($_GET['plugin'])) |
|---|
| 51 | { |
|---|
| 52 | switch ($_GET['upgradestatus']) |
|---|
| 53 | { |
|---|
| 54 | case 'ok': |
|---|
| 55 | array_push($page['infos'], |
|---|
| 56 | sprintf(l10n('plugins_upgrade_ok'), |
|---|
| 57 | $fs_plugins[$_GET['plugin']]['name'])); |
|---|
| 58 | break; |
|---|
| 59 | |
|---|
| 60 | case 'temp_path_error': |
|---|
| 61 | array_push($page['errors'], l10n('plugins_temp_path_error')); |
|---|
| 62 | break; |
|---|
| 63 | |
|---|
| 64 | case 'dl_archive_error': |
|---|
| 65 | array_push($page['errors'], l10n('plugins_dl_archive_error')); |
|---|
| 66 | break; |
|---|
| 67 | |
|---|
| 68 | case 'archive_error': |
|---|
| 69 | array_push($page['errors'], l10n('plugins_archive_error')); |
|---|
| 70 | break; |
|---|
| 71 | |
|---|
| 72 | default: |
|---|
| 73 | array_push($page['errors'], |
|---|
| 74 | sprintf(l10n('plugins_extract_error'), |
|---|
| 75 | $_GET['upgradestatus'])); |
|---|
| 76 | } |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | // +-----------------------------------------------------------------------+ |
|---|
| 81 | // | start template output | |
|---|
| 82 | // +-----------------------------------------------------------------------+ |
|---|
| 83 | $plugins_infos = check_server_plugins(); |
|---|
| 84 | |
|---|
| 85 | if ($plugins_infos !== false) |
|---|
| 86 | { |
|---|
| 87 | foreach($fs_plugins as $plugin_id => $fs_plugin) |
|---|
| 88 | { |
|---|
| 89 | if (isset($fs_plugin['extension']) |
|---|
| 90 | and isset($plugins_infos[$fs_plugin['extension']])) |
|---|
| 91 | { |
|---|
| 92 | $plugin_info = $plugins_infos[$fs_plugin['extension']]; |
|---|
| 93 | |
|---|
| 94 | $ext_desc = nl2br(htmlspecialchars(strip_tags( |
|---|
| 95 | utf8_encode($plugin_info['ext_description'])))); |
|---|
| 96 | |
|---|
| 97 | $ver_desc = sprintf(l10n('plugins_description'), |
|---|
| 98 | $plugin_info['version'], |
|---|
| 99 | date('Y-m-d', $plugin_info['date']), |
|---|
| 100 | nl2br(htmlspecialchars(strip_tags( |
|---|
| 101 | utf8_encode($plugin_info['description']))))); |
|---|
| 102 | |
|---|
| 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 | . ( |
|---|
| 119 | (isset($db_plugins_by_id[$plugin_id]) |
|---|
| 120 | and $db_plugins_by_id[$plugin_id]['state'] == 'active' |
|---|
| 121 | and $plugin_id != PLUGINSMANAGER_DIR) ? |
|---|
| 122 | '&action=deactivate' : '' |
|---|
| 123 | ) |
|---|
| 124 | . '&upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension'] |
|---|
| 125 | . '%2Frevision-' . $plugin_info['id_revision'] |
|---|
| 126 | . '%2F' . $plugin_info['url']; |
|---|
| 127 | |
|---|
| 128 | $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension'] |
|---|
| 129 | . '/revision-' . $plugin_info['id_revision'] |
|---|
| 130 | . '/' . $plugin_info['url']; |
|---|
| 131 | |
|---|
| 132 | $template->append('plugins_not_uptodate', |
|---|
| 133 | array('EXT_NAME' => $fs_plugin['name'], |
|---|
| 134 | 'EXT_URL' => $fs_plugin['uri'], |
|---|
| 135 | 'EXT_DESC' => $ext_desc, |
|---|
| 136 | 'VERSION' => $fs_plugin['version'], |
|---|
| 137 | 'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['id_revision'], |
|---|
| 138 | 'NEW_VERSION' => $plugin_info['version'], |
|---|
| 139 | 'NEW_VER_DESC' => $ver_desc, |
|---|
| 140 | 'URL_UPDATE' => $url_auto_update, |
|---|
| 141 | 'URL_DOWNLOAD' => $url_download)); |
|---|
| 142 | } |
|---|
| 143 | } |
|---|
| 144 | else |
|---|
| 145 | { |
|---|
| 146 | // Can't check plugin |
|---|
| 147 | $template->append('plugins_cant_check', |
|---|
| 148 | array('NAME' => $fs_plugin['name'], |
|---|
| 149 | 'VERSION' => $fs_plugin['version'])); |
|---|
| 150 | } |
|---|
| 151 | } |
|---|
| 152 | } |
|---|
| 153 | else |
|---|
| 154 | { |
|---|
| 155 | array_push($page['errors'], l10n('plugins_server_error')); |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | ?> |
|---|