Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
322011e9
Commit
322011e9
authored
Oct 29, 2015
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding style (qa-blobs.php)
parent
deffa191
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
50 deletions
+47
-50
qa-blob.php
qa-include/qa-blob.php
+47
-50
No files found.
qa-include/qa-blob.php
View file @
322011e9
...
...
@@ -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
'sw
f'
:
header
(
'Content-Type: application/x-shockwave-flash
'
);
break
;
case
'gi
f'
:
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
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment