[5143] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[5143] | 4 | // +-----------------------------------------------------------------------+ |
---|
[26461] | 5 | // | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | |
---|
[5143] | 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 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
| 25 | { |
---|
| 26 | die ("Hacking attempt!"); |
---|
| 27 | } |
---|
| 28 | |
---|
[5153] | 29 | include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php'); |
---|
[5143] | 30 | |
---|
[10638] | 31 | $base_url = get_root_url().'admin.php?page='.$page['page'].'&tab='.$page['tab']; |
---|
[5143] | 32 | |
---|
[5153] | 33 | $themes = new themes(); |
---|
[5143] | 34 | |
---|
| 35 | // +-----------------------------------------------------------------------+ |
---|
| 36 | // | setup check | |
---|
| 37 | // +-----------------------------------------------------------------------+ |
---|
| 38 | |
---|
| 39 | $themes_dir = PHPWG_ROOT_PATH.'themes'; |
---|
| 40 | if (!is_writable($themes_dir)) |
---|
| 41 | { |
---|
[25005] | 42 | $page['errors'][] = l10n('Add write access to the "%s" directory', 'themes'); |
---|
[5143] | 43 | } |
---|
| 44 | |
---|
| 45 | // +-----------------------------------------------------------------------+ |
---|
| 46 | // | perform installation | |
---|
| 47 | // +-----------------------------------------------------------------------+ |
---|
| 48 | |
---|
[5406] | 49 | if (isset($_GET['revision']) and isset($_GET['extension'])) |
---|
[5143] | 50 | { |
---|
[5406] | 51 | if (!is_webmaster()) |
---|
| 52 | { |
---|
[25018] | 53 | $page['errors'][] = l10n('Webmaster status is required.'); |
---|
[5406] | 54 | } |
---|
| 55 | else |
---|
| 56 | { |
---|
| 57 | check_pwg_token(); |
---|
| 58 | |
---|
| 59 | $install_status = $themes->extract_theme_files( |
---|
| 60 | 'install', |
---|
| 61 | $_GET['revision'], |
---|
| 62 | $_GET['extension'] |
---|
| 63 | ); |
---|
| 64 | |
---|
| 65 | redirect($base_url.'&installstatus='.$install_status); |
---|
| 66 | } |
---|
[5143] | 67 | } |
---|
| 68 | |
---|
| 69 | // +-----------------------------------------------------------------------+ |
---|
| 70 | // | installation result | |
---|
| 71 | // +-----------------------------------------------------------------------+ |
---|
| 72 | |
---|
| 73 | if (isset($_GET['installstatus'])) |
---|
| 74 | { |
---|
| 75 | switch ($_GET['installstatus']) |
---|
| 76 | { |
---|
| 77 | case 'ok': |
---|
[25018] | 78 | $page['infos'][] = l10n('Theme has been successfully installed'); |
---|
[5143] | 79 | break; |
---|
| 80 | |
---|
| 81 | case 'temp_path_error': |
---|
[25018] | 82 | $page['errors'][] = l10n('Can\'t create temporary file.'); |
---|
[5143] | 83 | break; |
---|
| 84 | |
---|
| 85 | case 'dl_archive_error': |
---|
[25018] | 86 | $page['errors'][] = l10n('Can\'t download archive.'); |
---|
[5143] | 87 | break; |
---|
| 88 | |
---|
| 89 | case 'archive_error': |
---|
[25018] | 90 | $page['errors'][] = l10n('Can\'t read or extract archive.'); |
---|
[5143] | 91 | break; |
---|
| 92 | |
---|
| 93 | default: |
---|
[25018] | 94 | $page['errors'][] = l10n( |
---|
| 95 | 'An error occured during extraction (%s).', |
---|
| 96 | htmlspecialchars($_GET['installstatus']) |
---|
[5143] | 97 | ); |
---|
| 98 | } |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | // +-----------------------------------------------------------------------+ |
---|
| 102 | // | template output | |
---|
| 103 | // +-----------------------------------------------------------------------+ |
---|
| 104 | |
---|
| 105 | $template->set_filenames(array('themes' => 'themes_new.tpl')); |
---|
| 106 | |
---|
[5153] | 107 | if ($themes->get_server_themes(true)) // only new themes |
---|
[5143] | 108 | { |
---|
[5153] | 109 | foreach($themes->server_themes as $theme) |
---|
[5143] | 110 | { |
---|
| 111 | $url_auto_install = htmlentities($base_url) |
---|
| 112 | . '&revision=' . $theme['revision_id'] |
---|
| 113 | . '&extension=' . $theme['extension_id'] |
---|
[5406] | 114 | . '&pwg_token='.get_pwg_token() |
---|
[5143] | 115 | ; |
---|
| 116 | |
---|
| 117 | $template->append( |
---|
| 118 | 'new_themes', |
---|
| 119 | array( |
---|
| 120 | 'name' => $theme['extension_name'], |
---|
[11917] | 121 | 'thumbnail' => PEM_URL.'/upload/extension-'.$theme['extension_id'].'/thumbnail.jpg', |
---|
| 122 | 'screenshot' => PEM_URL.'/upload/extension-'.$theme['extension_id'].'/screenshot.jpg', |
---|
[5143] | 123 | 'install_url' => $url_auto_install, |
---|
| 124 | ) |
---|
| 125 | ); |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | else |
---|
| 129 | { |
---|
[25018] | 130 | $page['errors'][] = l10n('Can\'t connect to server.'); |
---|
[5143] | 131 | } |
---|
| 132 | |
---|
[6015] | 133 | $template->assign('default_screenshot', |
---|
| 134 | get_root_url().'admin/themes/'.$conf['admin_theme'].'/images/missing_screenshot.png' |
---|
| 135 | ); |
---|
| 136 | |
---|
[5143] | 137 | $template->assign_var_from_handle('ADMIN_CONTENT', 'themes'); |
---|
| 138 | ?> |
---|