[2242] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 5 | // | Copyright(C) 2008-2011 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_list.tpl')); |
---|
[2255] | 32 | |
---|
[5475] | 33 | $base_url = get_root_url().'admin.php?page='.$page['page']; |
---|
[5195] | 34 | $action_url = $base_url.'&plugin='.'%s'.'&pwg_token='.get_pwg_token(); |
---|
[2255] | 35 | |
---|
[2264] | 36 | $plugins = new plugins(); |
---|
| 37 | |
---|
[2263] | 38 | //--------------------------------------------------perform requested actions |
---|
[8126] | 39 | if (isset($_GET['action']) and isset($_GET['plugin'])) |
---|
[2255] | 40 | { |
---|
[10007] | 41 | if (in_array($_GET['action'], array('install', 'uninstall')) AND !is_webmaster()) |
---|
| 42 | { |
---|
| 43 | array_push($page['errors'], l10n('Webmaster status is required.')); |
---|
| 44 | } |
---|
| 45 | else |
---|
| 46 | { |
---|
| 47 | check_pwg_token(); |
---|
[5691] | 48 | |
---|
[10007] | 49 | $page['errors'] = $plugins->perform_action($_GET['action'], $_GET['plugin']); |
---|
[2264] | 50 | |
---|
[10007] | 51 | if (empty($page['errors'])) |
---|
[3950] | 52 | { |
---|
[10007] | 53 | if ($_GET['action'] == 'activate' or $_GET['action'] == 'deactivate') |
---|
| 54 | { |
---|
| 55 | $template->delete_compiled_templates(); |
---|
| 56 | } |
---|
| 57 | redirect($base_url); |
---|
[3950] | 58 | } |
---|
| 59 | } |
---|
[2255] | 60 | } |
---|
| 61 | |
---|
[2264] | 62 | //--------------------------------------------------------------------Tabsheet |
---|
[5367] | 63 | $plugins->set_tabsheet($page['page']); |
---|
[2264] | 64 | |
---|
[11043] | 65 | //--------------------------------------------------------Incompatible Plugins |
---|
| 66 | if (isset($_GET['incompatible_plugins'])) |
---|
| 67 | { |
---|
| 68 | $incompatible_plugins = array(); |
---|
| 69 | foreach ($plugins->get_incompatible_plugins() as $plugin => $version) |
---|
| 70 | { |
---|
| 71 | if ($plugin == '~~expire~~') continue; |
---|
| 72 | array_push($incompatible_plugins, $plugin); |
---|
| 73 | |
---|
| 74 | } |
---|
| 75 | echo json_encode($incompatible_plugins); |
---|
| 76 | exit; |
---|
| 77 | } |
---|
| 78 | |
---|
[2255] | 79 | // +-----------------------------------------------------------------------+ |
---|
| 80 | // | start template output | |
---|
| 81 | // +-----------------------------------------------------------------------+ |
---|
[5474] | 82 | |
---|
[5475] | 83 | $plugins->sort_fs_plugins('name'); |
---|
[11043] | 84 | $merged_extensions = $plugins->get_merged_extensions(); |
---|
[10131] | 85 | $merged_plugins = false; |
---|
[2264] | 86 | |
---|
[2263] | 87 | foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) |
---|
[2242] | 88 | { |
---|
[11046] | 89 | if (isset($_SESSION['incompatible_plugins'][$plugin_id]) |
---|
| 90 | and $fs_plugin['version'] != $_SESSION['incompatible_plugins'][$plugin_id]) |
---|
[10131] | 91 | { |
---|
| 92 | // Incompatible plugins must be reinitilized |
---|
[11043] | 93 | unset($_SESSION['incompatible_plugins']); |
---|
[10131] | 94 | } |
---|
| 95 | |
---|
[5474] | 96 | $tpl_plugin = array( |
---|
[11043] | 97 | 'ID' => $plugin_id, |
---|
[5474] | 98 | 'NAME' => $fs_plugin['name'], |
---|
| 99 | 'VISIT_URL' => $fs_plugin['uri'], |
---|
| 100 | 'VERSION' => $fs_plugin['version'], |
---|
| 101 | 'DESC' => $fs_plugin['description'], |
---|
| 102 | 'AUTHOR' => $fs_plugin['author'], |
---|
[5691] | 103 | 'AUTHOR_URL' => @$fs_plugin['author uri'], |
---|
[10131] | 104 | 'U_ACTION' => sprintf($action_url, $plugin_id), |
---|
[5474] | 105 | ); |
---|
[2242] | 106 | |
---|
[2263] | 107 | if (isset($plugins->db_plugins_by_id[$plugin_id])) |
---|
[2293] | 108 | { |
---|
| 109 | $tpl_plugin['STATE'] = $plugins->db_plugins_by_id[$plugin_id]['state']; |
---|
[2242] | 110 | } |
---|
| 111 | else |
---|
| 112 | { |
---|
[2631] | 113 | $tpl_plugin['STATE'] = 'uninstalled'; |
---|
[2242] | 114 | } |
---|
[5474] | 115 | |
---|
[11043] | 116 | if (isset($fs_plugin['extension']) and isset($merged_extensions[$fs_plugin['extension']])) |
---|
[10131] | 117 | { |
---|
| 118 | switch($tpl_plugin['STATE']) |
---|
| 119 | { |
---|
| 120 | case 'active': $plugins->perform_action('deactivate', $plugin_id); |
---|
| 121 | case 'inactive': $plugins->perform_action('uninstall', $plugin_id); |
---|
| 122 | } |
---|
| 123 | $tpl_plugin['STATE'] = 'merged'; |
---|
| 124 | $tpl_plugin['DESC'] = l10n('THIS PLUGIN IS NOW PART OF PIWIGO CORE! DELETE IT NOW.'); |
---|
| 125 | $merged_plugins = true; |
---|
| 126 | } |
---|
| 127 | |
---|
[2242] | 128 | $template->append('plugins', $tpl_plugin); |
---|
| 129 | } |
---|
| 130 | |
---|
[10131] | 131 | $template->append('plugin_states', 'active'); |
---|
| 132 | $template->append('plugin_states', 'inactive'); |
---|
| 133 | $template->append('plugin_states', 'uninstalled'); |
---|
| 134 | |
---|
| 135 | if ($merged_plugins) |
---|
| 136 | { |
---|
| 137 | $template->append('plugin_states', 'merged'); |
---|
| 138 | } |
---|
| 139 | |
---|
[2242] | 140 | $missing_plugin_ids = array_diff( |
---|
[5474] | 141 | array_keys($plugins->db_plugins_by_id), |
---|
| 142 | array_keys($plugins->fs_plugins) |
---|
| 143 | ); |
---|
[2242] | 144 | |
---|
[5474] | 145 | if (count($missing_plugin_ids) > 0) |
---|
| 146 | { |
---|
[10131] | 147 | foreach($missing_plugin_ids as $plugin_id) |
---|
| 148 | { |
---|
| 149 | $template->append( |
---|
| 150 | 'plugins', |
---|
| 151 | array( |
---|
| 152 | 'NAME' => $plugin_id, |
---|
| 153 | 'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'], |
---|
| 154 | 'DESC' => l10n('ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW.'), |
---|
| 155 | 'U_ACTION' => sprintf($action_url, $plugin_id), |
---|
| 156 | 'STATE' => 'missing', |
---|
| 157 | ) |
---|
| 158 | ); |
---|
| 159 | } |
---|
[5474] | 160 | $template->append('plugin_states', 'missing'); |
---|
| 161 | } |
---|
[5691] | 162 | |
---|
[2255] | 163 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugins'); |
---|
[2242] | 164 | ?> |
---|