/** * โหลด GCMS เพื่อแสดงผลหน้าเว็บไซต์ */ public function run() { /** * inint session */ session_start(); if (!ob_get_status()) { if (extension_loaded('zlib') && !ini_get('zlib.output_compression')) { // เปิดใช้งานการบีบอัดหน้าเว็บไซต์ ob_start('ob_gzhandler'); } else { ob_start(); } } /** * โหลด GCMS */ $this->inint(); /** * save variable */ setCookie('gcms_language', LANGUAGE, time() + 3600 * 24 * 365); /** * create Router */ self::createClass('Core\\Router'); /** * return current instance */ return self::$instance; }
/** */ function wfStreamFile($fname) { $stat = @stat($fname); if (!$stat) { header('HTTP/1.0 404 Not Found'); $encFile = htmlspecialchars($fname); $encScript = htmlspecialchars($_SERVER['SCRIPT_NAME']); echo "<html><body>\n<h1>File not found</h1>\n<p>Although this PHP script ({$encScript}) exists, the file requested for output \n({$encFile}) does not.</p>\n</body></html>"; return; } header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT'); // Cancel output buffering and gzipping if set while ($status = ob_get_status()) { ob_end_clean(); if ($status['name'] == 'ob_gzhandler') { header('Content-Encoding:'); } } $type = wfGetType($fname); if ($type and $type != "unknown/unknown") { header("Content-type: {$type}"); } else { header('Content-type: application/x-wiki'); } if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $modsince = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); $sinceTime = strtotime($modsince); if ($stat['mtime'] <= $sinceTime) { header("HTTP/1.0 304 Not Modified"); return; } } header('Content-Length: ' . $stat['size']); readfile($fname); }
function getLatandLong($addr, $region) { $url = "http://maps.google.com/maps/api/geocode/json?address=" . $addr . "®ion=" . $region . "&sensor=false"; $response = file_get_contents($url); if ($response == false) { throw new Exception("Failure to obtain data"); } $places = json_decode($response); if (!$places) { throw new Exception("Invalid JSON response"); } if (is_array($places->results) && count($places->results)) { $result = $places->results[0]; $geometry = $result->{'geometry'}; $location = $geometry->{'location'}; $lat = $location->{'lat'}; $long = $location->{'lng'}; ob_start(); // ensures anything dumped out will be caught // do stuff here //header( "Location: $url" ); //return $lat.",".$long; // clear out the output buffer while (ob_get_status()) { ob_end_clean(); } } else { return "Unknown"; } }
public static function clean_buffers() { if ($status = ob_get_status()) { foreach (range(0, $status['level']) as $lvl) { ob_end_clean(); } } }
/** * @method flushHigherBuffers */ function flushHigherBuffers() { $status = ob_get_status(false); $level = $status['level']; // nesting level of current buffer for ($i = $level; $i > $this->level; --$i) { @ob_end_flush(); } }
public function displayError($message) { if (ob_get_status()["level"] > 0) { // Clear the buffer. ob_end_clean(); } // Terminate with an error message. exit("Error: {$message}."); }
/** * This function will need to run at the bottom of all pages if output * buffering is turned on. It also needs to be passed $mode from the * PMA_outBufferModeGet() function or it will be useless. * */ function PMA_outBufferPost() { if (ob_get_status() && PMA_outBufferModeGet()) { ob_flush(); } /** * previously we had here an "else flush()" but some PHP versions * (at least PHP 5.2.11) have a bug (49816) that produces garbled * data */ }
/** * Clear out all output that PHP buffered up to now. */ function phorum_api_buffer_clear() { // Clear out all output that PHP buffered up to now. for (;;) { $status = ob_get_status(); if (!$status || $status['name'] == 'ob_gzhandler' || !$status['del']) { break; } ob_end_clean(); } }
public function __construct($index = null) { if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); } # If we done have a configuration, then our IMGDIR and CSS are not defined if (!defined('IMGDIR')) { define('IMGDIR', 'images/default'); } if (!defined('CSSDIR')) { define('CSSDIR', 'css/default'); } $this->index = $index; # To be defined in a configuration file. $this->_app['title'] = app_name(); $this->_app['logo'] = IMGDIR . '/logo-small.png'; if (!is_null($index)) { $this->_app['urlcss'] = sprintf('%s/%s', CSSDIR, $_SESSION[APPCONFIG]->getValue('appearance', 'stylesheet')); } else { $this->_app['urlcss'] = sprintf('%s/%s', CSSDIR, 'style.css'); } # Default Values for configurable items. $this->_default['sysmsg']['error'] = IMGDIR . '/error-big.png'; $this->_default['sysmsg']['warn'] = IMGDIR . '/warn-big.png'; $this->_default['sysmsg']['info'] = IMGDIR . '/info-big.png'; # Capture any output so far (in case we send some headers below) - there shouldnt be any output anyway. $preOutput = ''; # Try and work around if php compression is on, or the user has set compression in the config. # type = 1 for user gzip, 0 for php.ini gzip. $obStatus = ob_get_status(); if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status']) { $preOutput = ob_get_contents(); ob_end_clean(); } header('Content-type: text/html; charset="UTF-8"'); if (isCompress()) { header('Content-Encoding: gzip'); if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) { debug_log('Sent COMPRESSED header to browser and discarded (%s)', 129, 0, __FILE__, __LINE__, __METHOD__, $preOutput); } } if (isset($_SESSION[APPCONFIG]) && $_SESSION[APPCONFIG]->getValue('appearance', 'compress') && ini_get('zlib.output_compression')) { $this->setsysmsg(array('title' => _('Warning'), 'body' => _('WARNING: You cannot have PHP compression and application compression enabled at the same time. Please unset zlib.output_compression or set $config->custom->appearance[\'compress\']=false'), 'type' => 'warn')); } # Turn back on output buffering. ob_start(); # Initial Values $this->_pageheader[] .= '<?xml version="1.0" encoding="utf-8"?>' . "\n"; $this->_pageheader[] .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"' . "\n"; $this->_pageheader[] .= '"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">' . "\n"; $this->_pageheader[] .= "\n"; $this->_pageheader[] .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="auto" lang="auto" dir="ltr">' . "\n"; $this->_pageheader[] .= "\n"; }
/** * Writes the message $msg to STDERR. * * @param string $msg The message to output * @param string $status Output status * * @return \Phrozn\Outputter */ public function stderr($msg, $status = self::STATUS_FAIL) { if (defined('STDERR')) { fwrite(STDERR, $msg); } else { echo $msg; if (count(\ob_get_status()) !== 0) { ob_flush(); } } return $this; }
function redirect($url) { ob_start(); // ensures anything dumped out will be caught // clear out the output buffer while (ob_get_status()) { ob_end_clean(); } // no redirect header("Location: {$url}"); exit; }
/** * Clean all existing user buffers */ static function cleanAllBuffers() { for ($i = 0; $i <= 30; $i++) { if (!ob_get_level()) { break; } $status = ob_get_status(); if ($status && strpos(strtolower($status["name"]), "zlib") === false) { ob_end_clean(); } } }
public static function closeOutputBuffers($targetLevel, $flush) { $status = ob_get_status(true); $level = count($status); $flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1; while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || $flags === ($s['flags'] & $flags) : $s['del'])) { if ($flush) { ob_end_flush(); } else { ob_end_clean(); } } }
public function procesar_facturas($valores_id, $archivo = FALSE) { if (!empty($valores_id)) { if (ob_get_status()) { ob_end_clean(); } $pdf_doc = new PDF_MC_Table('P', 'mm', 'letter'); $pdf_doc->SetTitle('Facturas de Venta'); $pdf_doc->SetSubject('Facturas de Venta para clientes'); $pdf_doc->SetAuthor($this->empresa->nombre); $pdf_doc->SetCreator('FacturaSctipts V_' . $this->version()); $this->archivo = $archivo; $contador = 0; $this->factura = FALSE; foreach ($valores_id as $id) { $factura = new factura_cliente(); $this->factura = $factura->get($id); if ($this->factura) { $ncf_datos = new ncf_ventas(); $valores = $ncf_datos->get_ncf($this->empresa->id, $this->factura->idfactura, $this->factura->codcliente, $this->factura->fecha); $ncf_tipo = new ncf_tipo(); $tipo_comprobante = $ncf_tipo->get($valores->tipo_comprobante); $this->factura->ncf = $valores->ncf; $this->factura->ncf_afecta = $valores->ncf_modifica; $this->factura->estado = $valores->estado; $this->factura->tipo_comprobante = $tipo_comprobante->descripcion; if ($this->distrib_transporte) { $transporte = $this->distrib_transporte->get($this->empresa->id, $this->factura->idfactura, $this->factura->codalmacen); $this->idtransporte = isset($transporte[0]->idtransporte) ? str_pad($transporte[0]->idtransporte, 10, "0", STR_PAD_LEFT) : false; } $cliente = new cliente(); $this->cliente = $cliente->get($this->factura->codcliente); $this->generar_pdf($pdf_doc); $contador++; } } // Damos salida al archivo PDF if ($this->archivo) { if (!file_exists('tmp/' . FS_TMP_NAME . 'enviar')) { mkdir('tmp/' . FS_TMP_NAME . 'enviar'); } $pdf_doc->Output('tmp/' . FS_TMP_NAME . 'enviar/' . $archivo, 'F'); } else { $pdf_doc->Output(); } if (!$this->factura) { $this->new_error_msg("¡Factura de cliente no encontrada!"); } } }
/** * Writes the message $msg to STDERR. * * @param string $msg The message to output * @param string $status Output status * * @return Outputter */ public function stderr($msg, $status = self::STATUS_FAIL) { $msg = "<strong>" . $msg . "</strong>"; $msg = $this->removeColors($msg); $msg = $this->replaceEOLs($msg); if (defined('STDERR')) { fwrite(STDERR, $msg); } else { echo $msg; if (count(\ob_get_status()) !== 0) { ob_flush(); } } return $this; }
function addEquToDB($equation) { #echo "<p>Adding equation \"$equation\" to database.</p>"; mysql_connect("localhost", DATABASE_USERNAME, DATABASE_PS) or die("<p>addEquToDB: Error connecting to database: " . mysql_error() . "</p>"); echo "Add"; mysql_select_db(DB_NAME) or die("<p>addEquToDB: Error selecting the database: " . mysql_error() . "</p>"); $result = mysql_query("INSERT INTO equations VALUES ( NULL, NULL, '" . $equation . "')") or die("<p>addEquToDB: Error inserting into the database: " . mysql_error() . "</p>"); //returns to main page after function is added; taken from: http://stackoverflow.com/questions/353803/redirect-to-specified-url-on-php-script-completion //did this so displayEQUInDB populates datalist ob_start(); $url = 'http://weblab.cs.uml.edu/~cburbine/A8_GraphCalc.php'; while (ob_get_status()) { ob_end_clean(); } header("Location: {$url}"); }
/** * Send response. */ public function send() { echo $this->content; if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } elseif ('cli' !== php_sapi_name()) { $level = ob_get_level(); if (0 < $level) { $status = ob_get_status(true); // PHP_OUTPUT_HANDLER_* are not defined on HHVM 3.3 $flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | PHP_OUTPUT_HANDLER_FLUSHABLE : -1; while ($level-- > 0 && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || $flags === ($s['flags'] & $flags) : $s['del'])) { ob_end_flush(); } } } }
function logout() { if (!isset($_SESSION)) { session_start(); } // ensures anything dumped out will be caught ob_start(); // destroy all session vars session_destroy(); // clear out the output buffer while (ob_get_status()) { ob_end_clean(); } // redirected to url header('Location: ' . ROOT_DIR); // end sripting die; }
public static function Refresh($url, $delay) { if (!isset($delay)) { $delay = 0; } if (isset($url)) { ob_start(); while (ob_get_status()) { ob_end_clean(); } header("Location: {$url}"); } else { ob_start(); while (ob_get_status()) { ob_end_clean(); } header("Location: /"); } }
/** * Clear out all output that PHP buffered up to now. */ function phorum_api_buffer_clear() { // Clear out all output that PHP buffered up to now. for (;;) { $status = ob_get_status(); if (empty($status) || $status === FALSE || $status['name'] == 'ob_gzhandler') { break; } if (version_compare(PHP_VERSION, '5.4.0', '>=')) { if (!($status['flags'] & PHP_OUTPUT_HANDLER_REMOVABLE)) { break; } } else { if (!$status['del']) { break; } } ob_end_clean(); } }
public function notify() { // Erase buffer $buffer = ob_get_status(); if (!empty($buffer)) { ob_end_clean(); } if ($this->_observers->count()) { foreach ($this->_observers as $observer) { $observer->update($this); } } // Clear error for avoid multiple call if ($this->_clearErrorAfterSending) { $this->_error = false; } // Show internal server error (500) if (!Application::getDebug()) { Router::getInstance()->show500(); } // Exit script exit; }
/** * Flushes output buffer * * @return void */ public function flush() { if (ob_get_status() && $this->_mode) { ob_flush(); } /** * previously we had here an "else flush()" but some PHP versions * (at least PHP 5.2.11) have a bug (49816) that produces garbled * data */ }
/** * ฟังก์ชั่นเริ่มต้นใช้งาน session */ public static function inintSession() { if (isset($_GET['sessid']) && preg_match('/[a-zA-Z0-9]{20,}/', $_GET['sessid'])) { session_id($_GET['sessid']); } session_start(); if (!ob_get_status()) { if (extension_loaded('zlib') && !ini_get('zlib.output_compression')) { // เปิดใช้งานการบีบอัดหน้าเว็บไซต์ ob_start('ob_gzhandler'); } else { ob_start(); } } return true; }
/** * Cleans or flushes output buffers up to target level. * * Resulting level can be greater than target level if a non-removable buffer has been encountered. * * @param int $targetLevel The target output buffering level * @param bool $flush Whether to flush or clean the buffers */ public static function closeOutputBuffers($targetLevel, $flush) { $status = ob_get_status(true); $level = count($status); while ($level-- > $targetLevel && (!empty($status[$level]['del']) || isset($status[$level]['flags']) && $status[$level]['flags'] & PHP_OUTPUT_HANDLER_REMOVABLE && $status[$level]['flags'] & ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE))) { if ($flush) { ob_end_flush(); } else { ob_end_clean(); } } }
/** * Processes a user password update * @param array $passedToView */ public static function updatePassword($passedToView = array()) { $post = Core\Input::post(); $passedToView["post"] = $post; $user = User::constructById($_SESSION["user"]); //check if password is set if (isset($post["password"])) { //check if password is valid if ($user->getPassword() === crypt($post["password"], $user->getPassword())) { //if new password matches if (isset($post["newPassword"]) && $post["newPassword"] === $post["confirmPassword"]) { $password = crypt($post["newPassword"]); $user->setPassword($password); Model\User::updateUser($user); } else { //new password does not match } } else { //password does not match } } ob_start(); $url = 'http://sfsuswe.com/~nthanlee/index.php/PetBasket/contactUpdate'; while (ob_get_status()) { ob_end_clean(); } header("Location: {$url}"); }
/** * Flush the output buffers * * @see Symfony\Component\HttpFoundation\Response */ public function flushAllData() { if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } elseif (PHP_SAPI !== 'cli') { $status = ob_get_status(true); $level = count($status); while ($level-- > 0 && (!empty($status[$level]['del']) || isset($status[$level]['flags']) && $status[$level]['flags'] & PHP_OUTPUT_HANDLER_REMOVABLE && $status[$level]['flags'] & PHP_OUTPUT_HANDLER_FLUSHABLE)) { ob_end_flush(); } flush(); } }
private static function cleanUpOutputBuffer() { while (count(ob_get_status(true)) > 1) { ob_end_clean(); } }
ob_start(); echo "test"; VS(ob_get_contents(), "test"); VS(ob_get_contents(), "test"); // verifying content stays ob_end_clean(); ob_start(); ob_start(); echo "test"; VS(ob_get_flush(), "test"); VS(ob_get_flush(), "test"); ob_end_clean(); VS(ob_get_flush(), false); ob_end_clean(); ob_start(); echo "test"; VS(ob_get_length(), 4); ob_end_clean(); VS(ob_get_level(), 0); ob_start(); VS(ob_get_level(), 1); ob_end_clean(); VS(ob_get_level(), 0); ob_get_status(); ob_start(); ob_start("mytolower"); $handlers = ob_list_handlers(); ob_end_clean(); ob_end_clean(); VS($handlers, array("default output handler", "mytolower")); echo "\nok\n";
/** * Commence page caching for any cacheable actions * * @return void */ public function preDispatch() { $controller = $this->getRequest()->getControllerName(); $action = $this->getRequest()->getActionName(); $stats = ob_get_status(true); foreach ($stats as $status) { if ($status['name'] == 'Zend_Cache_Frontend_Page::_flush' || $status['name'] == 'Zend_Cache_Frontend_Capture::_flush') { $obStarted = true; } } if (!isset($obStarted) && isset($this->_caching[$controller]) && in_array($action, $this->_caching[$controller])) { $reqUri = $this->getRequest()->getRequestUri(); $tags = array(); if (isset($this->_tags[$controller][$action]) && !empty($this->_tags[$controller][$action])) { $tags = array_unique($this->_tags[$controller][$action]); } $extension = null; if (isset($this->_extensions[$controller][$action])) { $extension = $this->_extensions[$controller][$action]; } $this->getCache(\Zend\Cache\Manager::PAGECACHE)->start($this->_encodeCacheId($reqUri), $tags, $extension); } }
/** * エラー画面を表示する * * @param string|null $errstr エラーメッセージ * @return void */ public static function displaySystemError($errstr = null) { SC_Helper_HandleError_Ex::$under_error_handling = true; ob_clean(); // 絵文字変換・除去フィルターが有効か評価する。 $loaded_ob_emoji = false; $arrObs = ob_get_status(true); foreach ($arrObs as $arrOb) { if ($arrOb['name'] === 'SC_MobileEmoji::handler') { $loaded_ob_emoji = true; break; } } // 絵文字変換・除去フィルターが無効で、利用できる場合、有効にする。 if (!$loaded_ob_emoji && class_exists('SC_MobileEmoji')) { ob_start(array('SC_MobileEmoji', 'handler')); } require_once CLASS_EX_REALDIR . 'page_extends/error/LC_Page_Error_SystemError_Ex.php'; $objPage = new LC_Page_Error_SystemError_Ex(); $objPage->init(); if (isset($errstr)) { $objPage->addDebugMsg($errstr); } $objPage->process(); }