1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2011 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 | |
---|
25 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
26 | { |
---|
27 | die ("Hacking attempt!"); |
---|
28 | } |
---|
29 | |
---|
30 | include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php'); |
---|
31 | |
---|
32 | $base_url = get_root_url().'admin.php?page='.$page['page']; |
---|
33 | |
---|
34 | $languages = new languages(); |
---|
35 | |
---|
36 | $languages->set_tabsheet($page['page']); |
---|
37 | |
---|
38 | //-----------------------------------------------------------automatic upgrade |
---|
39 | if (isset($_GET['language']) and isset($_GET['revision'])) |
---|
40 | { |
---|
41 | if (!is_webmaster()) |
---|
42 | { |
---|
43 | array_push($page['errors'], l10n('Webmaster status is required.')); |
---|
44 | } |
---|
45 | else |
---|
46 | { |
---|
47 | check_pwg_token(); |
---|
48 | |
---|
49 | $language_id = $_GET['language']; |
---|
50 | $revision = $_GET['revision']; |
---|
51 | |
---|
52 | $upgrade_status = $languages->extract_language_files('upgrade', $revision, $language_id); |
---|
53 | |
---|
54 | switch ($upgrade_status) |
---|
55 | { |
---|
56 | case 'ok': |
---|
57 | array_push($page['infos'], |
---|
58 | sprintf( |
---|
59 | l10n('%s has been successfully upgraded.'), |
---|
60 | $languages->fs_languages[$_GET['language']]['name'])); |
---|
61 | break; |
---|
62 | |
---|
63 | case 'temp_path_error': |
---|
64 | array_push($page['errors'], l10n('Can\'t create temporary file.')); |
---|
65 | break; |
---|
66 | |
---|
67 | case 'dl_archive_error': |
---|
68 | array_push($page['errors'], l10n('Can\'t download archive.')); |
---|
69 | break; |
---|
70 | |
---|
71 | case 'archive_error': |
---|
72 | array_push($page['errors'], l10n('Can\'t read or extract archive.')); |
---|
73 | break; |
---|
74 | |
---|
75 | default: |
---|
76 | array_push($page['errors'], |
---|
77 | sprintf(l10n('An error occured during extraction (%s).'), $upgrade_status) |
---|
78 | ); |
---|
79 | } |
---|
80 | |
---|
81 | $languages->languages(); |
---|
82 | $template->delete_compiled_templates(); |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | // +-----------------------------------------------------------------------+ |
---|
87 | // | start template output | |
---|
88 | // +-----------------------------------------------------------------------+ |
---|
89 | $template->set_filenames(array('languages' => 'languages_update.tpl')); |
---|
90 | |
---|
91 | if ($languages->get_server_languages()) |
---|
92 | { |
---|
93 | foreach($languages->fs_languages as $language_id => $fs_language) |
---|
94 | { |
---|
95 | if (isset($fs_language['extension']) |
---|
96 | and isset($languages->server_languages[$fs_language['extension']])) |
---|
97 | { |
---|
98 | $language_info = $languages->server_languages[$fs_language['extension']]; |
---|
99 | |
---|
100 | if (!$languages->language_version_compare($fs_language['version'], $language_info['revision_name'])) |
---|
101 | { |
---|
102 | $url_auto_update = $base_url |
---|
103 | . '&revision=' . $language_info['revision_id'] |
---|
104 | . '&language=' . $language_id |
---|
105 | . '&pwg_token='.get_pwg_token() |
---|
106 | ; |
---|
107 | |
---|
108 | $template->append('update_languages', array( |
---|
109 | 'ID' => $language_info['extension_id'], |
---|
110 | 'EXT_NAME' => $fs_language['name'], |
---|
111 | 'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$language_info['extension_id'], |
---|
112 | 'EXT_DESC' => trim($language_info['extension_description'], " \n\r"), |
---|
113 | 'REV_DESC' => trim($language_info['revision_description'], " \n\r"), |
---|
114 | 'CURRENT_VERSION' => $fs_language['version'], |
---|
115 | 'NEW_VERSION' => $language_info['revision_name'], |
---|
116 | 'AUTHOR' => $language_info['author_name'], |
---|
117 | 'DOWNLOADS' => $language_info['extension_nb_downloads'], |
---|
118 | 'URL_UPDATE' => $url_auto_update, |
---|
119 | 'URL_DOWNLOAD' => $language_info['download_url'] . '&origin=piwigo_download' |
---|
120 | ) |
---|
121 | ); |
---|
122 | } |
---|
123 | } |
---|
124 | } |
---|
125 | } |
---|
126 | else |
---|
127 | { |
---|
128 | $template->assign('SERVER_ERROR', true); |
---|
129 | array_push($page['errors'], l10n('Can\'t connect to server.')); |
---|
130 | } |
---|
131 | |
---|
132 | $template->assign_var_from_handle('ADMIN_CONTENT', 'languages'); |
---|
133 | ?> |
---|