Changeset 2431
- Timestamp:
- Jul 12, 2008, 2:38:52 AM (16 years ago)
- Location:
- branches/branch-1_7
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1_7/include/section_init.inc.php
r2423 r2431 97 97 { 98 98 $page['image_id'] = $token; 99 if ($page['image_id']==0) 100 { 101 bad_request('invalid picture identifier'); 102 } 99 103 } 100 104 else … … 526 530 and !isset($page['image_id']) ) 527 531 { 528 if ( !empty($page['items']) ) 529 { 530 $query = ' 531 SELECT id,file 532 FROM '.IMAGES_TABLE .' 533 WHERE file LIKE "' . $page['image_file'] . '.%" ESCAPE "|"'; 534 if ( count($page['items']) < 500) 535 {// for very large item sets do not add IN - because slow 536 $query .= ' 537 AND id IN ('.implode(',',$page['items']).') 538 LIMIT 0,1'; 539 } 540 $result = pwg_query($query); 541 switch (mysql_num_rows($result)) 542 { 543 case 0: break; 544 case 1: 545 list($page['image_id'], $page['image_file']) = mysql_fetch_row($result); 546 break; 547 default: // more than 1 file name match 548 while ($row = mysql_fetch_row($result) ) 549 { 550 if ( in_array($row[0], $page['items']) ) 551 { 552 list($page['image_id'], $page['image_file']) = $row; 553 break; 554 } 555 } 556 } 557 } 558 if ( !isset($page['image_id']) ) 559 { 560 $page['image_id'] = -1; // will fail in picture.php 561 } 532 $page['image_id'] = 0; // more work in picture.php 562 533 } 563 534 -
branches/branch-1_7/picture.php
r2406 r2431 46 46 if ( !isset($page['rank_of'][$page['image_id']]) ) 47 47 { 48 page_not_found( 49 'The requested image does not belong to this image set', 50 duplicate_index_url() 51 ); 48 $query = ' 49 SELECT id, file 50 FROM '.IMAGES_TABLE.' 51 WHERE '; 52 if ($page['image_id']>0) 53 { 54 $query .= 'id = '.$page['image_id']; 55 } 56 else 57 {// url given by file name 58 assert( !empty($page['image_file']) ); 59 $query .= 'file LIKE "' . $page['image_file'] . '.%" ESCAPE "|" LIMIT 1'; 60 } 61 if ( ! ( $row = mysql_fetch_array(pwg_query($query)) ) ) 62 {// element does not exist 63 page_not_found( 'The requested image does not exist', 64 duplicate_index_url() 65 ); 66 } 67 68 list($page['image_id'], $page['image_file']) = $row; 69 if ( !isset($page['rank_of'][$page['image_id']]) ) 70 {// the image can still be non accessible (filter/cat perm) and/or not in the set 71 global $filter; 72 if ( !empty($filter['visible_images']) and 73 !in_array($page['image_id'], explode(',',$filter['visible_images']) ) ) 74 { 75 page_not_found( 'The requested image is filtered', 76 duplicate_index_url() 77 ); 78 } 79 if ('categories'==$page['section'] and !isset($page['category']) ) 80 {// flat view - all items 81 access_denied(); 82 } 83 else 84 {// try to see if we can access it differently 85 $query = ' 86 SELECT id 87 FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id 88 WHERE id='.$page['image_id'] 89 . get_sql_condition_FandF( 90 array('forbidden_categories' => 'category_id'), 91 " AND" 92 ).' 93 LIMIT 1'; 94 if ( mysql_num_rows( pwg_query($query) ) == 0 ) 95 { 96 access_denied(); 97 } 98 else 99 { 100 if ('best_rated'==$page['section']) 101 { 102 $page['rank_of'][$page['image_id']] = count($page['items']); 103 array_push($page['items'], $page['image_id'] ); 104 } 105 else 106 { 107 $url = make_picture_url( 108 array( 109 'image_id' => $page['image_id'], 110 'image_file' => $page['image_file'], 111 'section' => 'categories', 112 'flat' => true, 113 ) 114 ); 115 set_status_header( 'recent_pics'==$page['section'] ? 301 : 302); 116 redirect_http( $url ); 117 } 118 } 119 } 120 } 52 121 } 53 122
Note: See TracChangeset
for help on using the changeset viewer.