source: trunk/admin/languages_new.php @ 22300

Last change on this file since 22300 was 13962, checked in by plg, 13 years ago

merge r13961 from branch 2.3 to trunk

bug 2612 fixed: sanitize $_GETinstallstatus before display for
themes/languages/plugins installation

File size: 5.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 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
24if( !defined("PHPWG_ROOT_PATH") )
25{
26  die ("Hacking attempt!");
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php');
30
31$template->set_filenames(array('languages' => 'languages_new.tpl'));
32
33$base_url = get_root_url().'admin.php?page='.$page['page'].'&tab='.$page['tab'];
34
35$languages = new languages();
36$languages->get_db_languages();
37
38// +-----------------------------------------------------------------------+
39// |                           setup check                                 |
40// +-----------------------------------------------------------------------+
41
42$languages_dir = PHPWG_ROOT_PATH.'language';
43if (!is_writable($languages_dir))
44{
45  array_push(
46    $page['errors'],
47    sprintf(
48      l10n('Add write access to the "%s" directory'),
49      'language'
50      )
51    );
52}
53
54// +-----------------------------------------------------------------------+
55// |                       perform installation                            |
56// +-----------------------------------------------------------------------+
57
58if (isset($_GET['revision']))
59{
60  if (!is_webmaster())
61  {
62    array_push($page['errors'], l10n('Webmaster status is required.'));
63  }
64  else
65  {
66    check_pwg_token();
67
68    $install_status = $languages->extract_language_files('install', $_GET['revision']);
69
70    redirect($base_url.'&installstatus='.$install_status);
71  }
72}
73
74// +-----------------------------------------------------------------------+
75// |                        installation result                            |
76// +-----------------------------------------------------------------------+
77if (isset($_GET['installstatus']))
78{
79  switch ($_GET['installstatus'])
80  {
81    case 'ok':
82      array_push($page['infos'],
83        l10n('Language has been successfully installed')
84      );
85      break;
86
87    case 'temp_path_error':
88      array_push($page['errors'], l10n('Can\'t create temporary file.'));
89      break;
90
91    case 'dl_archive_error':
92      array_push($page['errors'], l10n('Can\'t download archive.'));
93      break;
94
95    case 'archive_error':
96      array_push($page['errors'], l10n('Can\'t read or extract archive.'));
97      break;
98
99    default:
100      array_push(
101        $page['errors'],
102        sprintf(l10n('An error occured during extraction (%s).'), htmlspecialchars($_GET['installstatus']))
103      );
104  } 
105}
106
107// +-----------------------------------------------------------------------+
108// |                     start template output                             |
109// +-----------------------------------------------------------------------+
110if ($languages->get_server_languages(true))
111{
112  foreach($languages->server_languages as $language)
113  {
114    list($date, ) = explode(' ', $language['revision_date']);
115
116    $url_auto_install = htmlentities($base_url)
117      . '&amp;revision=' . $language['revision_id']
118      . '&amp;pwg_token='.get_pwg_token()
119    ;
120
121    $template->append('languages', array(
122      'EXT_NAME' => $language['extension_name'],
123      'EXT_DESC' => $language['extension_description'],
124      'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$language['extension_id'],
125      'VERSION' => $language['revision_name'],
126      'VER_DESC' => $language['revision_description'],
127      'DATE' => $date,
128      'AUTHOR' => $language['author_name'],
129      'URL_INSTALL' => $url_auto_install,
130      'URL_DOWNLOAD' => $language['download_url'] . '&amp;origin=piwigo_download'));
131  }
132}
133else
134{
135  array_push($page['errors'], l10n('Can\'t connect to server.'));
136}
137
138$template->assign_var_from_handle('ADMIN_CONTENT', 'languages');
139?>
Note: See TracBrowser for help on using the repository browser.