Ignore:
Timestamp:
Jul 12, 2008, 2:38:52 AM (16 years ago)
Author:
rvelices
Message:
  • merge -r2430 from trunk bug 600: Page not found after a strong rating revise (and extended to most cases when the image is not in the requested section)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1_7/picture.php

    r2406 r2431  
    4646if ( !isset($page['rank_of'][$page['image_id']]) )
    4747{
    48   page_not_found(
    49     'The requested image does not belong to this image set',
    50     duplicate_index_url()
    51     );
     48  $query = '
     49SELECT 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 = '
     86SELECT 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  }
    52121}
    53122
Note: See TracChangeset for help on using the changeset viewer.