public function verify()
 {
     if (Input::exists()) {
         //$remember = (Input::get('remember-me') === 'on') ? true : false;
         $login = Auth::load()->login(Input::get('username'), Input::get('password'));
         if ($login) {
             $status = DB::load()->query('SELECT 
           Status_ID FROM Users WHERE ID = ?', array(Session::getKey('User', 'ID')))->results();
             if ($status[0]->Status_ID == 1) {
                 $url = $this->data['project_url'];
                 Session::set('ERRORS', "Din bruger er blevet deaktiveret. <a href='{$url}#kontakt'>Kontakt</a> os venligst for at høre nærmere.");
                 Auth::load()->logout();
                 Redirect::to($this->data['project_url'] . 'login#form');
                 exit;
             }
             if (Auth::load()->role('admin') || Auth::load()->role('broker')) {
                 Session::set('SUCCESS', I18n::get('AUTH_LOGIN_SUCCESS'));
                 Redirect::to($this->data['project_url'] . 'admin');
             } else {
                 Session::set('SUCCESS', I18n::get('AUTH_LOGIN_SUCCESS'));
                 Redirect::to($this->data['project_url'] . 'min-side');
             }
         } else {
             Session::set('ERRORS', I18n::get('AUTH_LOGIN_FAILED'));
             Redirect::to($this->data['project_url'] . 'login#form');
         }
     }
 }
 public function validateInput()
 {
     $validate = Validator::load(DB::load());
     $validation = $validate->checkPost($_POST, array('username' => array('required' => true, 'min' => 3, 'max' => 32, 'notTaken' => 'Users'), 'full_name' => array('required' => true, 'min' => 3, 'max' => 50), 'org' => array('required' => false, 'max' => 32), 'password' => array('required' => true, 'min' => 3, 'max' => 64, 'ValidPass' => Input::get('password')), 'email' => array('required' => true, 'min' => 3, 'max' => 32, 'validEmail' => Input::get('email'))));
     if (!$v->passed()) {
         foreach ($v->errors() as $error) {
             Session::addKey('WARNINGS', $error, $error);
         }
         Redirect::to(Input::get('current'));
         exit;
     }
 }
 public function update($type, $ID)
 {
     if (Input::exists('post') && $ID == Input::get('ID')) {
         //Update post
         $this->validateInput();
         // update
         DB::load()->update('Options', 'ID', Input::get('ID'), array('Value' => Input::get('editor')));
         Session::set('SUCCESS', I18n::get('SYSTEM_CRUD_SUCCESS'));
         Redirect::to(Input::get('current_url'));
     } else {
         $options = DB::load()->query("SELECT \n        ID,Label, Name, Value FROM Options WHERE ID = ? ORDER BY ID DESC", array($ID))->results();
         return (object) array('options' => $options);
     }
 }
 public function delete($type)
 {
     if (Input::exists()) {
         $source = PATH_ROOT . 'public/uploads/source/';
         $thumbs = PATH_ROOT . 'public/uploads/thumbs/';
         $upload = DB::load()->select(array('ID, Slug'), 'Uploads', null, array(array('ID', '=', Input::get('ID'))))->results();
         $file = $upload[0]->Slug;
         Upload::load($source)->remove($file);
         Upload::load($source)->remove($file, $thumbs);
         DB::load()->delete('Uploads', array(array('ID', '=', Input::get('ID'))));
         Session::set('SUCCESS', I18n::get('SYSTEM_CRUD_SUCCESS'));
     }
     Redirect::to($this->data['project_url'] . 'admin/read/uploads');
 }
Example #5
0
<?php

/*
 * Bootstrap database
 */
use WebSupportDK\PHPScrud\DB;
define('DB_DRIVER', $app->get('config')->db->driver);
define('DB_HOST', $app->get('config')->db->host);
define('DB_NAME', $app->get('config')->db->name);
define('DB_USER', $app->get('config')->db->username);
define('DB_PASS', $app->get('config')->db->password);
define('DB_CHARSET', $app->get('config')->db->charset);
define('DB_COLLATION', $app->get('config')->db->collation);
define('DB_PREFIX', $app->get('config')->db->prefix);
DB::load(DB_DRIVER, DB_HOST, DB_NAME, DB_USER, DB_PASS);
Example #6
0
 * Set Cache
 */
use WebSupportDK\PHPFilesystem\Cache;
if ($app->get('config.cache.status')) {
    $app->set('Cache', new Cache());
    $app->get('Cache')->setDir(APP_CACHE);
    $app->get('Cache')->setTime($app->get('config.cache.time'));
    $app->get('Cache')->setExt($app->get('config.cache.ext'));
    $app->get('Cache')->setIgnore($app->get('config.cache.ignore'));
}
/*
 * Set database
 */
use WebSupportDK\PHPScrud\DB;
if ($app->get('config.database.status')) {
    $app->set('DB', DB::load($app->get('config.database.driver'), $app->get('config.database.host'), $app->get('config.database.name'), $app->get('config.database.username'), $app->get('config.database.password')));
}
/*
 * Set auth
 */
use WebSupportDK\PHPAuthFramework\Auth;
if ($app->get('config.auth.status')) {
    $app->set('Auth', Auth::load());
    $app->get('Auth')->setAttribute('db', $app->get('DB'));
    $app->get('Auth')->setAttribute('token', $app->get('config.app.key'));
    $app->get('Auth')->setAttribute('sessionName', $app->get('config.session.name'));
}
/*
 * Set mailer
 */
if ($app->get('config.mail.status')) {
 public function favorite()
 {
     if (Input::exists()) {
         $check = DB::load()->query('SELECT Meta_ID, Item_ID
                 FROM Meta_items 
                 WHERE Meta_ID = ?
                 AND Item_ID = ?
                 AND Type = ?', array(Input::get('post_id'), Input::get('user_id'), 'favorite'));
         if ($check->results() && $check->_error == false) {
             Session::set('INFO', 'Favorit eksitere allerede.');
             Redirect::to(Input::get('current_url'));
         }
         DB::load()->insert('Meta_items', array('Meta_ID' => Input::get('post_id'), 'Item_ID' => Input::get('user_id'), 'Type' => 'favorite'));
         Session::set('SUCCESS', 'Favorit gemt!');
         Redirect::to(Input::get('current_url'));
     }
 }
 protected function __construct()
 {
     $this->_DB = DB::load();
 }