public function deleteMessage($data)
 {
     $message = $data['params.message'];
     $data = $this->model('message')->getById($message);
     if ($data->to->id !== $_COOKIE['pws_uid']) {
         \flash('Bericht niet gevonden!', 'warning');
         Router::load()->redirect('/messages');
     }
     $this->model('message')->deleteById($message);
     \flash('Bericht verwijderd!');
     Router::load()->redirect('/messages');
 }
 public function doRegister($data)
 {
     $this->set('title', 'Registreren');
     $user = $this->model('user');
     $error = '';
     if (isset($data['post.email']) && isset($data['post.username']) && isset($data['post.password'])) {
         $email = $data['post.email'];
         $username = $data['post.username'];
         $password = $data['post.password'];
         $this->set('email', $email);
         $this->set('username', $username);
         $password = \hash_password($username, $password);
         if ($user->reset()->where('email', $email)->count()) {
             \flash('Dit e-mailadres is al in gebruik!', 'danger');
         } elseif ($user->reset()->where('username', $username)->count()) {
             \flash('Deze gebruikersnaam is al in gebruik!', 'danger');
         } else {
             $user->insert(['email' => $email, 'username' => $username, 'password' => $password]);
             \flash('Je account is aangemaakt. Log hieronder in om verder te gaan.', 'success');
             Router::load()->redirect('/login');
         }
     }
     $this->render('register');
 }
Esempio n. 3
0
    $className = ltrim($className, '\\');
    $fileName = '';
    $namespace = '';
    if ($lastNsPos = strrpos($className, '\\')) {
        $namespace = substr($className, 0, $lastNsPos);
        $className = substr($className, $lastNsPos + 1);
        $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
    }
    $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
    require_once PWS_ROOT . DIRECTORY_SEPARATOR . $fileName;
});
foreach (['medoo.php', 'security.php', 'flash.php', 'load.php'] as $helper) {
    require_once PWS_ROOT . DIRECTORY_SEPARATOR . 'PWS' . DIRECTORY_SEPARATOR . 'Common' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . $helper;
}
use PWS\Router;
ob_start();
try {
    $router = Router::load();
    require_once 'routes.php';
    $router->start();
} catch (Exception $e) {
    ob_end_clean();
    if (PWS_DEV) {
        echo '<h1>Exception!</h1>';
        echo '<p>' . $e->getMessage() . '</p>';
        throw $e;
    } else {
        echo '<h1>Er ging iets mis...</h1>';
        echo '<p>Probeer het later nog eens.</p>';
    }
}