예제 #1
0
 /**
  *
  * {@inheritDoc}
  *
  * @see \Psr\Log\LoggerInterface::log()
  */
 public function log($level, $message, array $context = array())
 {
     foreach ($context as $property => $val) {
         if (property_exists($this, $property)) {
             $this->{$property} = $val;
         }
     }
     $fb = new \FB();
     if (!empty($this->options)) {
         $fb->setOptions($this->options);
     }
     $fb->send($message, $this->label, $level);
     if ($level == LogLevel::DEBUG) {
         foreach ($context as $label => $object) {
             $fb->send($object, $label, $level);
         }
     }
 }
예제 #2
0
파일: minimal.php 프로젝트: Gimcrack/aimsys
||										Jeremy Bloomstrom																		||
||										Ingenious Design																		||
||										jeremy@in.genio.us																		||
||										November 27, 2012																		||
||																																||
|________________________________________________________________________________________________________________________________|
||																																||
||																																||
||										minimal.php																			||
||																																||
||																																||
*********************************************************************************************************************************/
/***** ***** ***** ***** ***** ***** ***** ***** ***** ***** DEBUGGING ***** ***** ***** ***** ***** ***** ***** ***** ***** *****/
require_once 'FirePHPCore/FirePHP.class.php';
$firephp = FirePHP::getInstance(true);
require_once 'FirePHPCore/fb.php';
$firephp->setEnabled(true);
// or FB::
FB::send('firephp enabled');
/***** ***** ***** ***** ***** ***** ***** ***** ***** ***** GLOBAL VARS ***** ***** ***** ***** ***** ***** ***** ***** ***** *****/
global $session_length;
$session_length = 60 * 10 - 2;
// 30 second sessions for debugging; 10 mins for production
include_once "./models/db.php";
/***** ***** ***** ***** ***** ***** ***** ***** ***** ***** CLASSES ***** ***** ***** ***** ***** ***** ***** ***** ***** *****/
include_once "classes/class_session.php";
include_once "classes/class_req.php";
include_once "classes/class_document.php";
include_once "classes/class_date.php";
/***** ***** ***** ***** ***** ***** ***** ***** ***** ***** OTHERS ***** ***** ***** ***** ***** ***** ***** ***** ***** *****/
include_once "php/functions.php";
예제 #3
0
파일: Panda.php 프로젝트: sssAlchemy/Panda
 /**
  * Display Error Message in debug mode.
  *
  * <pre>
  *
  * @param string $heading    Headding
  * @param string $subheading Sub headding
  * @param mixed  $info       error info
  * @param array  $options    options
  *
  * $options key:
  *
  * string $options['file']   file name
  * int    $options['line']   line
  * array  $options['trace']  backtrace
  * bool   $options['return'] return string(no echo)
  * </pre>
  *
  * @return void
  */
 public static function error($heading, $subheading = "", $info = "", array $options = array())
 {
     // return if live
     if (self::$_config[self::CONFIG_DEBUG] !== true) {
         return;
     }
     if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') {
         if (class_exists('FB', false)) {
             $in = isset($options['file']) ? "- in {$options['file']} on line {$options['line']}" : '';
             $msg = "{$heading} - {$subheading} {$in}";
             if ($info) {
                 FB::group($msg);
                 FB::error($info);
                 FB::groupEnd();
                 return;
             }
         }
     }
     static $num = 1;
     //div id number
     $heading = is_numeric($heading) ? self::$packageName[$heading] : $heading;
     // Application error callback
     if (is_callable(self::$_config[self::CONFIG_ON_ERROR_FIRED])) {
         call_user_func(self::$_config[self::CONFIG_ON_ERROR_FIRED], $heading, $subheading, $info, $options);
     }
     $fileInfoString = isset($options['file']) ? "in {$options['file']} on line {$options['line']}" : 'in unknown file';
     if (self::$_config[self::CONFIG_ENABLE_FIREPHP] && isset($options['severity'])) {
         $fireLevel = FirePHP::ERROR;
         switch (true) {
             case $options['severity'] == E_WARNING || $options['severity'] == E_USER_WARNING:
                 $fireLevel = FirePHP::WARN;
                 break;
             case $options['severity'] == E_NOTICE || $options['severity'] == E_USER_NOTICE:
                 $fireLevel = FirePHP::INFO;
                 break;
             case $options['severity'] == E_STRICT:
                 $fireLevel = FirePHP::LOG;
                 break;
             default:
                 $fireLevel = FirePHP::ERROR;
                 break;
         }
         FB::send("{$subheading} - {$fileInfoString}", $heading, $fireLevel);
     }
     self::GrowlNotify($heading, $subheading . "\n{$fileInfoString}");
     $defaultOptions = array('file' => null, 'line' => null, 'trace' => array(), 'return' => false, 'no_screen' => false);
     $options = array_merge($defaultOptions, $options);
     if ($options['no_screen']) {
         return '';
     }
     $output = self::_getDebugCss();
     if ($options['trace']) {
         $traceId = uniqid();
         $traceFile = self::getTempDir() . '/trace-' . $traceId . '.log';
         $refData = self::__addReflectInfo($options['trace']);
         file_put_contents($traceFile, serialize($options['trace']));
         file_put_contents("{$traceFile}.ref.log", serialize($refData));
     }
     if (PHP_SAPI == 'cli' || call_user_func(self::$_config[self::CONFIG_IS_API_CHECK])) {
         $output .= $heading . PHP_EOL;
         $output .= $subheading . PHP_EOL;
         $output .= $info . PHP_EOL;
         return $output;
     } else {
         if (is_array($info) || is_object($info)) {
             if (isset($options['package']) && $options['package'] === self::PACKAGE_PHP) {
                 $info = self::_getContextString($info, '$');
             } else {
                 $info = self::_getContextString($info);
             }
         }
         header('Content-Type: text/html; charset=utf-8');
         $output .= '<div id="panda-' . $num . '"class="panda">';
         $output .= '<div class="panda-header">';
         $output .= '<h1>' . $heading . '</h1>';
         $output .= isset($options['file']) ? '<p class="panda-file">' . self::getEditorLink($options['file'], $options['line'], 0) . '</p>' : '';
         $output .= '<h2>' . $subheading . '</h2>';
         $output .= '<p class="panda-cmd">';
         if ($options['trace']) {
             $output .= '<a target="_panda_trace_' . $traceId . '" href="' . "http://{$_SERVER['SERVER_NAME']}" . self::$_config[self::CONFIG_PANDA_PATH] . '__panda/trace/?id=' . $traceId . '">trace</a> | ';
         }
         $output .= '<a href=# onclick="var t = document.getElementById(\'panda-';
         $output .= $num . '\'); t.parentNode.removeChild(t);return false;">close</a>';
         $output .= '</p>';
         $output .= '</div>';
         $output .= '<div class="panda-body">';
         $output .= $info ? '<h3>Info</h3><p class="panda-info">' . $info . '</p>' : '';
         // file summary
         if ($options['file']) {
             $output .= '<h3>Source</h3>';
             $output .= '<a style="text-decoration:none;" href="/__panda/edit/?file=' . $options['file'];
             $output .= '&line=' . $options['line'] . '">';
             $output .= self::_getFileSummary($options['file'], $options['line'], 6);
             $output .= '</a>';
             if ($options['trace']) {
                 // trace summary
                 $output .= '<h3>Trace</h3>';
                 $output .= Panda_Debug::getTraceSummary($options['trace']);
             }
         }
         $output .= '</div></div>';
         // /body-error-body /panda
     }
     $num++;
     if ($options['return'] === true) {
         return $output;
     } else {
         echo $output;
     }
 }
예제 #4
0
 /**
  * Prints debug information if debug is set to true.
  * $msg is used as header/footer in the output.
  *
  * if FirePHP is available it will be used instead of
  * dumping the debug info into the document.
  *
  * It uses print_r and encapsulates it in HTML/XML comments.
  * (<!-- -->)
  *
  * @param  string  $msg    Debug identifier, e.g. "my array".
  * @param  mixed   $mixed  Object, type, etc, to be debugged.
  * @return void
  */
 public static function printDebug($msg, $mixed)
 {
     if (self::$debug) {
         if (class_exists('FB', false)) {
             FB::send($mixed, $msg);
         } else {
             echo "\n<!-- " . $msg . ": \n";
             print_r($mixed);
             echo "\n end " . $msg . " -->\n";
         }
     }
 }
예제 #5
0
function test($table)
{
    FB::table('Test deep table', $table);
    FB::send(array('Test deep table', $table), FirePHP::TABLE);
    throw new Exception('Test Exception');
}
예제 #6
0
<?php

$firephp = FirePHP::getInstance(true);
if ($firephp->getEnabled()) {
    $firephp->info('Enabled');
}
$firephp->fb('This should show');
$firephp->setEnabled(false);
if (!$firephp->getEnabled()) {
    $firephp->info('Disabled');
}
$firephp->fb('This should NOT show');
$firephp->setEnabled(true);
if ($firephp->getEnabled()) {
    $firephp->info('Enabled');
}
$firephp->fb('This should show');
if (FB::getEnabled()) {
    FB::info('Enabled');
}
FB::log('This should show');
FB::setEnabled(false);
if (!FB::getEnabled()) {
    FB::info('Disabled');
}
FB::send('This should NOT show');
FB::setEnabled(true);
if (FB::getEnabled()) {
    FB::info('Enabled');
}
FB::log('This should show');
예제 #7
0
 /**
  * Loads the class variable with
  * 
  * @return void
  * @access public
  */
 public function getImages()
 {
     FB::group("Image Loading Data");
     FB::send($this->dir, "Directory");
     if (($cache = Utilities::check_cache($this->dir)) !== FALSE) {
         $this->_imageArray = $cache;
     } else {
         if (is_dir($this->dir)) {
             // Open the directory for reading
             if ($folder = opendir($this->dir)) {
                 // Loop through the files in the directory
                 while (($file = readdir($folder)) !== FALSE) {
                     /*
                      * Verifies that the current value of $file
                      * refers to an existing file and that the 
                      * file is big enough not to throw an error.
                      */
                     if (is_file($this->dir . $file) && is_readable($this->dir . $file) && filesize($this->dir . $file) > 11) {
                         // Verify that the file is an image
                         //XXX Add EXIF check and fallback
                         if (exif_imagetype($this->dir . $file) !== FALSE) {
                             FB::send("The file is an image. Added to array.");
                             // Adds the image to the array
                             $this->_imageArray[] = $file;
                         }
                     }
                 }
                 // Sort the images according using natural sorting
                 natsort($this->_imageArray);
                 FB::send($this->_imageArray, "Image Array");
                 Utilities::save_cache($this->dir, $this->_imageArray);
             }
         }
     }
     FB::groupEnd();
 }
예제 #8
0
 /**
  * Log a table in the firebug console
  *
  * @see FirePHP::TABLE
  * @param string $Label
  * @param string $Table
  * @return true
  */
 function table($Label, $Table)
 {
     return FB::send($Table, $Label, FirePHP_TABLE);
 }
예제 #9
0
 /**
  * 最後のエラーを取得
  *
  * <pre>
  * _errorクエリーで最後のエラーを表示させます。
  * エラー表示がうまく行かない時に使用します。
  * </pre>
  *
  * <code>
  * ?_error                           エラー表示
  * ?_error=koriyama@bear-project.net エラーメール送信
  * ?_error=/tmp/error.log            エラーログファイルを書き込み
  * </code>
  *
  * @return void
  */
 public static function onShutdownDebug()
 {
     if (function_exists('FB')) {
         $errors = Panda::getOuterPathErrors();
         FB::group('errors', array('Collapsed' => true, 'Color' => 'gray'));
         foreach ($errors as $code => $error) {
             switch (true) {
                 case $code == E_WARNING || $code == E_USER_WARNING:
                     $fireLevel = FirePHP::WARN;
                     break;
                 case $code == E_NOTICE || $code == E_USER_NOTICE:
                     $fireLevel = FirePHP::INFO;
                     break;
                 case $code == E_STRICT || $code == E_DEPRECATED:
                     $fireLevel = FirePHP::LOG;
                     break;
                 default:
                     $fireLevel = FirePHP::ERROR;
                     break;
             }
             FB::send($error, '', $fireLevel);
         }
         FB::groupEnd();
     }
     $lastError = error_get_last();
     $err = print_r($lastError, true);
     if (isset($_GET['_error'])) {
         $errorTo = $_GET['_error'];
         if ($errorTo == '') {
             $errorCode = Panda::$phpError[$lastError['type']];
             Panda::error("{$errorCode} (Last Error)", "{$lastError['message']}", '', (array) $lastError);
             return;
         } elseif (strpos($errorTo, '@')) {
             error_log($err, 1, $errorTo);
         } elseif (is_writable(dirname($errorTo))) {
             error_log("{$err}\n\n", 3, $errorTo);
         } else {
             echo "<p style=\"color:red\">Error: Invalid destination for _error [{$errorTo}]</p>";
         }
     }
 }
예제 #10
0
<?php

FB::group('Test Group');
FB::send('Hello World');
FB::groupEnd();
FB::log('Log Message');
FB::info('Info Message');
FB::warn('Info Message');
FB::error('Info Message');
FB::trace('Trace to here');
FB::send('Trace to here', FirePHP::TRACE);
FB::table('2 SQL queries took 0.06 seconds', array(array('SQL Statement', 'Time', 'Result'), array('SELECT * FROM Foo', '0.02', array('row1', 'row2')), array('SELECT * FROM Bar', '0.04', array('row1', 'row2'))));
FB::dump('PHP Version', phpversion());
예제 #11
0
 /**
  * Validates a posted comment and sets error codes where applicable
  * 
  * @return mixed    bool FALSE on failure, object w/comment data on success
  */
 private function _validate_comment_data()
 {
     // Sanitize the user input
     $comment = $this->_store_comment_data();
     // Verify that all required fields were properly filled out
     //----------------------------------------------------------------------
     // Name was left blank
     if (empty($comment->name)) {
         $this->_sdata->error = '0001';
         FB::send("No name supplied");
         return FALSE;
     } else {
         if (!SIV::validate($comment->name, SIV::STRING)) {
             $this->_sdata->error = '0002';
             FB::send("Invalid name supplied");
             return FALSE;
         } else {
             if (empty($comment->email)) {
                 $this->_sdata->error = '0003';
                 FB::send("No email supplied");
                 return FALSE;
             } else {
                 if (!SIV::validate($comment->email, SIV::EMAIL)) {
                     $this->_sdata->error = '0004';
                     FB::send("Invalid email supplied");
                     return FALSE;
                 } else {
                     if (empty($comment->comment)) {
                         $this->_sdata->error = '0005';
                         FB::send("No comment supplied");
                         return FALSE;
                     } else {
                         if (!$this->_verify_spam_challenge()) {
                             // The user gets five chances to answer the anti-spam question
                             if ($this->_track_post_attempts() < 5) {
                                 $this->_sdata->error = '0006';
                                 FB::send("Failed spam verification");
                             } else {
                                 $this->_suspend_commenter();
                                 $this->_sdata->attempts = 0;
                                 $this->_sdata->error = '0009';
                                 FB::send("Too many failed spam attempts");
                             }
                             return FALSE;
                         } else {
                             if ($this->_sdata->suspend_until > time() && ($this->_sdata->error === '0009' || $this->_sdata->error === '0011')) {
                                 $this->_suspend_commenter();
                                 $this->_sdata->error = '0011';
                                 FB::send("Suspended for two minutes");
                                 return FALSE;
                             } else {
                                 if ($this->_sdata->suspend_until > time() && $this->_sdata->error === '0000' || $this->_sdata->error === '0012') {
                                     $this->_suspend_commenter(15);
                                     $this->_sdata->error = '0012';
                                     FB::send("Too many posts in 15 seconds. ");
                                     return FALSE;
                                 } else {
                                     // Send the success code
                                     $this->_sdata->error = '0000';
                                     // Reset the comment attempts
                                     $this->_sdata->attempts = 0;
                                     return $comment;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #12
0
 /**
  * (non-PHPdoc)
  * @see debugObject::vardump()
  */
 public function vardump($var, $name = null)
 {
     if ($this->_level & DEBUG_LOG) {
         FB::send($var, $name);
     }
 }
예제 #13
0
파일: GO.php 프로젝트: ajaboa/crmpuan
 /**
  * Write's to a debug log.
  *
  * @param string $text log entry
  */
 public static function debug($text, $config = false)
 {
     if (self::config()->debug || self::config()->debug_log || self::config()->firephp) {
         if (!isset($_REQUEST['r']) || $_REQUEST['r'] != 'core/debug') {
             if (self::config()->firephp) {
                 if (class_exists('FB')) {
                     ob_start();
                     FB::send($text);
                 }
             }
             //				if (self::config()->debug_log) {
             if (!is_string($text)) {
                 $text = var_export($text, true);
             }
             if ($text == '') {
                 $text = '(empty string)';
             }
             if ($text == 'undefined') {
                 throw new \Exception();
             }
             //$username=\GO::user() ? \GO::user()->username : '******';
             //$trace = debug_backtrace();
             //$prefix = "\n[".date("Ymd G:i:s")."][".$trace[0]['file'].":".$trace[0]['line']."]\n";
             //$lines = explode("\n", $text);
             //$text = $prefix.$text;
             $user = isset(\GO::session()->values['username']) ? \GO::session()->values['username'] : '******';
             $text = "[{$user}] " . str_replace("\n", "\n[{$user}] ", $text);
             file_put_contents(self::config()->file_storage_path . 'log/debug.log', $text . "\n", FILE_APPEND);
             //				}
         }
     }
 }