Changeset 12917 for trunk/admin/include
- Timestamp:
- Jan 17, 2012, 10:02:16 PM (13 years ago)
- Location:
- trunk/admin/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r12906 r12917 3 3 // | Piwigo - a PHP based photo gallery | 4 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-201 1Piwigo Team http://piwigo.org |5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | 6 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | … … 176 176 } 177 177 178 include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');179 180 178 $new_ids = array(); 181 179 … … 184 182 id, 185 183 path, 186 tn_ext,187 has_high,188 184 representative_ext 189 185 FROM '.IMAGES_TABLE.' … … 197 193 continue; 198 194 } 199 195 200 196 $files = array(); 201 197 $files[] = get_element_path($row); … … 216 212 } 217 213 } 218 214 219 215 if ($ok) 220 216 { 217 delete_element_derivatives($row); 221 218 $new_ids[] += $row['id']; 222 219 } … … 389 386 { 390 387 $orphan_tags = get_orphan_tags(); 391 388 392 389 if (count($orphan_tags) > 0) 393 390 { … … 413 410 { 414 411 $orphan_tags = array(); 415 412 416 413 $query = ' 417 414 SELECT … … 1390 1387 return false; 1391 1388 } 1392 1389 1393 1390 $query = ' 1394 1391 DELETE … … 1397 1394 ;'; 1398 1395 pwg_query($query); 1399 1396 1400 1397 $query = ' 1401 1398 DELETE … … 2039 2036 { 2040 2037 $result = pwg_query($query); 2041 2038 2042 2039 $taglist = array(); 2043 2040 while ($row = pwg_db_fetch_assoc($result)) … … 2058 2055 $row['name'] = preg_replace('#\[lang=(.*?)\](.*?)\[/lang\]#is', null, $row['name']); 2059 2056 } 2060 2057 2061 2058 if (strlen($row['name']) > 0) 2062 2059 { … … 2070 2067 } 2071 2068 } 2072 2069 2073 2070 $cmp = create_function('$a,$b', 'return strcasecmp($a["name"], $b["name"]);'); 2074 2071 usort($taglist, $cmp); … … 2137 2134 return; 2138 2135 } 2139 2136 2140 2137 // make sure categories are private and select uppercats or subcats 2141 2138 $cat_ids = (isset($_POST['apply_on_sub'])) ? implode(',', get_subcat_ids($category_ids)).",".implode(',', get_uppercat_ids($category_ids)) : implode(',', get_uppercat_ids($category_ids)); … … 2153 2150 return; 2154 2151 } 2155 2152 2156 2153 // We must not reinsert already existing lines in user_access table 2157 2154 $granteds = array(); … … 2160 2157 $granteds[$cat_id] = array(); 2161 2158 } 2162 2159 2163 2160 $query = ' 2164 2161 SELECT … … 2176 2173 2177 2174 $inserts = array(); 2178 2175 2179 2176 foreach ($private_cats as $cat_id) 2180 2177 { 2181 2178 $grant_to_users = array_diff($user_ids, $granteds[$cat_id]); 2182 2179 2183 2180 foreach ($grant_to_users as $user_id) 2184 2181 { … … 2208 2205 $status_list[] = 'webmaster'; 2209 2206 } 2210 2207 2211 2208 $query = ' 2212 2209 SELECT … … 2246 2243 $pattern .= derivative_to_url($types[0]); 2247 2244 } 2248 2245 2249 2246 $pattern.='(_[a-zA-Z0-9]+)*\.[a-zA-Z0-9]{3,4}$#'; 2250 2247 if ($contents = opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR)) … … 2295 2292 } 2296 2293 closedir($contents); 2297 2294 2298 2295 if ($rmdir) 2299 2296 { … … 2309 2306 } 2310 2307 2311 function delete_element_derivatives($ids) 2312 { 2313 // todo 2314 if (!is_array($ids)) 2315 { 2316 $ids = array($ids); 2317 } 2318 2319 // for now I do a massive clear, to be removed once the function is 2320 // properly implemented 2321 clear_derivative_cache(); 2308 function delete_element_derivatives($infos) 2309 { 2310 $path = $infos['path']; 2311 if (!empty($infos['representative_ext'])) 2312 { 2313 $path = original_to_representative( $path, $infos['representative_ext']); 2314 } 2315 if (substr_compare($path, '../', 0, 3)==0) 2316 { 2317 $path = substr($path, 3); 2318 } 2319 $dot = strpos($path, '.'); 2320 $path = substr_replace($path, '-*', $dot, 0); 2321 foreach( glob(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$path) as $file) 2322 { 2323 @unlink($file); 2324 } 2322 2325 } 2323 2326 ?> -
trunk/admin/include/functions_upload.inc.php
r12907 r12917 3 3 // | Piwigo - a PHP based photo gallery | 4 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-201 1Piwigo Team http://piwigo.org |5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | 6 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | … … 37 37 'can_be_null' => false, 38 38 ), 39 39 40 40 'original_resize_maxwidth' => array( 41 41 'default' => 2000, … … 46 46 'error_message' => l10n('The original maximum width must be a number between %d and %d'), 47 47 ), 48 48 49 49 'original_resize_maxheight' => array( 50 50 'default' => 2000, … … 55 55 'error_message' => l10n('The original maximum height must be a number between %d and %d'), 56 56 ), 57 57 58 58 'original_resize_quality' => array( 59 59 'default' => 95, … … 113 113 $max = $upload_form_config[$field]['max']; 114 114 $pattern = $upload_form_config[$field]['pattern']; 115 115 116 116 if (preg_match($pattern, $value) and $value >= $min and $value <= $max) 117 117 { … … 158 158 // 159 159 // 3) register in database 160 160 161 161 // TODO 162 162 // * check md5sum (already exists?) 163 163 164 164 global $conf, $user; 165 165 … … 172 172 $md5sum = md5_file($source_filepath); 173 173 } 174 174 175 175 $file_path = null; 176 176 177 177 if (isset($image_id)) 178 178 { … … 189 189 $file_path = $row['path']; 190 190 } 191 191 192 192 if (!isset($file_path)) 193 193 { … … 201 201 { 202 202 // this photo is new 203 203 204 204 // current date 205 205 list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); 206 206 list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4); 207 207 208 208 // upload directory hierarchy 209 209 $upload_dir = sprintf( … … 251 251 { 252 252 $need_resize = need_resize($file_path, $conf['original_resize_maxwidth'], $conf['original_resize_maxheight']); 253 253 254 254 if ($need_resize) 255 255 { 256 256 $img = new pwg_image($file_path); 257 257 258 258 $img->pwg_resize( 259 259 $file_path, … … 264 264 false 265 265 ); 266 266 267 267 $img->destroy(); 268 268 } … … 271 271 272 272 $file_infos = pwg_image_infos($file_path); 273 273 274 274 if (isset($image_id)) 275 275 { … … 282 282 'added_by' => $user['id'], 283 283 ); 284 284 285 285 if (isset($level)) 286 286 { … … 293 293 array('id' => $image_id) 294 294 ); 295 296 delete_element_derivatives($image_id);297 295 } 298 296 else … … 309 307 'added_by' => $user['id'], 310 308 ); 311 309 312 310 if (isset($level)) 313 311 { … … 316 314 317 315 single_insert(IMAGES_TABLE, $insert); 318 316 319 317 $image_id = pwg_db_insert_id(IMAGES_TABLE); 320 318 } … … 327 325 ); 328 326 } 329 327 330 328 // update metadata from the uploaded file (exif/iptc) 331 329 if ($conf['use_exif'] and !function_exists('read_exif_data')) … … 375 373 // invert width and height. 376 374 list($width, $height) = getimagesize($image_filepath); 377 375 378 376 if ($width > $max_width or $height > $max_height) 379 377 { … … 388 386 list($width, $height) = getimagesize($path); 389 387 $filesize = floor(filesize($path)/1024); 390 388 391 389 return array( 392 390 'width' => $width, … … 434 432 $size = convert_shorthand_notation_to_bytes($size); 435 433 } 436 434 437 435 return $size; 438 436 } … … 442 440 $suffix = substr($value, -1); 443 441 $multiply_by = null; 444 442 445 443 if ('K' == $suffix) 446 444 { … … 455 453 $multiply_by = 1024*1024*1024; 456 454 } 457 455 458 456 if (isset($multiply_by)) 459 457 { … … 500 498 { 501 499 @chmod($conf['upload_dir'], 0777); 502 500 503 501 if (!is_writable($conf['upload_dir'])) 504 502 {
Note: See TracChangeset
for help on using the changeset viewer.