Example #1
2
 /**
  * @ignore
  * @param array $options
  */
 public function prepareEnvironment($options = array())
 {
     if (empty($options['skipErrorHandler'])) {
         set_error_handler(array('Ip\\Internal\\ErrorHandler', 'ipErrorHandler'));
     }
     if (empty($options['skipError'])) {
         if (ipConfig()->showErrors()) {
             error_reporting(E_ALL | E_STRICT);
             ini_set('display_errors', '1');
         } else {
             ini_set('display_errors', '0');
         }
     }
     if (empty($options['skipSession'])) {
         if (session_id() == '' && !headers_sent()) {
             //if session hasn't been started yet
             session_name(ipConfig()->get('sessionName'));
             if (!ipConfig()->get('disableHttpOnlySetting')) {
                 ini_set('session.cookie_httponly', 1);
             }
             session_start();
         }
     }
     if (empty($options['skipEncoding'])) {
         mb_internal_encoding(ipConfig()->get('charset'));
     }
     if (empty($options['skipTimezone'])) {
         date_default_timezone_set(ipConfig()->get('timezone'));
         //PHP 5 requires timezone to be set.
     }
 }
Example #2
2
 public static function start($lifetime = 0, $path = '/', $domain = NULL)
 {
     if (!self::$_initialized) {
         if (!is_object(Symphony::Database()) || !Symphony::Database()->connected()) {
             return false;
         }
         $cache = Cache::instance()->read('_session_config');
         if (is_null($cache) || $cache === false) {
             self::create();
             Cache::instance()->write('_session_config', true);
         }
         if (!session_id()) {
             ini_set('session.save_handler', 'user');
             ini_set('session.gc_maxlifetime', $lifetime);
             ini_set('session.gc_probability', '1');
             ini_set('session.gc_divisor', '3');
         }
         session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'gc'));
         session_set_cookie_params($lifetime, $path, $domain ? $domain : self::getDomain(), false, false);
         if (strlen(session_id()) == 0) {
             if (headers_sent()) {
                 throw new Exception('Headers already sent. Cannot start session.');
             }
             session_start();
         }
         self::$_initialized = true;
     }
     return session_id();
 }
Example #3
1
 public static function exceptionHandle(Exception $exception)
 {
     if (DEBUG_MODE) {
         //直接输出调试信息
         echo nl2br($exception->__toString());
         echo '<hr /><p>Router:</p><pre>';
         print_r(Singleton::getInstance('Router'));
         echo '</pre>';
     } else {
         $code = $exception->getCode();
         $message = nl2br($exception->getMessage());
         /*
                     如果错误码"可能为"合法的http状态码则尝试设置,
                     setStatus()方法会忽略非法的http状态码. */
         if ($code >= 400 && $code <= 505 && !headers_sent()) {
             ResponseModule::setStatus($code);
         }
         $var_list = array('message' => $message, 'code' => $code, 'file' => $exception->getFile(), 'url' => Singleton::getInstance('Router')->getUrl());
         if ($error_file = self::_getErrorFilePath($code)) {
             Lugit::$view = new View($var_list);
             Lugit::$view->render($error_file);
         } else {
             echo 'No error page is found.<pre>';
             print_r($var_list);
             echo '</pre>';
         }
     }
     exit;
 }
Example #4
0
 /**
  * Display the given exception to the user.
  *
  * @param   object  $exception
  * @return  void
  */
 public function render(Exception $error)
 {
     if (!headers_sent()) {
         header('HTTP/1.1 500 Internal Server Error');
     }
     $response = 'Error: ' . $error->getCode() . ' - ' . $error->getMessage() . "\n\n";
     if ($this->debug) {
         $backtrace = $error->getTrace();
         if (is_array($backtrace)) {
             $backtrace = array_reverse($backtrace);
             for ($i = count($backtrace) - 1; $i >= 0; $i--) {
                 if (isset($backtrace[$i]['class'])) {
                     $response .= "\n[{$i}] " . sprintf("%s %s %s()", $backtrace[$i]['class'], $backtrace[$i]['type'], $backtrace[$i]['function']);
                 } else {
                     $response .= "\n[{$i}] " . sprintf("%s()", $backtrace[$i]['function']);
                 }
                 if (isset($backtrace[$i]['file'])) {
                     $response .= sprintf(' @ %s:%d', str_replace(PATH_ROOT, '', $backtrace[$i]['file']), $backtrace[$i]['line']);
                 }
             }
         }
     }
     echo php_sapi_name() == 'cli' ? $response : nl2br($response);
     exit;
 }
Example #5
0
 public function redirect($uri = null, array $params = [])
 {
     if (headers_sent()) {
         Exception::toss('Cannot redirect to "%s" from the view because output has already started.', $uri);
     }
     (new RequestUri($this->format($uri, $params)))->redirect();
 }
Example #6
0
 public function preprocess()
 {
     if (!headers_sent()) {
         header('Location: ../OpenBookFinancingV2/ObfWeeklyReportV2.php');
     }
     return false;
 }
 function init($dir = null)
 {
     if ($dir != null) {
         $this->setdir($dir);
     }
     $this->group('settings');
     $this->group('global');
     $this->group('modules');
     $this->group('custom');
     @ini_set('default_charset', '');
     if (!headers_sent()) {
         viscacha_header('Content-type: text/html; charset=' . $this->phrase('charset'));
     }
     global $slog;
     if (isset($slog) && is_object($slog) && method_exists($slog, 'setlang')) {
         $slog->setlang($this->phrase('fallback_no_username'), $this->phrase('timezone_summer'));
     }
     global $config, $breadcrumb;
     if (isset($breadcrumb)) {
         $isforum = array('addreply', 'attachments', 'edit', 'forum', 'manageforum', 'managetopic', 'misc', 'newtopic', 'pdf', 'search', 'showforum', 'showtopic');
         if ($config['indexpage'] != 'forum' && in_array(SCRIPTNAME, $isforum)) {
             $breadcrumb->Add($this->phrase('forumname'), iif(SCRIPTNAME != 'forum', 'forum.php'));
         }
     }
 }
Example #8
0
function espresso_ical()
{
    $name = $_REQUEST['event_summary'] . ".ics";
    $output = "BEGIN:VCALENDAR\n" . "PRODID:-//xyz Corp//NONSGML PDA Calendar Version 1.0//EN\n" . "VERSION:2.0\n" . "BEGIN:VEVENT\n" . "DTSTAMP:" . $_REQUEST['currentyear'] . $_REQUEST['currentmonth'] . $_REQUEST['currentday'] . "T" . $_REQUEST['currenttime'] . "\n" . "UID:" . $_REQUEST['attendee_id'] . "@" . $_REQUEST['event_id'] . "\n" . "ORGANIZER:MAILTO:" . $_REQUEST['contact'] . "\n" . "DTSTART:" . $_REQUEST['startyear'] . $_REQUEST['startmonth'] . $_REQUEST['startday'] . "T" . $_REQUEST['starttime'] . "\n" . "DTEND:" . $_REQUEST['endyear'] . $_REQUEST['endmonth'] . $_REQUEST['endday'] . "T" . $_REQUEST['endtime'] . "\n" . "STATUS:CONFIRMED\n" . "CATEGORIES:" . $_REQUEST['event_categories'] . "\n" . "SUMMARY:" . $_REQUEST['event_summary'] . "\n" . "DESCRIPTION:" . $_REQUEST['event_description'] . "\n" . "END:VEVENT\n" . "END:VCALENDAR";
    if (ob_get_length()) {
        echo 'Some data has already been output, can\'t send iCal file';
    }
    header('Content-Type: application/x-download');
    if (headers_sent()) {
        echo 'Some data has already been output, can\'t send iCal file';
    }
    header('Content-Length: ' . strlen($output));
    header('Content-Disposition: attachment; filename="' . $name . '"');
    header('Cache-Control: private, max-age=0, must-revalidate');
    header('Pragma: public');
    header('Content-Type: application/octet-stream');
    header('Content-Type: application/force-download');
    header('Content-type: application/pdf');
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Content-Transfer-Encoding: binary");
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
    // Date in the past
    ini_set('zlib.output_compression', '0');
    echo $output;
    die;
}
 public function redirect()
 {
     if (!headers_sent()) {
         header('Content-Type: text/html; charset=UTF-8');
     }
     return parent::redirect();
 }
Example #10
0
 /**
  * Override __toString() to send HTTP Content-Type header
  *
  * @return string
  */
 public function __toString()
 {
     if (!headers_sent()) {
         header('Content-Type: text/xml; charset=' . strtolower($this->getEncoding()));
     }
     return parent::__toString();
 }
 public function download()
 {
     $file = DIR_LOGS . $this->config->get('config_error_filename');
     clearstatcache();
     if (file_exists($file) && is_file($file)) {
         if (!headers_sent()) {
             if (filesize($file) > 0) {
                 header('Content-Type: application/octet-stream');
                 header('Content-Description: File Transfer');
                 header('Content-Disposition: attachment; filename=' . str_replace(' ', '_', $this->config->get('config_name')) . '_' . date('Y-m-d_H-i-s', time()) . '_error.log');
                 header('Content-Transfer-Encoding: binary');
                 header('Expires: 0');
                 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                 header('Pragma: public');
                 header('Content-Length: ' . filesize($file));
                 readfile($file, 'rb');
                 exit;
             }
         } else {
             exit('Error: Headers already sent out!');
         }
     } else {
         $this->redirect($this->url->link('tool/error_log', 'token=' . $this->session->data['token'], 'SSL'));
     }
 }
Example #12
0
 /**
  * Output object as JSON and set appropriate headers
  * @param mixed $object
  */
 protected function _printJson($object)
 {
     if (!headers_sent()) {
         header("Content-type: application/json");
     }
     echo json_encode($object);
 }
Example #13
0
 function __construct()
 {
     parent::__construct();
     if (RSFormProHelper::isJ16()) {
         JHTML::_('behavior.framework');
     }
     if (!headers_sent()) {
         header('Content-type: text/html; charset=utf-8');
     }
     $this->_db = JFactory::getDBO();
     $doc =& JFactory::getDocument();
     $doc->addScript(JURI::root(true) . '/administrator/components/com_rsform/assets/js/jquery.js?v=40');
     $doc->addScript(JURI::root(true) . '/administrator/components/com_rsform/assets/js/tablednd.js?v=40');
     $doc->addScript(JURI::root(true) . '/administrator/components/com_rsform/assets/js/jquery.scrollto.js?v=40');
     $doc->addScript(JURI::root(true) . '/administrator/components/com_rsform/assets/js/script.js?v=41');
     $doc->addStyleSheet(JURI::root(true) . '/administrator/components/com_rsform/assets/css/style.css?v=42');
     if (RSFormProHelper::isJ16()) {
         $doc->addStyleSheet(JURI::root(true) . '/administrator/components/com_rsform/assets/css/style16.css?v=40');
     }
     $this->registerTask('formsApply', 'formsSave');
     $this->registerTask('formsPublish', 'formsChangeStatus');
     $this->registerTask('formsUnpublish', 'formsChangeStatus');
     $this->registerTask('componentsPublish', 'componentsChangeStatus');
     $this->registerTask('componentsUnpublish', 'componentsChangeStatus');
     $this->registerTask('configurationApply', 'configurationSave');
     $this->registerTask('submissionsExportCSV', 'submissionsExport');
     $this->registerTask('submissionsExportExcel', 'submissionsExport');
     $this->registerTask('submissionsExportXML', 'submissionsExport');
     $this->registerTask('submissionsApply', 'submissionsSave');
     $this->registerTask('submissionsSave', 'submissionsSave');
     $this->registerTask('richtextApply', 'richtextSave');
     $this->registerTask('emailApply', 'emailSave');
 }
function redirect($url, $permanent = false)
{
    if (headers_sent() === false) {
        header('Location: ' . $url, true, $permanent === true ? 301 : 302);
    }
    exit;
}
Example #15
0
 /**
  * Constructor.
  * 
  * Create new JsHttpRequest backend object and attach it
  * to script output buffer. As a result - script will always return
  * correct JavaScript code, even in case of fatal errors.
  */
 function JsHttpRequest($enc)
 {
     // QUERY_STRING is in form: PHPSESSID=<sid>&a=aaa&b=bbb&<id>
     // where <id> is request ID, <sid> - session ID (if present),
     // PHPSESSID - session parameter name (by default = "PHPSESSID").
     // Parse QUERY_STRING wrapper format.
     if (preg_match('/^(.*)(?:&|^)JsHttpRequest=(\\d+)-([^&]+)((?:&|$).*)$/s', $_SERVER['QUERY_STRING'], $m)) {
         $this->ID = $m[2];
         $this->LOADER = strtolower($m[3]);
         $_SERVER['QUERY_STRING'] = $m[1] . $m[4];
         unset($_GET['JsHttpRequest']);
         unset($_REQUEST['JsHttpRequest']);
     } else {
         $this->ID = 0;
         $this->LOADER = 'unknown';
     }
     // Start OB handling early.
     $this->_uniqHash = md5(microtime() . getmypid());
     ini_set('error_prepend_string', ini_get('error_prepend_string') . $this->_uniqHash);
     ini_set('error_append_string', ini_get('error_append_string') . $this->_uniqHash);
     ob_start(array(&$this, "_obHandler"));
     // Set up encoding.
     $this->setEncoding($enc);
     // Check if headers are already sent (see Content-Type library usage).
     // If true - generate debug message and exit.
     $file = $line = null;
     if (headers_sent($file, $line)) {
         trigger_error("HTTP headers are already sent" . ($line !== null ? " in {$file} on line {$line}" : "") . ". " . "Possibly you have extra spaces (or newlines) before first line of the script or any library. " . "Please note that Subsys_JsHttpRequest uses its own Content-Type header and fails if " . "this header cannot be set. See header() function documentation for details", E_USER_ERROR);
         exit;
     }
 }
Example #16
0
/**
 * Routes the request to a registered page handler
 *
 * This function sets the context based on the handler name (first segment of the
 * URL). It also triggers a plugin hook 'route', $handler so that plugins can
 * modify the routing or handle a request.
 *
 * @param string $handler The name of the handler type (eg 'blog')
 * @param array  $page    The parameters to the page, as an array (exploded by '/' slashes)
 *
 * @return bool
 * @access private
 */
function page_handler($handler, $page)
{
    global $CONFIG;
    elgg_set_context($handler);
    $page = explode('/', $page);
    // remove empty array element when page url ends in a / (see #1480)
    if ($page[count($page) - 1] === '') {
        array_pop($page);
    }
    // return false to stop processing the request (because you handled it)
    // return a new $params array if you want to route the request differently
    $params = array('handler' => $handler, 'segments' => $page);
    $params = elgg_trigger_plugin_hook('route', $handler, NULL, $params);
    if ($params === false) {
        return true;
    }
    $handler = $params['handler'];
    $page = $params['segments'];
    $result = false;
    if (isset($CONFIG->pagehandler) && !empty($handler) && isset($CONFIG->pagehandler[$handler])) {
        $function = $CONFIG->pagehandler[$handler];
        $result = call_user_func($function, $page, $handler);
    }
    return $result || headers_sent();
}
Example #17
0
/**
 * My print_r - debug function
 * @author Oliwier Ptak (https://github.com/oliwierptak)
 *
 * Usage example:
 * mpr($mixed);
 * mpr($mixed,1); <- stop execution of the script
 * mpr($mixed,1,1); <- stop execution and show backtrace
 */
function mpr($val, $die = false, $showTrace = false)
{
    if (!headers_sent()) {
        header("content-type: text/plain");
    }
    echo '--MPR--';
    if (is_array($val) || is_object($val)) {
        print_r($val);
        if (is_array($val)) {
            reset($val);
        }
    } else {
        var_dump($val);
    }
    if ($showTrace || $die) {
        $trace = debug_backtrace();
        echo "--\n";
        echo sprintf("Who called me: %s line %s", $trace[0]['file'], $trace[0]['line']);
        if ($showTrace) {
            echo "\nTrace:";
            for ($i = 1; $i <= 100; $i++) {
                if (!isset($trace[$i])) {
                    break;
                }
                echo sprintf("\n%s line %s", $trace[$i]['file'], $trace[$i]['line']);
            }
        }
    }
    echo "\n";
    if ($die) {
        die;
    }
}
    public function setUp()
    {
        $savePath = ini_get('session.save_path');
        if (strpos($savePath, ';')) {
            $savePath = explode(';', $savePath);
            $savePath = array_pop($savePath);
        }
        if (empty($savePath)) {
            $this->markTestSkipped('Cannot test FlashMessenger due to unavailable session save path');
        }

        if (headers_sent()) {
            $this->markTestSkipped('Cannot test FlashMessenger: cannot start session because headers already sent');
        }
        Zend_Session::start();

        $this->front      = Zend_Controller_Front::getInstance();
        $this->front->resetInstance();
        $this->front->setControllerDirectory(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . '_files');
        $this->front->returnResponse(true);
        $this->request    = new Zend_Controller_Request_Http();
        $this->request->setControllerName('helper-flash-messenger');
        $this->response   = new Zend_Controller_Response_Cli();
        $this->controller = new HelperFlashMessengerController($this->request, $this->response, array());
        $this->helper     = new Zend_Controller_Action_Helper_FlashMessenger($this->controller);
    }
Example #19
0
 /**
  * Starts the session if it does not exist.
  *
  * @return void
  */
 protected function startSession()
 {
     // Check that the session hasn't already been started
     if (session_id() == '' && !headers_sent()) {
         session_start();
     }
 }
Example #20
0
 /** Display the error code and error message to the user if a database error occurred.
  *  The error must be read by the child method. This method will call a backtrace so
  *  you see the script and specific line in which the error occurred.
  *  @param $code    The database error code that will be displayed.
  *  @param $message The database error message that will be displayed.
  *  @return Will exit the script and returns a html output with the error informations.
  */
 public function db_error($code = 0, $message = '')
 {
     global $g_root_path, $gMessage, $gPreferences, $gCurrentOrganization, $gDebug, $gL10n;
     $htmlOutput = '';
     $backtrace = $this->getBacktrace();
     // Rollback on open transaction
     if ($this->transactions > 0) {
         $this->rollback();
     }
     if (!headers_sent() && isset($gPreferences) && defined('THEME_SERVER_PATH')) {
         // create html page object
         $page = new HtmlPage($gL10n->get('SYS_DATABASE_ERROR'));
     }
     // transform the database error to html
     $error_string = '<div style="font-family: monospace;">
                      <p><b>S Q L - E R R O R</b></p>
                      <p><b>CODE:</b> ' . $code . '</p>
                      ' . $message . '<br /><br />
                      <b>B A C K T R A C E</b><br />
                      ' . $backtrace . '
                      </div>';
     $htmlOutput = $error_string;
     // in debug mode show error in log file
     if ($gDebug === 1) {
         error_log($code . ': ' . $message);
     }
     // display database error to user
     if (!headers_sent() && isset($gPreferences) && defined('THEME_SERVER_PATH')) {
         $page->addHtml($htmlOutput);
         $page->show();
     } else {
         echo $htmlOutput;
     }
     exit;
 }
 public function renderRaw()
 {
     $attachment = $this->_params['attachment'];
     if (!headers_sent() && function_exists('header_remove')) {
         header_remove('Expires');
         header('Cache-control: private');
     }
     $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
     $imageTypes = array('svg' => 'image/svg+xml', 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
     if (isset($imageTypes[$extension]) && ($attachment['width'] && $attachment['height'])) {
         $this->_response->setHeader('Content-type', $imageTypes[$extension], true);
         $this->setDownloadFileName($attachment['filename'], true);
     } else {
         $this->_response->setHeader('Content-type', 'application/octet-stream', true);
         $this->setDownloadFileName($attachment['filename']);
     }
     $this->_response->setHeader('ETag', '"' . $attachment['attach_date'] . '"', true);
     $this->_response->setHeader('Content-Length', $attachment['file_size'], true);
     $this->_response->setHeader('X-Content-Type-Options', 'nosniff');
     $attachmentFile = $this->_params['attachmentFile'];
     $options = XenForo_Application::getOptions();
     if ($options->SV_AttachImpro_XAR) {
         if (SV_AttachmentImprovements_AttachmentHelper::ConvertFilename($attachmentFile)) {
             if (XenForo_Application::debugMode() && $options->SV_AttachImpro_log) {
                 XenForo_Error::debug('X-Accel-Redirect:' . $attachmentFile);
             }
             $this->_response->setHeader('X-Accel-Redirect', $attachmentFile);
             return '';
         }
         if (XenForo_Application::debugMode() && $options->SV_AttachImpro_log) {
             XenForo_Error::debug('X-Accel-Redirect skipped');
         }
     }
     return new XenForo_FileOutput($attachmentFile);
 }
 public function send_to_browser($destination_file_name, $redirect_to_referer = TRUE)
 {
     if (headers_sent()) {
         error_log("Headers already sent.  Download of {$this->full_path} failed.");
         die('Headers already sent');
     }
     // Required for some browsers
     if (ini_get('zlib.output_compression')) {
         ini_set('zlib.output_compression', 'Off');
     }
     // File Exists?
     if (is_dir($this->full_path) || !file_exists($this->full_path)) {
         return FALSE;
         # To stop hitting the 'exit' command at the bottom of this function.
     }
     if (ob_get_contents()) {
         # Make sure no junk is included in the file
         ob_end_clean();
     }
     header("Content-type: {$this->mime_type}");
     header('Content-Disposition: attachment; filename="' . $destination_file_name . '"');
     header('Cache-Control: no-store, no-cache');
     if (ob_get_contents()) {
         # Make __absolutely__ :) sure no junk is included in the file
         ob_end_flush();
         flush();
     }
     readfile($this->full_path);
     die;
 }
Example #23
0
 /**
  * Override __toString() to send HTTP Content-Type header
  * 
  * @return string
  */
 public function __toString()
 {
     if (!headers_sent()) {
         header('Content-Type: application/xml; charset=utf-8');
     }
     return parent::__toString();
 }
function vam_db_error($query, $errno, $error)
{
    // BOF db-error processing
    include DIR_WS_LANGUAGES . 'russian/russian_db_error.php';
    $msg = "\n" . 'MYSQL ERROR REPORT' . "\n" . " - " . date("d/m/Y H:m:s", time()) . "\n" . '---------------------------------------' . "\n";
    $msg .= $errno . ' - ' . $error . "\n\n" . $query . "\n";
    $msg .= '---------------------------------------' . "\n";
    $msg .= 'Server Name   : ' . $_SERVER['SERVER_NAME'] . "\n";
    $msg .= 'Remote Address: ' . $_SERVER['REMOTE_ADDR'] . "\n";
    $msg .= 'Referer       : ' . $_SERVER["HTTP_REFERER"] . "\n";
    $msg .= 'Requested     : ' . $_SERVER["REQUEST_URI"] . "\n";
    $msg .= 'Trace Back    : ' . str_replace(DIR_FS_CATALOG, '', str_replace('\\', '/', implode(" => ", zen_trace_back('', 0, 1, true)))) . "\n";
    if (defined('DEBUG') && DEBUG == true) {
        echo nl2br($msg);
        die('==========================================================================');
    }
    $log = date("d/m/Y H:m:s", time()) . ' | ' . $errno . ' - ' . $error . ' | ' . $query . ' | ' . $_SERVER["REQUEST_URI"] . "\n";
    // echo "<br>".$query."<br>".$error."<br>";
    error_log($log, 3, 'mysql_db_error.log');
    mail(DB_ERR_MAIL, 'MySQL DB Error!', $msg, 'From: db_error@' . $_SERVER["SERVER_NAME"]);
    if (!headers_sent() && file_exists('db_error.htm')) {
        header('Location: db_error.htm');
        //include('db_error.htm');
    }
    die(DB_ERR_MSG);
}
function pa_end_of_page_ob_filter($html)
{
    // if headers not sent yet, and we don't have a content type specified, send text/html; charset=UTF-8
    if (!headers_sent()) {
        $ct_sent = FALSE;
        foreach (headers_list() as $hdr) {
            if (preg_match("/^Content-Type:/", $hdr)) {
                $ct_sent = TRUE;
            }
        }
        if (!$ct_sent) {
            header("Content-Type: text/html; charset=UTF-8");
        }
    }
    // work out timing
    global $pa_page_render_start;
    $duration = microtime(TRUE) - $pa_page_render_start;
    $eop_text = sprintf("[%.2f s]", $duration);
    global $debug_show_svn_version;
    if ($debug_show_svn_version) {
        $svn_text = get_svn_version();
        $eop_text .= " [{$svn_text}]";
    }
    $eop_text .= " " . PA::$remote_ip;
    // now drop timing and anything else we want to show at the bottom of the page
    return str_replace("<!--**timing**-->", $eop_text, $html);
}
Example #26
0
 /**
  * 发送数据到客户端
  * @access protected
  * @param mixed $data 要返回的数据
  * @param String $type 返回数据格式
  * @param bool $return 是否返回数据
  * @return mixed
  */
 public static function send($data = '', $type = '', $return = false)
 {
     $type = strtolower($type ?: self::$type);
     $headers = ['json' => 'application/json', 'xml' => 'text/xml', 'html' => 'text/html', 'jsonp' => 'application/javascript', 'script' => 'application/javascript', 'text' => 'text/plain'];
     if (!headers_sent() && isset($headers[$type])) {
         header('Content-Type:' . $headers[$type] . '; charset=utf-8');
     }
     $data = $data ?: self::$data;
     switch ($type) {
         case 'json':
             // 返回JSON数据格式到客户端 包含状态信息
             $data = json_encode($data, JSON_UNESCAPED_UNICODE);
             break;
         case 'jsonp':
             // 返回JSON数据格式到客户端 包含状态信息
             $handler = Input::get(Config::get('datatype', "callback"));
             $data = $handler . '(' . json_encode($data, JSON_UNESCAPED_UNICODE) . ');';
             //exit($handler.'('.json_encode($data).');');
             break;
         case '':
         case 'html':
         case 'text':
             // 不做处理
             break;
         default:
             /* todo 其他扩展*/
     }
     if ($return) {
         return $data;
     }
     echo $data;
     exit;
 }
Example #27
0
 protected function initSharedSession()
 {
     $cookie_name = $this->getSharedSessionCookieName();
     if (isset($_COOKIE[$cookie_name])) {
         $data = $this->parseSignedRequest($_COOKIE[$cookie_name]);
         if ($data && !empty($data['domain']) && self::isAllowedDomain($this->getHttpHost(), $data['domain'])) {
             // good case
             $this->sharedSessionID = $data['id'];
             return;
         }
         // ignoring potentially unreachable data
     }
     // evil/corrupt/missing case
     $base_domain = $this->getBaseDomain();
     $this->sharedSessionID = md5(uniqid(mt_rand(), true));
     $cookie_value = $this->makeSignedRequest(array('domain' => $base_domain, 'id' => $this->sharedSessionID));
     $_COOKIE[$cookie_name] = $cookie_value;
     if (!headers_sent()) {
         $expire = time() + self::FBSS_COOKIE_EXPIRE;
         setcookie($cookie_name, $cookie_value, $expire, '/', '.' . $base_domain);
     } else {
         // @codeCoverageIgnoreStart
         self::errorLog('Shared session ID cookie could not be set! You must ensure you ' . 'create the Facebook instance before headers have been sent. This ' . 'will cause authentication issues after the first request.');
         // @codeCoverageIgnoreEnd
     }
 }
Example #28
0
 function getMessage()
 {
     if (!session_id() && !headers_sent()) {
         session_start();
     }
     $mess = null;
     switch ($_SESSION['apMess'][$this->getMessSessionName()]) {
         case 'delete_ok':
             $mess = 'File delete';
             break;
         case 'delete_fail':
             $mess = 'Error! Record is not removed';
             break;
         case 'update_ok':
             $mess = 'The information has been updated successfully';
             break;
         case 'update_fail':
             $mess = 'Error update';
             break;
         case 'add_ok':
             $mess = 'File add';
             break;
         case 'add_fail':
             $mess = 'When adding an entry error has occurred';
             break;
     }
     $_SESSION['apMess'] = array();
     return $mess;
 }
Example #29
0
 /**
  * Send a 304 Not Modified Response to the client if HTTP_IF_NONE_MATCH matched $etag and headers have not already been sent
  * Othewise, send the etag
  * @param string $etag The calculated etag for the current page
  *
  */
 public static function Send304($etag)
 {
     global $config;
     if (!$config['etag_headers']) {
         return;
     }
     if (headers_sent()) {
         return;
     }
     //always send the etag
     header('ETag: "' . $etag . '"');
     if (empty($_SERVER['HTTP_IF_NONE_MATCH']) || trim($_SERVER['HTTP_IF_NONE_MATCH'], '"') != $etag) {
         return;
     }
     //don't use ob_get_level() in while loop to prevent endless loops;
     $level = ob_get_level();
     while ($level > 0) {
         @ob_end_clean();
         $level--;
     }
     // 304 should not have a response body or Content-Length header
     //header('Not Modified',true,304);
     self::status_header(304, 'Not Modified');
     header('Connection: close');
     exit;
 }
Example #30
0
 protected function startSession()
 {
     //Make sure the session has not already started
     if (session_id() == '' && !headers_sent()) {
         session_start();
     }
 }