Changeset 2326
- Timestamp:
- May 3, 2008, 3:51:50 AM (16 years ago)
- Location:
- branches/branch-1_7
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1_7/include/category_cats.inc.php
r2202 r2326 58 58 $query = ' 59 59 SELECT 60 id, name, permalink, representative_picture_id, comment, nb_images, 60 id, name, permalink, representative_picture_id, comment, nb_images, uppercats, 61 61 date_last, max_date_last, count_images, count_categories 62 62 FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' … … 96 96 ON ic.category_id = c.id'; 97 97 $query.= ' 98 WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'99 '.get_sql_condition_FandF98 WHERE uppercats LIKE \''.$row['uppercats'].',%\'' 99 .get_sql_condition_FandF 100 100 ( 101 101 array … … 105 105 'visible_images' => 'image_id' 106 106 ), 107 'AND'107 "\n AND" 108 108 ).' 109 109 ORDER BY RAND() … … 122 122 FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' 123 123 ON id = cat_id and user_id = '.$user['id'].' 124 WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'125 AND representative_picture_id IS NOT NULL 126 '.get_sql_condition_FandF124 WHERE uppercats LIKE \''.$row['uppercats'].',%\' 125 AND representative_picture_id IS NOT NULL' 126 .get_sql_condition_FandF 127 127 ( 128 128 array … … 130 130 'visible_categories' => 'id', 131 131 ), 132 'AND'132 "\n AND" 133 133 ).' 134 134 ORDER BY RAND() -
branches/branch-1_7/include/section_init.inc.php
r2301 r2326 238 238 {// flat categories mode 239 239 if ( isset($page['category']) ) 240 { 241 $subcat_ids = get_subcat_ids( array($page['category']['id']) ); 240 { // get all allowed sub-categories 241 $query = ' 242 SELECT id 243 FROM '.CATEGORIES_TABLE.' 244 WHERE 245 uppercats LIKE "'.$page['category']['uppercats'].',%" ' 246 .get_sql_condition_FandF( 247 array 248 ( 249 'forbidden_categories' => 'id', 250 'visible_categories' => 'id', 251 ), 252 "\n AND" 253 ); 254 $subcat_ids = array_from_query($query, 'id'); 255 $subcat_ids[] = $page['category']['id']; 242 256 $where_sql = 'category_id IN ('.implode(',',$subcat_ids).')'; 257 // remove categories from forbidden because just checked above 258 $forbidden = get_sql_condition_FandF( 259 array( 'visible_images' => 'id' ), 260 'AND' 261 ); 243 262 } 244 263 else … … 503 522 SELECT id,file 504 523 FROM '.IMAGES_TABLE .' 505 WHERE id IN ('.implode(',',$page['items']).') 506 AND file LIKE "' . $page['image_file'] . '.%" ESCAPE "|"' 507 ; 524 WHERE file LIKE "' . $page['image_file'] . '.%" ESCAPE "|"'; 525 if ( count($page['items']) < 500) 526 {// for very large item sets do not add IN - because slow 527 $query .= ' 528 AND id IN ('.implode(',',$page['items']).') 529 LIMIT 0,1'; 530 } 508 531 $result = pwg_query($query); 509 if (mysql_num_rows($result)>0) 510 { 511 list($page['image_id'], $page['image_file']) = mysql_fetch_row($result); 532 switch (mysql_num_rows($result)) 533 { 534 case 0: break; 535 case 1: 536 list($page['image_id'], $page['image_file']) = mysql_fetch_row($result); 537 break; 538 default: // more than 1 file name match 539 while ($row = mysql_fetch_row($result) ) 540 { 541 if ( in_array($row[0], $page['items']) ) 542 { 543 list($page['image_id'], $page['image_file']) = $row; 544 break; 545 } 546 } 512 547 } 513 548 } -
branches/branch-1_7/picture.php
r2310 r2326 39 39 } 40 40 41 $page['rank_of'] = array_flip($page['items']); 42 41 43 // if this image_id doesn't correspond to this category, an error message is 42 44 // displayed, and execution is stopped 43 if ( !in_array($page['image_id'], $page['items']))45 if ( !isset($page['rank_of'][$page['image_id']]) ) 44 46 { 45 47 page_not_found( … … 103 105 // | initialization | 104 106 // +-----------------------------------------------------------------------+ 105 106 $page['rank_of'] = array_flip($page['items']);107 107 108 108 // caching first_rank, last_rank, current_rank in the displayed
Note: See TracChangeset
for help on using the changeset viewer.