source: trunk/admin/plugins_new.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.1 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_new.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_new.tpl'));
32
33
34//------------------------------------------------------automatic installation
35if (isset($_GET['install']) and isset($_GET['extension']) and !is_adviser())
36{
37  include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
38
39  $install_status  = extract_plugin_files('install',
40                      $_GET['install'],
41                      $_GET['extension']);
42
43  redirect($my_base_url . '&installstatus=' . $install_status);
44}
45
46
47//--------------------------------------------------------------install result
48if (isset($_GET['installstatus']))
49{
50  switch ($_GET['installstatus'])
51  {
52  case 'ok':
53    array_push($page['infos'], l10n('plugins_install_ok'), l10n('plugins_install_need_activate'));
54    break;
55
56  case 'temp_path_error':
57    array_push($page['errors'], l10n('plugins_temp_path_error'));
58    break;
59
60  case 'dl_archive_error':
61    array_push($page['errors'], l10n('plugins_dl_archive_error'));
62    break;
63
64  case 'archive_error':
65    array_push($page['errors'], l10n('plugins_archive_error'));
66    break;
67
68  default:
69    array_push($page['errors'], sprintf(l10n('plugins_extract_error'), $_GET['installstatus']), l10n('plugins_check_chmod'));
70  }
71}
72
73
74//----------------------------------------------------------------sort options
75$order = isset($_GET['order']) ? $_GET['order'] : 'date';
76
77$template->assign('order',
78    array(htmlentities($my_base_url.'&order=date') => l10n('Post date'),
79          htmlentities($my_base_url.'&order=name') => l10n('Name'),
80          htmlentities($my_base_url.'&order=author') => l10n('Author')));
81
82$template->assign('selected', htmlentities($my_base_url.'&order=').$order);
83
84
85// +-----------------------------------------------------------------------+
86// |                     start template output                             |
87// +-----------------------------------------------------------------------+
88$plugins_infos = check_server_plugins($fs_plugins, true);
89if ($plugins_infos !== false)
90{
91  if ($order == 'date') krsort($plugins_infos);
92  else uasort($plugins_infos, 'extension_'.$order.'_compare');
93
94  foreach($plugins_infos as $plugin)
95  {
96    $ext_desc = nl2br(htmlspecialchars(strip_tags(
97                  utf8_encode($plugin['ext_description']))));
98
99    $ver_desc = sprintf(l10n('plugins_description'),
100            $plugin['version'],
101            date('Y-m-d', $plugin['date']),
102            nl2br(htmlspecialchars(strip_tags(
103              utf8_encode($plugin['description'])))));
104
105    $url_auto_install = htmlentities($my_base_url)
106        . '&amp;extension=' . $plugin['id_extension']
107        . '&amp;install=%2Fupload%2Fextension-' . $plugin['id_extension']
108        . '%2Frevision-' . $plugin['id_revision'] . '%2F'
109        .  str_replace(' ', '%20',$plugin['url']);
110
111    $url_download = PEM_URL .'/upload/extension-'.$plugin['id_extension']
112        . '/revision-' . $plugin['id_revision']
113        . '/' . $plugin['url'];
114
115    $template->append('plugins',
116        array('EXT_NAME' => $plugin['ext_name'],
117          'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin['id_extension'],
118          'EXT_DESC' => $ext_desc,
119          'VERSION' => $plugin['version'],
120          'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin['id_revision'],
121          'VER_DESC' => $ver_desc,
122          'AUTHOR' => $plugin['author'],
123          'URL_INSTALL' => $url_auto_install,
124          'URL_DOWNLOAD' => $url_download));
125  }
126}
127else
128{
129  array_push($page['errors'], l10n('plugins_server_error'));
130}
131
132?>
Note: See TracBrowser for help on using the repository browser.