Es funktioniert soweit auch alles. Das Bild wird eigentlich immer erfolgreich dargestellt.
Aber bei ca. jedem 10. Mal bekomme ich eine Blank Seite.
Auch wenn ich error reporting aktiviere kommt keine Fehlermeldung. Ich kann auch keinen Fehler mehr finden. Laut php Manual kann ich auch keinen Fehler finden.
Code: Alles auswählen
<?php
//
// Get general information
//
include('config.php');
// ------------------------------------
// Check the request
// ------------------------------------
if( isset($HTTP_GET_VARS['id']) )
{
$id = intval($HTTP_GET_VARS['id']);
}
else if( isset($HTTP_POST_VARS['id']) )
{
$id = intval($HTTP_POST_VARS['id']);
}
else
{
die('No pic specified');
}
// ------------------------------------
// Get this pic info
// ------------------------------------
$sql = "SELECT * FROM ". PIC_TABLE ." WHERE id = $id";
$query = mysql_query($sql);
$ds = mysql_fetch_object($query);
$id = $ds->id;
$pic_extension = htmlentities($ds->extension);
$pic_filename = htmlentities($ds->filename);
$pic_upname = htmlentities($ds->upname);
// ------------------------------------
// Increase view counter and viewtime
// ------------------------------------
$viewtime = date('YmdHis');
$sql = "UPDATE ". PIC_TABLE ." SET views = views + 1, uptime = uptime, viewtime = NOW() WHERE id = $id";
$query = mysql_query($sql);
if ( empty($query) )
{
die("Error" . "Message: Could not get database results <br> at File: " . __FILE__ . " on line: " . __LINE__);
}
// ------------------------------------
// Okay, now we can send image to the browser
// ------------------------------------
// Send out the Headers
header('Pragma: public');
switch( $pic_extension )
{
case '.png':
header('Content-type: image/png name="' . $pic_upname . '"');
break;
case '.gif':
header('Content-type: image/gif name="' . $pic_upname . '"');
break;
case '.jpg':
header('Content-type: image/jpeg name="' . $pic_upname . '"');
break;
default:
die('The filename data in the DB was corrupted');
}
header('Content-Disposition: inline; filename="' . $pic_upname . '"');
$read_filename = $path . $pic_filename;
$pic_filesize = @filesize($read_filename);
if ($pic_filesize)
{
header("Content-length: $pic_filesize");
}
readfile($path . $pic_filename);
?>