Exemple #1
0
 public static function stack()
 {
     if (!extension_loaded('xdebug')) {
         throw new \RuntimeException('XDebug must be installed to use this function');
     }
     \xdebug_print_function_stack();
 }
Exemple #2
0
 public function registerAction()
 {
     // Request variables from html form
     $name = $this->request->getPost("name", "string");
     $email = $this->request->getPost("email", "email");
     // Stop execution and show a backtrace
     return xdebug_print_function_stack("stop here!");
     $user = new Users();
     $user->name = $name;
     $user->email = $email;
     // Store and check for errors
     $user->save();
 }
Exemple #3
0
 /**
  * Debug variables
  *
  * Example of usage
  *     debug(123);
  *     debug(new stdClass());
  *     debug($_GET, $_POST, $_FILES);
  *
  * @codeCoverageIgnore
  *
  * @param $params
  */
 function debug(...$params)
 {
     // check definition
     if (!getenv('BLUZ_DEBUG')) {
         return;
     }
     ini_set('xdebug.var_display_max_children', 512);
     if ('cli' == PHP_SAPI) {
         if (extension_loaded('xdebug')) {
             // try to enable CLI colors
             ini_set('xdebug.cli_color', 1);
             xdebug_print_function_stack();
         } else {
             debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
         }
         var_dump($params);
     } else {
         echo '<div class="textleft clear"><pre>';
         debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
         var_dump($params);
         echo '</pre></div>';
     }
 }
Exemple #4
0
 public function createAll()
 {
     // Creates all types and returns them
     xdebug_print_function_stack('$type->createAll called.');
     die;
 }
        $stk2 = new stack2();
        echo $stk2->c();
    }
    function b()
    {
        var_dump(xdebug_get_function_stack());
        // Displays the function's call flow or stack.
    }
}
class stack2
{
    function c()
    {
        $stk = new stack();
        //Call to class "Stack"
        echo $stk->b();
    }
}
$a = '';
$stk = new stack();
$res = $stk->a($a);
xdebug_print_function_stack('Your Message');
//To Print "Your Message" text in a message.
/* Used to Findout the time taken to execute code. */
echo '<br><br>' . xdebug_time_index() . '<br>';
//Display the start time.
for ($i = 0; $i < 100; $i++) {
    // anything.
}
echo xdebug_time_index() . '<br><br>';
//Display the end time.
Exemple #6
0
 public function shutdown_handler()
 {
     $e = error_get_last();
     if (empty($this->display_errors)) {
         return;
     }
     if (empty($e) or !($e['type'] & (E_ERROR | E_PARSE | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_RECOVERABLE_ERROR))) {
         return;
     }
     if ($e['type'] & E_RECOVERABLE_ERROR) {
         $error = 'Catchable fatal error';
     } else {
         if ($e['type'] & E_COMPILE_WARNING) {
             $error = 'Warning';
         } else {
             $error = 'Fatal error';
         }
     }
     if (function_exists('xdebug_print_function_stack')) {
         xdebug_print_function_stack(sprintf('%1$s: %2$s in %3$s on line %4$d. Output triggered ', $error, $e['message'], $e['file'], $e['line']));
     } else {
         printf('<br /><b>%1$s</b>: %2$s in <b>%3$s</b> on line <b>%4$d</b><br />', htmlentities($error), htmlentities($e['message']), htmlentities($e['file']), intval($e['line']));
     }
 }
Exemple #7
0
/**
 *	Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remontee des bugs.
 *	On doit appeler cette fonction quand une erreur technique bloquante est rencontree.
 *	Toutefois, il faut essayer de ne l'appeler qu'au sein de pages php, les classes devant
 *	renvoyer leur erreur par l'intermediaire de leur propriete "error".
 *	@param      db      	Database handler
 *	@param      error		String or array of errors strings to show
 *  @see        dol_htmloutput_errors
 */
function dol_print_error($db = '', $error = '')
{
    global $conf, $langs, $argv;
    global $dolibarr_main_prod;
    $out = '';
    $syslog = '';
    // Si erreur intervenue avant chargement langue
    if (!$langs) {
        require_once DOL_DOCUMENT_ROOT . "/core/class/translate.class.php";
        $langs = new Translate("", $conf);
        $langs->load("main");
    }
    $langs->load("main");
    $langs->load("errors");
    if ($_SERVER['DOCUMENT_ROOT']) {
        $out .= $langs->trans("DolibarrHasDetectedError") . ".<br>\n";
        if (!empty($conf->global->MAIN_FEATURES_LEVEL)) {
            $out .= "You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0.<br>\n";
        }
        $out .= $langs->trans("InformationToHelpDiagnose") . ":<br>\n";
        $out .= "<b>" . $langs->trans("Date") . ":</b> " . dol_print_date(time(), 'dayhourlog') . "<br>\n";
        $out .= "<b>" . $langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n";
        if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
            $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . $conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
        }
        if (function_exists("phpversion")) {
            $out .= "<b>" . $langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n";
            //phpinfo();       // This is to show location of php.ini file
        }
        $out .= "<b>" . $langs->trans("Server") . ":</b> " . $_SERVER["SERVER_SOFTWARE"] . "<br>\n";
        $out .= "<br>\n";
        $out .= "<b>" . $langs->trans("RequestedUrl") . ":</b> " . $_SERVER["REQUEST_URI"] . "<br>\n";
        $out .= "<b>" . $langs->trans("Referer") . ":</b> " . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '') . "<br>\n";
        $out .= "<b>" . $langs->trans("MenuManager") . ":</b> " . $conf->top_menu . "<br>\n";
        $out .= "<br>\n";
        $syslog .= "url=" . $_SERVER["REQUEST_URI"];
        $syslog .= ", query_string=" . $_SERVER["QUERY_STRING"];
    } else {
        $out .= '> ' . $langs->transnoentities("ErrorInternalErrorDetected") . ":\n" . $argv[0] . "\n";
        $syslog .= "pid=" . getmypid();
    }
    if (is_object($db)) {
        if ($_SERVER['DOCUMENT_ROOT']) {
            $out .= "<b>" . $langs->trans("DatabaseTypeManager") . ":</b> " . $db->type . "<br>\n";
            $out .= "<b>" . $langs->trans("RequestLastAccessInError") . ":</b> " . ($db->lastqueryerror() ? $db->lastqueryerror() : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
            $out .= "<b>" . $langs->trans("ReturnCodeLastAccessInError") . ":</b> " . ($db->lasterrno() ? $db->lasterrno() : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
            $out .= "<b>" . $langs->trans("InformationLastAccessInError") . ":</b> " . ($db->lasterror() ? $db->lasterror() : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
            $out .= "<br>\n";
        } else {
            $out .= '> ' . $langs->transnoentities("DatabaseTypeManager") . ":\n" . $db->type . "\n";
            $out .= '> ' . $langs->transnoentities("RequestLastAccessInError") . ":\n" . ($db->lastqueryerror() ? $db->lastqueryerror() : $langs->trans("ErrorNoRequestInError")) . "\n";
            $out .= '> ' . $langs->transnoentities("ReturnCodeLastAccessInError") . ":\n" . ($db->lasterrno() ? $db->lasterrno() : $langs->trans("ErrorNoRequestInError")) . "\n";
            $out .= '> ' . $langs->transnoentities("InformationLastAccessInError") . ":\n" . ($db->lasterror() ? $db->lasterror() : $langs->trans("ErrorNoRequestInError")) . "\n";
        }
        $syslog .= ", sql=" . $db->lastquery();
        $syslog .= ", db_error=" . $db->lasterror();
    }
    if ($error) {
        $langs->load("errors");
        if (is_array($error)) {
            $errors = $error;
        } else {
            $errors = array($error);
        }
        foreach ($errors as $msg) {
            $msg = $langs->trans($msg);
            if ($_SERVER['DOCUMENT_ROOT']) {
                $out .= "<b>" . $langs->trans("Message") . ":</b> " . $msg . "<br>\n";
            } else {
                $out .= '> ' . $langs->transnoentities("Message") . ":\n" . $msg . "\n";
            }
            $syslog .= ", msg=" . $msg;
        }
    }
    if (empty($dolibarr_main_prod) && $_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_call_file')) {
        xdebug_print_function_stack();
        $out .= '<b>XDebug informations:</b>' . "<br>\n";
        $out .= 'File: ' . xdebug_call_file() . "<br>\n";
        $out .= 'Line: ' . xdebug_call_line() . "<br>\n";
        $out .= 'Function: ' . xdebug_call_function() . "<br>\n";
        $out .= "<br>\n";
    }
    if (empty($dolibarr_main_prod)) {
        print $out;
    } else {
        define("MAIN_CORE_ERROR", 1);
    }
    //else print 'Sorry, an error occured but the parameter $dolibarr_main_prod is defined in conf file so no message is reported to your browser. Please read the log file for error message.';
    dol_syslog("Error " . $syslog, LOG_ERR);
}
   /**
    * Outputs a stack trace up to the first call to a trace function (which may be this one or a wrapper that calls
    * this one).
    * <p>It displays detailed timing and memory consumption information about each function/method call.
    *
    * <p>It requires a logger panel named 'trace' to be defined.
    * <p>It also requires XDebug to be installed.
    *
    * ##### Usage
    *
    * Put the following code at the place where you want the trace log to be captured:
    *
    *       \PhpKit\WebConsole\DebugConsole\DebugConsole::trace ();
    *
    * @throws Exception
    */
   public static function trace()
   {
       if (!extension_loaded('xdebug')) {
           throw new Exception("<kbd>trace()</kbd> requires Xdebug to be installed.");
       }
       $v = ini_get('xdebug.collect_params');
       ob_start();
       ini_set('xdebug.collect_params', 2);
       xdebug_print_function_stack();
       $trace = ob_get_clean();
       $trace = preg_replace('@^(?:.*?)<table class=\'xdebug-error xe-xdebug\'(.*?)<tr>(?:.*?)>Location</th></tr>@s', '<table class="__console-table trace"$1<colgroup>
 <col width=40><col width=72><col width=72><col width=72><col width=75%><col width=25%>
 <thead><tr><th>#<th>Time (ms)<th>Delta (ms)<th>Mem.(MB)<th>Function<th>Location</tr></thead>', $trace);
       $trace = preg_replace(['@</table>.*@s', "/align='center'/", '@(trace\\(  \\)</td>.*?</tr>)(.*)</table>@s'], ['</table>', 'align=right', '$1</table>'], $trace);
       $prev = 0;
       $trace = preg_replace_callback('#<tr><td (.*?)>(.*?)</td><td (.*?)>(.*?)</td><td (.*?)>(.*?)</td><td (.*?)>(.*?)</td><td title=\'(.*?)\'(.*?)>(.*?)</td></tr>#', function ($m) use(&$prev) {
           $t = $m[4] * 1000;
           $s = $t - $prev;
           $d = number_format($s, 1);
           $dd = $s >= self::PROFILER_WARNING_TRESHOLD ? ' class=__alert' : '';
           $prev = $t;
           $t = number_format($t, 1);
           $r = number_format($m[6] / 1048576, 3);
           $p = ErrorConsole::shortFileName($m[9]);
           $f = substr($m[11], 3);
           list($fn, $args) = explode('(', $m[8], 2);
           $info = preg_replace('/[\\w{}]+$/', '<b>$0</b>', $fn) . '(' . $args;
           return "<tr><th {$m['1']}>{$m['2']}<td {$m['3']}>{$t}<td align=right{$dd}>{$d}<td {$m['5']}>{$r}<td {$m['7']}>{$info}<td class='__type' title='{$p}'{$m['10']}>{$f}</tr>";
       }, $trace);
       ini_set('xdebug.collect_params', $v);
       self::logger('trace')->write($trace);
   }
Exemple #9
0
 public static function Error($errno, $errstr, $errfile, $errline, $errcontext)
 {
     if (self::$_Perfect) {
         $Logs = self::Logs();
         echo '<h2>Perfect Mode</h2>';
         echo '<pre class="console">' . self::Stack() . '</pre>' . PHP_EOL;
         echo $errno . ' ' . $errstr . ' ' . $errfile . '@' . $errline . '<pre>';
         if (function_exists('xdebug_print_function_stack')) {
             xdebug_print_function_stack();
         }
         foreach ($Logs as $Channel => $Records) {
             foreach ($Records as $Log) {
                 echo $Channel . "\t" . $Log[1] . "\t" . $Log[2] . "\t" . PHP_EOL;
             }
         }
         echo '</pre>';
         die;
     }
     self::Log('<pre>' . self::Stack() . '</pre>' . PHP_EOL . 'Err ' . $errno . ':' . $errstr . PHP_EOL . $errfile . '@' . $errline, LOG_CRIT);
 }
}
authorize();
$media_int = 0;
switch ($media_type) {
    case "print":
        $media_int = 1;
        break;
    case "video":
        $media_int = 3;
        break;
    case "digital":
        $media_int = 2;
        break;
    default:
        $media_int = 1;
}
//validate??
if ($ae != "") {
    try {
        createItem($title, $job_number, $client, $media_int, $description, $ae, $due_date, $budget);
        flash_message('Success', 'Added project successfully.');
    } catch (Exception $e) {
        flash_message('Error', 'Oops, something went wrong.');
        echo xdebug_print_function_stack($e);
    }
} else {
    flash_message('Error', 'Oops, you need to set your Screen Name in settings.');
}
$_SESSION["update"] = "update";
header('Location: http://kb-demos.com/podio2');
//after item added redirect back to home page
Exemple #11
0
 public function ss()
 {
     $m = $this->m('m');
     $result = $m->test();
     print_r(xdebug_print_function_stack());
 }
Exemple #12
0
 /**
  * Returns an array which resembles the stack trace up to this point.
  * @return array
  */
 public function printFunctionStack()
 {
     return xdebug_print_function_stack();
 }