function renderRackThumb($rack_id = 0) { // Don't call DB extra times, hence we are most probably not the // only script wishing to access the same data now. if (NULL !== ($thumbcache = loadThumbCache($rack_id))) { header("Content-type: image/png"); echo $thumbcache; return; } ob_start(); if (FALSE !== generateMiniRack($rack_id)) { $capture = ob_get_clean(); header("Content-type: image/png"); echo $capture; usePreparedExecuteBlade('REPLACE INTO RackThumbnail SET rack_id=?, thumb_data=?', array($rack_id, base64_encode($capture))); return; } // error text in the buffer ob_end_flush(); }
function dispatchMiniRackThumbRequest($rack_id) { if (NULL !== ($thumbcache = loadThumbCache($rack_id))) { header('Content-type: image/png'); echo $thumbcache; return; } ob_start(); printRackThumbImage($rack_id); $capture = ob_get_clean(); header('Content-type: image/png'); echo $capture; usePreparedExecuteBlade('REPLACE INTO RackThumbnail SET rack_id=?, thumb_data=?', array($rack_id, base64_encode($capture))); }