source: trunk/admin/plugins_update.php @ 2297

Last change on this file since 2297 was 2297, checked in by plg, 16 years ago

Modification: new header on PHP files, PhpWebGallery renamed Piwigo.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
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// +-----------------------------------------------------------------------+
23// +-----------------------------------------------------------------------+
24// | PhpWebGallery - a PHP based picture gallery                           |
25// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
26// +-----------------------------------------------------------------------+
27// | file          : $Id: plugins_update.php 2297 2008-04-04 22:57:23Z plg $
28// | last update   : $Date: 2008-04-04 22:57:23 +0000 (Fri, 04 Apr 2008) $
29// | last modifier : $Author: plg $
30// | revision      : $Revision: 2297 $
31// +-----------------------------------------------------------------------+
32// | This program is free software; you can redistribute it and/or modify  |
33// | it under the terms of the GNU General Public License as published by  |
34// | the Free Software Foundation                                          |
35// |                                                                       |
36// | This program is distributed in the hope that it will be useful, but   |
37// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
38// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
39// | General Public License for more details.                              |
40// |                                                                       |
41// | You should have received a copy of the GNU General Public License     |
42// | along with this program; if not, write to the Free Software           |
43// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
44// | USA.                                                                  |
45// +-----------------------------------------------------------------------+
46
47if( !defined("PHPWG_ROOT_PATH") )
48{
49  die ("Hacking attempt!");
50}
51
52include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');
53
54$template->set_filenames(array('plugins' => 'admin/plugins_update.tpl'));
55
56$base_url = get_root_url().'admin.php?page='.$page['page'];
57
58$plugins = new plugins();
59
60//-----------------------------------------------------------automatic upgrade
61if (isset($_GET['upgrade']) and isset($_GET['plugin']) and !is_adviser())
62{
63  $plugin_id = $_GET['plugin'];
64
65  if (isset($plugins->db_plugins_by_id[$plugin_id])
66    and $plugins->db_plugins_by_id[$plugin_id]['state'] == 'active')
67  {
68    $plugins->perform_action('deactivate', $plugin_id);
69
70    redirect($base_url
71      . '&upgrade=' . $_GET['upgrade']
72      . '&plugin=' . $plugin_id
73      . '&reactivate=true');
74  }
75
76  $upgrade_status =
77    $plugins->extract_plugin_files('upgrade', $_GET['upgrade'], $plugin_id);
78
79  if (isset($_GET['reactivate']))
80  {
81    $plugins->perform_action('activate', $plugin_id);
82  }
83  redirect($base_url.'&plugin='.$plugin_id.'&upgradestatus='.$upgrade_status);
84}
85
86//--------------------------------------------------------------upgrade result
87if (isset($_GET['upgradestatus']) and isset($_GET['plugin']))
88{
89  switch ($_GET['upgradestatus'])
90  {
91    case 'ok':
92      array_push($page['infos'],
93         sprintf(
94            l10n('plugins_upgrade_ok'),
95            $plugins->fs_plugins[$_GET['plugin']]['name']));
96      break;
97
98    case 'temp_path_error':
99      array_push($page['errors'], l10n('plugins_temp_path_error'));
100      break;
101
102    case 'dl_archive_error':
103      array_push($page['errors'], l10n('plugins_dl_archive_error'));
104      break;
105
106    case 'archive_error':
107      array_push($page['errors'], l10n('plugins_archive_error'));
108      break;
109
110    default:
111      array_push($page['errors'],
112        sprintf(l10n('plugins_extract_error'), $_GET['installstatus']),
113        l10n('plugins_check_chmod'));
114  } 
115}
116
117//--------------------------------------------------------------------Tabsheet
118set_plugins_tabsheet($page['page']);
119
120// +-----------------------------------------------------------------------+
121// |                     start template output                             |
122// +-----------------------------------------------------------------------+
123$plugins->get_server_plugins();
124
125if (is_array($plugins->server_plugins))
126{
127  foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
128  {
129    if (isset($fs_plugin['extension'])
130      and isset($plugins->server_plugins[$fs_plugin['extension']]))
131    {
132      $plugin_info = $plugins->server_plugins[$fs_plugin['extension']];
133
134      $ext_desc = nl2br(htmlspecialchars(strip_tags(
135                    utf8_encode($plugin_info['ext_description']))));
136
137      $ver_desc = sprintf(l10n('plugins_description'),
138          $plugin_info['version'],
139          date('Y-m-d', $plugin_info['date']),
140          nl2br(htmlspecialchars(strip_tags(
141              utf8_encode($plugin_info['description'])))));
142
143      if ($plugins->plugin_version_compare($fs_plugin, $plugin_info))
144      {
145        // Plugin is up to date
146        $template->append('plugins_uptodate',
147              array('URL' => $fs_plugin['uri'],
148                'NAME' => $fs_plugin['name'],
149                'EXT_DESC' => $ext_desc,
150                'VERSION' => $fs_plugin['version']));
151      }
152      else
153      {
154        // Plugin need upgrade
155        $url_auto_update = $base_url
156          . '&amp;plugin=' . $plugin_id
157          . '&amp;upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension']
158          . '%2Frevision-' . $plugin_info['id_revision']
159          . '%2F' . str_replace(' ', '%20',$plugin_info['url']);
160
161        $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension']
162          . '/revision-' . $plugin_info['id_revision']
163          . '/' . str_replace(' ', '%20',$plugin_info['url']);
164
165        $template->append('plugins_not_uptodate',
166          array('EXT_NAME' => $fs_plugin['name'],
167            'EXT_URL' => $fs_plugin['uri'],
168            'EXT_DESC' => $ext_desc,
169            'VERSION' => $fs_plugin['version'],
170            'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['id_revision'],
171            'NEW_VERSION' => $plugin_info['version'],
172            'NEW_VER_DESC' => $ver_desc,
173            'URL_UPDATE' => $url_auto_update,
174            'URL_DOWNLOAD' => $url_download));
175      }
176    }
177    else
178    {
179      // Can't check plugin
180      $template->append('plugins_cant_check',
181          array('NAME' => $fs_plugin['name'],
182            'VERSION' => $fs_plugin['version']));
183    }
184  }
185}
186else
187{
188  array_push($page['errors'], l10n('plugins_server_error'));
189}
190
191$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
192?>
Note: See TracBrowser for help on using the repository browser.