[2] | 1 | <?php |
---|
[362] | 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[675] | 5 | // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[362] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[362] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2006-07-11 20:56:51 +0000 (Tue, 11 Jul 2006) $ |
---|
| 10 | // | last modifier : $Author: rub $ |
---|
| 11 | // | revision : $Revision: 1459 $ |
---|
| 12 | // +-----------------------------------------------------------------------+ |
---|
| 13 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 14 | // | it under the terms of the GNU General Public License as published by | |
---|
| 15 | // | the Free Software Foundation | |
---|
| 16 | // | | |
---|
| 17 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 20 | // | General Public License for more details. | |
---|
| 21 | // | | |
---|
| 22 | // | You should have received a copy of the GNU General Public License | |
---|
| 23 | // | along with this program; if not, write to the Free Software | |
---|
| 24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 25 | // | USA. | |
---|
| 26 | // +-----------------------------------------------------------------------+ |
---|
[520] | 27 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
| 28 | { |
---|
[696] | 29 | die ("Hacking attempt!"); |
---|
[520] | 30 | } |
---|
[1072] | 31 | |
---|
| 32 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 33 | |
---|
| 34 | // +-----------------------------------------------------------------------+ |
---|
| 35 | // | Check Access and exit when user status is not ok | |
---|
| 36 | // +-----------------------------------------------------------------------+ |
---|
| 37 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 38 | |
---|
[26] | 39 | //--------------------------------------------------------------------- updates |
---|
[849] | 40 | |
---|
| 41 | if (isset($_POST)) |
---|
[26] | 42 | { |
---|
[849] | 43 | $to_validate = array(); |
---|
| 44 | $to_reject = array(); |
---|
| 45 | |
---|
| 46 | if (isset($_POST['submit'])) |
---|
| 47 | { |
---|
| 48 | foreach (explode(',', $_POST['list']) as $waiting_id) |
---|
| 49 | { |
---|
| 50 | if (isset($_POST['action-'.$waiting_id])) |
---|
| 51 | { |
---|
| 52 | switch ($_POST['action-'.$waiting_id]) |
---|
| 53 | { |
---|
| 54 | case 'reject' : |
---|
| 55 | { |
---|
| 56 | array_push($to_reject, $waiting_id); |
---|
| 57 | break; |
---|
| 58 | } |
---|
| 59 | case 'validate' : |
---|
| 60 | { |
---|
| 61 | array_push($to_validate, $waiting_id); |
---|
| 62 | break; |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | } |
---|
[1235] | 68 | elseif (isset($_POST['validate-all']) and !empty($_POST['list'])) |
---|
[26] | 69 | { |
---|
[849] | 70 | $to_validate = explode(',', $_POST['list']); |
---|
| 71 | } |
---|
[1235] | 72 | elseif (isset($_POST['reject-all']) and !empty($_POST['list'])) |
---|
[849] | 73 | { |
---|
| 74 | $to_reject = explode(',', $_POST['list']); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | if (count($to_validate) > 0) |
---|
| 78 | { |
---|
| 79 | $query = ' |
---|
| 80 | UPDATE '.WAITING_TABLE.' |
---|
| 81 | SET validated = \'true\' |
---|
| 82 | WHERE id IN ('.implode(',', $to_validate).') |
---|
| 83 | ;'; |
---|
| 84 | pwg_query($query); |
---|
| 85 | |
---|
| 86 | array_push( |
---|
| 87 | $page['infos'], |
---|
| 88 | sprintf( |
---|
| 89 | l10n('%d waiting pictures validated'), |
---|
| 90 | count($to_validate) |
---|
| 91 | ) |
---|
| 92 | ); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | if (count($to_reject) > 0) |
---|
| 96 | { |
---|
| 97 | // The uploaded element was refused, we have to delete its reference in |
---|
| 98 | // the database and to delete the element as well. |
---|
| 99 | $query = ' |
---|
| 100 | SELECT id, storage_category_id, file, tn_ext |
---|
| 101 | FROM '.WAITING_TABLE.' |
---|
| 102 | WHERE id IN ('.implode(',', $to_reject).') |
---|
| 103 | ;'; |
---|
| 104 | $result = pwg_query($query); |
---|
| 105 | while($row = mysql_fetch_array($result)) |
---|
[26] | 106 | { |
---|
[849] | 107 | $dir = get_complete_dir($row['storage_category_id']); |
---|
| 108 | unlink($dir.$row['file']); |
---|
| 109 | if (isset($row['tn_ext']) and $row['tn_ext'] != '') |
---|
[26] | 110 | { |
---|
[849] | 111 | unlink( |
---|
| 112 | get_thumbnail_src( |
---|
| 113 | $dir.$row['file'], |
---|
| 114 | $row['tn_ext'] |
---|
| 115 | ) |
---|
| 116 | ); |
---|
[26] | 117 | } |
---|
[849] | 118 | else if (@is_file(get_thumbnail_src($dir.$row['file'], 'jpg'))) |
---|
[26] | 119 | { |
---|
[849] | 120 | unlink( |
---|
| 121 | get_thumbnail_src( |
---|
| 122 | $dir.$row['file'], |
---|
| 123 | 'jpg' |
---|
| 124 | ) |
---|
| 125 | ); |
---|
[26] | 126 | } |
---|
| 127 | } |
---|
[849] | 128 | |
---|
| 129 | $query = ' |
---|
| 130 | DELETE |
---|
| 131 | FROM '.WAITING_TABLE.' |
---|
| 132 | WHERE id IN ('.implode(',', $to_reject).') |
---|
| 133 | ;'; |
---|
| 134 | pwg_query($query); |
---|
| 135 | |
---|
| 136 | array_push( |
---|
| 137 | $page['infos'], |
---|
| 138 | sprintf( |
---|
| 139 | l10n('%d waiting pictures rejected'), |
---|
| 140 | count($to_reject) |
---|
| 141 | ) |
---|
| 142 | ); |
---|
[26] | 143 | } |
---|
| 144 | } |
---|
[520] | 145 | |
---|
[26] | 146 | //----------------------------------------------------- template initialization |
---|
[520] | 147 | $template->set_filenames(array('waiting'=>'admin/waiting.tpl')); |
---|
| 148 | $template->assign_vars(array( |
---|
| 149 | 'L_AUTHOR'=>$lang['author'], |
---|
| 150 | 'L_THUMBNAIL'=>$lang['thumbnail'], |
---|
| 151 | 'L_DATE'=>$lang['date'], |
---|
| 152 | 'L_FILE'=>$lang['file'], |
---|
| 153 | 'L_CATEGORY'=>$lang['category'], |
---|
| 154 | 'L_SUBMIT'=>$lang['submit'], |
---|
[699] | 155 | 'L_RESET'=>$lang['reset'], |
---|
[520] | 156 | 'L_DELETE'=>$lang['delete'], |
---|
| 157 | |
---|
[1004] | 158 | 'F_ACTION'=>str_replace( '&', '&', $_SERVER['REQUEST_URI']) |
---|
[520] | 159 | )); |
---|
| 160 | |
---|
[26] | 161 | //---------------------------------------------------------------- form display |
---|
| 162 | $cat_names = array(); |
---|
[849] | 163 | $list = array(); |
---|
| 164 | |
---|
[520] | 165 | $query = 'SELECT * FROM '.WAITING_TABLE; |
---|
[26] | 166 | $query.= " WHERE validated = 'false'"; |
---|
[61] | 167 | $query.= ' ORDER BY storage_category_id'; |
---|
[26] | 168 | $query.= ';'; |
---|
[587] | 169 | $result = pwg_query( $query ); |
---|
[26] | 170 | $i = 0; |
---|
| 171 | while ( $row = mysql_fetch_array( $result ) ) |
---|
| 172 | { |
---|
[61] | 173 | if ( !isset( $cat_names[$row['storage_category_id']] ) ) |
---|
[26] | 174 | { |
---|
[61] | 175 | $cat = get_cat_info( $row['storage_category_id'] ); |
---|
| 176 | $cat_names[$row['storage_category_id']] = array(); |
---|
| 177 | $cat_names[$row['storage_category_id']]['dir'] = |
---|
[520] | 178 | PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] ); |
---|
[61] | 179 | $cat_names[$row['storage_category_id']]['display_name'] = |
---|
[642] | 180 | get_cat_display_name($cat['name']); |
---|
[26] | 181 | } |
---|
[520] | 182 | $preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file']; |
---|
| 183 | $class='row1'; |
---|
| 184 | if ( $i++ % 2== 0 ) $class='row2'; |
---|
| 185 | |
---|
[849] | 186 | $template->assign_block_vars( |
---|
| 187 | 'picture', |
---|
| 188 | array( |
---|
| 189 | 'WAITING_CLASS'=>$class, |
---|
| 190 | 'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'], |
---|
| 191 | 'ID_IMG'=>$row['id'], |
---|
| 192 | 'DATE_IMG' => date('Y-m-d H:i:s', $row['date']), |
---|
| 193 | 'FILE_TITLE'=>$row['file'], |
---|
| 194 | 'FILE_IMG' => |
---|
| 195 | (strlen($row['file']) > 10) ? |
---|
| 196 | (substr($row['file'], 0, 10)).'...' : $row['file'], |
---|
| 197 | 'PREVIEW_URL_IMG'=>$preview_url, |
---|
[1459] | 198 | 'UPLOAD_EMAIL'=>get_email_address_as_display_text($row['mail_address']), |
---|
[849] | 199 | 'UPLOAD_USERNAME'=>$row['username'] |
---|
| 200 | ) |
---|
| 201 | ); |
---|
[520] | 202 | |
---|
[26] | 203 | // is there an existing associated thumnail ? |
---|
[520] | 204 | if ( !empty( $row['tn_ext'] )) |
---|
[26] | 205 | { |
---|
| 206 | $thumbnail = $conf['prefix_thumbnail']; |
---|
| 207 | $thumbnail.= get_filename_wo_extension( $row['file'] ); |
---|
| 208 | $thumbnail.= '.'.$row['tn_ext']; |
---|
[520] | 209 | $url = $cat_names[$row['storage_category_id']]['dir']; |
---|
[61] | 210 | $url.= 'thumbnail/'.$thumbnail; |
---|
[520] | 211 | |
---|
[849] | 212 | $template->assign_block_vars( |
---|
| 213 | 'picture.thumbnail', |
---|
| 214 | array( |
---|
| 215 | 'PREVIEW_URL_TN_IMG' => $url, |
---|
| 216 | 'FILE_TN_IMG' => |
---|
| 217 | (strlen($thumbnail) > 10) ? |
---|
| 218 | (substr($thumbnail, 0, 10)).'...' : $thumbnail, |
---|
| 219 | 'FILE_TN_TITLE' => $thumbnail |
---|
| 220 | ) |
---|
| 221 | ); |
---|
[26] | 222 | } |
---|
[849] | 223 | |
---|
| 224 | array_push($list, $row['id']); |
---|
[26] | 225 | } |
---|
[849] | 226 | |
---|
| 227 | $template->assign_vars( |
---|
| 228 | array( |
---|
| 229 | 'LIST' => implode(',', $list) |
---|
| 230 | ) |
---|
| 231 | ); |
---|
| 232 | |
---|
[26] | 233 | //----------------------------------------------------------- sending html code |
---|
[520] | 234 | $template->assign_var_from_handle('ADMIN_CONTENT', 'waiting'); |
---|
[362] | 235 | ?> |
---|