- Timestamp:
- May 3, 2008, 3:52:08 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/category_cats.inc.php
r2299 r2327 55 55 $query = ' 56 56 SELECT 57 id, name, permalink, representative_picture_id, comment, nb_images, 57 id, name, permalink, representative_picture_id, comment, nb_images, uppercats, 58 58 date_last, max_date_last, count_images, count_categories 59 59 FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' … … 94 94 ON ic.category_id = c.id'; 95 95 $query.= ' 96 WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'97 '.get_sql_condition_FandF96 WHERE uppercats LIKE \''.$row['uppercats'].',%\'' 97 .get_sql_condition_FandF 98 98 ( 99 99 array … … 103 103 'visible_images' => 'image_id' 104 104 ), 105 'AND'105 "\n AND" 106 106 ).' 107 107 ORDER BY RAND() … … 120 120 FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' 121 121 ON id = cat_id and user_id = '.$user['id'].' 122 WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'123 AND representative_picture_id IS NOT NULL 124 '.get_sql_condition_FandF122 WHERE uppercats LIKE \''.$row['uppercats'].',%\' 123 AND representative_picture_id IS NOT NULL' 124 .get_sql_condition_FandF 125 125 ( 126 126 array … … 128 128 'visible_categories' => 'id', 129 129 ), 130 'AND'130 "\n AND" 131 131 ).' 132 132 ORDER BY RAND() -
trunk/include/section_init.inc.php
r2299 r2327 234 234 {// flat categories mode 235 235 if ( isset($page['category']) ) 236 { 237 $subcat_ids = get_subcat_ids( array($page['category']['id']) ); 236 { // get all allowed sub-categories 237 $query = ' 238 SELECT id 239 FROM '.CATEGORIES_TABLE.' 240 WHERE 241 uppercats LIKE "'.$page['category']['uppercats'].',%" ' 242 .get_sql_condition_FandF( 243 array 244 ( 245 'forbidden_categories' => 'id', 246 'visible_categories' => 'id', 247 ), 248 "\n AND" 249 ); 250 $subcat_ids = array_from_query($query, 'id'); 251 $subcat_ids[] = $page['category']['id']; 238 252 $where_sql = 'category_id IN ('.implode(',',$subcat_ids).')'; 253 // remove categories from forbidden because just checked above 254 $forbidden = get_sql_condition_FandF( 255 array( 'visible_images' => 'id' ), 256 'AND' 257 ); 239 258 } 240 259 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 } -
trunk/picture.php
r2309 r2327 36 36 } 37 37 38 $page['rank_of'] = array_flip($page['items']); 39 38 40 // if this image_id doesn't correspond to this category, an error message is 39 41 // displayed, and execution is stopped 40 if ( !in_array($page['image_id'], $page['items']))42 if ( !isset($page['rank_of'][$page['image_id']]) ) 41 43 { 42 44 page_not_found( … … 100 102 // | initialization | 101 103 // +-----------------------------------------------------------------------+ 102 103 $page['rank_of'] = array_flip($page['items']);104 104 105 105 // caching first_rank, last_rank, current_rank in the displayed … … 868 868 include(PHPWG_ROOT_PATH.'include/picture_metadata.inc.php'); 869 869 } 870 //------------------------------------------------------------ log informations871 pwg_log($picture['current']['id'], 'picture');872 870 873 871 include(PHPWG_ROOT_PATH.'include/page_header.php'); 874 872 trigger_action('loc_end_picture'); 875 873 $template->pparse('picture'); 874 //------------------------------------------------------------ log informations 875 pwg_log($picture['current']['id'], 'picture'); 876 876 include(PHPWG_ROOT_PATH.'include/page_tail.php'); 877 877 ?>
Note: See TracChangeset
for help on using the changeset viewer.