/**
  * This module implemented for AloBug with dummy localhost ipaddress for testing purpose.
  */
 public function exceptionHandler($exception)
 {
     // these are our templates
     $traceline = "#%s %s(%s): %s(%s)\r\n <pre class='code-block linenums'>%s</pre>";
     $msg = "PHP Fatal error:  Uncaught exception '%s' with message '%s' in %s:%s\r\nStack trace:\r\n%s\r\n  thrown in %s on line %s";
     // alter your trace as you please, here
     $trace = $exception->getTrace();
     foreach ($trace as $key => $stackPoint) {
         // I'm converting arguments to their type
         // (prevents passwords from ever getting logged as anything other than 'string')
         $trace[$key]['args'] = array_map('gettype', $trace[$key]['args']);
     }
     // build your tracelines
     $result = array();
     foreach ($trace as $key => $stackPoint) {
         $line = $stackPoint['line'];
         $source = "";
         if ($line !== null) {
             $range = getFileLines($line - 8, 10, $stackPoint['file']);
             if ($range) {
                 $range = array_map(function ($line) {
                     return empty($line) ? ' ' : $line;
                 }, $range);
                 $start = key($range) + 1;
                 $range[$line - 1] = "<strong>" . $range[$line - 1] . "</strong>";
                 $source = join("\r\n", $range);
             }
         }
         $result[] = sprintf($traceline, $key, $stackPoint['file'], $stackPoint['line'], $stackPoint['function'], implode(', ', $stackPoint['args']), $source);
     }
     // trace always ends with {main}
     $result[] = '#' . ++$key . ' {main}';
     // write tracelines into main template
     $msg = sprintf($msg, get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine(), implode("\r\n", $result), $exception->getFile(), $exception->getLine());
     $curl = curl_init();
     curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://192.168.0.6:81/api/projects/8a11b55c9e7ca56ac380039cf95ebbf9/errors', CURLOPT_POST => 1, CURLOPT_POSTFIELDS => array('error_name' => get_class($exception), 'error_desc' => $exception->getMessage(), 'error_data' => $msg)));
     if (!curl_exec($curl)) {
         die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));
     }
     curl_close($curl);
     // log or echo as you please
     echo $msg;
 }
示例#2
0
文件: out.php 项目: LoveOyy/woaini
        $xml = simplexml_load_string($str);
        $xml2 = $xml->{$_GET}['class']->function;
        foreach ($xml2[0] as $k => $v) {
            $m_arr = array();
            $m_arr['param'] = array();
            $m_arr['name'] = $v->name;
            $arr = $v->param[0];
            foreach ($arr as $k1 => $v1) {
                $m_arr['param'][$k1] = $v1;
            }
            include_once $_GET['dir'] . "/controller/" . $_GET['class'] . ".php";
            $str = "app\\" . $_GET['dir'] . "\\controller\\" . $_GET['class'];
            $func = new ReflectionMethod($str, $k);
            $start = $func->getStartLine();
            $end = $func->getEndLine();
            $m_arr['pre'] = getFileLines($_GET['dir'] . "/controller/" . $_GET['class'] . ".php", $start, $end);
            $main_arr[$k] = $m_arr;
        }
        //var_dump($main_arr);
        ?>
<html>
<head>
<link href="/public/static/system/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/public/static/system/js/jquery-1.4.3.min.js"></script>
</head>
<style>
.c{
	color:red;
	
}
.c_name{
示例#3
0
function getFileSpecifications($directories, $filelist, $filetypes)
{
    global $localdirectory, $localpackdirectory;
    foreach ($directories as $dir) {
        foreach ($filelist as $file) {
            foreach ($filetypes as $filetype) {
                $name = $file['file'] . $dir . '.' . $filetype;
                $plain = $localdirectory . $dir . '/' . $name;
                $pack = $localpackdirectory . $dir . '/' . $name . '.bz2';
                if (is_file($plain) && is_file($pack)) {
                    //error_log('getting specs for ' . $name . ' and ' . $name . '.bz2');
                    $resultarray[$name] = array('lines' => getFileLines($plain), 'filesize' => getFilesize($plain), 'bzip2' => getFilesize($pack));
                } else {
                    //error_log('WARNING: cannot get specs for ' . $plain . ' and ' . $pack);
                }
            }
        }
    }
    return $resultarray;
}