Commit b507ca2f by Scott

Coding style (misc. handlers)

parent 58fb33a4
......@@ -41,7 +41,7 @@ qa_report_process_stage('init_blob');
// Output the blob in question
require_once QA_INCLUDE_DIR.'app/blobs.php';
require_once QA_INCLUDE_DIR . 'app/blobs.php';
qa_db_connect('qa_blob_db_fail_handler');
......@@ -83,7 +83,7 @@ if (isset($blob) && isset($blob['content'])) {
// for compatibility with HTTP headers and all browsers
$filename = preg_replace('/[^A-Za-z0-9 \\._-]+/', '', $blob['filename']);
header('Content-Disposition: '.$disposition.'; filename="'.$filename.'"');
header('Content-Disposition: ' . $disposition . '; filename="' . $filename . '"');
echo $blob['content'];
......
......@@ -21,76 +21,71 @@
*/
// Ensure no PHP errors are shown in the image data
// Ensure no PHP errors are shown in the image data
@ini_set('display_errors', 0);
@ini_set('display_errors', 0);
function qa_image_db_fail_handler()
{
header('HTTP/1.1 500 Internal Server Error');
qa_exit('error');
}
function qa_image_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
// Load the Q2A base file which sets up a bunch of crucial stuff
require 'qa-base.php';
require 'qa-base.php';
qa_report_process_stage('init_image');
qa_report_process_stage('init_image');
// Retrieve the scaled image from the cache if available
// Retrieve the scaled image from the cache if available
require_once QA_INCLUDE_DIR.'db/cache.php';
require_once QA_INCLUDE_DIR . 'db/cache.php';
qa_db_connect('qa_image_db_fail_handler');
qa_db_connect('qa_image_db_fail_handler');
$blobid=qa_get('qa_blobid');
$size=(int)qa_get('qa_size');
$cachetype='i_'.$size;
$blobid = qa_get('qa_blobid');
$size = (int)qa_get('qa_size');
$cachetype = 'i_' . $size;
$content=qa_db_cache_get($cachetype, $blobid); // see if we've cached the scaled down version
$content = qa_db_cache_get($cachetype, $blobid); // see if we've cached the scaled down version
header('Cache-Control: max-age=2592000, public'); // allows browsers and proxies to cache images too
header('Cache-Control: max-age=2592000, public'); // allows browsers and proxies to cache images too
if (isset($content)) {
header('Content-Type: image/jpeg');
echo $content;
if (isset($content)) {
header('Content-Type: image/jpeg');
echo $content;
} else {
require_once QA_INCLUDE_DIR.'app/options.php';
require_once QA_INCLUDE_DIR.'app/blobs.php';
require_once QA_INCLUDE_DIR.'util/image.php';
} else {
require_once QA_INCLUDE_DIR . 'app/options.php';
require_once QA_INCLUDE_DIR . 'app/blobs.php';
require_once QA_INCLUDE_DIR . 'util/image.php';
// Otherwise retrieve the raw image and scale as appropriate
// Otherwise retrieve the raw image and scale as appropriate
$blob=qa_read_blob($blobid);
$blob = qa_read_blob($blobid);
if (isset($blob)) {
if ($size>0)
$content=qa_image_constrain_data($blob['content'], $width, $height, $size);
else
$content=$blob['content'];
if (isset($blob)) {
if ($size > 0)
$content = qa_image_constrain_data($blob['content'], $width, $height, $size);
else
$content = $blob['content'];
if (isset($content)) {
header('Content-Type: image/jpeg');
echo $content;
if (isset($content)) {
header('Content-Type: image/jpeg');
echo $content;
if (strlen($content) && ($size>0)) {
$cachesizes=qa_get_options(array('avatar_profile_size', 'avatar_users_size', 'avatar_q_page_q_size', 'avatar_q_page_a_size', 'avatar_q_page_c_size', 'avatar_q_list_size'));
// to prevent cache being filled with inappropriate sizes
if (strlen($content) && ($size > 0)) {
// to prevent cache being filled with inappropriate sizes
$cachesizes = qa_get_options(array('avatar_profile_size', 'avatar_users_size', 'avatar_q_page_q_size', 'avatar_q_page_a_size', 'avatar_q_page_c_size', 'avatar_q_list_size'));
if (array_search($size, $cachesizes))
qa_db_cache_set($cachetype, $blobid, $content);
}
if (array_search($size, $cachesizes))
qa_db_cache_set($cachetype, $blobid, $content);
}
}
}
}
qa_db_disconnect();
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
qa_db_disconnect();
......@@ -20,26 +20,21 @@
More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
header('HTTP/1.0 404 Not Found');
header('HTTP/1.0 404 Not Found');
qa_set_template('not-found');
qa_set_template('not-found');
$qa_content=qa_content_prepare();
$qa_content['error']=qa_lang_html('main/page_not_found');
$qa_content['suggest_next']=qa_html_suggest_qs_tags(qa_using_tags());
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('main/page_not_found');
$qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags());
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
......@@ -20,18 +20,13 @@
More about this license: http://www.question2answer.org/license.php
*/
if (qa_gpc_to_string(@$_GET['param'])==QA_URL_TEST_STRING) {
require_once QA_INCLUDE_DIR.'app/admin.php';
echo '<html><body style="margin:0; padding:0;">';
echo '<table width="100%" height="100%" cellspacing="0" cellpadding="0">';
echo '<tr valign="middle"><td align="center" style="border-style:solid; border-width:1px; background-color:#fff; ';
echo qa_admin_url_test_html();
echo '/td></tr></table>';
echo '</body></html>';
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
if (qa_gpc_to_string(@$_GET['param']) == QA_URL_TEST_STRING) {
require_once QA_INCLUDE_DIR . 'app/admin.php';
echo '<html><body style="margin:0; padding:0;">';
echo '<table width="100%" height="100%" cellspacing="0" cellpadding="0">';
echo '<tr valign="middle"><td align="center" style="border-style:solid; border-width:1px; background-color:#fff; ';
echo qa_admin_url_test_html();
echo '/td></tr></table>';
echo '</body></html>';
}
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