source: branches/2.0/admin/plugins_update.php @ 3046

Last change on this file since 3046 was 3046, checked in by plg, 15 years ago

Administration: happy new year 2009, all PHP headers updated.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
RevLine 
[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
24if( !defined("PHPWG_ROOT_PATH") )
25{
26  die ("Hacking attempt!");
27}
28
[2263]29include_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]38if (isset($_GET['plugin']) and isset($_GET['revision']) and !is_adviser())
[2242]39{
[2264]40  $plugin_id = $_GET['plugin'];
[2647]41  $revision = $_GET['revision'];
[2264]42
43  if (isset($plugins->db_plugins_by_id[$plugin_id])
44    and $plugins->db_plugins_by_id[$plugin_id]['state'] == 'active')
45  {
46    $plugins->perform_action('deactivate', $plugin_id);
47
48    redirect($base_url
[2647]49      . '&revision=' . $revision
[2264]50      . '&plugin=' . $plugin_id
51      . '&reactivate=true');
52  }
53
[2647]54  $upgrade_status = $plugins->extract_plugin_files('upgrade', $revision, $plugin_id);
[2264]55
56  if (isset($_GET['reactivate']))
57  {
58    $plugins->perform_action('activate', $plugin_id);
59  }
60  redirect($base_url.'&plugin='.$plugin_id.'&upgradestatus='.$upgrade_status);
[2242]61}
62
63//--------------------------------------------------------------upgrade result
64if (isset($_GET['upgradestatus']) and isset($_GET['plugin']))
65{
[2264]66  switch ($_GET['upgradestatus'])
67  {
68    case 'ok':
69      array_push($page['infos'],
70         sprintf(
71            l10n('plugins_upgrade_ok'),
72            $plugins->fs_plugins[$_GET['plugin']]['name']));
73      break;
74
75    case 'temp_path_error':
76      array_push($page['errors'], l10n('plugins_temp_path_error'));
77      break;
78
79    case 'dl_archive_error':
80      array_push($page['errors'], l10n('plugins_dl_archive_error'));
81      break;
82
83    case 'archive_error':
84      array_push($page['errors'], l10n('plugins_archive_error'));
85      break;
86
87    default:
88      array_push($page['errors'],
89        sprintf(l10n('plugins_extract_error'), $_GET['installstatus']),
90        l10n('plugins_check_chmod'));
91  } 
[2242]92}
93
[2264]94//--------------------------------------------------------------------Tabsheet
[2272]95set_plugins_tabsheet($page['page']);
[2264]96
[2242]97// +-----------------------------------------------------------------------+
98// |                     start template output                             |
99// +-----------------------------------------------------------------------+
[2881]100if ($plugins->get_server_plugins())
[2242]101{
[2263]102  foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
[2243]103  {
104    if (isset($fs_plugin['extension'])
[2263]105      and isset($plugins->server_plugins[$fs_plugin['extension']]))
[2243]106    {
[2263]107      $plugin_info = $plugins->server_plugins[$fs_plugin['extension']];
[2245]108
[2647]109      /* Need to remove this lines for final release : piwigo website will be utf8 only */
110      $plugin_info['extension_description'] = utf8_encode($plugin_info['extension_description']);
111      $plugin_info['revision_description'] = utf8_encode($plugin_info['revision_description']);
[2245]112
[2647]113      list($date, ) = explode(' ', $plugin_info['revision_date']);
114
[2243]115      $ver_desc = sprintf(l10n('plugins_description'),
[2647]116        $plugin_info['revision_name'],
117        $date,
118        $plugin_info['revision_description']);
[2245]119
[2647]120      if ($plugins->plugin_version_compare($fs_plugin['version'], $plugin_info['revision_name']))
[2243]121      {
122        // Plugin is up to date
[2647]123        $template->append('plugins_uptodate', array(
124          'URL' => $fs_plugin['uri'],
125          'NAME' => $fs_plugin['name'],
126          'EXT_DESC' => $plugin_info['extension_description'],
127          'VERSION' => $fs_plugin['version']));
[2243]128      }
129      else
130      {
131        // Plugin need upgrade
[2264]132        $url_auto_update = $base_url
[2647]133          . '&amp;revision=' . $plugin_info['revision_id']
134          . '&amp;plugin=' . $plugin_id;
[2245]135
[2647]136        $template->append('plugins_not_uptodate', array(
137          'EXT_NAME' => $fs_plugin['name'],
138          'EXT_URL' => $fs_plugin['uri'],
139          'EXT_DESC' => $plugin_info['extension_description'],
140          'VERSION' => $fs_plugin['version'],
141          'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['revision_id'],
142          'NEW_VERSION' => $plugin_info['revision_name'],
143          'NEW_VER_DESC' => $ver_desc,
144          'URL_UPDATE' => $url_auto_update,
145          'URL_DOWNLOAD' => $plugin_info['download_url'] . '&amp;origin=piwigo_download'));
[2243]146      }
147    }
[2245]148    else
[2243]149    {
150      // Can't check plugin
[2647]151      $template->append('plugins_cant_check', array(
152        'NAME' => $fs_plugin['name'],
153        'VERSION' => $fs_plugin['version']));
[2243]154    }
155  }
[2242]156}
157else
158{
[2243]159  array_push($page['errors'], l10n('plugins_server_error'));
[2242]160}
161
[2255]162$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
[2242]163?>
Note: See TracBrowser for help on using the repository browser.