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
b507ca2f
Commit
b507ca2f
authored
Jan 12, 2017
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding style (misc. handlers)
parent
58fb33a4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
83 deletions
+65
-83
qa-blob.php
qa-include/qa-blob.php
+2
-2
qa-image.php
qa-include/qa-image.php
+42
-48
qa-page-not-found.php
qa-include/qa-page-not-found.php
+11
-17
qa-url-test.php
qa-include/qa-url-test.php
+10
-16
No files found.
qa-include/qa-blob.php
View file @
b507ca2f
...
...
@@ -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'
];
...
...
qa-include/qa-image.php
View file @
b507ca2f
...
...
@@ -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
();
qa-include/qa-page-not-found.php
View file @
b507ca2f
...
...
@@ -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
;
qa-include/qa-url-test.php
View file @
b507ca2f
...
...
@@ -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>'
;
}
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