Changeset 1287


Ignore:
Timestamp:
04/28/06 07:11:46 (14 years ago)
Author:
rvelices
Message:

bug 349: Nicer display messages instead of "die" when urls cannot be
solved (also set 404 status code for bots)

Location:
branches/branch-1_6
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1_6/category.php

    r1110 r1287  
    4040    $url_params['section'] = 'categories'; 
    4141    $url_params['category'] = $_GET['cat']; 
     42    $result = get_cat_info($url_params['category']); 
     43    if ( !empty($result) ) 
     44      $url_params['cat_name'] = $result['name']; 
    4245  } 
    4346  elseif ( in_array($_GET['cat'], 
     
    4851    $url_params['section'] = $_GET['cat']; 
    4952  } 
     53  else 
     54  { 
     55    page_not_found(''); 
     56  } 
    5057} 
    5158 
  • branches/branch-1_6/include/functions_category.inc.php

    r1113 r1287  
    119119;'; 
    120120  $row = mysql_fetch_array(pwg_query($query)); 
     121  if (empty($row)) 
     122    return null; 
    121123 
    122124  $cat = array(); 
  • branches/branch-1_6/include/functions_html.inc.php

    r1275 r1287  
    592592  } 
    593593} 
     594 
     595/** 
     596 * exits the current script with 404 code when a page cannot be found 
     597 * @param string msg a message to display 
     598 * @param string alternate_url redirect to this url 
     599 */ 
     600function page_not_found($msg, $alternate_url=null) 
     601{ 
     602  header('HTTP/1.1 404 Not found'); 
     603  header('Status: 404 Not found'); 
     604  if ($alternate_url==null) 
     605    $alternate_url = make_index_url(); 
     606  redirect( $alternate_url, 
     607    '<div style="text-align:left; margin-left:5em;margin-bottom:5em;"> 
     608<h1 style="text-align:left; font-size:36px;">Page not found</h1><br/>' 
     609.$msg.'</div>', 
     610    5 ); 
     611} 
    594612?> 
  • branches/branch-1_6/include/section_init.inc.php

    r1228 r1287  
    198198  if ( empty($page['tags']) ) 
    199199  { 
    200     die('Fatal: no existing tag'); 
     200    page_not_found('Requested tag does not exist', get_root_url().'tags.php' ); 
    201201  } 
    202202} 
     
    317317  { 
    318318    $result = get_cat_info($page['category']); 
     319    if (empty($result)) 
     320    { 
     321      page_not_found('Requested category does not exist' ); 
     322    } 
    319323 
    320324    $page = array_merge( 
  • branches/branch-1_6/picture.php

    r1285 r1287  
    4343if (!in_array($page['image_id'], $page['items'])) 
    4444{ 
    45   die('Fatal: this picture does not belong to this section'); 
     45  page_not_found('The requested image does not belong to this image set', 
     46      duplicate_index_url() ); 
    4647} 
    4748 
Note: See TracChangeset for help on using the changeset viewer.