source: trunk/admin/plugins_update.php @ 2245

Last change on this file since 2245 was 2245, checked in by rvelices, 16 years ago
  • history, stats and redirect go smarty
  • lang correction
  • small change in calling check_server_plugins (use by ref param instead of global)
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
5// +-----------------------------------------------------------------------+
6// | file          : $Id: plugins_update.php 2245 2008-03-03 12:50:54Z rvelices $
7// | last update   : $Date: 2008-03-03 12:50:54 +0000 (Mon, 03 Mar 2008) $
8// | last modifier : $Author: rvelices $
9// | revision      : $Revision: 2245 $
10// +-----------------------------------------------------------------------+
11// | This program is free software; you can redistribute it and/or modify  |
12// | it under the terms of the GNU General Public License as published by  |
13// | the Free Software Foundation                                          |
14// |                                                                       |
15// | This program is distributed in the hope that it will be useful, but   |
16// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
17// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
18// | General Public License for more details.                              |
19// |                                                                       |
20// | You should have received a copy of the GNU General Public License     |
21// | along with this program; if not, write to the Free Software           |
22// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
23// | USA.                                                                  |
24// +-----------------------------------------------------------------------+
25
26if( !defined("PHPWG_ROOT_PATH") )
27{
28  die ("Hacking attempt!");
29}
30
31$template->set_filenames(array('plugins' => 'admin/plugins_update.tpl'));
32
33
34//-----------------------------------------------------------automatic upgrade
35if (isset($_GET['upgrade']) and isset($_GET['plugin']) and !is_adviser())
36{
37  include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
38
39  $upgrade_status  = extract_plugin_files('upgrade',
40                      $_GET['upgrade'],
41                      $_GET['plugin']);
42
43  $my_base_url .= isset($_GET['reactivate']) ? '&action=activate' : '';
44
45  redirect($my_base_url.'&plugin='.$_GET['plugin'].'&upgradestatus='.$upgrade_status);
46}
47
48
49//--------------------------------------------------------------upgrade result
50if (isset($_GET['upgradestatus']) and isset($_GET['plugin']))
51{
52  switch ($_GET['upgradestatus'])
53  {
54  case 'ok':
55    array_push($page['infos'],
56               sprintf(l10n('plugins_upgrade_ok'),
57               $fs_plugins[$_GET['plugin']]['name']));
58    break;
59
60  case 'temp_path_error':
61    array_push($page['errors'], l10n('plugins_temp_path_error'));
62    break;
63
64  case 'dl_archive_error':
65    array_push($page['errors'], l10n('plugins_dl_archive_error'));
66    break;
67
68  case 'archive_error':
69    array_push($page['errors'], l10n('plugins_archive_error'));
70    break;
71
72  default:
73    array_push($page['errors'],
74               sprintf(l10n('plugins_extract_error'),
75               $_GET['upgradestatus']));
76  }
77}
78
79
80// +-----------------------------------------------------------------------+
81// |                     start template output                             |
82// +-----------------------------------------------------------------------+
83$plugins_infos = check_server_plugins($fs_plugins);
84
85if ($plugins_infos !== false)
86{
87  foreach($fs_plugins as $plugin_id => $fs_plugin)
88  {
89    if (isset($fs_plugin['extension'])
90      and isset($plugins_infos[$fs_plugin['extension']]))
91    {
92      $plugin_info = $plugins_infos[$fs_plugin['extension']];
93
94      $ext_desc = nl2br(htmlspecialchars(strip_tags(
95                    utf8_encode($plugin_info['ext_description']))));
96
97      $ver_desc = sprintf(l10n('plugins_description'),
98              $plugin_info['version'],
99              date('Y-m-d', $plugin_info['date']),
100              nl2br(htmlspecialchars(strip_tags(
101                utf8_encode($plugin_info['description'])))));
102
103      if ($plugin_info['version'] == $fs_plugin['version'])
104      {
105        // Plugin is up to date
106        $template->append('plugins_uptodate',
107              array('URL' => $fs_plugin['uri'],
108                'NAME' => $fs_plugin['name'],
109                'EXT_DESC' => $ext_desc,
110                'VERSION' => $fs_plugin['version'],
111                'VER_DESC' => $ver_desc));
112      }
113      else
114      {
115        // Plugin need upgrade
116        $url_auto_update = htmlentities($my_base_url)
117          . '&amp;plugin=' . $plugin_id
118          . (
119              (isset($db_plugins_by_id[$plugin_id])
120                and $db_plugins_by_id[$plugin_id]['state'] == 'active') ?
121                  '&amp;action=deactivate' : ''
122            )
123          . '&amp;upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension']
124          . '%2Frevision-' . $plugin_info['id_revision']
125          . '%2F' . $plugin_info['url'];
126
127        $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension']
128            . '/revision-' . $plugin_info['id_revision']
129            . '/' . $plugin_info['url'];
130
131        $template->append('plugins_not_uptodate',
132          array('EXT_NAME' => $fs_plugin['name'],
133            'EXT_URL' => $fs_plugin['uri'],
134            'EXT_DESC' => $ext_desc,
135            'VERSION' => $fs_plugin['version'],
136            'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['id_revision'],
137            'NEW_VERSION' => $plugin_info['version'],
138            'NEW_VER_DESC' => $ver_desc,
139            'URL_UPDATE' => $url_auto_update,
140            'URL_DOWNLOAD' => $url_download));
141      }
142    }
143    else
144    {
145      // Can't check plugin
146      $template->append('plugins_cant_check',
147          array('NAME' => $fs_plugin['name'],
148            'VERSION' => $fs_plugin['version']));
149    }
150  }
151}
152else
153{
154  array_push($page['errors'], l10n('plugins_server_error'));
155}
156
157?>
Note: See TracBrowser for help on using the repository browser.