[9707] | 1 | <?php |
---|
| 2 | |
---|
| 3 | define('PHPWG_ROOT_PATH','../../../'); |
---|
| 4 | define('IN_ADMIN', true); |
---|
| 5 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
| 6 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 7 | |
---|
| 8 | if (!defined('AUTOUPDATE_PATH')) |
---|
| 9 | define('AUTOUPDATE_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(dirname(__FILE__))) . '/'); |
---|
| 10 | |
---|
| 11 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 12 | |
---|
| 13 | if (!is_webmaster()) |
---|
| 14 | { |
---|
| 15 | echo json_encode(array( |
---|
| 16 | 'result' => false, |
---|
| 17 | 'msg' => l10n('Webmaster status is required.'), |
---|
| 18 | ) |
---|
| 19 | ); |
---|
| 20 | exit; |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php'); |
---|
| 24 | $plugins = new plugins(); |
---|
| 25 | |
---|
| 26 | if (isset($_GET['upgradestatus']) and isset($_GET['id'])) |
---|
| 27 | { |
---|
| 28 | switch ($_GET['upgradestatus']) |
---|
| 29 | { |
---|
| 30 | case 'ok': |
---|
| 31 | $result = array( |
---|
| 32 | 'result' => true, |
---|
| 33 | 'msg' => sprintf(l10n('%s has been successfully upgraded.'), $plugins->fs_plugins[$_GET['id']]['name']) |
---|
| 34 | ); |
---|
| 35 | break; |
---|
| 36 | |
---|
| 37 | case 'temp_path_error': |
---|
| 38 | $result = array( |
---|
| 39 | 'result' => false, |
---|
| 40 | 'msg' => l10n('Can\'t create temporary file.') |
---|
| 41 | ); |
---|
| 42 | break; |
---|
| 43 | |
---|
| 44 | case 'dl_archive_error': |
---|
| 45 | $result = array( |
---|
| 46 | 'result' => false, |
---|
| 47 | 'msg' => l10n('Can\'t download archive.') |
---|
| 48 | ); |
---|
| 49 | break; |
---|
| 50 | |
---|
| 51 | case 'archive_error': |
---|
| 52 | $result = array( |
---|
| 53 | 'result' => false, |
---|
| 54 | 'msg' => l10n('Can\'t read or extract archive.') |
---|
| 55 | ); |
---|
| 56 | break; |
---|
| 57 | |
---|
| 58 | default: |
---|
| 59 | $result = array( |
---|
| 60 | 'result' => false, |
---|
| 61 | 'msg' => sprintf(l10n('An error occured during extraction (%s).'), $_GET['upgradestatus']) |
---|
| 62 | ); |
---|
| 63 | } |
---|
| 64 | echo json_encode($result); |
---|
| 65 | exit; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | if (empty($_REQUEST['id']) or empty($_REQUEST['revision'])) |
---|
| 69 | { |
---|
| 70 | echo json_encode(array( |
---|
| 71 | 'result' => false, |
---|
| 72 | 'msg' => 'Wrong parameters', |
---|
| 73 | ) |
---|
| 74 | ); |
---|
| 75 | exit; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | $plugin_id = $_REQUEST['id']; |
---|
| 79 | $revision = $_REQUEST['revision']; |
---|
| 80 | |
---|
| 81 | if (isset($plugins->db_plugins_by_id[$plugin_id]) |
---|
| 82 | and $plugins->db_plugins_by_id[$plugin_id]['state'] == 'active') |
---|
| 83 | { |
---|
| 84 | $plugins->perform_action('deactivate', $plugin_id); |
---|
| 85 | |
---|
| 86 | redirect(AUTOUPDATE_PATH |
---|
| 87 | . 'ajax/update_plugin.php' |
---|
| 88 | . '?revision=' . $revision |
---|
| 89 | . '&id=' . $plugin_id |
---|
| 90 | . '&reactivate=true'); |
---|
| 91 | } |
---|
| 92 | |
---|
[9710] | 93 | $upgrade_status = $plugins->extract_plugin_files('upgrade', $revision, $plugin_id); |
---|
[9707] | 94 | |
---|
| 95 | if (isset($_REQUEST['reactivate'])) |
---|
| 96 | { |
---|
| 97 | $plugins->perform_action('activate', $plugin_id); |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | $template->delete_compiled_templates(); |
---|
| 101 | |
---|
| 102 | redirect(AUTOUPDATE_PATH |
---|
| 103 | . 'ajax/update_plugin.php' |
---|
| 104 | . '?id=' . $plugin_id |
---|
| 105 | . '&upgradestatus='.$upgrade_status |
---|
| 106 | ); |
---|
| 107 | |
---|
| 108 | ?> |
---|