/** * send response (file) * @access public * */ function sendResponse() { if (!function_exists('ob_list_handlers') || !ob_list_handlers()) { @ob_end_clean(); } header("Content-Encoding: none"); $this->checkConnector(); $this->checkRequest(); if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); } $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["FileName"]); $_resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName)) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); } if (!$_resourceTypeInfo->checkExtension($fileName, false)) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); } $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName); if ($_resourceTypeInfo->checkIsHiddenFile($fileName) || !file_exists($filePath) || !is_file($filePath)) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); } $fileName = CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName); header("Cache-Control: cache, must-revalidate"); header("Pragma: public"); header("Expires: 0"); header("Content-type: application/octet-stream; name=\"" . $fileName . "\""); header("Content-Disposition: attachment; filename=\"" . str_replace("\"", "\\\"", $fileName) . "\""); header("Content-Length: " . filesize($filePath)); CKFinder_Connector_Utils_FileSystem::readfileChunked($filePath); exit; }
/** * Prints any header information for this output module * * @access public * @return null Prints header() information */ public function printHeader() { //----------------------------------------- // Start GZIP compression //----------------------------------------- if ($this->settings['disable_gzip'] != 1) { $buffer = ""; if (count(ob_list_handlers())) { $buffer = ob_get_contents(); ob_end_clean(); } @ob_start('ob_gzhandler'); print $buffer; } if (isset($_SERVER['SERVER_PROTOCOL']) and strstr($_SERVER['SERVER_PROTOCOL'], '/1.0')) { header("HTTP/1.0 200 OK"); } else { header("HTTP/1.1 200 OK"); } /* This now forces UTF-8 */ header("Content-type: text/xml;charset=UTF-8"); if ($this->settings['nocache']) { header("Cache-Control: no-cache, must-revalidate, max-age=0"); header("Expires: 0"); header("Pragma: no-cache"); } }
function log($text, $data = '') { if (empty($this->isActive) || empty($text)) { return; } // sometimes some system plugins can use the router. If we use // print_r in this situatation, this generates an error // Cannot use output buffering in output buffering display handlers // so we must check first that no handler is being used $logData = ''; if (!empty($data)) { $handlers = ob_list_handlers(); if (empty($handlers)) { $logData = ":\t" . print_r($data, true); } else { // we can't use print_r if (is_object($data)) { $logData .= $this->logObject($data); } else { if (is_array($data)) { $logData .= ":\n"; $logData .= $this->logArray($data); } else { $logData .= ":\t" . $data; } } } } fWrite($this->logFile, $this->logTime() . "\t" . $text . $logData . "\n"); }
public function show() { if (count(ob_list_handlers()) > 0) { ob_clean(); } header('Content-Type: image/png'); $this->generate(); $red = rand(200, 255); $green = rand(200, 250); $blue = rand(200, 200); $image = imagecreate(90, 30); $background_color = imagecolorallocate($image, 0, 0, 0); $textcolor = imagecolorallocate($image, $red, $green, $blue); imagestring($image, 5, 18, 8, $_SESSION['captcha'], $textcolor); for ($i = 0; $i < 20; ++$i) { $x1 = rand(1, 80); $y1 = rand(1, 25); $x2 = $x1 + 4; $y2 = $y1 + 4; $color = imagecolorallocate($image, ~$green, ~$blue, ~$red); imageline($image, $x1, $y1, $x2, $y2, $color); } imagepng($image); imagedestroy($image); }
/** * class constructor will include the external console class, initialize it and store * its instance as $console property. the class can not be instantiated other * then using singleton method create. the loaded console class will be init and map * with its log types to this classed log types. * * @error 10901 * @param string $driver expects the driver string to load * @param array $options expects an driver dependent option array * @throws Xapp_Error */ protected function __construct($driver, array $options = array()) { $this->_driver = strtolower(trim($driver)); switch ($this->_driver) { case 'firephp': xapp_import('firephp.firephp-core.*'); if (sizeof(ob_list_handlers()) === 0) { ob_start(); } $this->console = FirePHP::init(); $this->console->setOptions($options); self::$_typeMap = array_merge(self::$_typeMap, array('log' => FirePHP::LOG, 'warn' => FirePHP::WARN, 'info' => FirePHP::INFO, 'error' => FirePHP::ERROR, 'dump' => FirePHP::DUMP, 'trace' => FirePHP::TRACE, 'group' => FirePHP::GROUP_START, 'ungroup' => FirePHP::GROUP_END)); break; case 'chromephp': xapp_import('xapp.Ext.ChromePhp'); $this->console = ChromePhp::getInstance(); if (!isset($options[ChromePhp::BACKTRACE_LEVEL])) { $options[ChromePhp::BACKTRACE_LEVEL] = 2; } $this->console->addSettings($options); self::$_typeMap = array_merge(self::$_typeMap, array('log' => ChromePhp::LOG, 'warn' => ChromePhp::WARN, 'info' => ChromePhp::INFO, 'error' => ChromePhp::ERROR, 'dump' => ChromePhp::INFO, 'trace' => ChromePhp::INFO, 'group' => ChromePhp::GROUP, 'ungroup' => ChromePhp::GROUP_END)); break; default: throw new Xapp_Error(xapp_sprintf(_("xapp console driver: %s not supported"), $driver), 1090101); } }
function checkAndClean() { print_r(ob_list_handlers()); while (ob_get_level() > 0) { ob_end_flush(); } }
/** * */ public function renderErrorGui(\fbenard\Zero\Classes\Error $error) { // Clean the buffer $handlers = ob_list_handlers(); while (empty($handlers) === false) { ob_end_clean(); $handlers = ob_list_handlers(); } // Get HTTP request headers $requestHeaders = apache_request_headers(); $requestHeaders = array_change_key_case($requestHeaders, CASE_LOWER); // Build HTTP response headers $responseHeaders = ['cache-control' => 'private, no-cache, no-store, must-revalidate', 'content-type' => 'text/html; charset=UTF-8']; // Build the result $result = []; if (array_key_exists('accept-content', $requestHeaders) === true && $requestHeaders['accept-content'] === 'application/json') { // Content-Type is application/json $responseHeaders['content-type'] = 'application/json; charset=UTF-8'; // Render the error $result = $this->renderErrorJson($error); } else { $result = $this->renderErrorHtml($error); } // Send HTTP response headers if (headers_sent() === false) { foreach ($responseHeaders as $headerCode => $headerValue) { header($headerCode . ': ' . $headerValue); } } return $result; }
/** * Starts the GZIP output buffer. * * @return bool **/ function headway_gzip() { //If zlib is not loaded, we can't gzip. if (!extension_loaded('zlib')) { return false; } //If zlib.output_compression is on, do not gzip if (ini_get('zlib.output_compression') == 1) { return false; } //If a cache system is active then do not gzip if (defined('WP_CACHE') && WP_CACHE) { return false; } //Allow headway_gzip filter to cancel gzip compression. if (!($gzip = apply_filters('headway_gzip', HeadwayOption::get('enable-gzip', false, true)))) { return false; } //If gzip has already happened, then just return. if (in_array('ob_gzhandler', ob_list_handlers())) { return; } ob_start('ob_gzhandler'); return true; }
function wrap_layout($template) { if ($template) { $template = realpath($template); if (!file_exists($template)) { trigger_error('Could not locate layout: (' . $template . ')', E_USER_ERROR); return false; } view_set('layout', $template); if (!in_array('layout_capture_content', ob_list_handlers())) { ob_start('layout_capture_content'); register_shutdown_function('render_layout'); } } else { // clear all pre-existing layout handling while (ob_list_handlers()) { @ob_get_clean(); } view_set('layout', $template); view_set('content', ''); ob_start(); //echo "hi patrick [$template]"; global $mf_view; print_r($mf_view); } return true; }
/** * clear ob filters. */ protected static function _clearObFilters() { $handlers = ob_list_handlers(); while (!empty($handlers)) { ob_end_clean(); $handlers = ob_list_handlers(); } }
/** * Move output buffer after Above The Fold optimization output buffer */ public function move_output_buffer() { // get callbacks $ob_callbacks = ob_list_handlers(); if (!empty($ob_callbacks) && in_array('WebSharks\\CometCache\\Classes\\AdvancedCache::outputBufferCallbackHandler', $ob_callbacks)) { // move $this->CTRL->optimization->move_ob_to_front(); } }
/** * Move output buffer after Above The Fold optimization output buffer */ public function move_output_buffer() { // get callbacks $ob_callbacks = ob_list_handlers(); if (!empty($ob_callbacks) && in_array('wpsmy_minify_html', $ob_callbacks)) { // move $this->CTRL->optimization->move_ob_to_front(); } }
public static function redirect_abs301($url) { $handlers = ob_list_handlers(); for ($cnt = 0; $cnt < sizeof($handlers); $cnt++) { ob_end_clean(); } header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $url); }
private static function fix_output_buffer() { $ob_list_handlers = ob_list_handlers(); $ob_list_handlers_count = count($ob_list_handlers); $exclude = array('ob_gzhandler', 'zlib output compression'); if ($ob_list_handlers_count && !in_array($ob_list_handlers[$ob_list_handlers_count - 1], $exclude)) { ob_clean(); } }
function error_handler($errNo, $errStr, $errFile, $errLine) { $handlers = ob_list_handlers(); while (!empty($handlers)) { ob_end_clean(); $handlers = ob_list_handlers(); } $error_message = 'ERRNO: ' . $errNo . '<br>' . 'TEXT: ' . $errStr . '<br>' . 'LOCATION: ' . $errFile . ', line ' . $errLine; send_error('<span style="color:red;font-weight:400;font-size:12pt">' . $error_message . '</span><br><br><br><pre>' . print_r(debug_backtrace(), true) . '</pre>', 'Ошибка: ' . $errNo . ' - ' . $errFile . ', ' . $errLine . ''); }
/** * Stops buffering the output - the title should now be in the buffer. */ function wds_stop_title_buffer() { if (function_exists('ob_list_handlers')) { $active_handlers = ob_list_handlers(); } else { $active_handlers = array(); } if (count($active_handlers) > 0 && preg_match('/::wds_process_title_buffer$/', trim($active_handlers[count($active_handlers) - 1]))) { ob_end_flush(); } }
/** * Check if client accepts gzip and we should compress content * * Plugin settings, client preferences and server capabilities are * checked to make sure we should use gzip for output compression. * * @uses Ai1ec_Settings::get_instance To early instantiate object * * @return bool True when gzip should be used */ public static function client_use_gzip() { if (Ai1ec_Settings::get_instance()->disable_gzip_compression || isset($_SERVER['HTTP_ACCEPT_ENCODING']) && 'identity' === $_SERVER['HTTP_ACCEPT_ENCODING'] || !extension_loaded('zlib')) { return false; } $zlib_output_handler = ini_get('zlib.output_handler'); if (in_array('ob_gzhandler', ob_list_handlers()) || in_array(strtolower(ini_get('zlib.output_compression')), array('1', 'on')) || !empty($zlib_output_handler)) { return false; } return true; }
/** * */ public function clearBuffer() { // Get buffers handlers $handlers = ob_list_handlers(); // Parse each handler while (empty($handlers) === false) { // Clean the handler ob_end_clean(); // Get the next handler $handlers = ob_list_handlers(); } }
public function execute() { $text = serialize($this->getResultData()); // Bug 66776: wfMangleFlashPolicy() is needed to avoid a nasty bug in // Flash, but what it does isn't friendly for the API. There's nothing // we can do here that isn't actively broken in some manner, so let's // just be broken in a useful manner. if ($this->getConfig()->get('MangleFlashPolicy') && in_array('wfOutputHandler', ob_list_handlers(), true) && preg_match('/\\<\\s*cross-domain-policy(?=\\s|\\>)/i', $text)) { $this->dieUsage('This response cannot be represented using format=php. See https://bugzilla.wikimedia.org/show_bug.cgi?id=66776', 'internalerror'); } $this->printText($text); }
/** * Check if client accepts gzip and we should compress content * * Plugin settings, client preferences and server capabilities are * checked to make sure we should use gzip for output compression. * * @return bool True when gzip should be used */ public function client_use_gzip() { $settings = $this->_registry->get('model.settings'); if ($settings->get('disable_gzip_compression') || (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && 'identity' === $_SERVER['HTTP_ACCEPT_ENCODING'] || !extension_loaded('zlib'))) { return false; } $zlib_output_handler = ini_get('zlib.output_handler'); if (in_array('ob_gzhandler', ob_list_handlers()) || in_array(strtolower(ini_get('zlib.output_compression')), array('1', 'on')) || !empty($zlib_output_handler)) { return false; } return true; }
function redirect($target) { $target = make_absolute($target); if (session_id()) { session_write_close(); } do_commits(); if (ob_list_handlers()) { ob_clean(); } header("Location: {$target}"); exit; }
function ob_start_first($handler) { $handlers = ob_list_handlers(); $contents = array(); foreach ($handlers as $k => $h) { $contents[$k] = ob_get_contents(); ob_end_clean(); } ob_start($handler); foreach ($handlers as $k => $h) { ob_start($h); print $contents[$k]; } }
function getFrontpageXMLData() { $model = $this->getModel('modfrontpage'); $xml = $model->getXml(); if (!count(array_diff(ob_list_handlers(), array('default output handler'))) || ob_get_length()) { @ob_clean(); } if (!headers_sent()) { $document = JFactory::getDocument(); header('Content-Type: \'text/xml\'; charset=' . $document->_charset); } echo $xml; JFactory::getApplication()->close(); }
function __error($str) { while (count(ob_list_handlers()) > 0) { $ret = @ob_end_clean(); if ($ret == false) break; } ?> <h1>Error</h1> <?php echo $str; ?> <? die(); }
/** * @param \Exception $exception */ public function handleException($exception) { $message = ''; $e = $exception; do { $message .= sprintf("%s:%d: [%s] (%d) %s\n", $e->getFile(), $e->getLine(), get_class($e), $e->getCode(), $e->getMessage()); $e = $e->getPrevious(); } while ($e); $this->logger->error(rtrim($message)); while (count(ob_list_handlers())) { ob_end_clean(); } header("HTTP/1.1 500 Internal Server Error"); echo '500 Internal Server Error'; exit(1); }
public function render($template = null, $data = false, $merge = false) { $file = $this->getPathTemplate($template); if (!file_exists($file)) { throw new Exception\Template("No existe el archivo: " . $file, 2); } if (!in_array("ob_gzhandler", ob_list_handlers())) { ob_start("ob_gzhandler"); } else { ob_start(); } $extract = !$data ? $this->_store->getStore() : ($merge == false ? $data : array_merge($this->_store->getStore(), $data)); $extract['__data__'] = $extract; extract($extract); include $file; return ob_get_clean(); }
/** * @return void */ public function send() { $this->sendHeaders(); // Some plugins leave open buffers and when it happens the returned output is blank $bufferCount = count(ob_list_handlers()); while ($bufferCount) { ob_end_clean(); --$bufferCount; } if ($this instanceof MWP_Http_StreamingResponseInterface) { $stream = $this->createResponseStream(); while (!$stream->eof()) { print $stream->read(1048576); } } else { print $this->getContentAsString(); } }
function ghpseo_obnoxious_mode_finish() { // flush the output buffer, and flag if there's a potential conflict with any other rude apps $handlers = ob_list_handlers(); $handlecount = count($handlers); if ($handlecount > 0) { $ok = str_replace('ghpseo', '', $handlers[$handlecount - 1]) != $handlers[$handlecount - 1] ? true : false; } if ($ok) { // if where expected in the ob handler array, all is well ob_end_flush(); } else { // otherwise, something else may be interfering, so flag it in the source code for debugging echo '<!-- mismatched object handlers detected:' . $handlers[$handlecount - 1] . ' -->'; // let's not flush at this point and just rely on eventual flush upon page delivery -- while this may clobber our head modifications badly, it's better than risking really fouling up some other plugin and potentially the whole page // @ob_end_flush(); // flush anyway, with errors suppressed } return; }
/** * Prints any header information for this output module * * @access public * @return @e void Prints header() information */ public function printHeader() { //----------------------------------------- // Start GZIP compression //----------------------------------------- if ($this->settings['disable_gzip'] != 1) { $buffer = ""; if (count(ob_list_handlers())) { $buffer = ob_get_contents(); ob_end_clean(); } if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) and strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { @ob_start('ob_gzhandler'); } else { @ob_start(); } print $buffer; } if (isset($_SERVER['SERVER_PROTOCOL']) and strstr($_SERVER['SERVER_PROTOCOL'], '/1.0')) { header("HTTP/1.0 " . $this->_headerCode . ' ' . $this->_headerStatus); } else { header("HTTP/1.1 " . $this->_headerCode . ' ' . $this->_headerStatus); } if ($this->settings['print_headers']) { /* Forcing a download? */ if ($this->_forceDownload) { header("Content-type: unknown/unknown"); header("Content-Disposition: attachment; filename=\"" . IPSText::alphanumericalClean(IPSText::transliterate(mb_strtolower($this->registry->output->getTitle()))) . ".html\""); } else { header("Content-type: text/html;charset=" . IPS_DOC_CHAR_SET); } if ($this->settings['nocache']) { $expires = $this->_headerExpire ? gmdate("D, d M Y H:i:s", time() + $this->_headerExpire) . " GMT" : gmdate("D, d M Y H:i:s", time() - 86400) . " GMT"; $maxAge = $this->_headerExpire; $nocache = !$this->_headerExpire ? 'no-cache, ' : ''; header("Cache-Control: " . $nocache . "must-revalidate, max-age=" . $maxAge); header("Expires: " . $expires); if (!$this->_headerExpire) { header("Pragma: no-cache"); } } } }
/** * send response (file) * @access public * */ public function sendResponse() { if (!function_exists('ob_list_handlers') || ob_list_handlers()) { @ob_end_clean(); } header("Content-Encoding: none"); $this->checkConnector(); $this->checkRequest(); if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); } $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["FileName"]); $_resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName)) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); } if (!$_resourceTypeInfo->checkExtension($fileName, false)) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST); } $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName); if ($_resourceTypeInfo->checkIsHiddenFile($fileName) || !file_exists($filePath) || !is_file($filePath)) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND); } $fileName = CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName); header("Cache-Control: cache, must-revalidate"); header("Pragma: public"); header("Expires: 0"); if (!empty($_GET['format']) && $_GET['format'] == 'text') { header("Content-Type: text/plain; charset=utf-8"); } else { $user_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; $encodedName = str_replace("\"", "\\\"", $fileName); if (strpos($user_agent, "MSIE") !== false) { $encodedName = str_replace(array("+", "%2E"), array(" ", "."), urlencode($encodedName)); } header("Content-type: application/octet-stream; name=\"" . $fileName . "\""); header("Content-Disposition: attachment; filename=\"" . $encodedName . "\""); } header("Content-Length: " . filesize($filePath)); CKFinder_Connector_Utils_FileSystem::readfileChunked($filePath); exit; }