Ejemplo n.º 1
0
 public function exists($username)
 {
     $db = Database::getInstance($this->dbInstance);
     $result = $db->prepare("SELECT id FROM users WHERE username = ?");
     $result->execute(array($username));
     return $result->rowCount() > 0;
 }
Ejemplo n.º 2
0
 public function exists($text)
 {
     $db = Database::getInstance($this->dbInstance);
     $result = $db->prepare("SELECT id FROM categories WHERE categoryText = ?");
     $result->execute(array($text));
     return $result->rowCount() > 0;
 }
Ejemplo n.º 3
0
 public static function isUserInRole($username, $roleText)
 {
     $result = false;
     $db = Database::getInstance(self::DB_INSTANCE);
     $desiredRoleQuery = $db->prepare("select id from user_roles where roleText = ?");
     $desiredRoleQuery->execute(array($roleText));
     $desiredRole = $desiredRoleQuery->fetch();
     if ($desiredRoleQuery->rowCount() < 1) {
         throw new \Exception("Role {$roleText} does not exist");
     }
     $actualRoleQuery = $db->prepare("select roleId from users where username = ?");
     $actualRoleQuery->execute(array($username));
     $actualRole = $actualRoleQuery->fetch();
     if ($desiredRole['id'] === $actualRole['roleId']) {
         $result = true;
     }
     return $result;
 }
Ejemplo n.º 4
0
$method = $_SERVER['REQUEST_METHOD'];
// echo $self; exit;
//var_dump($route);exit;
$index = basename($self);
$directories = str_replace($index, '', $self);
$requestString = str_replace($directories, '', $uri);
$requestParams = explode("/", $requestString);
$controller = array_shift($requestParams);
$action = array_shift($requestParams);
$isArea = false;
//check if route requested route is configured in the custom routes
// if not- try to use the default routing system
try {
    $foundRoute = $router->findRoute(strtolower($method), $requestString);
    $exploded = explode("\\", $foundRoute['action']);
    $tempExploded = $exploded;
    $controllerAndMethod = array_pop($exploded);
    $exploded = explode("@", $controllerAndMethod);
    $action = $exploded[1];
    $controllerSplit = explode("Controller", $exploded[0]);
    $controller = $controllerSplit[0];
    $requestParams = $foundRoute['params'];
    if (strpos($foundRoute['action'], 'Hyper\\Application\\\\Areas\\') !== false) {
        $isArea = true;
    }
} catch (\Hyper\Core\Exceptions\RouteNotFoundException $e) {
    //do nothing; execution will continue with the default routing configuration
}
\Hyper\Core\Database::setInstance(\Hyper\Config\DatabaseConfig::DB_INSTANCE, \Hyper\Config\DatabaseConfig::DB_DRIVER, \Hyper\Config\DatabaseConfig::DB_USER, \Hyper\Config\DatabaseConfig::DB_PASS, \Hyper\Config\DatabaseConfig::DB_NAME, \Hyper\Config\DatabaseConfig::DB_HOST);
$app = new \Hyper\Application($controller, $action, $requestParams, $isArea, $tempExploded[4]);
$app->start();