예제 #1
0
 public static function getFileAndMailLogger($logFile, $fileLevel, $mailTo, $mailLevel)
 {
     $monolog = new Monolog('f&mLog');
     $streamHandler = new StreamHandler($logFile, $fileLevel);
     $mailHandler = new NativeMailerHandler($mailTo, date("Y-m-d H:i:s") . ' - e7Bot error ', "e7bot", $fileLevel, true, 300);
     $mailHandler->setFormatter(new LineFormatter(self::LOG_FORMAT, null, true));
     $streamHandler->setFormatter(new LineFormatter(self::LOG_FORMAT, null, true));
     $monolog->pushHandler($streamHandler);
     $monolog->pushHandler($mailHandler);
     ErrorHandler::register($monolog);
     return new Logger($monolog, $logFile);
 }
예제 #2
0
 public function testSend()
 {
     $to = '*****@*****.**';
     $subject = 'dear victim';
     $from = '*****@*****.**';
     $mailer = new NativeMailerHandler($to, $subject, $from);
     $mailer->handleBatch(array());
     // batch is empty, nothing sent
     $this->assertEmpty($GLOBALS['mail']);
     // non-empty batch
     $mailer->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
     $this->assertNotEmpty($GLOBALS['mail']);
     $this->assertInternalType('array', $GLOBALS['mail']);
     $this->assertArrayHasKey('0', $GLOBALS['mail']);
     $params = $GLOBALS['mail'][0];
     $this->assertCount(5, $params);
     $this->assertSame($to, $params[0]);
     $this->assertSame($subject, $params[1]);
     $this->assertStringEndsWith(" test.ERROR: Foo Bar  Baz [] []\n", $params[2]);
     $this->assertSame("From: {$from}\r\nContent-type: text/plain; charset=utf-8\r\n", $params[3]);
     $this->assertSame('', $params[4]);
 }
 public static function configureEmails(Monolog $monolog, $emailAddresses, $emailSubject)
 {
     if (!empty($emailAddresses)) {
         $senderEmail = config('logging.email_sender_address') ?: false;
         if (empty($senderEmail)) {
             $senderEmail = 'errors@' . (empty($_SERVER['HTTP_HOST']) ? 'unknown.host' : $_SERVER['HTTP_HOST']);
         }
         $mail = new NativeMailerHandler($emailAddresses, $emailSubject, $senderEmail, config('logging.log_level', Logger::WARNING));
         $mail->setFormatter(new HtmlFormatter());
         $mail->pushProcessor(new WebProcessor());
         $mail->pushProcessor(new IntrospectionProcessor(Logger::DEBUG));
         $mail->setContentType('text/html');
         $monolog->pushHandler($mail);
     }
 }
예제 #4
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testSetterArrayHeaderInjection()
 {
     $mailer = new NativeMailerHandler('*****@*****.**', 'dear victim', '*****@*****.**');
     $mailer->addHeader(array("Content-Type: text/html\r\nFrom: faked@attacker.org"));
 }
 /**
  * @expectedException InvalidArgumentException
  */
 public function testSetterEncodingInjection()
 {
     $mailer = new NativeMailerHandler('*****@*****.**', 'dear victim', '*****@*****.**');
     $mailer->setEncoding("utf-8\r\nFrom: faked@attacker.org");
 }
 public function testMessageSubjectFormatting()
 {
     $mailer = new NativeMailerHandler('*****@*****.**', 'Alert: %level_name% %message%', '*****@*****.**');
     $mailer->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
     $this->assertNotEmpty($GLOBALS['mail']);
     $this->assertInternalType('array', $GLOBALS['mail']);
     $this->assertArrayHasKey('0', $GLOBALS['mail']);
     $params = $GLOBALS['mail'][0];
     $this->assertCount(5, $params);
     $this->assertSame('Alert: ERROR Foo Bar  Baz', $params[1]);
 }
    ini_set("display_errors", 0);
    error_reporting(0);
}
$nataraja = strpos($_SERVER['REQUEST_URI'], '/wordpress/wordpress_') !== false;
// Error log
if (WP_DEBUG == false || !$nataraja) {
    $titulo = 'Falha em Eventos';
    if (WP_DEBUG && !$nataraja) {
        $titulo = 'DEV - Falha em Eventos';
    }
    require_once 'lib/MonologFormatter.class.php';
    if (!file_exists(ABSPATH . '/log/')) {
        die('É necessário existir a pasta ' . ABSPATH . '/log/');
    }
    $log = new Logger('name');
    $mailer = new NativeMailerHandler(TGO_EVENTO_ADMIN, $titulo, TGO_EVENTO_ADMIN);
    $streamHandler = new StreamHandler(ABSPATH . '/log/monolog.log');
    $errHandler = new ErrorHandler($log);
    $errHandler->registerErrorHandler();
    $errHandler->registerExceptionHandler();
    $mailer->setFormatter(new MonologFormatter());
    $log->pushHandler($streamHandler, Logger::WARNING);
    $log->pushHandler($mailer, Logger::WARNING);
}
add_filter('wpseo_locale', 'override_og_locale');
function override_og_locale($locale)
{
    return "pt_BR";
}
// Requires iniciais
include_once 'lib/Cpp.php';