Esempio n. 1
0
 /**
  * Handle exceptions
  * @param $exception
  */
 public function handleException($exception)
 {
     if ($this->getRollbar()->enabled) {
         \Rollbar::report_exception($exception);
     }
     parent::handleException($exception);
 }
Esempio n. 2
0
 public function onBootstrap(MvcEvent $e)
 {
     $application = $e->getApplication();
     $eventManager = $application->getEventManager();
     $serviceManager = $application->getServiceManager();
     $config = $serviceManager->get('Config');
     if (!isset($config['eye4web']['zf2rollbar'])) {
         throw new \Exception('Rollbar configuration missing. Please copy .dist config file into your autoloader directory.');
     }
     $rollbarConfig = $config['eye4web']['zf2rollbar'];
     if ($serviceManager->has('zfcuser_auth_service')) {
         $authService = $serviceManager->get('zfcuser_auth_service');
         if ($authService->hasIdentity()) {
             $user = $authService->getIdentity();
             $rollbarConfig['person'] = ['id' => $user->getId(), 'email' => $user->getEmail(), 'username' => $user->getDisplayName()];
         }
     }
     \Rollbar::init($rollbarConfig, $set_exception_handler = false, $set_error_handler = true);
     $eventManager->attach('dispatch.error', function ($event) {
         $exception = $event->getResult()->exception;
         if ($exception) {
             \Rollbar::report_exception($exception);
         }
     });
     $eventManager->attach('render.error', function ($event) {
         $exception = $event->getResult()->exception;
         if ($exception) {
             \Rollbar::report_exception($exception);
         }
     });
 }
Esempio n. 3
0
 public static function init($config = array(), $set_exception_handler = true, $set_error_handler = true, $report_fatal_errors = true)
 {
     // Heroku support
     // Use env vars for configuration, if set
     if (isset($_ENV['ROLLBAR_ACCESS_TOKEN']) && !isset($config['access_token'])) {
         $config['access_token'] = $_ENV['ROLLBAR_ACCESS_TOKEN'];
     }
     if (isset($_ENV['ROLLBAR_ENDPOINT']) && !isset($config['endpoint'])) {
         $config['endpoint'] = $_ENV['ROLLBAR_ENDPOINT'];
     }
     if (isset($_ENV['HEROKU_APP_DIR']) && !isset($config['root'])) {
         $config['root'] = $_ENV['HEROKU_APP_DIR'];
     }
     self::$instance = new RollbarNotifier($config);
     if ($set_exception_handler) {
         set_exception_handler('Rollbar::report_exception');
     }
     if ($set_error_handler) {
         set_error_handler('Rollbar::report_php_error');
     }
     if ($report_fatal_errors) {
         register_shutdown_function('Rollbar::report_fatal_error');
     }
     if (self::$instance->batched) {
         register_shutdown_function('Rollbar::flush');
     }
 }
 public function initialize()
 {
     // Only initialise rollbar if it's been installed.
     if (class_exists('Rollbar')) {
         \Rollbar::init($this->getConfig());
     }
 }
Esempio n. 5
0
 public function log(IEvent $e)
 {
     $level = $e->getStr('level');
     if (Log::logLevelAllowed($level, $this->_logLevel)) {
         // "critical", "error", "warning", "info", "debug"
         switch ($level) {
             case LogLevel::EMERGENCY:
             case LogLevel::ALERT:
             case LogLevel::CRITICAL:
                 $level = 'critical';
                 break;
             case LogLevel::ERROR:
                 $level = 'error';
                 break;
             case LogLevel::WARNING:
                 $level = 'warning';
                 break;
             case LogLevel::DEBUG:
                 $level = 'debug';
                 break;
             case LogLevel::NOTICE:
             case LogLevel::INFO:
             default:
                 $level = 'info';
                 break;
         }
         $data = ['file' => $e->getStr('file'), 'line' => $e->getStr('line'), 'context' => $e->getArr('context')];
         if (CUBEX_CLI) {
             $data['cli_command'] = implode(' ', $_SERVER['argv']);
         }
         \Rollbar::report_message($e->getStr('message'), $level, $data);
     }
 }
Esempio n. 6
0
 public function testScrub()
 {
     Rollbar::init(self::$simpleConfig);
     $method = new ReflectionMethod(get_class(Rollbar::$instance), 'scrub_request_params');
     $method->setAccessible(true);
     Rollbar::$instance->scrub_fields = array('secret', 'scrubme');
     $this->assertEquals($method->invoke(Rollbar::$instance, array('some_item', 'apples' => array('green', 'red'), 'bananas' => array('yellow'), 'secret' => 'shh', 'a' => array('b' => array('secret' => 'deep', 'scrubme' => 'secrets')))), array('some_item', 'apples' => array('green', 'red'), 'bananas' => array('yellow'), 'secret' => '***', 'a' => array('b' => array('secret' => '****', 'scrubme' => '*******'))));
 }
function errorHandler($n, $m, $f, $l)
{
    require_once 'errorsend.php';
    $config = array('access_token' => 'a4073d551fb44087b5ebeea61588bbc4', 'environment' => 'production', 'root' => $_SERVER['DOCUMENT_ROOT']);
    Rollbar::init($config);
    Rollbar::report_message($m, 'error');
    $str = 'phperror.php?n=' . urlencode($n) . '&m=' . urlencode($m) . '&f=' . urlencode($f) . '&l=' . urlencode($l);
    header('Location: ' . $str);
}
 protected function processLogs($logs)
 {
     foreach ($logs as $log) {
         // Exclude records by the exceptions handler. RollbarErrorHandler takes care of them.
         if (strncmp($log[2], 'exception', 9) !== 0) {
             Rollbar::report_message($log[0], $this->correspondingLevel($log[1]));
         }
     }
 }
Esempio n. 9
0
 public function testFlush()
 {
     Rollbar::init(self::$simpleConfig);
     $this->assertEquals(0, Rollbar::$instance->queueSize());
     Rollbar::report_message("Hello world");
     $this->assertEquals(1, Rollbar::$instance->queueSize());
     Rollbar::flush();
     $this->assertEquals(0, Rollbar::$instance->queueSize());
 }
Esempio n. 10
0
 /**
  * Report or log an exception.
  *
  * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
  *
  * @param \Exception $e
  *
  * @return void
  */
 public function report(Exception $e)
 {
     parent::report($e);
     if (app()->environment() === 'local') {
         return;
     }
     if ($this->isHttpException($e)) {
         return;
     }
     \Rollbar::init(['environment' => app()->environment()]);
     \Rollbar::report_exception($e);
 }
Esempio n. 11
0
 /**
  * Create a new controller instance.
  * @return void
  */
 public function __construct()
 {
     // Instanciate the middleware auth
     $this->middleware('auth');
     // installs global error and exception handlers
     \Rollbar::init(array('access_token' => env('ROLLBAR_ACCESS_TOKEN')));
     // Check if user is logged in
     if (\Auth::check()) {
         // if user is logged in, run the 'getUsersRole' method
         $this->role = $this->getUsersRole(\Auth::user()->id);
     }
 }
Esempio n. 12
0
 /**
  * Initialize Rollbar.
  */
 public function init()
 {
     // Require Rollbar vendor code
     require_once __DIR__ . '/vendor/autoload.php';
     // Initialize Rollbar
     \Rollbar::init(array('access_token' => craft()->config->get('accessToken', 'rollbar'), 'environment' => CRAFT_ENVIRONMENT), false, false);
     // Log Craft Exceptions to Rollbar
     craft()->onException = function ($event) {
         \Rollbar::report_exception($event->exception);
     };
     // Log Craft Errors to Rollbar
     craft()->onError = function ($event) {
         \Rollbar::report_message($event->message);
     };
 }
Esempio n. 13
0
 public static function init($config, $set_exception_handler = true, $set_error_handler = true, $report_fatal_errors = true)
 {
     self::$instance = new RollbarNotifier($config);
     if ($set_exception_handler) {
         set_exception_handler('Rollbar::report_exception');
     }
     if ($set_error_handler) {
         set_error_handler('Rollbar::report_php_error');
     }
     if ($report_fatal_errors) {
         register_shutdown_function('Rollbar::report_fatal_error');
     }
     if (self::$instance->batched) {
         register_shutdown_function('Rollbar::flush');
     }
 }
Esempio n. 14
0
 private function reportRollbar($logEntry)
 {
     if ($this->rollbarEnabled && $logEntry['severity'] <= WATCHDOG_ERROR) {
         switch ($logEntry['severity']) {
             case WATCHDOG_ERROR:
                 $severity = 'error';
                 break;
             case WATCHDOG_EMERGENCY:
             case WATCHDOG_ALERT:
             case WATCHDOg_CRITICAL:
                 $severity = 'critical';
                 break;
         }
         $message = self::formatMessage($logEntry);
         Rollbar::report_message($message, $severity);
     }
 }
Esempio n. 15
0
function rollbar_initialize()
{
    // If logging is not enabled, exit immediately.
    $str_is_logging_enabled = rollbar_is_logging_enabled();
    if ($str_is_logging_enabled == false) {
        return;
    }
    $str_access_token = rollbar_get_access_token();
    if ($str_access_token == '') {
        return;
    }
    $str_environment = rollbar_get_environment();
    $int_logging_level = get_option('rollbar_logging_level', '1024');
    if (strlen($str_access_token) > 0) {
        Rollbar::init(array('access_token' => $str_access_token, 'environment' => $str_environment, 'root' => ABSPATH, 'max_errno' => $int_logging_level));
    }
}
Esempio n. 16
0
 public function init()
 {
     $this->enabled = $this->enabled !== false;
     if ($this->enabled === true) {
         if (empty($this->accessToken)) {
             throw new \yii\base\InvalidConfigException(sprintf('`rollbar\\Component::%s` must be specified.', 'accessToken'));
         }
         $logger = $this->logger;
         if (!$logger instanceof \iRollbarLogger && $this->useLogger === true) {
             $logger = new Logger();
         }
         $agentLogLocation = \Yii::getAlias($this->agentLogLocation);
         if (!empty($agentLogLocation)) {
             \yii\helpers\FileHelper::createDirectory($agentLogLocation);
         }
         $config = ['access_token' => $this->accessToken, 'agent_log_location' => $agentLogLocation, 'base_api_url' => $this->baseApiUrl, 'batch_size' => $this->batchSize, 'batched' => $this->batched, 'branch' => $this->branch, 'capture_error_stacktraces' => $this->captureErrorStacktraces, 'code_version' => $this->codeVersion, 'environment' => $this->environment, 'error_sample_rates' => $this->errorSampleRates, 'handler' => $this->handler, 'host' => $this->host, 'included_errno' => $this->includedErrno, 'logger' => $logger, 'person' => $this->person, 'person_fn' => $this->personFn, 'root' => \Yii::getAlias($this->root), 'scrub_fields' => $this->scrubFields, 'shift_function' => $this->shiftFunction, 'timeout' => $this->timeout, 'report_suppressed' => $this->reportSuppressed, 'use_error_reporting' => $this->useErrorReporting, 'proxy' => $this->proxy];
         \Rollbar::init($config, $this->setExceptionHandler, $this->setErrorHandler, $this->reportFatalErrors);
     }
     parent::init();
 }
Esempio n. 17
0
function main()
{
    $config = array('access_token' => 'ad865e76e7fb496fab096ac07b1dbabb', 'environment' => 'test', 'root' => '/Users/brian/www/rollbar-php', 'logger' => new EchoLogger(), 'error_sample_rates' => array(E_NOTICE => 0.5, E_USER_ERROR => 1, E_USER_NOTICE => 0.5), 'person_fn' => 'get_current_person', 'included_errno' => E_USER_ERROR | E_USER_NOTICE);
    // $config, $set_exception_handler, $set_error_handler
    Rollbar::init($config, true, true);
    try {
        throw_test_exception("yo");
    } catch (Exception $e) {
        Rollbar::report_exception($e);
    }
    Rollbar::report_message("hey there", "info");
    Rollbar::report_message("hey there", "info", array("extra" => "data"), array("fingerprint" => "test fingerprint", "title" => "test title"));
    trigger_error("test user warning", E_USER_WARNING);
    trigger_error("test user notice", E_USER_NOTICE);
    trigger_error("test user error", E_USER_ERROR);
    // raises an E_NOTICE, reported by the error handler
    $foo = $bar2;
    // reported by the exception handler
    throw new Exception("uncaught exception");
}
Esempio n. 18
0
<?php

if (file_exists('../install')) {
    echo 'Please Delete Install Directiory';
    die;
}
session_start();
include 'functions/rollbar.php';
$config = ['access_token' => '8545589ebc374e4ca8e70db5d302c0f4', 'environment' => 'test'];
$set_exception_handler = false;
$set_error_handler = false;
Rollbar::init($config, $set_exception_handler, $set_error_handler);
if (!isset($_SESSION['username'])) {
    header('Location: index.php');
    die;
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <title>poKe Dashboard</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.css" rel="stylesheet">
<script src="js/tether.js"></script>
<script src="js/uikit.js"></script>
    <!-- Custom styles for this template -->
Esempio n. 19
0
 * - consumerKey: The "consumer token" given to you when registering your app
 * - consumerSecret: The "secret token" given to you when registering your app
 * - localPassphrase: The (base64 encoded) key used for encrypting cookie content
 * - jpegtranPath: Path to jpegtran
 * - rollbarToken: Token for the Rollbar service
 * - rollbarEnv: Rollbar environment
 */
$configFile = '../config.ini';
$config = parse_ini_file($configFile);
if ($config === false) {
    header("HTTP/1.1 500 Internal Server Error");
    echo 'The ini file could not be read';
    exit(0);
}
if (isset($config['rollbarToken'])) {
    Rollbar::init(array('access_token' => $config['rollbarToken'], 'environment' => $config['rollbarEnv']));
}
// create a log channel
$logfile = dirname(dirname(__FILE__)) . '/logs/croptool.log';
if (!file_exists($logfile)) {
    @touch($logfile);
}
if (!is_writable($logfile)) {
    header("HTTP/1.1 500 Internal Server Error");
    die("Log file " . $logfile . " is not writable");
}
$log = new Logger('croptool');
$log->pushHandler(new StreamHandler($logfile, Logger::INFO));
function shutdown()
{
    $error = error_get_last();
Esempio n. 20
0
 public function init()
 {
     Rollbar::init(array('access_token' => $this->accessToken, 'environment' => $this->environment, 'branch' => $this->branch, 'code_version' => $this->code_version, 'host' => $this->host, 'batched' => $this->batched, 'batch_size' => $this->batchSize, 'timeout' => $this->timeout, 'logger' => $this->logger, 'included_errno' => $this->includedErrno, 'base_api_url' => $this->baseApiUrl, 'root' => !empty($this->rootAlias) ? Yii::getPathOfAlias($this->rootAlias) : '', 'scrub_fields' => $this->scrubFields), false, false);
     parent::init();
 }
Esempio n. 21
0
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function __construct()
 {
     // installs global error and exception handlers
     \Rollbar::init(array('access_token' => env('ROLLBAR_ACCESS_TOKEN')));
 }
Esempio n. 22
0
 public function flush()
 {
     \Rollbar::flush();
 }
Esempio n. 23
0
    {
        echo "<hr />";
        echo "<b>paymentListWithDates</b><br/><br/>";
        $response = $client->Charity->paymentsListWithDates(183731, "2015-05-20", "2015-05-29");
        echo '<pre>';
        print_r($response);
        echo '</pre><p>';
        foreach ($response as $key => $object) {
            echo "Date: " . $object->PaymentDate . "Ref: " . $object->PaymentRef . "<br/>";
        }
        $paymentRefData = array("Mike", "John", "Jane", "Sam");
        echo '<pre>';
        print_r($paymentRefData);
        echo '</pre><p>';
    }
}
///############### RUN TESTS
include_once '../JustGivingClient.php';
include_once 'TestContextCRM.php';
require_once 'rollbar.php';
Rollbar::init(array('environment' => 'production'));
$testContextCRM = new TestContextCRM();
$client = new JustGivingClient($testContextCRM->ApiLocation, $testContextCRM->ApiKey, $testContextCRM->ApiVersion, $testContextCRM->TestUsername, $testContextCRM->TestValidPassword);
$client->debug = $testContextCRM->Debug;
function WriteLine($string)
{
    echo $string . "<br/>";
}
echo "<h1>Executing...</h1>";
$tests = new CharityApiTests();
$tests->paymentListWithDates($client);
 /**
  * Handles & reports fatal PHP errors that are causing the shutdown
  */
 public function handleFatalError()
 {
     \Rollbar::report_fatal_error();
     parent::handleFatalError();
 }
Esempio n. 25
0
 public function init()
 {
     \Rollbar::init(['access_token' => $this->accessToken, 'environment' => $this->environment, 'branch' => $this->branch, 'batched' => $this->batched, 'batch_size' => $this->batchSize, 'timeout' => $this->timeout, 'logger' => $this->logger, 'max_errno' => $this->maxErrno, 'base_api_url' => $this->baseApiUrl, 'root' => !empty($this->rootAlias) ? \Yii::getAlias($this->rootAlias) : ''], false, false);
     parent::init();
 }
Esempio n. 26
0
        // Web requests
        if (!preg_match(';^(.*\\.|)[^.]+\\.[^.]{2,}$;i', $_SERVER['HTTP_HOST'])) {
            newrelic_ignore_transaction();
        } else {
            newrelic_set_appname($_SERVER['HTTP_HOST']);
            newrelic_capture_params();
            $baseURI = preg_replace(';[?&#].*;', '', $_SERVER['REQUEST_URI']);
            if ($baseURI != '/' && $baseURI != '') {
                newrelic_name_transaction($baseURI);
            }
        }
    } else {
        // Command line scripts
        newrelic_background_job(true);
    }
}
if (defined('ROLLBAR_ACCESS_TOKEN') && defined('DEPLOY_ROOT')) {
    @(include_once 'scripts/rollbar/rollbar.php');
    if (class_exists('Rollbar')) {
        $config = array('access_token' => constant('ROLLBAR_ACCESS_TOKEN'));
        if (defined('ROLLBAR_HANDLER')) {
            $config['handler'] = constant('ROLLBAR_HANDLER');
        }
        if (defined('ROLLBAR_AGENT_LOG_LOCATION')) {
            $logDir = constant('ROLLBAR_AGENT_LOG_LOCATION');
            $logDir = ($logDir[0] != '/' ? constant('DEPLOY_ROOT') . '/' : '') . $logDir;
            $config['agent_log_location'] = $logDir;
        }
        Rollbar::init($config);
    }
}
Esempio n. 27
0
<?php

require_once 'rollbar.php';
Rollbar::init(array('access_token' => 'e6a6dc6bff064be085be00dd5411d617'));
/**
 * The base configurations of the WordPress.
 *
 * This file has the following configurations: MySQL settings, Table Prefix,
 * Secret Keys, WordPress Language, and ABSPATH. You can find more information
 * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
 * wp-config.php} Codex page. You can get the MySQL settings from your web host.
 *
 * This file is used by the wp-config.php creation script during the
 * installation. You don't have to use the web site, you can just copy this file
 * to "wp-config.php" and fill in the values.
 *
 * @package WordPress
 */
// Disable filesystem level changes from WP
define('DISALLOW_FILE_EDIT', true);
define('DISALLOW_FILE_MODS', true);
// Set SSL'ed domain
if (!empty($_ENV["SSL_DOMAIN"])) {
    define('FORCE_SSL_LOGIN', true);
    define('FORCE_SSL_ADMIN', true);
}
// HTTPS port is always 80 because SSL is terminated at Heroku router / CloudFlare
define('JETPACK_SIGNATURE__HTTPS_PORT', 80);
/**#@+
 * Memcache settings.
 */
 /**
  * @param \ErrorException $exception
  */
 protected function handleFatalError($exception)
 {
     \Rollbar::report_php_error($exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
     parent::handleException($exception);
 }
<?php

require_once 'secure/rollbar.php';
$config = array('access_token' => '79f4496bab774563862a8da48e15cf19', 'environment' => 'production', 'root' => '/Users/brian/www/myapp');
Rollbar::init($config);
// installs global error and exception handlers
Rollbar::init(array('access_token' => '79f4496bab774563862a8da48e15cf19'));
date_default_timezone_set('Europe/London ');
include "inc_action_functions.php";
if ($_GET[time] != NULL) {
    $time = CleanNumber($_GET[time]);
    setcookie("lastdayview", $time);
} else {
    $time = time();
}
$ip_current = getenv("REMOTE_ADDR");
// get the ip number of the user
if ($_COOKIE[password] == NULL or $_COOKIE[user] == NULL) {
    header("Location: login.php");
} else {
    // Get the database variables from file
    $database_read = file_get_contents("secure/database.inc");
    $database_read_array = explode("\n", $database_read);
    $settings_companyaddress = file_get_contents("secure/address.inc");
    $database_location = $database_read_array[0];
    $database_username = $database_read_array[1];
    $database_password = $database_read_array[2];
    $database_name = $database_read_array[3];
    $settings_popup_login = $database_read_array[4];
    $settings_popup_newmessage = $database_read_array[5];
    $settings_style = $database_read_array[6];
 public function init()
 {
     \Rollbar::init(array('access_token' => $this->access_token, 'agent_log_location' => $this->agent_log_location, 'base_api_url' => $this->base_api_url, 'batch_size' => $this->batch_size, 'batched' => $this->batched, 'branch' => $this->branch, 'capture_error_stacktraces' => $this->capture_error_stacktraces, 'code_version' => $this->code_version, 'environment' => $this->environment, 'error_sample_rates' => $this->error_sample_rates, 'handler' => $this->handler, 'host' => $this->host, 'included_errno' => $this->included_errno, 'logger' => $this->logger, 'person' => $this->person, 'person_fn' => $this->person_fn, 'root' => $this->root, 'scrub_fields' => $this->scrub_fields, 'shift_function' => $this->shift_function, 'timeout' => $this->timeout, 'report_suppressed' => $this->report_suppressed, 'use_error_reporting' => $this->use_error_reporting, 'max_errno' => $this->max_errno), $this->set_exception_handler, $this->set_error_handler, $this->report_fatal_errors);
     parent::init();
 }