Example #1
0
 /**
  * Dump sql queries
  * @param $select
  */
 public function sql($select)
 {
     return;
     // for debug only
     if (self::$_jbdump !== null) {
         $select = (string) $select;
         self::$_jbdump->dump((string) $select, 'jbdebug::sql');
     }
 }
Example #2
0
 /**
  * @param array  $array
  * @param string $arrayName
  */
 public function logArray($array, $arrayName = 'data')
 {
     if (self::$_jbdump !== null && method_exists(self::$_jbdump, 'phpArray')) {
         $arrayString = self::$_jbdump->phpArray($array, $arrayName);
         $this->log($arrayString);
     }
 }
Example #3
0
 /**
  * JBDump init
  */
 function onAfterInitialise()
 {
     $logPath = $this->params->get('logPath', JPATH_ROOT . DS . 'logs');
     if (empty($logPath)) {
         $logPath = JPATH_ROOT . DS . 'logs';
     }
     $logFile = $this->params->get('logFile', false);
     if (empty($logFile)) {
         $logFile = false;
     }
     // init and configuration JBDump library
     $params = array('root' => JPATH_SITE, 'logPath' => $logPath, 'logFile' => $logFile, 'serialize' => $this->params->get('serialize', 'print_r'), 'logFormat' => "{DATETIME}\t{CLIENT_IP}\t\t{FILE}\t\t{NAME}\t\t{TEXT}", 'autoProfile' => (int) $this->params->get('autoProfile', true), 'profileToFile' => (int) $this->params->get('profileToFile', false), 'sort' => array('array' => (int) $this->params->get('sort_array', false), 'object' => (int) $this->params->get('sort_object', true), 'methods' => (int) $this->params->get('sort_methods', true)), 'handler' => array('error' => (int) $this->params->get('handler_error', true), 'exception' => (int) $this->params->get('handler_exception', true), 'context' => (int) $this->params->get('handler_context', false)), 'ip' => $this->params->get('ip', false), 'requestParam' => $this->params->get('requestParam', false), 'requestValue' => $this->params->get('requestValue', false), 'lite_mode' => (int) $this->params->get('lite_mode', false), 'stringLength' => $this->params->get('stringLength', 50), 'maxDepth' => $this->params->get('maxDepth', 3), 'showMethods' => (int) $this->params->get('showMethods', true), 'allToLog' => (int) $this->params->get('allToLog', false), 'showArgs' => (int) $this->params->get('showMethods', false));
     // init jbdump
     JBDump::i('jbdump', $params);
 }
Example #4
0
<?php

/**
 * @package     JBDump test
 * @version     1.2.0
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 * 
 */
include './included_file.php';
JBDump::showErrors();
?>
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
?>
<h3>Result</h3><?php 
echo 'JBDump::server();';
JBDump::server();
echo 'JBDump::globals();';
JBDump::globals();
echo 'JBDump::env();';
JBDump::env();
echo 'JBDump::headers();';
JBDump::headers();
Example #5
0
<?php

/**
 * @package     JBDump test
 * @version     1.2.0
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 * 
 */
include './included_file.php';
JBDump::showErrors();
?>
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
?>
<h3>Result</h3><?php 
echo "JBDump::pathInfo('./included_file.php');";
JBDump::pathInfo('./included_file.php');
echo "JBDump::pathInfo('.');";
JBDump::pathInfo('.');
echo "JBDump::pathInfo('./unknowfile_123.php');";
JBDump::pathInfo('./unknowfile_123.php');
Example #6
0
 /**
  * Check trace
  */
 public function checkTrace()
 {
     JBDump::trace(1);
     simpleFunction('simple string');
 }
Example #7
0
 /**
  * Disable debug
  * @return JBDump
  */
 public static function off()
 {
     self::$enabled = false;
     return self::i();
 }
Example #8
0
<?php

if (!isset($_POST['value'])) {
    $_POST['value'] = '';
}
?>
<html>
    <head>
        <title>Mail</title>
    </head>
    <body>
        <form action="" method="post">
            <textarea name="value" rows="5" cols="50"><?php 
echo $_POST['value'];
?>
</textarea>
            <br>
            <input type="submit" value="Submit">
        </form>
        <?php 
if ($_POST['value']) {
    $message = 'Testing is sending a letter with the PHP mail ()';
    JBDump::mail($message, 'JBDump test', $_POST['value']);
}
?>
    </body>
</html>
Example #9
0
<?php

/**
 * @package     JBDump test
 * @version     1.2.0
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 *
 */
include './included_file.php';
include './included_benchmarks.php';
JBDump::showErrors();
//d(GetPHPCPUMark());
d(GetPHPFilesMark());
Example #10
0
<?php

/**
 * @package     JBDump test
 * @version     1.2.0
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 */
include './included_file.php';
JBDump::showErrors();
?>
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
echo 'Disabled for demo';
JBDump::off();
JBDump::mail('Test message');
JBDump::mail('Test message', null, '*****@*****.**');
JBDump::mail('Test message', 'Test subject text', null);
JBDump::mail('Test message', 'Test subject text', '*****@*****.**');
JBDump::i()->mail(array('test' => 'test2', 'test4' => 'test3'));
Example #11
0
<?php

/**
 * @package     JBDump test
 * @version     1.2.0
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 * 
 */
include './included_file.php';
JBDump::showErrors();
?>
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
?>
<h3>Result</h3><?php 
jbdump(1, 0);
JBDump::off();
echo 'text1<br/>';
JBDump('JBDump with die flag', 1, 'die');
echo 'text2<br/>';
JBDump::on();
jbdump(2, 1);
Example #12
0
 * @version     1.2.0
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 * 
 */
include './included_file.php';
JBDump::showErrors();
?>
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
?>
<h3>Result</h3><?php 
echo 'JBDump::locale();';
JBDump::locale();
echo 'JBDump::conf();';
JBDump::conf();
echo "JBDump::conf('pcre')";
JBDump::conf('pcre');
echo "JBDump::extensions();";
JBDump::extensions();
echo "JBDump::extensions(1);";
JBDump::extensions(1);
echo "JBDump::phpini();";
JBDump::phpini();
echo "JBDump::timezone();";
JBDump::timezone();
echo "JBDump::path();";
JBDump::path();
Example #13
0
<?php

if (!isset($_POST['value'])) {
    $_POST['value'] = '';
}
?>
<html>
    <head>
        <title>All hash</title>
    </head>
    <body>
        <form action="" method="post">
            <textarea name="value" rows="5" cols="50"><?php 
echo $_POST['value'];
?>
</textarea>
            <br>
            <input type="submit" value="Submit">
        </form>

        <?php 
if ($_POST['value']) {
    JBDump::hash($_POST['value']);
}
?>

    </body>
</html>

Example #14
0
<?php

/**
 * @package     JBDump test
 * @version     1.2.0
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 * 
 */
include './included_file.php';
JBDump::showErrors();
?>
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
?>
<h3>Result</h3><?php 
echo "JBDump::trace();";
JBDump::trace();
$var['simpleObject']->checkTrace('arg1', 2, simpleObject::SIMPLE_CONST);
testFuncArgs(1, 2);
$var['simpleObject']->testFuncArgs(1, 2);
Example #15
0
echo "JBDump::classInfo(new simpleObject());";
JBDump::classInfo(new simpleObject());
echo "JBDump::classInfo(JBDump::i());";
JBDump::classInfo(JBDump::i());
echo "JBDump::classInfo('reflection');";
JBDump::classInfo('reflection');
echo "JBDump::classInfo('unknowClass_123');";
JBDump::classInfo('unknowClass_123');
?>
<h3>Functions</h3><?php 
echo "JBDump::funcInfo('simpleFunction');";
JBDump::funcInfo('simpleFunction');
echo 'JBDump::funcInfo($simpleClosureFunction);';
JBDump::funcInfo($simpleClosureFunction);
echo "JBDump::funcInfo('is_array');";
JBDump::funcInfo('is_array');
echo "JBDump::funcInfo('mysql_query');";
JBDump::funcInfo('mysql_query');
echo "JBDump::funcInfo('call_user_method_array');";
JBDump::funcInfo('call_user_method_array');
echo "JBDump::funcInfo('unkhowFunction_123');";
JBDump::funcInfo('unkhowFunction_123');
?>
<h3>Extensions</h3><?php 
echo "JBDump::extInfo('reflection');";
JBDump::extInfo('reflection');
echo "JBDump::extInfo('mysqli');";
JBDump::extInfo('mysqli');
echo "JBDump::extInfo('unknowExtenseion_123');";
JBDump::extInfo('unknowExtenseion_123');
Example #16
0
<?php

/**
 * @package     JBDump test
 * @version     1.2.0
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 */
include './included_file.php';
JBDump::showErrors();
?>
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
?>
<h3>Result</h3><?php 
echo "JBDump::request();";
JBDump::request();
echo "JBDump::request(1);";
JBDump::request(1);
echo "JBDump::session();";
JBDump::session();
Example #17
0
if (!isset($_POST['value'])) {
    $_POST['value'] = '';
}
?>
<html>
    <head>
        <title>Parse url string</title>
    </head>
    <body>
        <form action="" method="post">
            <textarea name="value" rows="5" cols="50"><?php 
echo $_POST['value'];
?>
</textarea>
            <br>
            <input type="submit" value="Submit">
        </form>

        <?php 
if ($_POST['value']) {
    JBDump::url($_POST['value'], 'JBDump::url');
    parse_str($_POST['value'], $var);
    JBDump($var, 0, 'Parsed url params');
}
?>

    </body>
</html>

Example #18
0
<?php

/**
 * @package     JBDump test
 * @version     1.2.0
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 * 
 */
include './included_file.php';
JBDump::showErrors();
?>
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
?>
<h3>Result</h3><?php 
JBDump::errors();
// trigger some errors, first define a mixed array with a non-numeric item
$a = array(2, 3, "foo", 5.5, 43.3, 21.11);
// now generate second array
$b = scale_by_log($a, M_PI);
// this is trouble, we pass a string instead of an array
$c = scale_by_log("not array", 2.3);
// this is a critical error, log of zero or negative number is undefined
$d = scale_by_log($a, -2.5);
echo $_NOT_DEFINED_VAR;
$simpleObject = new simpleObject();
$simpleObject->getException();
echo "Not Executed\n";
Example #19
0
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 */
include './included_file.php';
JBDump::showErrors();
?>
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
?>
<h3>Result</h3><?php 
$logger = JBDump::i();
echo 'Disable for demo';
JBDump::off();
// only for test
JBDump::log($var['null'], 'null');
JBDump::log($var['bool'], 'Boolean');
JBDump::log($var['integer'], 'Integer');
JBDump::log($var['float'], 'Float');
JBDump::log($var['string'], 'String');
JBDump::log($var['longString'], 'longString');
JBDump::log($var['stdClass'], 'stdClass');
JBDump::log($var['simpleObject'], 'simpleObject');
JBDump::log($var['var'], 'complex var');
//// other methods
JBDump::i()->log('Hello world!');
if (function_exists('l')) {
    l('short log function');
}
// set params
$logger->setParams(array('file' => 'newLogName'), 'log')->log($var['string'], 'message_name');
$logger->setParams(array('file' => 'newLogFormat', 'format' => "{DATETIME}\t{CLIENT_IP} --------- {VAR1} // {VAR2} // {VAR3}", 'serialize' => 'format'), 'log')->log(array('var1' => '1', 'Var2' => '2', 'vAR3' => '3', 'VAR4' => '4'));
Example #20
0
/**
 * @package     JBDump test
 * @version     1.2.0
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 * 
 */
include './included_file.php';
JBDump::showErrors();
?>
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
?>
<h3>Result</h3><?php 
echo 'JBDump::classes();';
JBDump::classes();
echo 'JBDump::defines();';
JBDump::defines();
echo 'JBDump::defines(1);';
JBDump::defines(1);
echo 'JBDump::functions();';
JBDump::functions();
echo 'JBDump::functions(1);';
JBDump::functions(1);
echo 'JBDump::includes();';
JBDump::includes();
echo 'JBDump::interfaces();';
JBDump::interfaces();
Example #21
0
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
?>
<h3>Result</h3><?php 
JBDump::memory();
JBDump::mark('start loop');
$bigArray = array(0 => 0);
for ($i = 1; $i < 10000; $i++) {
    $bigArray[$i] = $i + @$bigArray[$i - 1];
}
JBDump::mark('finish loop');
unset($bigArray);
JBDump::mark('unset $bigArray');
JBDump::mark('start loop #2');
for ($i = 0; $i < 1000000; $i++) {
}
JBDump::mark('finish loop #2');
JBDump::mark('start loop #3');
$j = 0;
for ($i = 0; $i < 1000000; $i++) {
    $j++;
}
JBDump::mark('finish loop #3');
echo "JBDump::microtime();";
JBDump::microtime();
echo "JBDump::memory();";
JBDump::memory();
echo "JBDump::microtime();";
JBDump::microtime();
JBDump::i()->mark('other functions');
Example #22
0
/**
 * @package     JBDump test
 * @version     1.2.0
 * @author      admin@joomla-book.ru
 * @link        http://joomla-book.ru/
 * @copyright   Copyright (c) 2009-2011 Joomla-book.ru
 * @license     GNU General Public License version 2 or later; see LICENSE
 * 
 */
include './included_file.php';
JBDump::showErrors();
?>
<h3>Code</h3><?php 
JBDump(file_get_contents(__FILE__), 0, '-= Code =-::source');
?>
<h3>Result</h3><?php 
echo "JBDump::hash('123456');";
JBDump::hash('123456');
echo "JBDump::timestamp(time());";
JBDump::timestamp(time());
echo "JBDump::ip();";
JBDump::ip();
echo 'JBDump::json($jsonData, \'JSON\');';
JBDump::json($jsonData, 'JSON');
echo "JBDump::url('http://yandex.ru/yandsearch?text=joomla-book.ru&lr=213', 'yandex url');";
JBDump::url('http://yandex.ru/yandsearch?text=joomla-book.ru&lr=213', 'yandex url');
echo 'JBDump::print_r($var, 0, \'print_r\');';
JBDump::print_r($var, 0, 'print_r');
echo 'JBDump::var_dump($var, 0, \'var_dump\');';
JBDump::var_dump($var, 'var_dump');
Example #23
0
/**
 * Useful console dump
 * @param mixed  $var
 * @param bool   $isDie
 * @param string $label
 * @throws Exception
 *
 * @SuppressWarnings(PHPMD.ExitExpression)
 * @SuppressWarnings(PHPMD.NPathComplexity)
 */
function dump($var, $isDie = true, $label = '')
{
    if (!class_exists('\\JBDump')) {
        throw new Exception('jbzoo/jbdump required for dump() function');
    }
    if (!class_exists('\\Symfony\\Component\\VarDumper\\VarDumper')) {
        throw new Exception('symfony/var-dumper required for dump() function');
    }
    $isCliMode = defined('STDOUT');
    // get trace mesage
    $trace = debug_backtrace(false);
    $dirname = pathinfo(dirname($trace[0]['file']), PATHINFO_BASENAME);
    $filename = pathinfo($trace[0]['file'], PATHINFO_BASENAME);
    $line = $trace[0]['line'];
    $callplace = "({$dirname}/{$filename}:{$line})";
    // output backtrace information
    $message = $label ? '--- "' . $label . '" ---' : str_repeat('-', 20);
    $message = PHP_EOL . $message . ' ' . $callplace;
    if ($isCliMode) {
        fwrite(STDOUT, $message . PHP_EOL);
        $isSimpleVar = is_string($var) || is_numeric($var) || is_bool($var) || null === $var;
        if ($isSimpleVar) {
            ob_start();
            var_dump($var);
            $dump = ob_get_contents();
            ob_end_clean();
            fwrite(STDOUT, $dump);
        } else {
            putenv("ANSICON=on");
            // Add colored output
            VarDumper::dump($var);
        }
    } elseif (class_exists('\\JBDump')) {
        $jbdump = \JBDump::i(array('log' => array('path' => PROJECT_ROOT . '/logs'), 'profiler' => array('render' => 4, 'auto' => 1, 'showStart' => 0, 'showEnd' => 0, 'showOnAjax' => 1), 'dump' => array('die' => 0, 'maxDepth' => 5, 'expandLevel' => 3)));
        if ($jbdump->isDebug()) {
            $jbdump->dump($var, $label, array('trace' => debug_backtrace()));
        }
    } else {
        echo $message . '<br/>';
        var_dump($var);
    }
    if ($isDie) {
        if ($isCliMode) {
            fwrite(STDOUT, 'Dump die!' . PHP_EOL);
            exit(255);
        } else {
            die('Dump die!' . PHP_EOL);
        }
    }
}