Ejemplo n.º 1
0
Archivo: App.php Proyecto: zweifisch/zf
 function __construct($mode = null)
 {
     ob_start();
     ob_implicit_flush(false);
     parent::__construct();
     $this->isCli = 'cli' == ($mode ? $mode : PHP_SAPI);
     $basedir = $this->isCli ? dirname(realpath($_SERVER['argv'][0])) : $_SERVER['DOCUMENT_ROOT'];
     set_include_path($basedir . PATH_SEPARATOR . get_include_path());
     $this->config = new Config($this);
     $this->config->load(__DIR__ . DIRECTORY_SEPARATOR . 'defaults.php');
     if ($configFile = getenv('CONFIG_FILE')) {
         $this->config->load($configFile, false);
     } else {
         $this->config->load('configs.php', true);
     }
     $this->config->basedir = $basedir;
     $on_exception = function ($exception) {
         if (!$this->emit('exception', $exception)) {
             throw $exception;
         }
     };
     set_exception_handler($on_exception->bindTo($this));
     $on_shutdown = function () {
         $this->emit('shutdown');
     };
     register_shutdown_function($on_shutdown->bindTo($this));
     $on_error = function (...$args) {
         return $this->emit('error', (object) array_combine(['no', 'str', 'file', 'line', 'context'], $args));
     };
     set_error_handler($on_error->bindTo($this));
     $this->useMiddleware($this->config->use);
 }
Ejemplo n.º 2
0
 public function run()
 {
     /*
      * Instead of manually rendering scripts after this function returns we
      * use the callback. This ensures that scripts are always rendered, even
      * if we call exit at some point in the code. (Which we shouldn't, but
      * it happens.)
      */
     // Ensure to set some var, but script are replaced in SurveyRuntimeHelper
     $aLSJavascriptVar = array();
     $aLSJavascriptVar['bFixNumAuto'] = (int) (bool) Yii::app()->getConfig('bFixNumAuto', 1);
     $aLSJavascriptVar['bNumRealValue'] = (int) (bool) Yii::app()->getConfig('bNumRealValue', 0);
     $aLangData = getLanguageData();
     $aRadix = getRadixPointData($aLangData[Yii::app()->getConfig('defaultlang')]['radixpoint']);
     $aLSJavascriptVar['sLEMradix'] = $aRadix['separator'];
     $sLSJavascriptVar = "LSvar=" . json_encode($aLSJavascriptVar) . ';';
     App()->clientScript->registerScript('sLSJavascriptVar', $sLSJavascriptVar, CClientScript::POS_HEAD);
     App()->clientScript->registerScript('setJsVar', "setJsVar();", CClientScript::POS_BEGIN);
     // Ensure all js var is set before rendering the page (User can click before $.ready)
     App()->getClientScript()->registerPackage('jqueryui');
     App()->getClientScript()->registerPackage('jquery-touch-punch');
     App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js");
     useFirebug();
     ob_start(function ($buffer, $phase) {
         App()->getClientScript()->render($buffer);
         App()->getClientScript()->reset();
         return $buffer;
     });
     ob_implicit_flush(false);
     $this->action();
     ob_flush();
 }
Ejemplo n.º 3
0
 /**
 +----------------------------------------------------------
 * 渲染模板输出 供render方法内部调用
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $templateFile  模板文件
 * @param mixed $var  模板变量
 * @param string $charset  模板编码
 +----------------------------------------------------------
 * @return string
 +----------------------------------------------------------
 */
 protected function renderFile($templateFile = '', $var = '', $charset = 'utf-8')
 {
     ob_start();
     ob_implicit_flush(0);
     if (!file_exists_case($templateFile)) {
         // 自动定位模板文件
         $name = substr(get_class($this), 0, -6);
         $filename = empty($templateFile) ? $name : $templateFile;
         $templateFile = LIB_PATH . 'Widget/' . $name . '/' . $filename . C('TMPL_TEMPLATE_SUFFIX');
         if (!file_exists_case($templateFile)) {
             throw_exception(L('_TEMPLATE_NOT_EXIST_') . '[' . $templateFile . ']');
         }
     }
     $template = $this->template ? $this->template : strtolower(C('TMPL_ENGINE_TYPE') ? C('TMPL_ENGINE_TYPE') : 'php');
     if ('php' == $template) {
         // 使用PHP模板
         if (!empty($var)) {
             extract($var, EXTR_OVERWRITE);
         }
         // 直接载入PHP模板
         include $templateFile;
     } else {
         $className = 'Template' . ucwords($template);
         require_cache(THINK_PATH . '/Lib/Think/Util/Template/' . $className . '.class.php');
         $tpl = new $className();
         $tpl->fetch($templateFile, $var, $charset);
     }
     $content = ob_get_clean();
     return $content;
 }
Ejemplo n.º 4
0
 public function __construct(Base\Provider $requestProvider, Manager $threadManager)
 {
     set_time_limit(0);
     ob_implicit_flush();
     $this->_requestProvider = $requestProvider;
     $this->_threadManager = $threadManager;
 }
 public function connect(Application $app)
 {
     $controllers = new ControllerCollection();
     $supervisor = new API();
     $servers = (include __DIR__ . '/../../config.php');
     foreach (array_keys($servers) as $server_id) {
         $servers[$server_id]['id'] = $server_id;
     }
     $controllers->get('/list.{_format}', function ($_format) use($supervisor, $app, $servers) {
         if ($_format == 'json') {
             return $app->json($servers);
         } else {
             // use a closure to avoid leaking any vars into the template that we don't explicitly want
             return call_user_func(function () use($app) {
                 $url_root = $app['url_generator']->generate('home');
                 ob_start();
                 ob_implicit_flush(false);
                 include __DIR__ . '/../../views/supervisorui.html.php';
                 return ob_get_clean();
             });
         }
     })->bind('server_list')->value('_format', 'html');
     $controllers->get('/details/{server_id}', function ($server_id) use($supervisor, $app, $servers) {
         $server_ip = $servers[$server_id]['ip'];
         $details = array_merge(array('version' => $supervisor->getSupervisorVersion('127.0.0.1'), 'pid' => $supervisor->getPID('127.0.0.1')), $supervisor->getState('127.0.0.1'), $servers[$server_id]);
         return $app->json($details);
     });
     return $controllers;
 }
Ejemplo n.º 6
0
 /**
  * Constructor.
  *
  * @param   object  &$subject  The object to observe
  * @param   array   $config    An array that holds the plugin configuration
  *
  * @since   1.5
  */
 public function __construct(&$subject, $config)
 {
     parent::__construct($subject, $config);
     // Log the deprecated API.
     if ($this->params->get('log-deprecated')) {
         JLog::addLogger(array('text_file' => 'deprecated.php'), JLog::ALL, array('deprecated'));
     }
     $this->debugLang = JFactory::getApplication()->getCfg('debug_lang');
     // Only if debugging or language debug is enabled
     if (JDEBUG || $this->debugLang) {
         JFactory::getConfig()->set('gzip', 0);
         ob_start();
         ob_implicit_flush(false);
     }
     $this->linkFormat = ini_get('xdebug.file_link_format');
     if ($this->params->get('logs', 1)) {
         $priority = 0;
         foreach ($this->params->get('log_priorities', array()) as $p) {
             $const = 'JLog::' . strtoupper($p);
             if (!defined($const)) {
                 continue;
             }
             $priority |= constant($const);
         }
         // Split into an array at any character other than alphabet, numbers, _, ., or -
         $categories = array_filter(preg_split('/[^A-Z0-9_\\.-]/i', $this->params->get('log_categories', '')));
         $mode = $this->params->get('log_category_mode', 0);
         JLog::addLogger(array('logger' => 'callback', 'callback' => array($this, 'logger')), $priority, $categories, $mode);
     }
     // Prepare disconnect-handler for SQL profiling:
     $db = JFactory::getDbo();
     $db->addDisconnectHandler(array($this, 'mysqlDisconnectHandler'));
 }
Ejemplo n.º 7
0
/**
 * 
 * @param biz\models\GlDetail $model
 * @param integer $index
 * @return string
 */
function renderRow($model, $index)
{
    ob_start();
    ob_implicit_flush(false);
    ?>
                    <tr>
                        <?php 
    echo Html::activeHiddenInput($model, "[{$index}]id_gl_detail");
    ?>
                        <td class="serial"><?php 
    echo $index;
    ?>
</td>
                        <td><?php 
    echo Html::activeTextInput($model, "[{$index}]id_coa");
    ?>
</td>
                        <td><?php 
    echo Html::activeTextInput($model, "[{$index}]debit");
    ?>
</td>
                        <td><?php 
    echo Html::activeTextInput($model, "[{$index}]kredit");
    ?>
</td>
                        <td class="action"><a class="fa fa-minus-square-o" href="#"></a></td>
                    </tr>
                    <?php 
    return trim(preg_replace('/>\\s+</', '><', ob_get_clean()));
}
Ejemplo n.º 8
0
 /**
  * Executes the widget.
  */
 public function init()
 {
     parent::init();
     $this->initOptions();
     ob_start();
     ob_implicit_flush(false);
 }
 public function load()
 {
     ob_start();
     ob_implicit_flush(false);
     include __DIR__ . '/data/admin.php';
     ob_get_clean();
 }
Ejemplo n.º 10
0
/**
 * Use to begin a preformatted code block.
 * 
 * By default creates <pre class="code">.
 * 
 * @return 
 * @param object $cssClass[optional]
 */
function pre_start($cssClass = 'code')
{
    echo '<pre class="' . $cssClass . "\">\n";
    coreConfig::set('pre_highlight_mode', $cssClass);
    ob_start();
    ob_implicit_flush(0);
}
Ejemplo n.º 11
0
function generatePrologDTDtyping($dtd)
{
    $table = "dtdFile";
    include_once realpath('') . '/includes/configuration/core_configuration.php';
    //Load the pear library
    require_once 'XML_DTD/DTD.php';
    ob_implicit_flush(true);
    $path = ini_get('include_path');
    $dtd = 'w3cDtds/' . $dtd;
    ini_set('include_path', realpath('..') . ":{$path}");
    $formElements = array();
    $formElements[0] = 'select';
    $formElements[1] = 'option';
    $formElements[2] = 'textarea';
    $formElements[3] = 'input';
    $typeRulesArray = array(":- multifile attributetype/3.\n\n");
    for ($index = 0; $index < sizeof($formElements); $index++) {
        $typeRule = dtd::findAttributes($formElements[$index], $dtd);
        $typeRulesArray = array_merge($typeRulesArray, $typeRule->toArray());
    }
    for ($index = 0; $index < sizeof($typeRulesArray); $index++) {
        echo "{$typeRulesArray[$index]}<br>";
    }
    writer::write('typedefinitions.pl', 'cgi-bin/htmlTyping/', $typeRulesArray);
}
Ejemplo n.º 12
0
 public function init()
 {
     if ($this->visible) {
         ob_start();
         ob_implicit_flush(false);
         $cs = Yii::app()->clientScript;
         if ($this->cssFile === null) {
             $cssFile = CHtml::asset(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'portlet.css');
             $cs->registerCssFile($cssFile);
         } else {
             if ($this->cssFile !== false) {
                 $cs->registerCssFile($this->cssFile);
             }
         }
         echo "<div class=\"{$this->cssClass}\" style=\"width:{$this->width}\">\n";
         if ($this->headerimage !== null) {
             echo "<div class=\"{$this->headerCssClass}\"><img src=\"";
         }
         echo XHtml::imageUrl($this->headerimage);
         echo "\"></div>\n";
         echo "<div class=\"{$this->contentCssClass}\">\n";
         $this->_openTag = ob_get_contents();
         ob_clean();
     }
 }
Ejemplo n.º 13
0
 public function response()
 {
     if (function_exists('apache_setenv')) {
         @apache_setenv('no-gzip', 1);
     }
     @ini_set('zlib.output_compression', 0);
     @ini_set('implicit_flush', 1);
     for ($i = 0; $i < ob_get_level(); $i++) {
         ob_end_clean();
     }
     ob_implicit_flush(1);
     header('Content-Type: ' . (isset($_GET['callback']) ? 'text/javascript' : 'application/json'));
     header('Access-Control-Allow-Origin: *');
     try {
         if ($this->auth()) {
             $this->handler = new RestHandler($this->method, $this);
             $response = $this->handler->response();
             echo $this->formatResponse($response);
         } else {
             throw new RestException(RestException::APP_NOT_AUTHORIZED);
         }
     } catch (RestException $e) {
         echo $this->formatResponse($e);
     }
     @ob_flush();
     @flush();
 }
Ejemplo n.º 14
0
 /**
  * Constructor.
  *
  * @param   object  &$subject  The object to observe
  * @param   array   $config    An array that holds the plugin configuration
  *
  * @since 1.5
  */
 public function __construct(&$subject, $config)
 {
     parent::__construct($subject, $config);
     // Log the deprecated API.
     if ($this->params->get('log-deprecated')) {
         \JLog::addLogger(array('text_file' => 'deprecated.php'), \JLog::ALL, array('deprecated'));
     }
     // Log database errors
     if ($this->params->get('log-database-errors')) {
         \JLog::addLogger(array('text_file' => 'jdatabase.error.php'), \JLog::ALL, array('database'));
     }
     // Log database queries
     if ($this->params->get('log-database-queries')) {
         \JLog::addLogger(array('text_file' => 'jdatabase.query.php'), \JLog::ALL, array('databasequery'));
         // Register the HUBzero database logger as well
         // Don't worry, this won't log things twice...queries through joomla's database driver
         // will get logged above, and this will catch queries through hubzero's database driver
         \Event::listen(function ($event) {
             \Hubzero\Database\Log::add($event->getArgument('query'), $event->getArgument('time'));
         }, 'database_query');
     }
     // Only if debugging or language debug is enabled
     if (Config::get('debug') || Config::get('debug_lang')) {
         Config::set('gzip', 0);
         ob_start();
         ob_implicit_flush(false);
     }
     $this->linkFormat = ini_get('xdebug.file_link_format');
 }
Ejemplo n.º 15
0
 function catch_output(callable $callback)
 {
     ob_start();
     ob_implicit_flush(false);
     call_user_func($callback);
     return ob_get_clean();
 }
Ejemplo n.º 16
0
Archivo: H.php Proyecto: hfw/h
 /**
  * Bootstraps a few INI settings, error handling, and enables direct output.
  *
  * - `session.serialize_handler` is set to `php_serialize`
  *
  * - `session.cookie_httpOnly` is enabled.
  *
  * - `display_errors` and `display_startup_errors` is set to boolean of whether we are running in the CLI server.
  *
  * - `log_errors` is enabled.
  *
  * - PHP's internal output buffer is disabled.
  * All content is sent directly over the wire unless buffering functions are used.
  * This means that views ({@link \H\V}) and other dynamic content will have no `Content-Length` header unless explicitly set (see {@link \H\O}).
  *
  * - [error_reporting()](http://php.net/error-reporting) is set to non-informational errors and warnings. `E_STRICT` is ignored.
  *
  * - [set_error_handler()](http://php.net/set-error-handler) to throw an [ErrorException](http://php.net/ErrorException)
  * for errors in [error_reporting()](http://php.net/error-reporting), thus "reporting" becomes synonymous with "throwing".
  * All uncaught exceptions find their way to the `error` event (see below).
  * Excluded error levels are not thrown, but do get sent to the `log` event (see below), unless silenced with `@`.
  *
  * - [set_exception_handler()](http://php.net/set-exception-handler) to notify the `log` and `error` events (see below).
  * {@link \H\X} is not given to the `log` event, as it is intended for error slippage and can contain potentially large payloads for the user.
  *
  * - Puts a listener on the `error` event. The listener sets a response code and **exits gracefully**.
  * This event should *only* be notified by the global exception handler, you should not notify it manually.
  * Because event listeners are called in LIFO order (see {@link \H\E}), this listener is always called last,
  * so you can pile on additional listeners and exit *more* gracefully.
  * The listener behaves as follows:
  * If the exception is {@link \H\X} then its code and message are used for the response.
  * Otherwise the response code is set to `503` and a generic message is used including the request ID
  * so the user at least has a reference for the failure (see {@link \H\I::id()}).
  * If you attach a listener to the `error` event you can expect an `Exception` as the only argument, or a `Throwable` if in PHP 7.
  * {@link \H\X} must be treated as a JSON encoded HTTP error for the user, and *not* as a server error.
  * You can simply `return` from your listener if you encounter {@link \H\X} so it can find its way to this listener.
  *
  * - Puts a listener on the `log` event.
  * The listener formats a message including the error code, client IP, request method, and request URI, and gives it to [error_log()](php.net/function.error-log).
  * The listener can be trumped by attaching a new listener and returning `false` from it (see {@link \H\E::notify()}).
  *
  * The `log` event can be manually notified with the following arguments:
  *
  * - `string $message`
  * - `int $type` (optional)
  *
  * As a rule of thumb, HTTP status codes can be used for custom log types, since they don't collide with any
  * [error constants](http://php.net/errorfunc.constants) (powers of 2),
  * and the numeric categories of HTTP codes provide context for the nature of the log.
  *
  * Listeners should assume the type is `100` (informational/verbose) if not given.
  * The framework doesn't notify the `log` event except for error reporting.
  *
  * The `log` event is for broadcasting logs only and should **not** output user content or exit.
  */
 public static function init()
 {
     error_reporting(E_ALL);
     // in case of problems with init. made quieter below.
     ini_set('log_errors', true);
     ob_implicit_flush();
     // directly output
     header('X-Request-ID: ' . I::id());
     $dev = php_sapi_name() === 'cli-server';
     ini_set('display_errors', $dev);
     ini_set('display_startup_errors', $dev);
     ini_set('session.cookie_httpOnly', true);
     ini_set('session.serialize_handler', 'php_serialize');
     E::listen('error', function ($thrown) {
         self::onError($thrown);
     });
     E::listen('log', function ($message, $type = 100) {
         self::onLog($message, $type);
     });
     set_error_handler(function ($code, $message, $file, $line) {
         self::phpErrorHandler($code, $message, $file, $line);
     });
     set_exception_handler(function ($thrown) {
         self::phpExceptionHandler($thrown);
     });
     error_reporting(E_RECOVERABLE_ERROR | E_WARNING | E_USER_ERROR | E_USER_WARNING);
 }
Ejemplo n.º 17
0
 public static function init(&$sockets, &$clients)
 {
     if (self::$initalized) {
         return;
     }
     $sockets =& self::$sockets;
     $clients =& self::$clients;
     self::$initalized = 1;
     // Allow the script to hang around waiting for connections.
     set_time_limit(0);
     // Turn on implicit output flushing so output gets sent imediately
     ob_implicit_flush();
     $DEBUG = true;
     define('DEBUG', $DEBUG);
     self::require_libs();
     self::load_config();
     if (issetArg('help') || issetArg('?')) {
         self::show_help();
         exit;
     }
     if (!($modules = self::config('modules'))) {
         exit("[FATAL ERROR] no modules loaded in the config.\n");
     }
     foreach ($modules as $m) {
         module::load($m);
     }
 }
Ejemplo n.º 18
0
 /**
  * Метод безопасно получает контент.
  * В случае возникновения ошибки возвращает её стек.
  */
 public static function getContent($objOrTpl, $method = 'buildContent')
 {
     $isCallable = is_callable($objOrTpl);
     $isTpl = $objOrTpl instanceof Smarty_Internal_Template;
     if (!$isCallable && !$isTpl) {
         check_condition(is_object($objOrTpl), 'Not object passed to ' . __FUNCTION__);
         PsUtil::assertMethodExists($objOrTpl, $method);
     }
     $returned = null;
     $flushed = null;
     ob_start();
     ob_implicit_flush(false);
     try {
         if ($isCallable) {
             $returned = call_user_func($objOrTpl);
         } else {
             if ($isTpl) {
                 $returned = $objOrTpl->fetch();
             } else {
                 $returned = $objOrTpl->{$method}();
             }
         }
     } catch (Exception $ex) {
         ob_end_clean();
         return ExceptionHandler::getHtml($ex);
     }
     $flushed = ob_get_contents();
     ob_end_clean();
     return isEmpty($returned) ? isEmpty($flushed) ? null : $flushed : $returned;
 }
Ejemplo n.º 19
0
 /**
  * Calls a cacheable function or method (or not if there is already a cache for it).
  *
  * Arguments of this method are read with func_get_args. So it doesn't appear in the function definition.
  *
  * The first argument can be any PHP callable:
  *
  * $cache->call('functionName', array($arg1, $arg2));
  * $cache->call(array($object, 'methodName'), array($arg1, $arg2));
  *
  * @param mixed $callable  A PHP callable
  * @param array $arguments An array of arguments to pass to the callable
  *
  * @return mixed The result of the function/method
  */
 public function call($callable, $arguments = array())
 {
     // Generate a cache id
     $key = $this->computeCacheKey($callable, $arguments);
     $serialized = $this->cache->get($key);
     if ($serialized !== null) {
         $data = unserialize($serialized);
     } else {
         $data = array();
         if (!is_callable($callable)) {
             throw new sfException('The first argument to call() must be a valid callable.');
         }
         ob_start();
         ob_implicit_flush(false);
         try {
             $data['result'] = call_user_func_array($callable, $arguments);
         } catch (Exception $e) {
             ob_end_clean();
             throw $e;
         }
         $data['output'] = ob_get_clean();
         $this->cache->set($key, serialize($data));
     }
     echo $data['output'];
     return $data['result'];
 }
Ejemplo n.º 20
0
 /**
  * Start the cache
  *
  * @param  string  $id       (optional) A cache id (if you set a value here, maybe you have to use Output frontend instead)
  * @param  boolean $doNotDie For unit testing only !
  * @return boolean True if the cache is hit (false else)
  */
 public function start($id = false, $doNotDie = false)
 {
     $this->_cancel = false;
     $lastMatchingRegexp = null;
     foreach ($this->_specificOptions['regexps'] as $regexp => $conf) {
         if (preg_match("`{$regexp}`", $_SERVER['REQUEST_URI'])) {
             $lastMatchingRegexp = $regexp;
         }
     }
     $this->_activeOptions = $this->_specificOptions['default_options'];
     if ($lastMatchingRegexp !== null) {
         $conf = $this->_specificOptions['regexps'][$lastMatchingRegexp];
         foreach ($conf as $key => $value) {
             $this->_activeOptions[$key] = $value;
         }
     }
     if (!$this->_activeOptions['cache']) {
         return false;
     }
     if (!$id) {
         $id = $this->_makeId();
         if (!$id) {
             return false;
         }
     }
     $data = $this->load($id);
     if ($data !== false) {
         echo $data;
         die;
     }
     ob_start(array($this, '_flush'));
     ob_implicit_flush(false);
     return false;
 }
Ejemplo n.º 21
0
 protected function dispatch($page)
 {
     $GLOBALS['_PX_tests_templates'] = array();
     $_SERVER['REQUEST_URI'] = $page;
     foreach ($this->cookies as $cookie => $data) {
         $_COOKIE[$cookie] = $data;
     }
     ob_implicit_flush(False);
     list($request, $response) = $this->dispatcher->dispatch($page);
     ob_start();
     $response->render();
     $content = ob_get_contents();
     ob_end_clean();
     $response->content = $content;
     $response->request = $request;
     if (isset($GLOBALS['_PX_tests_templates'])) {
         if (count($GLOBALS['_PX_tests_templates']) == 1) {
             $response->template = $GLOBALS['_PX_tests_templates'][0];
         } else {
             $response->template = $GLOBALS['_PX_tests_templates'];
         }
     }
     foreach ($response->cookies as $cookie => $data) {
         $_COOKIE[$cookie] = $data;
         $this->cookies[$cookie] = $data;
     }
     return $response;
 }
Ejemplo n.º 22
0
function disable_ob()
{
    // Turn off output buffering
    ini_set('output_buffering', 'off');
    // Turn off PHP output compression
    ini_set('zlib.output_compression', false);
    // Implicitly flush the buffer(s)
    ini_set('implicit_flush', true);
    ob_implicit_flush(true);
    // Clear, and turn off output buffering
    while (ob_get_level() > 0) {
        // Get the curent level
        $level = ob_get_level();
        // End the buffering
        ob_end_clean();
        // If the current level has not changed, abort
        if (ob_get_level() == $level) {
            break;
        }
    }
    // Disable apache output buffering/compression
    if (function_exists('apache_setenv')) {
        apache_setenv('no-gzip', '1');
        apache_setenv('dont-vary', '1');
    }
}
Ejemplo n.º 23
0
 /**
  *
  * @param string $methodName
  * @param array $arguments
  * @return mixed
  */
 public function __call($methodName, $arguments)
 {
     $cacheBool1 = $this->_cacheByDefault;
     $cacheBool2 = in_array($methodName, $this->_cachableMethods);
     $cacheBool3 = in_array($methodName, $this->_nonCachedMethods);
     $cache = ($cacheBool1 || $cacheBool2) && !$cacheBool3;
     $box = $this->_getBox();
     if (!$cache) {
         // We do not have not cache
         return call_user_func_array(array($box, $methodName), $arguments);
     }
     /** Get cache instance */
     $cache = Axis::cache();
     $id = $this->_makeId($methodName, $arguments);
     if ($cache->test($id)) {
         // A cache is available
         $result = $cache->load($id);
         $output = $result[0];
         $return = $result[1];
         $box->setFromArray($result[2]);
         //<---
     } else {
         // A cache is not available
         ob_start();
         ob_implicit_flush(false);
         $return = call_user_func_array(array($box, $methodName), $arguments);
         $output = ob_get_contents();
         ob_end_clean();
         $data = array($output, $return, $box->getCacheData());
         //<---
         $cache->save($data, $id, array_merge($this->_tags, array('boxes')), $this->_specificLifetime, $this->_priority);
     }
     echo $output;
     return $return;
 }
Ejemplo n.º 24
0
	function __construct(){
		$this->cache_token = obcer::cache_token((COUCH?'db':NULL));
		$this->start_time = (float) array_sum(explode(' ',microtime()));
		$this->oh_memory = round(memory_get_usage() / 1024);
		// set up the 'filter' variable to determine what columns to show
		if(SHOW_ALL == FALSE){
			if(SHOW_LANGUAGE == false  ) $this->c_filter []='language';
			if(SHOW_SUPPRESS == false) $this->c_filter []='suppress';
			if(SHOW_RXCUI == false) $this->c_filter []='rxcui';
			if(SHOW_NAME == false) $this->c_filter []='name';
			if(SHOW_ALL_SYNONYM == FALSE) $this->c_filter []= 'synonym';
			if(SHOW_TTY == false) $this->c_filter []='tty';
			if(SHOW_UML == false) $this->c_filter []= 'umlscui';
		}
		// of course I could make a checkbox panel to allow for any combination of display fields, and cache entire returned xml results to do manipulations
		if(PROGRESSIVE_LOAD){
   	 	    @apache_setenv('no-gzip', 1);
			@ini_set('zlib.output_compression', 0);
			@ini_set('implicit_flush', 1);
			for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
			flush();
			ob_implicit_flush(1);
			ob_start();
		}
		// process any post if existant
		if($_POST) self::post_check();

		// if we haven't died by now then close and flush the ob cache for the final time

		// echo the footer and stats to screen.
		echo '<div id="stats">' . $this->stats().'</div>';

	}
Ejemplo n.º 25
0
 /**
  * Start the cache
  *
  * @param  string  $id Cache id
  * @return mixed True if the cache is hit (false else) with $echoData=true (default) ; string else (datas)
  */
 public function start($id, $tags)
 {
     ob_start(array($this, '_flush'));
     ob_implicit_flush(false);
     $this->_idStack[] = $id;
     return false;
 }
Ejemplo n.º 26
0
 /**
  * Start the cache
  *
  * @param   string  $id     The cache data id
  * @param   string  $group  The cache data group
  *
  * @return  boolean  True if the cache is hit (false else)
  *
  * @since   11.1
  */
 public function start($id, $group = null)
 {
     // If we have data in cache use that.
     $data = $this->cache->get($id, $group);
     $this->_locktest = new stdClass();
     $this->_locktest->locked = null;
     $this->_locktest->locklooped = null;
     if ($data === false) {
         $this->_locktest = $this->cache->lock($id, $group);
         if ($this->_locktest->locked == true && $this->_locktest->locklooped == true) {
             $data = $this->cache->get($id, $group);
         }
     }
     if ($data !== false) {
         $data = unserialize(trim($data));
         echo $data;
         if ($this->_locktest->locked == true) {
             $this->cache->unlock($id, $group);
         }
         return true;
     } else {
         // Nothing in cache... let's start the output buffer and start collecting data for next time.
         if ($this->_locktest->locked == false) {
             $this->_locktest = $this->cache->lock($id, $group);
         }
         ob_start();
         ob_implicit_flush(false);
         // Set id and group placeholders
         $this->_id = $id;
         $this->_group = $group;
         return false;
     }
 }
Ejemplo n.º 27
0
 public function __construct($args)
 {
     $this->args = $args;
     Console::$have_readline = function_exists("readline");
     for ($x = 1; $x < count($args); $x++) {
         switch ($args[$x]) {
             case "-h":
             case "--help":
                 $this->usage();
                 break;
             default:
                 if (substr($args[$x], 0, 1) == "-") {
                     $this->usage();
                 } elseif (defined("HALFMOON_ENV")) {
                     $this->usage();
                 } else {
                     define("HALFMOON_ENV", $args[$x]);
                 }
         }
     }
     require_once __DIR__ . "/../halfmoon.php";
     error_reporting(E_ALL | E_STRICT);
     ini_set("error_log", NULL);
     ini_set("log_errors", 1);
     ini_set("html_errors", 0);
     ini_set("display_errors", 0);
     while (ob_get_level()) {
         ob_end_clean();
     }
     ob_implicit_flush(true);
     /* TODO: forcibly load models so they're in the tab-completion cache */
     print "Loaded " . HALFMOON_ENV . " environment (halfmoon)\n";
     $this->loop();
 }
Ejemplo n.º 28
0
 /**
  * post Note Action
  *
  * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION'])
  * @return array containg the case notes
  */
 function postNote($httpData)
 {
     require_once "classes/model/AppNotes.php";
     //extract(getExtJSParams());
     if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
         $appUid = $httpData->appUid;
     } else {
         $appUid = $_SESSION['APPLICATION'];
     }
     if (!isset($appUid)) {
         throw new Exception('Can\'t resolve the Apllication ID for this request.');
     }
     $usrUid = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : "";
     $noteContent = addslashes($httpData->noteText);
     //Disabling the controller response because we handle a special behavior
     $this->setSendResponse(false);
     //Add note case
     $appNote = new AppNotes();
     $response = $appNote->addCaseNote($appUid, $usrUid, $noteContent, intval($httpData->swSendMail));
     //Send the response to client
     @ini_set("implicit_flush", 1);
     ob_start();
     echo G::json_encode($response);
     @ob_flush();
     @flush();
     @ob_end_flush();
     ob_implicit_flush(1);
 }
Ejemplo n.º 29
0
function info($message)
{
    echo $message;
    flush();
    ob_flush();
    ob_implicit_flush();
}
Ejemplo n.º 30
-1
 public function run()
 {
     ignore_user_abort(false);
     ob_implicit_flush(1);
     ini_set('implicit_flush', true);
     cachemgr::init(false);
     if (strpos(strtolower(PHP_OS), 'win') === 0) {
         if (function_exists('mb_internal_encoding')) {
             mb_internal_encoding('UTF-8');
             mb_http_output('GBK');
             ob_start('mb_output_handler', 2);
         } elseif (function_exists('iconv_set_encoding')) {
             iconv_set_encoding('internal_encoding', 'UTF-8');
             iconv_set_encoding('output_encoding', 'GBK');
             ob_start('ob_iconv_handler', 2);
         }
     }
     if (isset($_SERVER['argv'][1])) {
         $args = array_shift($_SERVER['argv']);
         $rst = $this->exec_command(implode(' ', $_SERVER['argv']));
         if ($rst === false) {
             exit(-1);
         }
     } else {
         $this->interactive();
     }
 }