Ejemplo n.º 1
0
 public function tearDown()
 {
     parent::tearDown();
     Log::unsetInstance();
     @unlink(self::getLogFileLocation());
     Error::$debugBacktraceForTests = ExceptionHandler::$debugBacktraceForTests = null;
 }
Ejemplo n.º 2
0
/**
 * Piwik - free/libre analytics platform
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 * @package Piwik
 */
use Piwik\Error;
use Piwik\ExceptionHandler;
use Piwik\FrontController;
use Piwik\Plugin\ControllerAdmin as PluginControllerAdmin;
PluginControllerAdmin::disableEacceleratorIfEnabled();
if (!defined('PIWIK_ENABLE_ERROR_HANDLER') || PIWIK_ENABLE_ERROR_HANDLER) {
    require_once PIWIK_INCLUDE_PATH . '/core/Error.php';
    Error::setErrorHandler();
    require_once PIWIK_INCLUDE_PATH . '/core/ExceptionHandler.php';
    ExceptionHandler::setUp();
}
FrontController::setUpSafeMode();
if (!defined('PIWIK_ENABLE_DISPATCH')) {
    define('PIWIK_ENABLE_DISPATCH', true);
}
if (PIWIK_ENABLE_DISPATCH) {
    $controller = FrontController::getInstance();
    $controller->init();
    $response = $controller->dispatch();
    if (is_array($response)) {
        var_export($response);
    } elseif (!is_null($response)) {
        echo $response;
Ejemplo n.º 3
0
require_once PIWIK_INCLUDE_PATH . '/core/Tracker/Request.php';
require_once PIWIK_INCLUDE_PATH . '/core/Tracker/Referrer.php';
require_once PIWIK_INCLUDE_PATH . '/core/Tracker/VisitExcluded.php';
require_once PIWIK_INCLUDE_PATH . '/core/Tracker/VisitorNotFoundInDb.php';
require_once PIWIK_INCLUDE_PATH . '/core/CacheFile.php';
require_once PIWIK_INCLUDE_PATH . '/core/Filesystem.php';
require_once PIWIK_INCLUDE_PATH . '/core/Cookie.php';
session_cache_limiter('nocache');
@date_default_timezone_set('UTC');
if (!defined('PIWIK_ENABLE_TRACKING') || PIWIK_ENABLE_TRACKING) {
    ob_start();
}
if ($GLOBALS['PIWIK_TRACKER_DEBUG'] === true) {
    require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
    require_once PIWIK_INCLUDE_PATH . '/core/Error.php';
    \Piwik\Error::setErrorHandler();
    require_once PIWIK_INCLUDE_PATH . '/core/ExceptionHandler.php';
    \Piwik\ExceptionHandler::setUp();
    $timer = new Timer();
    Common::printDebug("Debug enabled - Input parameters: <br/>" . var_export($_GET, true));
    \Piwik\Tracker\Db::enableProfiling();
    \Piwik\FrontController::createConfigObject();
}
if (!defined('PIWIK_ENABLE_TRACKING') || PIWIK_ENABLE_TRACKING) {
    $process = new Tracker();
    try {
        $process->main();
    } catch (Exception $e) {
        echo "Error:" . $e->getMessage();
    }
    ob_end_flush();
Ejemplo n.º 4
0
 public static function formatScreenMessage(&$message, $level, $tag, $datetime, $log)
 {
     if ($message instanceof Error) {
         $errno = $message->errno & error_reporting();
         // problem when using error_reporting with the @ silent fail operator
         // it gives an errno 0, and in this case the objective is to NOT display anything on the screen!
         // is there any other case where the errno is zero at this point?
         if ($errno == 0) {
             $message = false;
             return;
         }
         Common::sendHeader('Content-Type: text/html; charset=utf-8');
         $htmlString = '';
         $htmlString .= "\n<div style='word-wrap: break-word; border: 3px solid red; padding:4px; width:70%; background-color:#FFFF96;'>\n        <strong>There is an error. Please report the message (Piwik " . (class_exists('Piwik\\Version') ? Version::VERSION : '') . ")\n        and full backtrace in the <a href='?module=Proxy&action=redirect&url=http://forum.piwik.org' target='_blank'>Piwik forums</a> (please do a Search first as it might have been reported already!).<br /><br/>\n        ";
         $htmlString .= Error::getErrNoString($message->errno);
         $htmlString .= ":</strong> <em>{$message->errstr}</em> in <strong>{$message->errfile}</strong>";
         $htmlString .= " on line <strong>{$message->errline}</strong>\n";
         $htmlString .= "<br /><br />Backtrace --&gt;<div style=\"font-family:Courier;font-size:10pt\"><br />\n";
         $htmlString .= str_replace("\n", "<br />\n", $message->backtrace);
         $htmlString .= "</div><br />";
         $htmlString .= "\n </pre></div><br />";
         $message = $htmlString;
     }
 }