function cs_get_site_cache() { global $cache; $cache = json_decode(qa_db_cache_get('cs_cache', 0), true); }
@ini_set('display_errors', 0); 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 require 'qa-base.php'; qa_report_process_stage('init_image'); // Retrieve the scaled image from the cache if available require_once QA_INCLUDE_DIR . 'qa-db-cache.php'; qa_db_connect('qa_image_db_fail_handler'); $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 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; } else { require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-app-blobs.php'; require_once QA_INCLUDE_DIR . 'qa-util-image.php'; // Otherwise retrieve the raw image and scale as appropriate $blob = qa_read_blob($blobid); if (isset($blob)) { if ($size > 0) { $content = qa_image_constrain_data($blob['content'], $width, $height, $size);