static function Handle($errno, $errstr, $errfile = '', $errline = '') { if (!(error_reporting() & $errno)) { // This error code is not included in error_reporting return; } switch ($errno) { case E_USER_ERROR: // echo "<b>My ERROR</b> [$errno] $errstr<br />\n"; // echo " Fatal error on line $errline in file $errfile"; // echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n"; // echo "Aborting...<br />\n"; LogCLI::Fail($errstr); // exit(1); break; case E_USER_WARNING: // echo "<b>My WARNING</b> [$errno] $errstr<br />\n"; LogCLI::Warning($errstr); break; case E_USER_NOTICE: // echo "<b>My NOTICE</b> [$errno] $errstr<br />\n"; LogCLI::Notice($errstr); break; default: // echo "Unknown error type: [$errno] $errstr<br />\n"; $trace = debug_backtrace(); LogCLI::Fail($errstr); LogCLI::Fail('File: ' . $trace[0]['file']); LogCLI::Fail('Line: ' . $trace[0]['line']); LogCLI::Fail('Function: ' . $trace[0]['function']); break; } /* Don't execute PHP internal error handler */ return true; }
public static function Dump($var, $verbosityLevel = 0, $message = null, $level = 0) { $output = ''; if ($level == 0) { $display = false; } else { $display = true; //$output = ']['; } foreach ((array) $var as $i => $value) { if (is_array($value) or is_object($value)) { $output .= self::Dump($value, $verbosityLevel, $message, $level + 1); } else { if ($display === true) { LogCLI::MessageResult($message . LogCLI::GREEN . $i . LogCLI::RESET . ' = ' . LogCLI::YELLOW . $value . LogCLI::RESET, $verbosityLevel, LogCLI::INFO); } else { $output .= "[{$i} = {$value}]"; } } } return $output; }
public static function TraverseTree(array &$paths, $lookFor = 'defaults') { LogCLI::Message('Traversing definition tree in search for: ' . LogCLI::YELLOW . $lookFor . LogCLI::RESET, 6); $matches = array(); foreach (self::GetMultiDimentionalElements($paths) as $path) { //LogCLI::MessageResult('Element: '.LogCLI::BLUE.$path.LogCLI::RESET, 6, LogCLI::INFO); $pathElements = explode('/', $path); //$lastElement = end($pathElements); //if(stripos($path, $lookFor) !== FALSE) if (end($pathElements) == $lookFor) { LogCLI::MessageResult('Match found at: ' . LogCLI::BLUE . $path . LogCLI::RESET, 2, LogCLI::INFO); $matches[] = $path; /* this code is good, don't remove if(!is_object(self::accessArrayElementByPath($this->nginx, $fullpath))) { $last = StringTools::ReturnLastBit($fullpath); $fullpath = StringTools::DropLastBit($fullpath, 1); $fullpath = StringTools::AddBit($fullpath, $this->foreignDefinitions[$last]); LogCLI::MessageResult('Common config detected! Defined by: '.LogCLI::BLUE.$fullpath.LogCLI::RESET, 5, LogCLI::INFO); } */ } } LogCLI::Result(LogCLI::INFO); if (!empty($matches)) { return $matches; } else { return false; } }