当前位置: 首页>>代码示例>>PHP>>正文


PHP eZDebug::setHandleType方法代码示例

本文整理汇总了PHP中eZDebug::setHandleType方法的典型用法代码示例。如果您正苦于以下问题:PHP eZDebug::setHandleType方法的具体用法?PHP eZDebug::setHandleType怎么用?PHP eZDebug::setHandleType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZDebug的用法示例。


在下文中一共展示了eZDebug::setHandleType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct(array $settings = array())
 {
     $this->settings = $settings + array('use-cache-headers' => true, 'max-age' => 86400, 'siteaccess' => null, 'use-exceptions' => false);
     unset($settings);
     require_once __DIR__ . '/treemenu_functions.php';
     $this->setUseExceptions($this->settings['use-exceptions']);
     header('X-Powered-By: ' . eZPublishSDK::EDITION . ' (index_treemenu)');
     if ($this->settings['use-cache-headers'] === true) {
         define('MAX_AGE', $this->settings['max-age']);
         if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
             header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
             header('Expires: ' . gmdate('D, d M Y H:i:s', time() + MAX_AGE) . ' GMT');
             header('Cache-Control: max-age=' . MAX_AGE);
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) . ' GMT');
             header('Pragma: ');
             exit;
         }
     }
     // Tweaks ini filetime checks if not defined!
     // This makes ini system not check modified time so
     // that index_treemenu.php can assume that index.php does
     // this regular enough, set in config.php to override.
     if (!defined('EZP_INI_FILEMTIME_CHECK')) {
         define('EZP_INI_FILEMTIME_CHECK', false);
     }
     eZExecution::addFatalErrorHandler(function () {
         header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
     });
     eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP);
     // Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs):
     $_SERVER['SCRIPT_FILENAME'] = str_replace('/index_treemenu.php', '/index.php', $_SERVER['SCRIPT_FILENAME']);
     $_SERVER['PHP_SELF'] = str_replace('/index_treemenu.php', '/index.php', $_SERVER['PHP_SELF']);
     $ini = eZINI::instance();
     $timezone = $ini->variable('TimeZoneSettings', 'TimeZone');
     if ($timezone) {
         putenv("TZ={$timezone}");
     }
     // init uri code
     $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI');
     eZSys::init('index.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true');
     $this->uri = eZURI::instance(eZSys::requestURI());
     $GLOBALS['eZRequestedURI'] = $this->uri;
     // Check for extension
     eZExtension::activateExtensions('default');
     // load siteaccess
     // Use injected siteaccess if available or match it internally.
     $this->access = isset($this->settings['siteaccess']) ? $this->settings['siteaccess'] : eZSiteAccess::match($this->uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
     eZSiteAccess::change($this->access);
     // Check for new extension loaded by siteaccess
     eZExtension::activateExtensions('access');
 }
开发者ID:nfrp,项目名称:ezpublish,代码行数:51,代码来源:ezpkerneltreemenu.php

示例2: header

    header( $_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error' );
}

function exitWithInternalError()
{
    header( $_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error' );
    eZExecution::cleanup();
    eZExecution::setCleanExit();
}

ignore_user_abort( true );
ob_start();
error_reporting ( E_ALL );

eZExecution::addFatalErrorHandler( 'eZFatalError' );
eZDebug::setHandleType( eZDebug::HANDLE_FROM_PHP );

// Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs):
$_SERVER['SCRIPT_FILENAME'] = str_replace( '/index_treemenu.php', '/index.php', $_SERVER['SCRIPT_FILENAME'] );
$_SERVER['PHP_SELF'] = str_replace( '/index_treemenu.php', '/index.php', $_SERVER['PHP_SELF'] );

$ini = eZINI::instance();
$timezone = $ini->variable( 'TimeZoneSettings', 'TimeZone' );
if ( $timezone )
{
    putenv( "TZ=$timezone" );
}

// init uri code
$GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable( 'REQUEST_URI' );
eZSys::init( 'index.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) === 'true' );
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:31,代码来源:index_treemenu.php

示例3: connect

 function connect($server, $db, $user, $password, $socketPath, $charset = null, $port = false)
 {
     $connection = false;
     if ($socketPath !== false) {
         ini_set("mysqli.default_socket", $socketPath);
     }
     if ($this->UsePersistentConnection == true) {
         // Only supported on PHP 5.3 (mysqlnd)
         if (version_compare(PHP_VERSION, '5.3') > 0) {
             $this->Server = 'p:' . $this->Server;
         } else {
             eZDebug::writeWarning('mysqli only supports persistent connections when using php 5.3 and higher', __METHOD__);
         }
     }
     $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
     eZPerfLogger::accumulatorStart('mysqli_connection', 'mysqli_total', 'Database connection');
     try {
         $connection = mysqli_connect($server, $user, $password, null, (int) $port, $socketPath);
     } catch (ErrorException $e) {
     }
     eZPerfLogger::accumulatorStop('mysqli_connection');
     eZDebug::setHandleType($oldHandling);
     $maxAttempts = $this->connectRetryCount();
     $waitTime = $this->connectRetryWaitTime();
     $numAttempts = 1;
     while (!$connection && $numAttempts <= $maxAttempts) {
         sleep($waitTime);
         $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
         eZPerfLogger::accumulatorStart('mysqli_connection', 'mysqli_total', 'Database connection');
         try {
             $connection = mysqli_connect($this->Server, $this->User, $this->Password, null, (int) $this->Port, $this->SocketPath);
         } catch (ErrorException $e) {
         }
         eZPerfLogger::accumulatorStop('mysqli_connection');
         eZDebug::setHandleType($oldHandling);
         $numAttempts++;
     }
     $this->setError();
     $this->IsConnected = true;
     if (!$connection) {
         eZDebug::writeError("Connection error: Couldn't connect to database server. Please try again later or inform the system administrator.\n{$this->ErrorMessage}", __CLASS__);
         $this->IsConnected = false;
         throw new eZDBNoConnectionException($server, $this->ErrorMessage, $this->ErrorNumber);
     }
     if ($this->IsConnected && $db != null) {
         eZPerfLogger::accumulatorStart('mysqli_selectdb', 'mysqli_total', 'Database selection');
         $ret = mysqli_select_db($connection, $db);
         eZPerfLogger::accumulatorStop('mysqli_selectdb');
         if (!$ret) {
             $this->setError($connection);
             eZDebug::writeError("Connection error: Couldn't select the database. Please try again later or inform the system administrator.\n{$this->ErrorMessage}", __CLASS__);
             $this->IsConnected = false;
         }
     }
     if ($charset !== null) {
         $originalCharset = $charset;
         $charset = eZCharsetInfo::realCharsetCode($charset);
     }
     if ($this->IsConnected and $charset !== null) {
         eZPerfLogger::accumulatorStart('mysqli_setcharset', 'mysqli_total', 'Charset selection');
         $status = mysqli_set_charset($connection, eZMySQLCharset::mapTo($charset));
         eZPerfLogger::accumulatorStop('mysqli_setcharset');
         if (!$status) {
             $this->setError();
             eZDebug::writeWarning("Connection warning: " . mysqli_errno($connection) . ": " . mysqli_error($connection), "eZMySQLiDB");
         }
     }
     return $connection;
 }
开发者ID:gggeek,项目名称:ezperformancelogger,代码行数:69,代码来源:ezmysqlitracingdb.php

示例4: updateSettings

 static function updateSettings($settings)
 {
     // Make sure errors are handled by PHP when we read, including our own debug output.
     $oldHandleType = eZDebug::setHandleType(self::HANDLE_TO_PHP);
     if (isset($settings['debug-log-files-enabled'])) {
         $GLOBALS['eZDebugLogFileEnabled'] = $settings['debug-log-files-enabled'];
         if (isset($GLOBALS["eZDebugGlobalInstance"])) {
             $GLOBALS["eZDebugGlobalInstance"]->GlobalLogFileEnabled = $settings['debug-log-files-enabled'];
         }
     }
     if (isset($settings['debug-styles'])) {
         $GLOBALS['eZDebugStyles'] = $settings['debug-styles'];
     }
     if (isset($settings['always-log']) and is_array($settings['always-log'])) {
         $GLOBALS['eZDebugAlwaysLog'] = $settings['always-log'];
     }
     if (isset($settings['log-only'])) {
         $GLOBALS['eZDebugLogOnly'] = $settings['log-only'] == 'enabled';
     }
     $GLOBALS['eZDebugAllowedByIP'] = isset($settings['debug-by-ip']) && $settings['debug-by-ip'] ? self::isAllowedByCurrentIP($settings['debug-ip-list']) : true;
     // updateSettings is meant to be called before the user session is started
     // so we do not take debug-by-user into account yet, but store the debug-user-list in $GLOBALS
     // so it can be used in the final check, done by checkDebugByUser()
     if (isset($settings['debug-by-user']) && $settings['debug-by-user']) {
         $GLOBALS['eZDebugUserIDList'] = $settings['debug-user-list'] ? $settings['debug-user-list'] : array();
     }
     $GLOBALS['eZDebugAllowed'] = $GLOBALS['eZDebugAllowedByIP'];
     $GLOBALS['eZDebugEnabled'] = $settings['debug-enabled'] && $GLOBALS['eZDebugAllowedByIP'];
     eZDebug::setHandleType($oldHandleType);
 }
开发者ID:schwabokaner,项目名称:ezpublish-legacy,代码行数:30,代码来源:ezdebug.php

示例5: query

 function query($sql, $server = false)
 {
     if ($this->isConnected()) {
         eZDebug::accumulatorStart('postgresql_query', 'postgresql_total', 'Postgresql queries');
         if ($this->OutputSQL) {
             $this->startTimer();
         }
         // postgres will by default cast an error if a query fails
         // exception handling mode needs to catch this exception and set the $result variable to false
         if ($this->errorHandling == eZDB::ERROR_HANDLING_EXCEPTIONS) {
             $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
             try {
                 $result = pg_query($this->DBConnection, $sql);
             } catch (ErrorException $e) {
                 $result = false;
             }
             eZDebug::setHandleType($oldHandling);
         } else {
             $result = pg_query($this->DBConnection, $sql);
         }
         if ($this->OutputSQL) {
             $this->endTimer();
             if ($this->timeTaken() > $this->SlowSQLTimeout) {
                 $this->reportQuery('eZPostgreSQLDB', $sql, false, $this->timeTaken());
             }
         }
         eZDebug::accumulatorStop('postgresql_query');
         if (!$result) {
             $this->setError();
             eZDebug::writeError("Error: error executing query: {$sql}: {$this->ErrorMessage}", "eZPostgreSQLDB");
             if ($this->errorHandling == eZDB::ERROR_HANDLING_EXCEPTIONS) {
                 throw new eZDBException($this->ErrorMessage, $this->ErrorNumber);
             }
             $this->reportError();
         }
     } else {
         $result = false;
     }
     return $result;
 }
开发者ID:legende91,项目名称:ez,代码行数:40,代码来源:ezpostgresqldb.php

示例6: __construct

 /**
  * @param array $settings
  * @param null $responseWriterClass Name of the ezpRestHttpResponseWriter implementation to use during request
  */
 public function __construct(array $settings = array(), $responseWriterClass = null)
 {
     $this->responseWriterClass = $responseWriterClass;
     if (isset($settings['injected-settings'])) {
         $injectedSettings = array();
         foreach ($settings['injected-settings'] as $keySetting => $injectedSetting) {
             list($file, $section, $setting) = explode('/', $keySetting);
             $injectedSettings[$file][$section][$setting] = $injectedSetting;
         }
         // Those settings override anything else in local .ini files and their overrides
         eZINI::injectSettings($injectedSettings);
     }
     if (isset($settings['injected-merge-settings'])) {
         $injectedSettings = array();
         foreach ($settings['injected-merge-settings'] as $keySetting => $injectedSetting) {
             list($file, $section, $setting) = explode('/', $keySetting);
             $injectedSettings[$file][$section][$setting] = $injectedSetting;
         }
         // Those settings override anything else in local .ini files and their overrides
         eZINI::injectMergeSettings($injectedSettings);
     }
     $this->settings = $settings + array('use-cache-headers' => true, 'max-age' => 86400, 'siteaccess' => null, 'use-exceptions' => false);
     unset($settings, $injectedSettings, $file, $section, $setting, $keySetting, $injectedSetting);
     // lazy loaded database driver
     include __DIR__ . '/lazy.php';
     $this->setUseExceptions($this->settings['use-exceptions']);
     // Tweaks ini filetime checks if not defined!
     // This makes ini system not check modified time so
     // that index_treemenu.php can assume that index.php does
     // this regular enough, set in config.php to override.
     if (!defined('EZP_INI_FILEMTIME_CHECK')) {
         define('EZP_INI_FILEMTIME_CHECK', false);
     }
     eZExecution::addFatalErrorHandler(function () {
         if (!headers_sent()) {
             header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
         }
     });
     eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP);
     // Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs):
     $_SERVER['SCRIPT_FILENAME'] = str_replace('/index_rest.php', '/index.php', $_SERVER['SCRIPT_FILENAME']);
     $_SERVER['PHP_SELF'] = str_replace('/index_rest.php', '/index.php', $_SERVER['PHP_SELF']);
     $ini = eZINI::instance();
     $timezone = $ini->variable('TimeZoneSettings', 'TimeZone');
     if ($timezone) {
         putenv("TZ={$timezone}");
     }
     eZDebug::setHandleType(eZDebug::HANDLE_NONE);
     $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI');
     $ini = eZINI::instance();
     eZSys::init('index_rest.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') == 'true');
     $uri = eZURI::instance(eZSys::requestURI());
     $GLOBALS['eZRequestedURI'] = $uri;
     // load extensions
     eZExtension::activateExtensions('default');
     require_once __DIR__ . '/restkernel_functions.php';
     // set siteaccess from X-Siteaccess header if given and exists
     if (isset($_SERVER['HTTP_X_SITEACCESS']) && eZSiteAccess::exists($_SERVER['HTTP_X_SITEACCESS'])) {
         $access = array('name' => $_SERVER['HTTP_X_SITEACCESS'], 'type' => eZSiteAccess::TYPE_STATIC);
     } else {
         $access = eZSiteAccess::match($uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
     }
     eZSiteAccess::change($access);
     // load siteaccess extensions
     eZExtension::activateExtensions('access');
     // Now that all extensions are activated and siteaccess has been changed, reset
     // all eZINI instances as they may not take into account siteaccess specific settings.
     eZINI::resetAllInstances(false);
     if (ezpRestDebug::isDebugEnabled()) {
         $debug = ezpRestDebug::getInstance();
         $debug->updateDebugSettings();
     }
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:77,代码来源:ezpkernelrest.php

示例7: connect

    function connect( $server, $db, $user, $password, $socketPath, $charset = null, $port = false )
    {
        // if a port is specified, we add it to $server, this is how mysql_(p)connect accepts a port number
        if ( $port )
        {
            $server .= ':' . $port;
        }

        $connection = false;

        if ( $socketPath !== false )
        {
            ini_set( "mysql.default_socket", $socketPath );
        }

        $oldHandling = eZDebug::setHandleType( eZDebug::HANDLE_EXCEPTION );
        try {
            if ( $this->UsePersistentConnection == true )
            {
                $connection = mysql_pconnect( $server, $user, $password );
            }
            else
            {
                $connection = mysql_connect( $server, $user, $password, true );
            }
        } catch( ErrorException $e ) {}
        eZDebug::setHandleType( $oldHandling );

        $this->setError();
        $maxAttempts = $this->connectRetryCount();
        $waitTime = $this->connectRetryWaitTime();
        $numAttempts = 1;
        while ( !$connection && $numAttempts <= $maxAttempts )
        {
            sleep( $waitTime );
            $oldHandling = eZDebug::setHandleType( eZDebug::HANDLE_EXCEPTION );
            eZDebug::accumulatorStart( 'mysql_connection', 'mysql_total', 'Database connection' );
            try {
                if ( $this->UsePersistentConnection == true )
                {
                    $connection = mysql_pconnect( $this->Server, $this->User, $this->Password );
                }
                else
                {
                    $connection = mysql_connect( $this->Server, $this->User, $this->Password );
                }
            } catch( ErrorException $e ) {}
            eZDebug::accumulatorStop( 'mysql_connection' );
            eZDebug::setHandleType( $oldHandling );
            $numAttempts++;
        }
        $this->setError();

        $this->IsConnected = true;

        if ( !$connection )
        {
            eZDebug::writeError( "Connection error: Couldn't connect to database server. Please try again later or inform the system administrator.\n{$this->ErrorMessage}", __CLASS__ );
            $this->IsConnected = false;
            throw new eZDBNoConnectionException( $server, $this->ErrorMessage, $this->ErrorNumber );
        }

        if ( $this->IsConnected && $db != null )
        {
            $ret = mysql_select_db( $db, $connection );
            if ( !$ret )
            {
                $this->setError( $connection );
                eZDebug::writeError( "Connection error: Couldn't select the database. Please try again later or inform the system administrator.\n{$this->ErrorMessage}", __CLASS__ );
                $this->IsConnected = false;
            }
        }

        if ( $charset !== null )
        {
            $charset = eZCharsetInfo::realCharsetCode( $charset );
        }

        if ( $this->IsConnected and $charset !== null and $this->isCharsetSupported( $charset ) )
        {
            $query = "SET NAMES '" . eZMySQLCharset::mapTo( $charset ) . "'";
            $status = mysql_query( $query, $connection );
            $this->reportQuery( 'eZMySQLDB', $query, false, false, true );
            if ( !$status )
            {
                $this->setError();
                eZDebug::writeWarning( "Connection warning: " . mysql_errno( $connection ) . ": " . mysql_error( $connection ), "eZMySQLDB" );
            }
        }

        return $connection;
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:92,代码来源:ezmysqldb.php

示例8: eZUpdateDebugSettings

<?php

/**
 * File containing the rest bootstrap
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version //autogentag//
 * @package kernel
 */
require __DIR__ . '/autoload.php';
require __DIR__ . '/kernel/private/rest/classes/lazy.php';
// Below we are setting up a minimal eZ Publish environment from the old index.php
// This is a temporary measure.
// We want PHP to deal with all errors here.
eZDebug::setHandleType(eZDebug::HANDLE_TO_PHP);
$GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI');
$ini = eZINI::instance();
eZSys::init('index_rest.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') == 'true');
$uri = eZURI::instance(eZSys::requestURI());
$GLOBALS['eZRequestedURI'] = $uri;
// load extensions
eZExtension::activateExtensions('default');
// setup for eZSiteAccess:change() needs some methods defined in old index.php
// We disable it, since we dont' want any override settings to change the
// debug settings here
function eZUpdateDebugSettings()
{
}
// load siteaccess
$access = eZSiteAccess::match($uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
开发者ID:heliopsis,项目名称:ezpublish-legacy,代码行数:31,代码来源:index_rest.php

示例9: reportError

 /**
  * This is called whenever an error occurs in one of the database handlers.
  *
  * If a transaction is active it will be invalidated as well.
  *
  * @access protected
  * @throws eZDBException
  */
 function reportError()
 {
     // If we have a running transaction we must mark as invalid
     // in which case a call to commit() will perform a rollback
     if ($this->TransactionCounter > 0) {
         $this->invalidateTransaction();
         // This is the unique ID for this incidence which will also be placed in the error logs.
         $transID = 'TRANSID-' . md5(time() . mt_rand());
         eZDebug::writeError('Transaction in progress failed due to DB error, transaction was rollbacked. Transaction ID is ' . $transID . '.', 'eZDBInterface::commit ' . $transID);
         $this->rollback();
         if ($this->errorHandling == eZDB::ERROR_HANDLING_EXCEPTIONS) {
             throw new eZDBException($this->ErrorMessage, $this->ErrorNumber);
         } else {
             // Stop execution immediately while allowing other systems (session etc.) to cleanup
             eZExecution::cleanup();
             eZExecution::setCleanExit();
             // Give some feedback, and also possibly show the debug output
             eZDebug::setHandleType(eZDebug::HANDLE_NONE);
             $ini = eZINI::instance();
             $adminEmail = $ini->variable('MailSettings', 'AdminEmail');
             if (!eZSys::isShellExecution()) {
                 if (!headers_sent()) {
                     header("HTTP/1.1 500 Internal Server Error");
                 }
                 $site = eZSys::serverVariable('HTTP_HOST');
                 $uri = eZSys::serverVariable('REQUEST_URI');
                 print "<div class=\"fatal-error\" style=\"";
                 print 'margin: 0.5em 0 1em 0; ' . 'padding: 0.25em 1em 0.75em 1em;' . 'border: 4px solid #000000;' . 'background-color: #f8f8f4;' . 'border-color: #f95038;" >';
                 print "<b>Fatal error</b>: A database transaction in eZ Publish failed.<br/>";
                 print "<p>";
                 print "The current execution was stopped to prevent further problems.<br/>\n" . "You should contact the <a href=\"mailto:{$adminEmail}?subject=Transaction failed on {$site} and URI {$uri} with ID {$transID}\">System Administrator</a> of this site with the information on this page.<br/>\n" . "The current transaction ID is <b>{$transID}</b> and has been logged.<br/>\n" . "Please include the transaction ID and the current URL when contacting the system administrator.<br/>\n";
                 print "</p>";
                 print "</div>";
                 $templateResult = null;
                 if (function_exists('eZDisplayResult')) {
                     eZDisplayResult($templateResult);
                 }
             } else {
                 fputs(STDERR, "Fatal error: A database transaction in eZ Publish failed.\n");
                 fputs(STDERR, "\n");
                 fputs(STDERR, "The current execution was stopped to prevent further problems.\n" . "You should contact the System Administrator ({$adminEmail}) of this site.\n" . "The current transaction ID is {$transID} and has been logged.\n" . "Please include the transaction ID and the name of the current script when contacting the system administrator.\n");
                 fputs(STDERR, "\n");
                 fputs(STDERR, eZDebug::printReport(false, false, true));
             }
             // PHP execution stops here
             exit(1);
         }
     }
 }
开发者ID:netbliss,项目名称:ezpublish,代码行数:57,代码来源:ezdbinterface.php

示例10: initialize

 function initialize()
 {
     if (ob_get_length() != 0) {
         ob_end_clean();
     }
     $debugINI = eZINI::instance('debug.ini');
     eZDebugSetting::setDebugINI($debugINI);
     // Initialize text codec settings
     $this->updateTextCodecSettings();
     // Initialize debug settings
     $this->updateDebugSettings($this->UseDebugOutput);
     // Set the different permissions/settings.
     $ini = eZINI::instance();
     $iniFilePermission = $ini->variable('FileSettings', 'StorageFilePermissions');
     $iniDirPermission = $ini->variable('FileSettings', 'StorageDirPermissions');
     $iniVarDirectory = eZSys::cacheDirectory();
     eZCodePage::setPermissionSetting(array('file_permission' => octdec($iniFilePermission), 'dir_permission' => octdec($iniDirPermission), 'var_directory' => $iniVarDirectory));
     eZExecution::addCleanupHandler('eZDBCleanup');
     eZExecution::addFatalErrorHandler('eZFatalError');
     eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP);
     if ($this->UseExtensions) {
         // Check for extension
         eZExtension::activateExtensions('default');
         // Extension check end
     } else {
         if (!$this->isQuiet()) {
             $cli = eZCLI::instance();
             $cli->output("Notice: This script uses 'use-extensions' => false, meaning extension settings are not loaded!");
         }
     }
     $siteaccess = $this->SiteAccess;
     if ($siteaccess) {
         $access = array('name' => $siteaccess, 'type' => eZSiteAccess::TYPE_STATIC);
     } else {
         $ini = eZINI::instance();
         $siteaccess = $ini->variable('SiteSettings', 'DefaultAccess');
         $access = array('name' => $siteaccess, 'type' => eZSiteAccess::TYPE_DEFAULT);
     }
     $access = eZSiteAccess::change($access);
     if ($this->UseExtensions) {
         // Check for siteaccess extension
         eZExtension::activateExtensions('access');
         // Extension check end
     }
     // Now that all extensions are activated and siteaccess has been changed, reset
     // all eZINI instances as they may not take into account siteaccess specific settings.
     eZINI::resetAllInstances(false);
     // Set the global setting which is read by the session lib
     $GLOBALS['eZSiteBasics']['session-required'] = $this->UseSession;
     if ($this->UseSession) {
         $db = eZDB::instance();
         if ($db->isConnected()) {
             eZSession::start();
         } else {
             $this->setIsInitialized(false);
             $this->InitializationErrorMessage = 'database error: ' . $db->errorMessage();
             return;
         }
     }
     if ($this->User) {
         $userLogin = $this->User['login'];
         $userPassword = $this->User['password'];
         if ($userLogin and $userPassword) {
             $userID = eZUser::loginUser($userLogin, $userPassword);
             if (!$userID) {
                 $cli = eZCLI::instance();
                 if ($this->isLoud()) {
                     $cli->warning('Failed to login with user ' . $userLogin);
                 }
                 eZExecution::cleanup();
                 eZExecution::setCleanExit();
             }
         }
     }
     // Initialize module handling
     if ($this->UseModules) {
         $moduleRepositories = eZModule::activeModuleRepositories($this->UseExtensions);
         eZModule::setGlobalPathList($moduleRepositories);
     }
     $this->setIsInitialized(true);
 }
开发者ID:nlescure,项目名称:ezpublish,代码行数:81,代码来源:ezscript.php

示例11: __construct

 /**
  * Constructs an ezpKernel instance
  */
 public function __construct(array $settings = array())
 {
     $this->settings = $settings + array('siteaccess' => null, 'use-exceptions' => false, 'session' => null);
     unset($settings);
     require_once __DIR__ . '/global_functions.php';
     $this->setUseExceptions($this->settings['use-exceptions']);
     $GLOBALS['eZSiteBasics'] = array('external-css' => true, 'show-page-layout' => true, 'module-run-required' => true, 'policy-check-required' => true, 'policy-check-omit-list' => array(), 'url-translator-allowed' => true, 'validity-check-required' => false, 'user-object-required' => true, 'session-required' => true, 'db-required' => false, 'no-cache-adviced' => false, 'site-design-override' => false, 'module-repositories' => array());
     $this->siteBasics =& $GLOBALS['eZSiteBasics'];
     // Reads settings from i18n.ini and passes them to eZTextCodec.
     list($i18nSettings['internal-charset'], $i18nSettings['http-charset'], $i18nSettings['mbstring-extension']) = eZINI::instance('i18n.ini')->variableMulti('CharacterSettings', array('Charset', 'HTTPCharset', 'MBStringExtension'), array(false, false, 'enabled'));
     eZTextCodec::updateSettings($i18nSettings);
     // @todo Change so code only supports utf-8 in 5.0?
     // Initialize debug settings.
     eZUpdateDebugSettings();
     // Set the different permissions/settings.
     $ini = eZINI::instance();
     // Set correct site timezone
     $timezone = $ini->variable("TimeZoneSettings", "TimeZone");
     if ($timezone) {
         date_default_timezone_set($timezone);
     }
     list($iniFilePermission, $iniDirPermission) = $ini->variableMulti('FileSettings', array('StorageFilePermissions', 'StorageDirPermissions'));
     // OPTIMIZATION:
     // Sets permission array as global variable, this avoids the eZCodePage include
     $GLOBALS['EZCODEPAGEPERMISSIONS'] = array('file_permission' => octdec($iniFilePermission), 'dir_permission' => octdec($iniDirPermission), 'var_directory' => eZSys::cacheDirectory());
     unset($i18nSettings, $timezone, $iniFilePermission, $iniDirPermission);
     eZExecution::addCleanupHandler(function () {
         if (class_exists('eZDB', false) && eZDB::hasInstance()) {
             eZDB::instance()->setIsSQLOutputEnabled(false);
         }
     });
     eZExecution::addFatalErrorHandler(function () {
         header("HTTP/1.1 500 Internal Server Error");
         echo "<b>Fatal error</b>: The web server did not finish its request<br/>";
         if (ini_get('display_errors') == 1) {
             if (eZDebug::isDebugEnabled()) {
                 echo "<p>The execution of eZ Publish was abruptly ended, the debug output is present below.</p>";
             } else {
                 echo "<p>Debug information can be found in the log files normally placed in var/log/* or by enabling 'DebugOutput' in site.ini</p>";
             }
         } else {
             echo "<p>Contact website owner with current url and info on what you did, and owner will be able to debug the issue further (by enabling 'display_errors' in php.ini).</p>";
         }
         eZDisplayResult(null);
     });
     eZExecution::setCleanExit();
     // Enable this line to get eZINI debug output
     // eZINI::setIsDebugEnabled( true );
     // Enable this line to turn off ini caching
     // eZINI::setIsCacheEnabled( false);
     if ($ini->variable('RegionalSettings', 'Debug') === 'enabled') {
         eZLocale::setIsDebugEnabled(true);
     }
     eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP);
     $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI');
     // Initialize basic settings, such as vhless dirs and separators
     eZSys::init('index.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true');
     // Check for extension
     eZExtension::activateExtensions('default');
     // Extension check end
     // Use injected siteaccess if available or match it internally.
     $this->access = isset($this->settings['siteaccess']) ? $this->settings['siteaccess'] : eZSiteAccess::match(eZURI::instance(eZSys::requestURI()), eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
     eZSiteAccess::change($this->access);
     eZDebugSetting::writeDebug('kernel-siteaccess', $this->access, 'current siteaccess');
     // Check for siteaccess extension
     eZExtension::activateExtensions('access');
     // Siteaccess extension check end
     // Now that all extensions are activated and siteaccess has been changed, reset
     // all eZINI instances as they may not take into account siteaccess specific settings.
     eZINI::resetAllInstances(false);
     ezpEvent::getInstance()->registerEventListeners();
     $this->mobileDeviceDetect = new ezpMobileDeviceDetect(ezpMobileDeviceDetectFilter::getFilter());
     if ($this->mobileDeviceDetect->isEnabled()) {
         $this->mobileDeviceDetect->process();
         if ($this->mobileDeviceDetect->isMobileDevice()) {
             $this->mobileDeviceDetect->redirect();
         }
     }
     // eZSession::setSessionArray( $mainRequest->session );
     /**
      * Check for activating Debug by user ID (Final checking. The first was in eZDebug::updateSettings())
      * @uses eZUser::instance() So needs to be executed after eZSession::start()|lazyStart()
      */
     eZDebug::checkDebugByUser();
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:88,代码来源:ezpkernelweb.php

示例12: updateSettings

 static function updateSettings($settings)
 {
     // Make sure errors are handled by PHP when we read, including our own debug output.
     $oldHandleType = eZDebug::setHandleType(self::HANDLE_TO_PHP);
     if (isset($settings['debug-log-files-enabled'])) {
         $GLOBALS['eZDebugLogFileEnabled'] = $settings['debug-log-files-enabled'];
         if (isset($GLOBALS["eZDebugGlobalInstance"])) {
             $GLOBALS["eZDebugGlobalInstance"]->GlobalLogFileEnabled = $settings['debug-log-files-enabled'];
         }
     }
     if (isset($settings['debug-styles'])) {
         $GLOBALS['eZDebugStyles'] = $settings['debug-styles'];
     }
     if (isset($settings['always-log']) and is_array($settings['always-log'])) {
         $GLOBALS['eZDebugAlwaysLog'] = $settings['always-log'];
     }
     if (isset($settings['log-only'])) {
         $GLOBALS['eZDebugLogOnly'] = $settings['log-only'] == 'enabled';
     }
     $notDebugByIP = true;
     $debugEnabled = $settings['debug-enabled'];
     if ($settings['debug-enabled'] and $settings['debug-by-ip']) {
         $ipAddress = eZSys::serverVariable('REMOTE_ADDR', true);
         if ($ipAddress) {
             $debugEnabled = false;
             foreach ($settings['debug-ip-list'] as $itemToMatch) {
                 if (preg_match("/^(([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+))(\\/([0-9]+)\$|\$)/", $itemToMatch, $matches)) {
                     if ($matches[6]) {
                         if (eZDebug::isIPInNet($ipAddress, $matches[1], $matches[7])) {
                             $debugEnabled = true;
                             $notDebugByIP = false;
                             break;
                         }
                     } else {
                         if ($matches[1] == $ipAddress) {
                             $debugEnabled = true;
                             $notDebugByIP = false;
                             break;
                         }
                     }
                 }
             }
         } else {
             $debugEnabled = in_array('commandline', $settings['debug-ip-list']) && php_sapi_name() == 'cli';
         }
     }
     if ($settings['debug-enabled'] and isset($settings['debug-by-user']) and $settings['debug-by-user'] and $notDebugByIP) {
         $debugUserIDList = $settings['debug-user-list'] ? $settings['debug-user-list'] : array();
         $GLOBALS['eZDebugUserIDList'] = $debugUserIDList;
         // We enable the debug temporarily.
         // In checkDebugByUser() will be last(final) check for debug by user id.
         $debugEnabled = true;
     }
     $GLOBALS['eZDebugEnabled'] = $debugEnabled;
     eZDebug::setHandleType($oldHandleType);
 }
开发者ID:BGCX067,项目名称:ezfire-svn-to-git,代码行数:56,代码来源:ezdebug.php

示例13: __construct

 /**
  * Constructs an ezpKernel instance
  */
 public function __construct(array $settings = array())
 {
     if (isset($settings['injected-settings'])) {
         $injectedSettings = array();
         foreach ($settings['injected-settings'] as $keySetting => $injectedSetting) {
             list($file, $section, $setting) = explode('/', $keySetting);
             $injectedSettings[$file][$section][$setting] = $injectedSetting;
         }
         // Those settings override anything else in local .ini files and their overrides
         eZINI::injectSettings($injectedSettings);
     }
     if (isset($settings['injected-merge-settings'])) {
         $injectedSettings = array();
         foreach ($settings['injected-merge-settings'] as $keySetting => $injectedSetting) {
             list($file, $section, $setting) = explode('/', $keySetting);
             $injectedSettings[$file][$section][$setting] = $injectedSetting;
         }
         // Those settings override anything else in local .ini files and their overrides
         eZINI::injectMergeSettings($injectedSettings);
     }
     $this->settings = $settings + array('siteaccess' => null, 'use-exceptions' => false, 'session' => null, 'service-container' => null);
     unset($settings, $injectedSettings, $file, $section, $setting, $keySetting, $injectedSetting);
     require_once __DIR__ . '/global_functions.php';
     $this->setUseExceptions($this->settings['use-exceptions']);
     $GLOBALS['eZSiteBasics'] = array('external-css' => true, 'show-page-layout' => true, 'module-run-required' => true, 'policy-check-required' => true, 'policy-check-omit-list' => array(), 'url-translator-allowed' => true, 'validity-check-required' => false, 'user-object-required' => true, 'session-required' => true, 'db-required' => false, 'no-cache-adviced' => false, 'site-design-override' => false, 'module-repositories' => array());
     $this->siteBasics =& $GLOBALS['eZSiteBasics'];
     // Reads settings from i18n.ini and passes them to eZTextCodec.
     list($i18nSettings['internal-charset'], $i18nSettings['http-charset'], $i18nSettings['mbstring-extension']) = eZINI::instance('i18n.ini')->variableMulti('CharacterSettings', array('Charset', 'HTTPCharset', 'MBStringExtension'), array(false, false, 'enabled'));
     eZTextCodec::updateSettings($i18nSettings);
     // @todo Change so code only supports utf-8 in 5.0?
     // Initialize debug settings.
     eZUpdateDebugSettings();
     // Set the different permissions/settings.
     $ini = eZINI::instance();
     // Set correct site timezone
     $timezone = $ini->variable("TimeZoneSettings", "TimeZone");
     if ($timezone) {
         date_default_timezone_set($timezone);
     }
     list($iniFilePermission, $iniDirPermission) = $ini->variableMulti('FileSettings', array('StorageFilePermissions', 'StorageDirPermissions'));
     // OPTIMIZATION:
     // Sets permission array as global variable, this avoids the eZCodePage include
     $GLOBALS['EZCODEPAGEPERMISSIONS'] = array('file_permission' => octdec($iniFilePermission), 'dir_permission' => octdec($iniDirPermission), 'var_directory' => eZSys::cacheDirectory());
     unset($i18nSettings, $timezone, $iniFilePermission, $iniDirPermission);
     eZExecution::addCleanupHandler(function () {
         if (class_exists('eZDB', false) && eZDB::hasInstance()) {
             eZDB::instance()->setIsSQLOutputEnabled(false);
         }
     });
     // Sets up the FatalErrorHandler
     $this->setupFatalErrorHandler();
     // Enable this line to get eZINI debug output
     // eZINI::setIsDebugEnabled( true );
     // Enable this line to turn off ini caching
     // eZINI::setIsCacheEnabled( false);
     if ($ini->variable('RegionalSettings', 'Debug') === 'enabled') {
         eZLocale::setIsDebugEnabled(true);
     }
     eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP);
     $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI');
     // Initialize basic settings, such as vhless dirs and separators
     if ($this->hasServiceContainer() && $this->getServiceContainer()->has('request')) {
         eZSys::init(basename($this->getServiceContainer()->get('request')->server->get('SCRIPT_FILENAME')), $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true');
     } else {
         eZSys::init('index.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true');
     }
     // Check for extension
     eZExtension::activateExtensions('default');
     // Extension check end
     // Use injected siteaccess if available or match it internally.
     $this->access = isset($this->settings['siteaccess']) ? $this->settings['siteaccess'] : eZSiteAccess::match(eZURI::instance(eZSys::requestURI()), eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
     eZSiteAccess::change($this->access);
     eZDebugSetting::writeDebug('kernel-siteaccess', $this->access, 'current siteaccess');
     // Check for siteaccess extension
     eZExtension::activateExtensions('access');
     // Siteaccess extension check end
     // Now that all extensions are activated and siteaccess has been changed, reset
     // all eZINI instances as they may not take into account siteaccess specific settings.
     eZINI::resetAllInstances(false);
     ezpEvent::getInstance()->registerEventListeners();
     $this->mobileDeviceDetect = new ezpMobileDeviceDetect(ezpMobileDeviceDetectFilter::getFilter());
     // eZSession::setSessionArray( $mainRequest->session );
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:86,代码来源:ezpkernelweb.php

示例14: eZUpdateDebugSettings

/**
 * File containing the rest bootstrap
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version //autogentag//
 * @package kernel
 */

require __DIR__ . '/autoload.php';
require __DIR__ . '/kernel/private/rest/classes/lazy.php';

// Below we are setting up a minimal eZ Publish environment from the old index.php
// This is a temporary measure.

eZDebug::setHandleType( eZDebug::HANDLE_NONE );
$GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable( 'REQUEST_URI' );
$ini = eZINI::instance();
eZSys::init( 'index_rest.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) == 'true' );
$uri = eZURI::instance( eZSys::requestURI() );
$GLOBALS['eZRequestedURI'] = $uri;

// load extensions
eZExtension::activateExtensions( 'default' );

// setup for eZSiteAccess:change() needs some functions defined in old index.php
function eZUpdateDebugSettings()
{
    $ini = eZINI::instance();
    $debugSettings = array( 'debug-enabled' => false );
    $logList = $ini->variable( 'DebugSettings', 'AlwaysLog' );
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:31,代码来源:index_rest.php

示例15: eZOracleTracing50DB

 /**
  * Creates a new eZOracleDB object and connects to the database.
  */
 function eZOracleTracing50DB($parameters)
 {
     $this->eZDBInterface($parameters);
     if (!extension_loaded('oci8')) {
         if (function_exists('eZAppendWarningItem')) {
             eZAppendWarningItem(array('error' => array('type' => 'ezdb', 'number' => eZDBInterface::ERROR_MISSING_EXTENSION), 'text' => 'Oracle extension was not found, the DB handler will not be initialized.'));
             $this->IsConnected = false;
         }
         eZDebug::writeWarning('Oracle extension was not found, the DB handler will not be initialized.', 'eZOracleDB');
         return;
     }
     //$server = $this->Server;
     $user = $this->User;
     $password = $this->Password;
     $db = $this->DB;
     $this->ErrorMessage = false;
     $this->ErrorNumber = false;
     $this->IgnoreTriggerErrors = false;
     $ini = eZINI::instance();
     if (function_exists("oci_connect")) {
         $this->Mode = OCI_COMMIT_ON_SUCCESS;
         // translate chosen charset to its Oracle analogue
         $oraCharset = null;
         if (isset($this->Charset) && $this->Charset !== '') {
             if (array_key_exists($this->Charset, $this->CharsetsMap)) {
                 $oraCharset = $this->CharsetsMap[$this->Charset];
             }
         }
         $maxAttempts = $this->connectRetryCount();
         $waitTime = $this->connectRetryWaitTime();
         $numAttempts = 1;
         if ($ini->variable("DatabaseSettings", "UsePersistentConnection") == "enabled") {
             eZDebugSetting::writeDebug('kernel-db-oracle', $ini->variable("DatabaseSettings", "UsePersistentConnection"), "using persistent connection");
             eZPerfLogger::accumulatorStart('oracle_connection', 'oracle_total', 'Database connection');
             $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
             try {
                 $this->DBConnection = oci_pconnect($user, $password, $db, $oraCharset);
             } catch (ErrorException $e) {
             }
             eZPerfLogger::accumulatorStop('oracle_connection');
             eZDebug::setHandleType($oldHandling);
             while ($this->DBConnection == false and $numAttempts <= $maxAttempts) {
                 sleep($waitTime);
                 eZPerfLogger::accumulatorStart('oracle_connection', 'oracle_total', 'Database connection');
                 $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
                 try {
                     $this->DBConnection = oci_pconnect($user, $password, $db, $oraCharset);
                 } catch (ErrorException $e) {
                 }
                 eZPerfLogger::accumulatorStop('oracle_connection');
                 eZDebug::setHandleType($oldHandling);
                 $numAttempts++;
             }
         } else {
             eZDebugSetting::writeDebug('kernel-db-oracle', "using real connection", "using real connection");
             $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
             eZPerfLogger::accumulatorStart('oracle_connection', 'oracle_total', 'Database connection');
             try {
                 $this->DBConnection = oci_connect($user, $password, $db, $oraCharset);
             } catch (ErrorException $e) {
             }
             eZPerfLogger::accumulatorStop('oracle_connection');
             eZDebug::setHandleType($oldHandling);
             while ($this->DBConnection == false and $numAttempts <= $maxAttempts) {
                 sleep($waitTime);
                 $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
                 eZPerfLogger::accumulatorStart('oracle_connection', 'oracle_total', 'Database connection');
                 try {
                     $this->DBConnection = @oci_connect($user, $password, $db, $oraCharset);
                 } catch (ErrorException $e) {
                 }
                 eZPerfLogger::accumulatorStop('oracle_connection');
                 eZDebug::setHandleType($oldHandling);
                 $numAttempts++;
             }
         }
         //            OCIInternalDebug(1);
         if ($this->DBConnection === false) {
             $this->IsConnected = false;
         } else {
             $this->IsConnected = true;
             // make sure the decimal separator is the dot
             $this->query("ALTER SESSION SET NLS_NUMERIC_CHARACTERS='. '");
         }
         if ($this->DBConnection === false) {
             $error = oci_error();
             // workaround for bug in PHP oci8 extension
             if ($error === false && !getenv("ORACLE_HOME")) {
                 $error = array('code' => -1, 'message' => 'ORACLE_HOME environment variable is not set');
             }
             if ($error['code'] != 0) {
                 if ($error['code'] == 12541) {
                     $error['message'] = 'No listener (probably the server is down).';
                 }
                 $this->ErrorMessage = $error['message'];
                 $this->ErrorNumber = $error['code'];
                 eZDebug::writeError("Connection error(" . $error["code"] . "):\n" . $error["message"] . " ", "eZOracleDB");
//.........这里部分代码省略.........
开发者ID:gggeek,项目名称:ezperformancelogger,代码行数:101,代码来源:ezoracletracingdb.php


注:本文中的eZDebug::setHandleType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。