Example #1
0
 /**
  * Handle any uncaught Zend Framework Exceptions
  */
 private function _initZendExceptions()
 {
     # Prepare
     $this->bootstrap('zend-run');
     global $Exceptions;
     # Error Handling
     if (!empty($Exceptions)) {
         # An Error Occured
         if (class_exists('Bal_Exceptor') && class_exists('Bal_Log')) {
             # Log Exceptions
             if (is_traversable($Exceptions)) {
                 foreach ($Exceptions as $Exception) {
                     # Log Exceptions
                     $Exceptor = new Bal_Exceptor($Exception);
                     $Exceptor->log();
                 }
             }
             # Try to Dispatch the Error Controller
             try {
                 # Fetch
                 $FrontController = Zend_Controller_Front::getInstance();
                 //$Response = $FrontController->getResponse();
                 //$Request = $FrontController->getRequest();
                 # Apply
                 //$Request->setDispatched(false);
                 //$Response->setException(new Exception('An uncaught error has occurred'));
                 # Dispatch
                 //$FrontController->dispatch($Request, $Response);
                 $FrontController->dispatch();
             } catch (Exception $Exception) {
                 # Log Exception
                 $Exceptor = new Bal_Exceptor($Exception);
                 $Exceptor->log();
                 # Display a Error Page
                 echo '<!DOCTYPE html><html><head><title>An error has occurred.</title></head><body>' . '<h1>An error has occurred.</h1>' . '<h2>Error Log</h2>' . Bal_Log::getInstance()->render() . '<h2>Error Details</h2>' . '<pre>' . '$_GET = ' . "\n" . var_export($_GET, true) . "\n\n" . '$_POST = ' . "\n" . var_export($_POST, true) . "\n\n" . '$_SERVER = ' . "\n" . var_export($_SERVER, true) . "\n\n" . '$_ENV = ' . "\n" . var_export($_SERVER, true) . "\n\n" . 'php.include_path = ' . "\n" . var_export(get_include_path(), true) . "\n\n" . '</pre>' . '</body></html>';
             }
         } else {
             echo '<!DOCTYPE html><html><head><title>An error has occurred.</title></head><body>' . '<h1>An error has occurred.</h1>' . '</body></html>';
         }
     }
 }
Example #2
0
/**
 * Test if a value is like an array (IS an array,
 * or implements \Traversable, \Countable and \ArrayAccess interfaces).
 *
 * @param mixed $var the value
 * @return bool true if the value is like an array
 */
function is_like_array($var) : bool
{
    return is_array($var) || is_traversable($var) && is_countable($var) && is_array_access($var);
}