- new function set_status_header (set http status code)

- correction on recent/recent_by_child icons

git-svn-id: http://piwigo.org/svn/trunk@1643 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices
2006-12-08 00:12:44 +00:00
parent 92fc9abb14
commit 7325369bf5
3 changed files with 29 additions and 12 deletions

View File

@@ -55,8 +55,7 @@ function guess_mime_type($ext)
function do_error( $code, $str )
{
header("HTTP/1.1 $code ");
header("Status: $code ");
set_status_header( $code );
echo $str ;
exit();
}
@@ -148,8 +147,7 @@ if (!url_is_remote($file))
if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
{
header("HTTP/1.1 304 Not modified ");
header("Status: 304 Not modified");
set_status_header(304);
foreach ($http_headers as $header)
{
header( $header );

View File

@@ -65,8 +65,7 @@ $image_ids = array();
while ($row = mysql_fetch_assoc($result))
{
$row['is_child_date_last'] = isset($row['date_last'])
and $row['max_date_last']>$row['date_last'];
$row['is_child_date_last'] = @$row['max_date_last']>@$row['date_last'];
if (isset($row['representative_picture_id'])
and is_numeric($row['representative_picture_id']))

View File

@@ -481,8 +481,7 @@ function get_html_menu_category($categories)
: $category['count_images']).']';
$menu.= '</span>';
}
$child_date_last = isset($category['date_last'])
and $category['max_date_last']>$category['date_last'] ;
$child_date_last = @$category['max_date_last']> @$category['date_last'];
$menu.= get_icon($category['max_date_last'], $child_date_last);
}
@@ -609,8 +608,7 @@ function access_denied()
}
else
{
header('HTTP/1.1 401 Authorization required');
header('Status: 401 Authorization required');
set_status_header(401);
redirect($login_url);
}
}
@@ -622,8 +620,7 @@ function access_denied()
*/
function page_not_found($msg, $alternate_url=null)
{
header('HTTP/1.1 404 Not found');
header('Status: 404 Not found');
set_status_header(404);
if ($alternate_url==null)
$alternate_url = make_index_url();
redirect( $alternate_url,
@@ -680,4 +677,27 @@ function get_tags_content_title()
}
return $title;
}
/**
Sets the http status header (200,401,...)
*/
function set_status_header($code, $text='')
{
if (empty($text))
{
switch ($code)
{
case 200: $text='OK';break;
case 301: $text='Moved permanently';break;
case 302: $text='Moved temporarily';break;
case 304: $text='Not modified';break;
case 400: $text='Bad request';break;
case 401: $text='Authorization required';break;
case 403: $text='Forbidden';break;
case 404: $text='Not found';break;
}
}
header("HTTP/1.1 $code $text");
header("Status: $code $text");
}
?>