Ejemplo n.º 1
0
 public function __construct()
 {
     $this->app = Application::getInstance();
     $this->view = View::getInstance();
     $this->config = $this->app->getConfig();
     $this->input = InputData::getInstance();
     $this->httpContext = $this->app->getHttpContext();
     $this->db = new SimpleDB();
 }
Ejemplo n.º 2
0
<div>
    <?php 
if (!\EndF\Application::getInstance()->getHttpContext()->getSession()->hasSessionKey('token')) {
    ?>
    <div id="login" class="row">
        <?php 
    \EndF\FormViewHelper::init()->initForm('../users/login', ['class' => 'formGroup'], 'post')->initLabel()->setValue("Username")->setAttribute('for', 'username')->create()->initTextBox()->setName('username')->setAttribute('id', 'username')->setAttribute('class', 'form-control input-md')->create()->initLabel()->setValue("Password")->setAttribute('for', 'password')->create()->initPasswordBox()->setName('password')->setAttribute('id', 'password')->setAttribute('class', 'form-control input-md')->create()->initSubmit()->setAttribute('value', 'Login')->setAttribute('class', 'btn btn-primary btn-lg col-sm-4 col-sm-offset-4')->create()->render();
    ?>
    </div>
    <div class="row">
        <h1 class="text-center">Register</h1>
        <?php 
    \EndF\FormViewHelper::init()->initForm('../users/register', ['class' => 'form-group'], 'post')->initLabel()->setValue("Username")->setAttribute('for', 'username')->create()->initTextBox()->setName('username')->setAttribute('id', 'username')->setAttribute('class', 'form-control input-md')->create()->initLabel()->setValue("Password")->setAttribute('for', 'password')->create()->initPasswordBox()->setName('password')->setAttribute('id', 'password')->setAttribute('class', 'form-control input-md')->create()->initLabel()->setValue("Confirm Password")->setAttribute('for', 'confPassword')->create()->initPasswordBox()->setName('confirm')->setAttribute('id', 'confPassword')->setAttribute('class', 'form-control input-md')->create()->initSubmit()->setAttribute('value', 'Register')->setAttribute('class', 'btn btn-primary btn-lg col-sm-4 col-sm-offset-4')->create()->render(true);
    ?>
    </div>
    <?php 
} else {
    ?>
    <div>
        <h1>Hello, <?php 
    echo \EndF\Application::getInstance()->getHttpContext()->getUserData()->username;
    ?>
</h1>
        <?php 
    \EndF\FormViewHelper::init()->initForm('../users/logout', ['class' => 'formGroup'], 'post')->initSubmit()->setAttribute('value', 'Logout')->setAttribute('class', 'btn btn-primary btn-lg col-sm-4 col-sm-offset-4')->create()->render();
    ?>
    </div>
    <?php 
}
?>
</div>
Ejemplo n.º 3
0
 public static function hasRole($role)
 {
     $col = 'is' . ucfirst($role);
     try {
         $statement = self::$database->prepare("SELECT {$col}\n                      FROM users\n                      WHERE username = ? AND id = ?");
         $statement->bindColumn(1, $col);
         $statement->bindParam(1, Application::getInstance()->getSession()->_username);
         $statement->bindParam(2, Application::getInstance()->getSession()->_login);
         $statement->execute();
         $response = $statement->fetch(\PDO::FETCH_ASSOC);
         $response = $response['is' . ucfirst($role)];
     } catch (\PDOException $ex) {
         throw new \Exception("Check your db, missing role '{$col}'");
     }
     if ($response) {
         return Common::normalize($response, 'bool');
     }
     return false;
 }
Ejemplo n.º 4
0
<div id="header">
    <header>
        <nav class="navbar navbar-default">
            <ul class="nav navbar-nav">
                <li><a href="/">Home</a></li>
                <?php 
if (\EndF\Application::getInstance()->getHttpContext()->getSession()->hasSessionKey('token')) {
    ?>
                    <li><a href="/users/profile">Profile</a></li>
                <?php 
}
?>
                <li role="separator" class="divider"></li>
            </ul>
        </nav>
        <div class="row">
            <h1>Welcome to Hell's Conferences!</h1>
        </div>
    </header>

</div>
Ejemplo n.º 5
0
<?php

declare (strict_types=1);
include '../../EndF/Application.php';
ini_set('display_errors', '1');
$app = \EndF\Application::getInstance();
$app->run();
Ejemplo n.º 6
0
<?php

$userData = \EndF\Application::getInstance()->getHttpContext()->getUserData();
?>

<div class="row">
    <ul class="list-group">
        <li class="list-group-item lead"><span class="label label-primary pull-left">Username: </span><?php 
echo $userData->username;
?>
</li>
        <li class="list-group-item lead"><span class="label label-primary pull-left">Your role: </span><?php 
echo $userData->role;
?>
</li>
    </ul>
</div>