Commit 322011e9 by Scott

Coding style (qa-blobs.php)

parent deffa191
......@@ -21,74 +21,72 @@
*/
// Ensure no PHP errors are shown in the blob response
// Ensure no PHP errors are shown in the blob response
@ini_set('display_errors', 0);
@ini_set('display_errors', 0);
function qa_blob_db_fail_handler()
{
header('HTTP/1.1 500 Internal Server Error');
qa_exit('error');
}
// Load the Q2A base file which sets up a bunch of crucial stuff
function qa_blob_db_fail_handler()
{
header('HTTP/1.1 500 Internal Server Error');
qa_exit('error');
}
require 'qa-base.php';
qa_report_process_stage('init_blob');
// Load the Q2A base file which sets up a bunch of crucial stuff
require 'qa-base.php';
// Output the blob in question
qa_report_process_stage('init_blob');
require_once QA_INCLUDE_DIR.'app/blobs.php';
qa_db_connect('qa_blob_db_fail_handler');
// Output the blob in question
$blob=qa_read_blob(qa_get('qa_blobid'));
require_once QA_INCLUDE_DIR.'app/blobs.php';
if (isset($blob)) {
$filename=preg_replace('/[^A-Za-z0-9 \\._-]/', '-', $blob['filename']); // for compatibility with HTTP headers and all browsers
header('Cache-Control: max-age=2592000, public'); // allows browsers and proxies to cache the blob
qa_db_connect('qa_blob_db_fail_handler');
switch ($blob['format']) {
case 'jpeg':
case 'jpg':
header('Content-Type: image/jpeg');
break;
$blob = qa_read_blob(qa_get('qa_blobid'));
case 'gif':
header('Content-Type: image/gif');
break;
if (isset($blob)) {
// allows browsers and proxies to cache the blob (30 days)
header('Cache-Control: max-age=2592000, public');
case 'png':
header('Content-Type: image/png');
break;
// for compatibility with HTTP headers and all browsers
$filename = preg_replace('/[^A-Za-z0-9 \\._-]/', '-', $blob['filename']);
case 'pdf':
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="'.$filename.'"');
break;
switch ($blob['format']) {
case 'jpeg':
case 'jpg':
header('Content-Type: image/jpeg');
break;
case 'swf':
header('Content-Type: application/x-shockwave-flash');
break;
case 'gif':
header('Content-Type: image/gif');
break;
default:
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$filename.'"');
break;
}
case 'png':
header('Content-Type: image/png');
break;
echo $blob['content'];
case 'pdf':
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="'.$filename.'"');
break;
} else
header('HTTP/1.0 404 Not Found');
case 'swf':
header('Content-Type: application/x-shockwave-flash');
break;
default:
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$filename.'"');
break;
}
qa_db_disconnect();
echo $blob['content'];
} else {
header('HTTP/1.0 404 Not Found');
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa_db_disconnect();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment