static function display() { $status = array('requested url' => SE::getCurrentUrl(), 'controller' => SE::getController(), 'action' => SE::getAction(), 'params' => 'array(' . join(', ', SE::getParams()) . ')', 'request method' => Request::method()); self::displayTable($status, 'Dispatcher status'); $markers = array(); $old_mark = ''; foreach (Benchmark::$mark as $mark => $time) { $markers[$mark] = Benchmark::time($old_mark, $mark); $old_mark = $mark; } self::displayTable($markers, 'Benchmark'); if (!empty($_GET)) { self::displayTable($_GET, 'GET'); } if (!empty($_POST)) { self::displayTable($_POST, 'POST'); } if (!empty($_COOKIE)) { self::displayTable($_COOKIE, 'COOKIE'); } self::displayTable($_SERVER, 'SERVER'); }
define('TABLE_PREFIX', $config[$db_group]['prefix']); define('USE_PDO', $config[$db_group]['pdo']); if (USE_PDO) { try { $__SE_CONN__ = new PDO(DB_DSN, DB_USER, DB_PASS); } catch (PDOException $error) { die('DB Connection failed: ' . $error->getMessage()); } if ($__SE_CONN__->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { $__SE_CONN__->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } } else { require_once SYSPATH . '/libraries/DoLite.php'; $__SE_CONN__ = new DoLite(DB_DSN, DB_USER, DB_PASS); } Model::connection($__SE_CONN__); Model::getConnection()->exec("set names 'utf8'"); } // Set debugger define('DEBUG', $config['debug']); /** * Get all routes and process them */ if (isset($route)) { foreach ($route as $key => $value) { SE::addRoute($key, $value); } } // Dispatch Simplengine SE::dispatch();
echo "in SE: accessing SC\n"; var_dump(get_class_vars('SC')); echo "in SE: accessing SD\n"; var_dump(get_class_vars('SD')); echo "in SE: accessing SE\n"; var_dump(get_class_vars('SE')); } } echo ">>> testing instance variables from global scope\n"; echo "accessing C\n"; var_dump(get_class_vars('C')); echo "accessing D\n"; var_dump(get_class_vars('D')); echo "accessing E\n"; var_dump(get_class_vars('E')); echo ">>> testing instance variables from class scope\n"; C::show(); D::show(); E::show(); echo ">>> testing static variables from global scope\n"; echo "accessing SC\n"; var_dump(get_class_vars('SC')); echo "accessing SD\n"; var_dump(get_class_vars('SD')); echo "accessing SE\n"; var_dump(get_class_vars('SE')); echo ">>> testing static variables from class scope\n"; SC::show(); SD::show(); SE::show();
public static function dispatch($url = null) { Benchmark::start('dispatch'); if ($url === null) { $url = $_SERVER['QUERY_STRING']; } // we populate the $_GET table if ($pos = strpos($url, '&')) { parse_str(substr($url, $pos), $_GET); } // remove slashes (for route convention) $url = trim($url, '/'); // removing the suffix for search engine static simulations if (URL_SUFFIX != null and ($pos_to_cut = strrpos($requested_url, $suffix)) !== false) { $requested_url = substr($requested_url, 0, $pos_to_cut); } self::$url = $url; if (empty($url)) { return self::executeAction(self::getController(), self::getAction(), self::getParams()); } else { if (count(self::$routes) === 0) { self::$params = explode('/', $url); return self::executeAction(self::getController(), self::getAction(), self::getParams()); } else { if (isset(self::$routes[$url])) { self::$params = explode('/', self::$routes[$url]); return self::executeAction(self::getController(), self::getAction(), self::getParams()); } } } // loop through the route array looking for wildcards foreach (self::$routes as $rule => $route) { // convert wildcards to regex if (strpos($rule, ':') !== false) { $rule = str_replace(':any', '(.+)', str_replace(':num', '([0-9]+)', $rule)); } // does the regex match? if (preg_match('#^' . $rule . '$#', $url)) { // do we have a back-reference? if (strpos($route, '$') !== false and strpos($rule, '(') !== false) { $route = preg_replace('#^' . $rule . '$#', $route, $url); } self::$params = explode('/', $route); // we fund it, so we can break the loop now! return self::executeAction(self::getController(), self::getAction(), self::getParams()); } } self::$params = explode('/', $url); return self::executeAction(self::getController(), self::getAction(), self::getParams()); }