public function validateFile()
 {
     $v = Validator::load();
     $v->checkFile($_FILES, array('files' => array('ext' => array('png', 'jpg', 'jpeg'), 'size' => 3000000)));
     if (!$v->passed()) {
         foreach ($v->errors() as $error) {
             $_SESSION['ERRORS'][] = $error;
         }
         var_dump($v->errors());
         Redirect::to($this->data['current_url']);
         exit;
     }
 }
 public function validateInput()
 {
     $v = Validator::load();
     $v->checkPost($_POST, array('editor' => array('required' => true, 'min' => 1)));
     if (!$v->passed()) {
         //            Session::set($title, Input::get($title));
         foreach ($v->errors() as $error) {
             $_SESSION['ERRORS'][] = $error;
         }
         Redirect::to(Input::get('current_url'));
         exit;
     }
 }
 public function reset($key)
 {
     if (isset($key)) {
         $user = UserModel::load()->get(array(array('Reset_token', '=', $key)));
         if ($user) {
             if ($user[0]->Status_ID == 0) {
                 UserModel::load()->update(array('Status_ID' => 1), $user[0]->ID);
                 Session::set('SUCCESS', 'User activated!');
                 Redirect::to($this->url);
             } elseif ($user[0]->Status_ID == 1) {
                 Session::set('WARNING', 'User already activated!');
                 Redirect::to($this->url);
             } elseif ($user[0]->Status_ID == 2) {
                 Session::set('ERRORS', 'User blocked!');
                 Redirect::to($this->url);
             }
         }
         Session::set('ERRORS', 'User key invalid!');
         Redirect::to($this->url);
     }
 }
 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'));
     }
 }
 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;
     }
 }