예제 #1
0
    foreach (dumpVarsText($___DUMP) as $___VAR) {
        $___DUMP .= dumpVarText($___VAR, isset(${$___VAR}) ? ${$___VAR} : null);
    }
    /**
     * View dump
     */
    echo "       /* * * * * * * * * * * * * *\n        * EvolutionSDK Debug Dump *\n        * * * * * * * * * * * * * */\n\n";
    echo $___DUMP;
    $stack = debug_backtrace();
    echo "Stack:\n\n";
    array_shift($stack);
    if (defined('DUMP_SINGLE_VAR')) {
        array_shift($stack);
    }
    echo dumpVarText(null, $stack);
    e\disable_trace();
    e\complete();
}
/**
 * Ensure proper content type
 * @author Kelly Becker
 */
header("Content-Type: text/html");
e\trace('Debug Dump');
/**
 * Helper functions
 */
function dumpVars(&$out)
{
    list($void, $file, $line) = $out;
    if (defined('DUMP_SINGLE_VAR')) {
예제 #2
0
 public function route_bundle_api($bundle, $path)
 {
     $version = array_shift($path);
     $type = array_shift($path);
     if ($type !== 'json') {
         throw new Exception("API format `{$type}` is not a valid type");
     } else {
         if (!isset($_GET['--debug'])) {
             header("Content-type: application/json");
         }
     }
     e\trace(__CLASS__, "API `{$type}` access for bundle `{$bundle}`");
     /**
      * Wrap any exceptions
      */
     try {
         if (strlen($bundle) === 0) {
             throw new Exception("No bundle specified for routing after API access `@`");
         }
         $class = "Bundles\\{$bundle}\\api\\{$version}";
         $result = new $class($path);
         e\trace(__CLASS__, "Processing API access with `" . get_class($result) . "`");
         foreach ($path as $segment) {
             /**
              * Null
              */
             if (is_null($result)) {
                 break;
             }
             /**
              * Handle String access
              */
             if (is_string($result)) {
                 $subs = explode(',', $segment);
                 $temp = '';
                 foreach ($subs as $sub) {
                     $sub = explode('-', $sub);
                     if (count($sub) == 1) {
                         $sub[] = $sub[0];
                     }
                     $temp .= substr($result, $sub[0], $sub[1] - $sub[0] + 1);
                 }
                 $result = $temp;
             } else {
                 if (is_array($result)) {
                     if (isset($result[$result])) {
                         $result = $result[$result];
                     } else {
                         $result = null;
                     }
                 } else {
                     if (is_object($result)) {
                         if (isset($result->{$segment})) {
                             $result = $result->{$segment};
                         } else {
                             if (method_exists($result, $segment)) {
                                 $result = $result->{$segment}();
                             } else {
                                 $result = null;
                             }
                         }
                     }
                 }
             }
         }
         /**
          * API output
          */
         switch ($type) {
             case 'plain':
                 echo $result;
                 break;
             case 'json':
                 if (method_exists($result, '__toAPI')) {
                     $result = $result->__toAPI();
                 }
                 echo json_encode($result);
                 break;
         }
     } catch (Exception $exception) {
         e::$events->exception($exception);
         if (isset($_GET['--debug'])) {
             throw $exception;
         }
         /**
          * Format exception for API
          */
         switch ($type) {
             case 'plain':
                 throw $exception;
             case 'json':
                 echo json_encode(array('exception' => $exception->getMessage()));
                 break;
             default:
                 throw $exception;
         }
     }
     if (!isset($_GET['--debug'])) {
         e\disable_trace();
     }
     e\complete();
 }
예제 #3
0
 /**
  * Handle Static Resources
  * @author Nate Ferrero
  */
 private function staticResource($bundle, $book, $path)
 {
     $path = implode('/', $path);
     if (!empty($bundle)) {
         $file = stack::bundleLocations($bundle) . '/documentation/static/' . $path;
     }
     if (!empty($book)) {
         $file = $this->files['books'][$book] . '/static/' . $path;
     }
     if (!is_file($file)) {
         throw new Exception("Static documentation file `{$file}` does not exist");
     }
     $mime = 'application/octet-stream';
     switch (pathinfo($file, PATHINFO_EXTENSION)) {
         case 'png':
             $mime = 'image/png';
             break;
         case 'jpeg':
         case 'jpg':
             $mime = 'image/jpeg';
             break;
     }
     e\disable_trace();
     header('Content-Type: ' . $mime);
     header('Content-Length: ' . filesize($file));
     readfile($file);
     e\complete();
 }