Exemplo n.º 1
0
/**
 * function runDebug()
 * Building to a global debug array
 * @param  string $fileName - the file the error came from
 * @param  string $functionName - the function that triggered the error
 * @param  string $line - the line of code
 * @param  string $info - the message to display
**/
function runDebug($fileName, $functionName, $line, $info, $level = 0)
{
    global $debugArr, $srai_iterations, $debuglevel, $quickdebug, $writetotemp;
    if (empty($functionName)) {
        $functionName = "Called outside of function";
    }
    //only log the debug info if the info level is equal to or less than the chosen level
    if ($level <= $debuglevel && $level != 0 && $debuglevel != 0) {
        if ($quickdebug == 1) {
            outputDebug($fileName, $functionName, $line, $info);
        }
        list($usec, $sec) = explode(" ", microtime());
        //build timestamp index for the debug array
        $index = date("d-m-Y H:i:s") . ltrim($usec, '0');
        //add to array
        $debugArr[$index]['fileName'] = basename($fileName);
        $debugArr[$index]['functionName'] = $functionName;
        $debugArr[$index]['line'] = $line;
        $debugArr[$index]['info'] = $info;
        if ($srai_iterations < 1) {
            $sr_it = 0;
        } else {
            $sr_it = $srai_iterations;
        }
        $debugArr[$index]['srai_iteration'] = $sr_it;
        //if we are logging to file then build a log file. This will be overwriten if the program completes
        if ($writetotemp == 1) {
            writefile_debug($debugArr);
        }
    }
    //return $debugArr;
}
Exemplo n.º 2
0
function update_aiml_tbl()
{
    global $con, $dbn;
    $sql = "ALTER TABLE `{$dbn}`.aiml` ADD `php_code` TEXT NOT NULL ";
    $result = mysql_query($sql, $con);
    if ($result) {
        outputDebug(__FILE__, __FUNCTION__, __LINE__, "Altered AIML tbl");
    } else {
        outputDebug(__FILE__, __FUNCTION__, __LINE__, "Error while altering AIML tabl - Exiting");
        exit;
    }
}
Exemplo n.º 3
0
/**
 * function runDebug()
 * Building to a global debug array
 *
 * @param  string $fileName     - the file the error came from
 * @param  string $functionName - the function that triggered the error
 * @param  string $line         - the line of code
 * @param  string $info         - the message to display
 * @param int     $level
 */
function runDebug($fileName, $functionName, $line, $info, $level = 0)
{
    global $debugArr, $srai_iterations, $quickdebug, $writetotemp, $convoArr, $last_timestamp, $debug_level;
    $debug_level = isset($convoArr['conversation']['debug_level']) ? $convoArr['conversation']['debug_level'] : $debug_level;
    if (empty($functionName)) {
        $functionName = 'Called outside of function';
    }
    //only log the debug info if the info level is equal to or less than the chosen level
    if ($level <= $debug_level) {
        // Set elapsed time from last debug call and update last timestamp
        if ($quickdebug == 1) {
            outputDebug($fileName, $functionName, $line, $info);
        }
        $current_timestamp = microtime(true);
        $usecN = round($current_timestamp - floor($current_timestamp), 5);
        //Lose the decimal point and everything to the left of it
        $usecD = str_replace('0.', '', $usecN);
        $et = $current_timestamp - $last_timestamp;
        $elapsed_time = number_format($et * 1000, 3);
        $last_timestamp = $current_timestamp;
        //build timestamp index for the debug array
        $index = date('d-m-Y H:i:s.') . $usecD . "[{$level}][{$debug_level}] - Elapsed time: {$elapsed_time} milliseconds";
        //If there's already an index in the debug array with the same value, just add a space, to make a new, unique index that is visually identical.
        while (array_key_exists($index, $debugArr)) {
            $index .= ' ';
        }
        //mem_tracer($fileName, $functionName, $line); # only uncomment this to trace memory leaks!
        //add to array
        $debugArr[$index]['fileName'] = basename($fileName);
        $debugArr[$index]['functionName'] = $functionName;
        $debugArr[$index]['line'] = $line;
        $debugArr[$index]['info'] = $info;
        if ($srai_iterations < 1) {
            $sr_it = 0;
        } else {
            $sr_it = $srai_iterations;
        }
        $debugArr[$index]['srai_iteration'] = $sr_it;
        //if we are logging to file then build a log file. This will be overwriten if the program completes
        if ($writetotemp == 1) {
            writefile_debug(implode("\n", $debugArr), $convoArr);
        }
    }
}
Exemplo n.º 4
0
/**
 * Determine where a function is being called from
 *
 * @version 1.0
 * @since   1.0.0
 * @author  Dan Aldridge
 *
 * @param   string     $info
 * @param   string  $nl
 *
 * @return  string
 */
function getExecInfo($info = null, $nl = '<br />')
{
    $a = debug_backtrace();
    $a = array_slice($a, 2);
    $msg = array();
    $x = 0;
    foreach ($a as $key => $file) {
        $msg[] = outputDebug($file, $x == 0 ? $info : null, $nl);
        $x++;
    }
    return implode('', $msg) . $nl;
}
Exemplo n.º 5
0
 function Path($param1 = null, $param2 = null, $param3 = null, $param4 = null, $param5 = null, $param6 = null, $param7 = null, $param8 = null, $param9 = null)
 {
     $debug = false;
     $num_args = func_num_args();
     $arg_list = func_get_args();
     outputDebug("creating new Path ({$num_args})", $debug);
     $args = "";
     for ($i = 0; $i < $num_args; $i++) {
         if ($i != 0) {
             $args .= ", ";
         }
         $args .= "\$param" . ($i + 1);
     }
     eval("\$this->constructor" . $i . "(" . $args . ");");
 }