| 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 | // +-----------------------------------------------------------------------+ |
|---|
| 26 | // | Uploaded photos | |
|---|
| 27 | // +-----------------------------------------------------------------------+ |
|---|
| 28 | |
|---|
| 29 | if (isset($page['thumbnails'])) |
|---|
| 30 | { |
|---|
| 31 | $template->assign( |
|---|
| 32 | array( |
|---|
| 33 | 'thumbnails' => $page['thumbnails'], |
|---|
| 34 | ) |
|---|
| 35 | ); |
|---|
| 36 | |
|---|
| 37 | // only display the batch link if we have more than 1 photo |
|---|
| 38 | if (count($page['thumbnails']) > 1) |
|---|
| 39 | { |
|---|
| 40 | $template->assign( |
|---|
| 41 | array( |
|---|
| 42 | 'batch_link' => $page['batch_link'], |
|---|
| 43 | 'batch_label' => sprintf( |
|---|
| 44 | l10n('Manage this set of %d photos'), |
|---|
| 45 | count($page['thumbnails']) |
|---|
| 46 | ), |
|---|
| 47 | ) |
|---|
| 48 | ); |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | // +-----------------------------------------------------------------------+ |
|---|
| 53 | // | Photo selection | |
|---|
| 54 | // +-----------------------------------------------------------------------+ |
|---|
| 55 | |
|---|
| 56 | $uploadify_path = PHPWG_ROOT_PATH.'admin/include/uploadify'; |
|---|
| 57 | |
|---|
| 58 | $template->assign( |
|---|
| 59 | array( |
|---|
| 60 | 'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL, |
|---|
| 61 | 'uploadify_path' => $uploadify_path, |
|---|
| 62 | 'upload_max_filesize' => min( |
|---|
| 63 | get_ini_size('upload_max_filesize'), |
|---|
| 64 | get_ini_size('post_max_size') |
|---|
| 65 | ), |
|---|
| 66 | ) |
|---|
| 67 | ); |
|---|
| 68 | |
|---|
| 69 | $upload_modes = array('html', 'multiple'); |
|---|
| 70 | $upload_mode = isset($conf['upload_mode']) ? $conf['upload_mode'] : 'multiple'; |
|---|
| 71 | |
|---|
| 72 | if (isset($_GET['upload_mode']) and in_array($_GET['upload_mode'], $upload_modes)) |
|---|
| 73 | { |
|---|
| 74 | $upload_mode = $_GET['upload_mode']; |
|---|
| 75 | conf_update_param('upload_mode', $upload_mode); |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | // what is the upload switch mode |
|---|
| 79 | $index_of_upload_mode = array_flip($upload_modes); |
|---|
| 80 | $upload_mode_index = $index_of_upload_mode[$upload_mode]; |
|---|
| 81 | $upload_switch = $upload_modes[ ($upload_mode_index + 1) % 2 ]; |
|---|
| 82 | |
|---|
| 83 | $template->assign( |
|---|
| 84 | array( |
|---|
| 85 | 'upload_mode' => $upload_mode, |
|---|
| 86 | 'form_action' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_mode.'&processed=1', |
|---|
| 87 | 'switch_url' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_switch, |
|---|
| 88 | 'upload_id' => md5(rand()), |
|---|
| 89 | 'session_id' => session_id(), |
|---|
| 90 | 'pwg_token' => get_pwg_token(), |
|---|
| 91 | 'another_upload_link' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_mode, |
|---|
| 92 | ) |
|---|
| 93 | ); |
|---|
| 94 | |
|---|
| 95 | $template->append( |
|---|
| 96 | 'head_elements', |
|---|
| 97 | '<link rel="stylesheet" type="text/css" href="'.$uploadify_path.'/uploadify.css">'."\n" |
|---|
| 98 | ); |
|---|
| 99 | |
|---|
| 100 | // +-----------------------------------------------------------------------+ |
|---|
| 101 | // | Categories | |
|---|
| 102 | // +-----------------------------------------------------------------------+ |
|---|
| 103 | |
|---|
| 104 | // we need to know the category in which the last photo was added |
|---|
| 105 | $selected_category = array(); |
|---|
| 106 | $selected_parent = array(); |
|---|
| 107 | |
|---|
| 108 | $query = ' |
|---|
| 109 | SELECT |
|---|
| 110 | category_id, |
|---|
| 111 | id_uppercat |
|---|
| 112 | FROM '.IMAGES_TABLE.' AS i |
|---|
| 113 | JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = i.id |
|---|
| 114 | JOIN '.CATEGORIES_TABLE.' AS c ON category_id = c.id |
|---|
| 115 | ORDER BY i.id DESC |
|---|
| 116 | LIMIT 1 |
|---|
| 117 | ;'; |
|---|
| 118 | $result = pwg_query($query); |
|---|
| 119 | if (pwg_db_num_rows($result) > 0) |
|---|
| 120 | { |
|---|
| 121 | $row = pwg_db_fetch_assoc($result); |
|---|
| 122 | |
|---|
| 123 | $selected_category = array($row['category_id']); |
|---|
| 124 | |
|---|
| 125 | if (!empty($row['id_uppercat'])) |
|---|
| 126 | { |
|---|
| 127 | $selected_parent = array($row['id_uppercat']); |
|---|
| 128 | } |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | // existing album |
|---|
| 132 | $query = ' |
|---|
| 133 | SELECT id,name,uppercats,global_rank |
|---|
| 134 | FROM '.CATEGORIES_TABLE.' |
|---|
| 135 | ;'; |
|---|
| 136 | |
|---|
| 137 | display_select_cat_wrapper( |
|---|
| 138 | $query, |
|---|
| 139 | $selected_category, |
|---|
| 140 | 'category_options' |
|---|
| 141 | ); |
|---|
| 142 | |
|---|
| 143 | // new category |
|---|
| 144 | display_select_cat_wrapper( |
|---|
| 145 | $query, |
|---|
| 146 | $selected_parent, |
|---|
| 147 | 'category_parent_options' |
|---|
| 148 | ); |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | // image level options |
|---|
| 152 | $selected_level = isset($_POST['level']) ? $_POST['level'] : 0; |
|---|
| 153 | $template->assign( |
|---|
| 154 | array( |
|---|
| 155 | 'level_options'=> get_privacy_level_options(), |
|---|
| 156 | 'level_options_selected' => array($selected_level) |
|---|
| 157 | ) |
|---|
| 158 | ); |
|---|
| 159 | |
|---|
| 160 | // +-----------------------------------------------------------------------+ |
|---|
| 161 | // | Setup errors/warnings | |
|---|
| 162 | // +-----------------------------------------------------------------------+ |
|---|
| 163 | |
|---|
| 164 | // Errors |
|---|
| 165 | $setup_errors = array(); |
|---|
| 166 | |
|---|
| 167 | $error_message = ready_for_upload_message(); |
|---|
| 168 | if (!empty($error_message)) |
|---|
| 169 | { |
|---|
| 170 | array_push($setup_errors, $error_message); |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | if (!function_exists('gd_info')) |
|---|
| 174 | { |
|---|
| 175 | array_push($setup_errors, l10n('GD library is missing')); |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | $template->assign( |
|---|
| 179 | array( |
|---|
| 180 | 'setup_errors'=> $setup_errors, |
|---|
| 181 | ) |
|---|
| 182 | ); |
|---|
| 183 | |
|---|
| 184 | // Warnings |
|---|
| 185 | if (isset($_GET['hide_warnings'])) |
|---|
| 186 | { |
|---|
| 187 | $_SESSION['upload_hide_warnings'] = true; |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | if (!isset($_SESSION['upload_hide_warnings'])) |
|---|
| 191 | { |
|---|
| 192 | $setup_warnings = array(); |
|---|
| 193 | |
|---|
| 194 | if ($conf['use_exif'] and !function_exists('read_exif_data')) |
|---|
| 195 | { |
|---|
| 196 | array_push( |
|---|
| 197 | $setup_warnings, |
|---|
| 198 | l10n('Exif extension not available, admin should disable exif use') |
|---|
| 199 | ); |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | if (get_ini_size('upload_max_filesize') > get_ini_size('post_max_size')) |
|---|
| 203 | { |
|---|
| 204 | array_push( |
|---|
| 205 | $setup_warnings, |
|---|
| 206 | sprintf( |
|---|
| 207 | l10n('In your php.ini file, the upload_max_filesize (%sB) is bigger than post_max_size (%sB), you should change this setting'), |
|---|
| 208 | get_ini_size('upload_max_filesize', false), |
|---|
| 209 | get_ini_size('post_max_size', false) |
|---|
| 210 | ) |
|---|
| 211 | ); |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | $template->assign( |
|---|
| 215 | array( |
|---|
| 216 | 'setup_warnings' => $setup_warnings, |
|---|
| 217 | 'hide_warnings_link' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_mode.'&hide_warnings=1' |
|---|
| 218 | ) |
|---|
| 219 | ); |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | ?> |
|---|