Example #1
0
 public function testBuildWithPathType()
 {
     $router = new Router();
     $router->add("test", new Host("/", array()));
     $this->assertSame("/", $router->build("test", array(), Host::PATH_ONLY));
     $this->assertSame("/", $router->build("test", array(), Host::PATH_NETWORK));
     $this->assertSame("/", $router->build("test", array(), Host::PATH_FULL));
     // with _host
     $this->assertSame("/", $router->build("test", array("_host" => "example.com"), Host::PATH_ONLY));
     $this->assertSame("//example.com/", $router->build("test", array("_host" => "example.com"), Host::PATH_NETWORK));
     $this->assertSame("//example.com/", $router->build("test", array("_host" => "example.com"), Host::PATH_FULL));
     // with _scheme, no _host
     $this->assertSame("/", $router->build("test", array("_scheme" => "https"), Host::PATH_ONLY));
     $this->assertSame("/", $router->build("test", array("_scheme" => "https"), Host::PATH_NETWORK));
     $this->assertSame("/", $router->build("test", array("_scheme" => "https"), Host::PATH_FULL));
     // with _scheme and _host
     $this->assertSame("/", $router->build("test", array("_host" => "example.com", "_scheme" => "https"), Host::PATH_ONLY));
     $this->assertSame("//example.com/", $router->build("test", array("_host" => "example.com", "_scheme" => "https"), Host::PATH_NETWORK));
     $this->assertSame("https://example.com/", $router->build("test", array("_host" => "example.com", "_scheme" => "https"), Host::PATH_FULL));
 }
Example #2
0
 public function testBuild()
 {
     $router = new Router();
     $router->add("home", new Route("/"));
     $router->add("article", new Route("/show/{title}"));
     $router->add("mvc", new Route("/{controller}/{action}/{param}", array("controller" => "home", "action" => "index", "param" => "")));
     $this->assertSame("/", $router->build("home", array()));
     $this->assertSame("/", $router->build("home", array("something" => "else")));
     $this->assertFalse($router->build("article", array()));
     $this->assertFalse($router->build("article", array("something" => "else")));
     $this->assertFalse($router->build("article", array("title" => "")));
     $this->assertFalse($router->build("article", array("title" => false)));
     $this->assertSame("/show/1", $router->build("article", array("title" => "1")));
     $this->assertSame("/show/thisisatitle", $router->build("article", array("title" => "thisisatitle")));
     $this->assertSame("/", $router->build("mvc", array()));
     $this->assertSame("/", $router->build("mvc", array("foo" => "bar")));
     $this->assertSame("/", $router->build("mvc", array("controller" => "")));
     $this->assertSame("/", $router->build("mvc", array("controller" => false)));
     $this->assertSame("/", $router->build("mvc", array("controller" => "home")));
 }
Example #3
0
$config = new Config();
$utility = new Utility();
$config->load();
$session = new Session();
$db = new mysqli($config->sql_hostname, $config->sql_username, $config->sql_password, $config->sql_database);
if ($db->connect_error) {
    die("Unable to connect to MySQLi");
}
foreach (glob("hooks/*.hook.php") as $file) {
    include $file;
}
$session->authorize();
$session->user->permissions = new Permissions();
$session->user->permissions->load($session->user->id);
$kyros->theme = $utility->load_theme();
$router->build();
$kyros->site_dir = $config->site_dir;
$kyros->theme_dir = $config->theme_dir . $config->theme . "/";
$wrapper = new Template();
$wrapper->sidebar = true;
$wrapper->admin_button = "";
$wrapper->topic_button = "";
$wrapper->hooks = $hooks;
$wrapper->site_name = $config->site_name;
$wrapper->site_dir = $config->site_dir;
$categories = array();
if ($result = $db->query("SELECT * FROM categories")) {
    while ($row = $result->fetch_object()) {
        $categories[] = $row;
    }
} else {