[2242] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[3046] | 5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
---|
[2297] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
[2242] | 23 | |
---|
| 24 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
| 25 | { |
---|
| 26 | die ("Hacking attempt!"); |
---|
| 27 | } |
---|
| 28 | |
---|
[2263] | 29 | include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php'); |
---|
[2255] | 30 | |
---|
[2530] | 31 | $template->set_filenames(array('plugins' => 'plugins_update.tpl')); |
---|
[2242] | 32 | |
---|
[2264] | 33 | $base_url = get_root_url().'admin.php?page='.$page['page']; |
---|
[2242] | 34 | |
---|
[2264] | 35 | $plugins = new plugins(); |
---|
| 36 | |
---|
[2242] | 37 | //-----------------------------------------------------------automatic upgrade |
---|
[2647] | 38 | if (isset($_GET['plugin']) and isset($_GET['revision']) and !is_adviser()) |
---|
[2242] | 39 | { |
---|
[4506] | 40 | check_pwg_token(); |
---|
| 41 | |
---|
[2264] | 42 | $plugin_id = $_GET['plugin']; |
---|
[2647] | 43 | $revision = $_GET['revision']; |
---|
[2264] | 44 | |
---|
| 45 | if (isset($plugins->db_plugins_by_id[$plugin_id]) |
---|
| 46 | and $plugins->db_plugins_by_id[$plugin_id]['state'] == 'active') |
---|
| 47 | { |
---|
| 48 | $plugins->perform_action('deactivate', $plugin_id); |
---|
| 49 | |
---|
| 50 | redirect($base_url |
---|
[2647] | 51 | . '&revision=' . $revision |
---|
[2264] | 52 | . '&plugin=' . $plugin_id |
---|
[4506] | 53 | . '&pwg_token='.get_pwg_token() |
---|
[2264] | 54 | . '&reactivate=true'); |
---|
| 55 | } |
---|
| 56 | |
---|
[2647] | 57 | $upgrade_status = $plugins->extract_plugin_files('upgrade', $revision, $plugin_id); |
---|
[2264] | 58 | |
---|
| 59 | if (isset($_GET['reactivate'])) |
---|
| 60 | { |
---|
| 61 | $plugins->perform_action('activate', $plugin_id); |
---|
| 62 | } |
---|
| 63 | redirect($base_url.'&plugin='.$plugin_id.'&upgradestatus='.$upgrade_status); |
---|
[2242] | 64 | } |
---|
| 65 | |
---|
| 66 | //--------------------------------------------------------------upgrade result |
---|
| 67 | if (isset($_GET['upgradestatus']) and isset($_GET['plugin'])) |
---|
| 68 | { |
---|
[2264] | 69 | switch ($_GET['upgradestatus']) |
---|
| 70 | { |
---|
| 71 | case 'ok': |
---|
| 72 | array_push($page['infos'], |
---|
| 73 | sprintf( |
---|
| 74 | l10n('plugins_upgrade_ok'), |
---|
| 75 | $plugins->fs_plugins[$_GET['plugin']]['name'])); |
---|
| 76 | break; |
---|
| 77 | |
---|
| 78 | case 'temp_path_error': |
---|
| 79 | array_push($page['errors'], l10n('plugins_temp_path_error')); |
---|
| 80 | break; |
---|
| 81 | |
---|
| 82 | case 'dl_archive_error': |
---|
| 83 | array_push($page['errors'], l10n('plugins_dl_archive_error')); |
---|
| 84 | break; |
---|
| 85 | |
---|
| 86 | case 'archive_error': |
---|
| 87 | array_push($page['errors'], l10n('plugins_archive_error')); |
---|
| 88 | break; |
---|
| 89 | |
---|
| 90 | default: |
---|
| 91 | array_push($page['errors'], |
---|
[3144] | 92 | sprintf(l10n('plugins_extract_error'), $_GET['upgradestatus']), |
---|
[2264] | 93 | l10n('plugins_check_chmod')); |
---|
| 94 | } |
---|
[2242] | 95 | } |
---|
| 96 | |
---|
[2264] | 97 | //--------------------------------------------------------------------Tabsheet |
---|
[2272] | 98 | set_plugins_tabsheet($page['page']); |
---|
[2264] | 99 | |
---|
[2242] | 100 | // +-----------------------------------------------------------------------+ |
---|
| 101 | // | start template output | |
---|
| 102 | // +-----------------------------------------------------------------------+ |
---|
[2881] | 103 | if ($plugins->get_server_plugins()) |
---|
[2242] | 104 | { |
---|
[2263] | 105 | foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) |
---|
[2243] | 106 | { |
---|
| 107 | if (isset($fs_plugin['extension']) |
---|
[2263] | 108 | and isset($plugins->server_plugins[$fs_plugin['extension']])) |
---|
[2243] | 109 | { |
---|
[2263] | 110 | $plugin_info = $plugins->server_plugins[$fs_plugin['extension']]; |
---|
[2245] | 111 | |
---|
[2647] | 112 | list($date, ) = explode(' ', $plugin_info['revision_date']); |
---|
| 113 | |
---|
[3144] | 114 | $ext_desc = '<i>'.l10n('Downloads').':</i> '.$plugin_info['extension_nb_downloads']."\r\n" |
---|
| 115 | ."\r\n" |
---|
| 116 | .$plugin_info['extension_description']; |
---|
[2245] | 117 | |
---|
[3144] | 118 | $rev_desc = '<i>'.l10n('Version').':</i> '.$plugin_info['revision_name']."\r\n" |
---|
| 119 | .'<i>'.l10n('Released on').':</i> '.$date."\r\n" |
---|
| 120 | .'<i>'.l10n('Downloads').':</i> '.$plugin_info['revision_nb_downloads']."\r\n" |
---|
| 121 | ."\r\n" |
---|
| 122 | .$plugin_info['revision_description']; |
---|
| 123 | |
---|
[2647] | 124 | if ($plugins->plugin_version_compare($fs_plugin['version'], $plugin_info['revision_name'])) |
---|
[2243] | 125 | { |
---|
| 126 | // Plugin is up to date |
---|
[2647] | 127 | $template->append('plugins_uptodate', array( |
---|
[3144] | 128 | 'URL' => PEM_URL.'/extension_view.php?eid='.$plugin_info['extension_id'], |
---|
[2647] | 129 | 'NAME' => $fs_plugin['name'], |
---|
[3144] | 130 | 'EXT_DESC' => $ext_desc, |
---|
| 131 | 'VERSION' => $fs_plugin['version'], |
---|
| 132 | 'VER_DESC' => $rev_desc)); |
---|
[2243] | 133 | } |
---|
| 134 | else |
---|
| 135 | { |
---|
| 136 | // Plugin need upgrade |
---|
[2264] | 137 | $url_auto_update = $base_url |
---|
[2647] | 138 | . '&revision=' . $plugin_info['revision_id'] |
---|
[4506] | 139 | . '&plugin=' . $plugin_id |
---|
| 140 | . '&pwg_token='.get_pwg_token() |
---|
| 141 | ; |
---|
[2245] | 142 | |
---|
[2647] | 143 | $template->append('plugins_not_uptodate', array( |
---|
| 144 | 'EXT_NAME' => $fs_plugin['name'], |
---|
[3144] | 145 | 'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin_info['extension_id'], |
---|
| 146 | 'EXT_DESC' => $ext_desc, |
---|
[2647] | 147 | 'VERSION' => $fs_plugin['version'], |
---|
| 148 | 'NEW_VERSION' => $plugin_info['revision_name'], |
---|
[3144] | 149 | 'NEW_VER_DESC' => $rev_desc, |
---|
[2647] | 150 | 'URL_UPDATE' => $url_auto_update, |
---|
| 151 | 'URL_DOWNLOAD' => $plugin_info['download_url'] . '&origin=piwigo_download')); |
---|
[2243] | 152 | } |
---|
| 153 | } |
---|
[2245] | 154 | else |
---|
[2243] | 155 | { |
---|
| 156 | // Can't check plugin |
---|
[2647] | 157 | $template->append('plugins_cant_check', array( |
---|
| 158 | 'NAME' => $fs_plugin['name'], |
---|
| 159 | 'VERSION' => $fs_plugin['version'])); |
---|
[2243] | 160 | } |
---|
| 161 | } |
---|
[2242] | 162 | } |
---|
| 163 | else |
---|
| 164 | { |
---|
[2243] | 165 | array_push($page['errors'], l10n('plugins_server_error')); |
---|
[2242] | 166 | } |
---|
| 167 | |
---|
[2255] | 168 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugins'); |
---|
[2242] | 169 | ?> |
---|