Пример #1
0
 public function __routeBundle($path)
 {
     /**
      * Security access for development
      */
     e::$security->developerAccess("EvolutionSDK Management Center");
     // Get name
     $name = array_shift($path);
     // Site sandbox TODO MOVE THIS SOMEWHERE ELSE?
     if ($name == 'sandbox') {
         $path = implode('/', $path);
         if ($path === '') {
             $path = 'index';
         }
         $file = e\site . '/sandbox/' . $path . '.php';
         $dir = dirname($file);
         if (!is_dir($dir)) {
             throw new Exception("Sandbox directory `{$dir}` does not exist");
         }
         chdir($dir);
         echo '<style>body {margin: 0; padding: 0; font-family: Tahoma, Lucida Grande, Sans, sans-serif;}</style>';
         echo '<div style="padding: 1em; background: black; box-shadow: 0 0 4px #000; color: #fff;"><b>Sandbox File </b>';
         echo '<pre style="display: inline">' . $file . '</pre></div>';
         require_once $file;
         e\complete();
     }
     if ($name === 'manage') {
         e\redirect('/@manage');
     }
     if ($name === '' || is_null($name)) {
         $name = 'manage';
     }
     $bundles = e::configure('manage')->bundle;
     $ns = array_search($name, $bundles);
     if ($ns === false) {
         throw new Exception("No manage panel for `{$name}`");
     }
     $class = $ns . '\\Manage';
     $panel = new $class();
     $title = "EvolutionSDK&trade; &rarr; " . $panel->title;
     $css = file_get_contents(__DIR__ . '/../debug/theme.css') . self::style();
     $header = '<span>EvolutionSDK</span> &rarr; <a href="/@manage">Manage System</a>' . ($name !== 'manage' ? " &rarr; <span>" . $panel->title . "</span>" : '');
     echo "<!doctype html><html><head><title>{$title}</title><style>{$css}</style></head><body class='_e_dump'><h1>{$header}</h1><div class='manage-page'>";
     echo $panel->page($path);
     echo "</div></body></html>";
     e\complete();
 }
Пример #2
0
<?php

namespace e;

use e;
/**
 * Display the exception
 */
if (isset($exception)) {
    header("Content-Type: text/html");
    $title = "EvolutionSDK&trade; &bull; Exception";
    $css = file_get_contents(__DIR__ . '/theme.css');
    echo "<!doctype html><html><head><title>{$title}</title><style>{$css}</style></head><body class='_e_dump'>";
    echo render_exception($exception, isset($overrideUrl) ? $overrideUrl : null);
    if (!empty($additional)) {
        echo $additional;
    }
    echo "</body></html>";
    e\complete(true);
}
if (isset($title)) {
    header("Content-Type: text/html");
    $htmlt = "EvolutionSDK&trade; &bull; {$title}";
    $css = file_get_contents(__DIR__ . '/theme.css');
    echo "<!doctype html><html><head><title>{$htmlt}</title><style>{$css}</style></head><body class='_e_dump'>";
    if (isset($body)) {
        echo "<div class='section'><h1>{$title}</h1><p>{$body}</p></div>";
    }
    echo "</body></html>";
    e\complete(true);
}
Пример #3
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();
 }
Пример #4
0
 public function __routeBundle($path)
 {
     /**
      * Security access for development
      */
     e::$security->developerAccess("Modify environment variable.");
     $form = array_shift($path);
     if (isset($_GET['var'])) {
         $var = base64_encode($_GET['var']);
     } else {
         $var = array_shift($path);
     }
     if (!in_array($form, array('edit', 'delete', 'update'))) {
         throw new Exception("Invalid environment variable action `{$form}`");
     }
     $this->{$form}($var);
     e\complete();
 }
Пример #5
0
                            }
                        }
                    }
                }
            }
        }
    }
    return $out . "\n";
}
/**
 * Get source and loop vars
 */
foreach (dumpVars($___DUMP) as $___VAR) {
    $___DUMP .= dumpVar($___VAR, isset(${$___VAR}) ? ${$___VAR} : null);
}
/**
 * View dump
 */
$title = "EvolutionSDK&trade; &bull; Debug Dump";
$css = file_get_contents(__DIR__ . '/theme.css');
echo "<!doctype html><html><head><title>{$title}</title><style>{$css}</style></head><body class='_e_dump'><h1>{$title}</h1>";
echo $___DUMP;
$stack = debug_backtrace();
array_shift($stack);
if (defined('DUMP_SINGLE_VAR')) {
    array_shift($stack);
}
echo stylize_stack_trace($stack);
echo "</body></html>";
e\complete();
Пример #6
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();
 }