Example #1
0
 public function set($data)
 {
     foreach ($data as $key => $value) {
         $this->_fields[$key] = $value;
     }
     if (isset($this->schema)) {
         $validate = new Validate();
         $validate->check($this->_fields, $this->schema, $this->_identifier);
         if (!$validate->passed()) {
             $this->_errors = $validate->errors();
         }
     }
     $this->clean();
 }
Example #2
0
 /**
  * Validates the stored fields in session based on the given form id.
  */
 public function validate()
 {
     $formId = $_POST['form_id'];
     $data = Cache::get($formId);
     if ($data) {
         $fields = unserialize($data);
         foreach ($fields as $fieldName => $fieldData) {
             if (isset($fieldData['validate'])) {
                 Validate::check($fieldName, $fieldData['validate']);
             }
         }
         return Validate::passed();
     }
     return false;
 }
 public function save_step2()
 {
     $validate = new Validate();
     $source = $_POST;
     $items = array('fb-app-id' => array('required' => true), 'fb-app-secret-id' => array('required' => true));
     $validate->check($source, $items);
     if (!$validate->passed()) {
         echo "Please provide all required <span class='required'>*</span> fields.";
         return;
     }
     $this->loadmodel("install");
     if ($this->model->step2()) {
         echo "Success";
     }
 }
Example #4
0
 /**
  * Used to run the admin install if it hasn't been created yet.
  */
 public static function install()
 {
     if ($_POST) {
         Validate::check('email', array('email'));
         Validate::check('password', array('required'));
         Validate::check('conf_password', array('matches:password'));
         if (Validate::passed()) {
             $userId = User::user()->insert(array('email' => $_POST['email'], 'pass' => md5($_POST['password']), 'is_admin' => 1));
             if ($userId) {
                 Message::ok('Admin install complete.');
                 Url::redirect('admin/login');
             } else {
                 Message::error('Error creating admin account. Please try again.');
             }
         }
     }
 }
Example #5
0
function createPage($smarty)
{
    if (Users::loggedIn()) {
        Redirect::to('?page=profile');
    }
    if (Input::exists()) {
        if (Input::get('action') === 'register') {
            $validation = new Validate();
            $validation->check($_POST, array_merge(Config::get('validation/register_info'), Config::get('validation/set_password')));
            if ($validation->passed()) {
                try {
                    Users::create(array('student_id' => Input::get('sid'), 'password' => Hash::hashPassword(Input::get('password')), 'permission_group' => 1, 'name' => Input::get('name'), 'email' => Input::get('email'), 'umail' => Input::get('sid') . '@umail.leidenuniv.nl', 'phone' => Phone::formatNumber(Input::get('phone')), 'joined' => DateFormat::sql()));
                    Users::login(Input::get('sid'), Input::get('password'));
                    Notifications::addSuccess('You have been succesfully registered!');
                    Redirect::to('?page=profile');
                } catch (Exception $e) {
                    Notifications::addError($e->getMessage());
                }
            } else {
                Notifications::addValidationFail($validation->getErrors());
            }
        }
        if (Input::get('action') === 'login') {
            $validation = new Validate();
            $validation->check($_POST, Config::get('validation/login'));
            if ($validation->passed()) {
                $login = Users::login(Input::get('sid'), Input::get('password'), Input::getAsBool('remember'));
                if ($login) {
                    Notifications::addSuccess('You have been logged in!');
                    Redirect::to('?page=profile');
                } else {
                    Notifications::addValidationFail('Invalid student number or password.');
                }
            } else {
                Notifications::addValidationFail($validation->getErrors());
            }
        }
    }
    $smarty->assign('remember', Input::getAsBool('remember'));
    $smarty->assign('name', Input::get('name'));
    $smarty->assign('sid', Input::get('sid'));
    $smarty->assign('email', Input::get('email'));
    $smarty->assign('phone', Input::get('phone'));
    return $smarty;
}
 function changePassword()
 {
     $input = Input::parse();
     if (Token::check($input['token'])) {
         $validate = new Validate();
         $validate->check($input, array('password_current' => ['required' => true, 'min' => 6], 'password' => ['required' => true, 'min' => 6], 'password_repeat' => ['required' => true, 'min' => 6, 'matches' => 'password']));
         if ($validate->passed()) {
             $user = new User();
             if (Hash::make($input['password_current'], config::get('encryption/salt')) !== $user->data()->password) {
                 echo "incorrent password";
             } else {
                 $user->update(array('password' => Hash::make($input['password'], config::get('ecryption/salt'))));
                 Session::flash('success', 'Successfully changed password');
                 Redirect::to('changepassword');
             }
         } else {
             Session::flash('error', $validate->errors());
             Redirect::to('changepassword');
         }
     }
 }
 function signup()
 {
     $input = Input::parse();
     if (Token::check($input['token'])) {
         $validate = new Validate();
         $validate->check($input, array('username' => ['required' => true, 'min' => 5, 'max' => 20, 'unique' => 'users'], 'name' => ['required' => true, 'max' => 50], 'password' => ['required' => true, 'min' => 6]));
         if ($validate->passed()) {
             $user = new User();
             $salt = config::get("encription/hash");
             try {
                 $user->create(array('username' => $input['username'], 'password' => Hash::make($input['password']), 'name' => $input['name'], 'joined' => date('Y-m-d H:i:s'), 'group_id' => 1));
             } catch (Exception $e) {
                 die($e->getMessage());
             }
             Session::flash('login', 'You registered successfully! Please login!');
             Redirect::to('login');
         } else {
             Session::flash('error', $validate->errors());
             Redirect::to('signup');
         }
     } else {
         echo "Invalid token";
     }
 }
Example #8
0
function createPage($smarty)
{
    if (!Users::loggedIn()) {
        Redirect::to('?page=login');
    }
    if (Input::exists()) {
        if (Input::get('action') === 'logout') {
            if (Users::loggedIn()) {
                Users::logout();
                Notifications::addSuccess('You have been logged out!');
                Redirect::to('?page=login');
            }
        }
        if (Input::get('action') === 'update_info') {
            $validation = new Validate();
            $validation->check($_POST, Config::get('validation/user_info'));
            if ($validation->passed()) {
                $data = array('name' => Input::get('name'), 'student_id' => Input::get('sid'), 'email' => Input::get('email'), 'phone' => Phone::formatNumber(Input::get('phone')));
                if (Users::currentUser()->update($data)) {
                    Notifications::addSuccess('User information updated!');
                } else {
                    Notifications::addError('Could not update user information.');
                }
            } else {
                Notifications::addValidationFail($validation->getErrors());
            }
        }
        if (Input::get('action') === 'update_pass') {
            $validation = new Validate();
            $validation->check($_POST, array_merge(Config::get('validation/set_password'), array('password_current' => array('name' => 'Current Password', 'required' => true, 'max' => 72))));
            if ($validation->passed()) {
                if (Hash::checkPassword(Input::get('password_current'), Users::currentData()->password)) {
                    if (Users::currentUser()->update(array('password' => Hash::hashPassword(Input::get('password'))))) {
                        Notifications::addSuccess('Password changed!');
                    } else {
                        Notifications::addError('Could not change password.');
                    }
                } else {
                    Notifications::addValidationFail('Invalid current password.');
                }
            } else {
                Notifications::addValidationFail($validation->getErrors());
            }
        }
        if (Input::get('action') === 'update_googleAuth') {
            $validation = new Validate();
            $validation->check($_POST, array('authcode' => array('name' => 'Authorisation Code', 'required' => true)));
            if ($validation->passed()) {
                if (Calendar::setCredentials(Input::get('authcode'))) {
                    Notifications::addSuccess('Google Calendar API authorized!');
                } else {
                    Notifications::addValidationFail('Could not authorize Google Calendar API.');
                }
            } else {
                Notifications::addValidationFail($validation->getErrors());
            }
        }
        if (Input::get('action') === 'update_calendarAssignmentsId') {
            $validation = new Validate();
            $validation->check($_POST, array('calid-ass' => array('name' => 'Assignments Calendar ID', 'required' => false), 'calid-ex' => array('name' => 'Exams Calendar ID', 'required' => false)));
            if ($validation->passed()) {
                $data = array('calendar_assignments' => Input::get('calid-ass'), 'calendar_exams' => Input::get('calid-ex'));
                if (Users::currentUser()->update($data)) {
                    Notifications::addSuccess('Calendar ID\'s updated!');
                } else {
                    Notifications::addValidationFail('Could not update calendar ID\'s.');
                }
            } else {
                Notifications::addValidationFail($validation->getErrors());
            }
        }
        if (Input::get('action') === 'delete_googleAuth') {
            Calendar::deleteCredentials();
        }
        if (Input::get('action') === 'update_calendarAssignments' && Users::isEditor()) {
            $assignments = DB::instance()->get(Users::safeSid() . "_assignments")->results();
            foreach ($assignments as $assignment) {
                Calendar::updateAssignment($assignment->id);
            }
        }
        if (Input::get('action') === 'create_database') {
            if (!UserTables::hasTables()) {
                UserTables::createTables();
                if (Users::isGuest()) {
                    Users::currentUser()->update(array('permission_group' => '2'));
                }
            }
        }
    }
    if (!Calendar::isReady()) {
        $smarty->assign('authUrl', Calendar::getAuthUrl());
    }
    $smarty->assign('authCode', Input::get('authcode'));
    $smarty->assign('calid_ass', Users::currentData()->calendar_assignments);
    $smarty->assign('calid_ex', Users::currentData()->calendar_exams);
    $smarty->assign('name', Users::currentData()->name);
    $smarty->assign('sid', Users::currentData()->student_id);
    $smarty->assign('email', Users::currentData()->email);
    $smarty->assign('phone', Users::currentData()->phone);
    return $smarty;
}
Example #9
0
        header('Location: /TCP/' . Input::get('page'));
        exit;
    } else {
        $_SESSION["errors"][] = array('message' => 'Deletion failed', 'type' => 'danger');
    }
    //}
} else {
    if (Input::exist()) {
        //check if token is from this session
        if (Token::check(Input::get('token'))) {
            $validate = new Validate();
            $salt = Hash::salt(32);
            //validate input
            $validation = $validate->check($_POST, array('Email' => array('required' => true, 'min' => 2, 'unique' => 'user'), 'Password' => array('min' => 6, 'max' => 16), 'Repeat-password' => array('min' => 6, 'max' => 16, 'matches' => 'Password'), 'fName' => array('regex' => true), 'lName' => array('regex' => true)));
            //update user
            if (Input::get('view') && $validate->passed()) {
                $account = array('fName' => Input::get('fName'), 'lName' => Input::get('lName'), 'nationality' => Input::get('nationality'), 'email' => Input::get('Email'), 'password' => Hash::make(Input::get('Password'), $salt), 'salt' => $salt);
                if (strlen(Input::get('intake')) > 0) {
                    $account['intakeID'] = Input::get('intake');
                }
                try {
                    $user->update(Input::get('view'), $account);
                } catch (Exception $e) {
                    die($e->getMessage());
                }
                //force refresh
                header('Location: /TCP/' . Input::get('page'));
            } else {
                if ($validate->passed()) {
                    $account = array('role' => Input::get('role'), 'fName' => Input::get('fName'), 'lName' => Input::get('lName'), 'gender' => Input::get('gender'), 'nationality' => Input::get('nationality'), 'email' => Input::get('Email'), 'password' => Hash::make(Input::get('Password'), $salt), 'salt' => $salt);
                    if (strlen(Input::get('intake')) > 0) {
Example #10
0
 public static function adminDeleteItem()
 {
     if (Users::isAdmin()) {
         $validation = new Validate();
         $validation->check($_POST, array('action' => array('name' => 'Action', 'required' => true, 'wildcard' => 'admin_item_delete'), 'table' => array('name' => 'Table Name', 'required' => true), 'id' => array('name' => 'Entry ID', 'required' => true)));
         if ($validation->passed()) {
             DB::instance()->delete(Input::get('table'), array("", "id", "=", Input::get('id')));
             if (Input::get('table') === Users::safeSid() . '_assignments') {
                 Calendar::deleteAssignment(Input::get('id'));
             }
             Notifications::addSuccess('Entry deleted!');
             Redirect::to('?page=home');
         } else {
             Notifications::addValidationFail($validation->getErrors());
         }
     } else {
         Redirect::error(403);
     }
 }
Example #11
0
<?php

require_once '/../modal/core/setup.php';
if (Input::exist() && $user->isLoggedIn()) {
    $validate = new Validate();
    $salt = Hash::salt(32);
    $upload = new Upload();
    //validate input
    $validation = $validate->check($_POST, array('email' => array('required' => true, 'min' => 2), 'fullName' => array('regex' => true)));
    $userArr = array('type' => Input::get('type'), 'fullName' => Input::get('fullName'), 'gender' => Input::get('gender'), 'email' => Input::get('email'));
    //update user
    if (is_numeric(Input::get('userID')) && $validate->passed()) {
        try {
            if ($user->find(Input::get('userID'))) {
                if (!empty($filename = $upload->imgUpload($_FILES['image'], 'profile'))) {
                    unlink('../upload/profile/' . $user->data()->imageURL);
                    $userArr['imageURL'] = $filename;
                }
                if (Input::get('password')) {
                    $validation = $validate->check($_POST, array('password' => array('min' => 6, 'max' => 16), 'repeat-password' => array('min' => 6, 'max' => 16, 'matches' => 'password')));
                    if ($validate->passed()) {
                        $userArr['password'] = Hash::make(Input::get('password'), $salt);
                        $userArr['salt'] = $salt;
                    }
                }
                $user->update(Input::get('userID'), $userArr);
            }
        } catch (Exception $e) {
            die($e->getMessage());
        }
        //force refresh
Example #12
0
 $validation = new Validate();
 if (Input::exists()) {
     //regeln für alle felder, analog zum erstellen eines events
     $validation->check($_POST, array('eventName' => array('name' => 'Event Name', 'required' => true, 'max' => 100), 'eventCast' => array('name' => 'Cast', 'max' => 255), 'eventDescription' => array('name' => 'Event Description', 'required' => true), 'eventDate' => array('name' => 'Event Date', 'required' => true, 'date' => true), 'eventTimeHour' => array('name' => 'Time of the Event ( Hours )', 'required' => true, 'minValue' => 0, 'maxValue' => 23), 'eventTimeMinute' => array('name' => 'Time of the Event ( Minutes )', 'required' => true, 'maxValue' => 59, 'minValue' => 0), 'eventDuration' => array('name' => 'Duration of the Event', 'required' => true, 'minValue' => 1), 'eventLink' => array('name' => 'Event Link', 'max' => 100), 'eventLinkDescription' => array('name' => 'Description of the EventLink', 'max' => 255), 'pricegroup' => array('name' => 'Price Group', 'required' => true)));
     //date-time stempel wird gebaut
     $rawdate = new DateTime(Input::get('eventDate') . ' ' . Input::get('eventTimeHour') . ':' . Input::get('eventTimeMinute') . ':00');
     $date = $rawdate->format('Y-m-d H:i:s');
     $duration = Input::get('eventDuration');
     $endTime = strtotime("+{$duration} minutes", strtotime($date));
     //hier wird überprüft ob ein event in einem zeitkonflikt mit einem anderen event steht
     $conflicts = DB::getInstance()->getInterferingEvents('event', 'date', $date, date('Y-m-d h:i:s', $endTime))->results();
     if (count($conflicts)) {
         $validation->addError('Dieses Event steht in einem Zeitkonflikt mit einem bereits bestehendem Event');
         $validation->setPassed(false);
     }
     if (!$validation->passed()) {
         foreach ($validation->errors() as $error) {
             echo $error . '<br>';
         }
     }
     //wenn alles validiert werden konnte wird hier der event aktualisiert
     if ($validation->passed()) {
         //2015-11-12 15:26:53 das wollen wir
         $rawdate = new DateTime(Input::get('eventDate') . ' ' . Input::get('eventTimeHour') . ':' . Input::get('eventTimeMinute') . ':00');
         $date = $rawdate->format('Y-m-d H:i:s');
         $eventName = Input::get('eventName');
         try {
             //neue daten werden in der db gespeichert
             $db->update('event', Input::get('id'), array('name' => $eventName, 'starring' => Input::get('eventCast'), 'description' => Input::get('eventDescription'), 'date' => $date, 'duration' => Input::get('eventDuration'), 'link' => Input::get('eventLink'), 'linkDescription' => Input::get('eventLinkDescription'), 'fk_genre_id' => Input::get('genre')));
             $eventID = $db->get('event', array('name', '=', $eventName))->first()->id;
             $rowCount = $db->get('event_has_price', array('fk_event_id', '=', $_POST['delete']))->count();
Example #13
0
 public function post($post_id)
 {
     $this->model('User');
     $this->model('Article');
     $user = new User();
     $article = new Article();
     $this->loginRequired($user);
     // If new post is to be created
     if (empty($post_id) || $post_id == 'new') {
         if (Input::exists()) {
             $validate = new Validate();
             // Validation for Inputs
             $validation = $validate->check($_POST, array('title' => array('name' => 'Post title', 'required' => true, 'min' => 5), 'description' => array('name' => 'description', 'required' => true, 'min' => 50), 'featuredimage' => array('name' => 'Featured Image', 'required' => true), 'link' => array('name' => 'Article Link', 'required' => true, 'unique' => ARTICLE_TABLE)));
             if (empty(Input::get('type'))) {
                 $type = 0;
             } else {
                 $type = 1;
             }
             if ($validate->passed()) {
                 $template = Strings::get('catagory');
                 try {
                     $article->create(array('TITLE' => Input::get('title'), 'SECURL' => Input::get('catagory'), 'SUBSEC' => Input::get('subsec'), 'CREATED_DATE' => date("Y-m-d  H:i:s", time()), 'IMG' => Input::get('featuredimage'), 'DES' => Input::get('description'), 'LINK' => Input::get('link'), 'TYPE' => $type, 'TEMPLATE' => Input::get('template')));
                     // Get the created article details from LINK to redirect the user to edit it.
                     $newarticle = new Article(Input::get('link'));
                     Redirect::to(ADMINPATH . 'post/' . $newarticle->data()->SL_NO);
                 } catch (Exception $e) {
                     die($e->getMessage());
                 }
                 if (isset($data)) {
                     $submissionData = Input::values($_POST);
                     $data = array_merge($data, $submissionData);
                 } else {
                     $data = Input::values($_POST);
                 }
             } else {
                 $data = $validate->errors();
             }
         }
         if (isset($data)) {
             $submissionData = Input::values($_POST);
             $data = array_merge($data, $submissionData);
         } else {
             $data = Input::values($_POST);
         }
         $data['CATAGORY'] = Strings::get('catagory');
         $data['SUBCATAGORY'] = Strings::get('subcatagory');
         $data['TEMPLATES'] = Strings::get('templates');
         $data['token'] = Token::generate();
         $data['TITLE'] = "Create New Post";
         $this->view('admin/post.new.html', $data);
     } else {
         /** 
          * Edit Post section
          * 
          * The edit and after creation events happen here
          */
         $article = new Article($post_id);
         if (Input::exists()) {
             $validate = new Validate();
             // Validation for Inputs
             $validation = $validate->check($_POST, array('title' => array('name' => 'Post title', 'required' => true, 'min' => 5), 'description' => array('name' => 'description', 'required' => true, 'min' => 50), 'featuredimage' => array('name' => 'Featured Image', 'required' => true)));
             // If Article URL is changed check if it already exist
             if ($validate->passed() && $article->data()->LINK != Input::get('link')) {
                 $validation = $validate->check($_POST, array('link' => array('name' => 'Article Link', 'required' => true, 'unique' => ARTICLE_TABLE)));
             }
             if (empty(Input::get('type'))) {
                 $type = 0;
             } else {
                 $type = 1;
             }
             if (empty(Input::get('featured'))) {
                 $featured = 0;
             } else {
                 $featured = 1;
             }
             if (Input::get('publish') == 1) {
                 $publish = $article->data()->STATUS ? 0 : 1;
             } else {
                 $publish = $article->data()->STATUS;
             }
             if ($validation) {
                 $template = Strings::get('catagory');
                 try {
                     $article->update(array('TITLE' => Input::get('title'), 'SECURL' => Input::get('catagory'), 'SUBSEC' => Input::get('subsec'), 'CONTENT' => Input::get('content'), 'DATE' => Input::get('date'), 'IMG' => Input::get('featuredimage'), 'DES' => Input::get('description'), 'LINK' => Input::get('link'), 'TYPE' => $type, 'TEMPLATE' => Input::get('template'), 'FEATURED' => $featured, 'STATUS' => $publish), $post_id);
                     Redirect::to(ADMINPATH . 'post/' . $post_id);
                 } catch (Exception $e) {
                     die($e->getMessage());
                 }
                 if (isset($data)) {
                     $submissionData = Input::values($_POST);
                     $data = array_merge($data, $submissionData);
                 } else {
                     $data = Input::values($_POST);
                 }
             } else {
                 $data = $validate->errors();
             }
         }
         if ($article->count()) {
             if (isset($data)) {
                 $data = array_merge($data, objectToArray($article->data()));
             } else {
                 $data = objectToArray($article->data());
             }
             $data['CATAGORY'] = Strings::get('catagory');
             $data['SUBCATAGORY'] = Strings::get('subcatagory');
             $data['TEMPLATES'] = Strings::get('templates');
             $data['CONTENT_RAW'] = $data['CONTENT'];
             $data['CONTENT'] = str_replace('[IMAGE]', MEDIAPATH, $data['CONTENT']);
             $data['CONTENT'] = $data['CONTENT'];
             $data['token'] = Token::generate();
             $this->view('admin/post.html', $data);
         }
     }
 }
Example #14
0
if ($user->isLoggedIn()) {
    echo '<br><br>';
    if (!is_null($_POST['id'])) {
        $updateId = $_POST['id'];
        $_POST = array();
    }
    $db = DB::getInstance();
    $event = $db->get('event', array('id', '=', $updateId))->first();
    $fileSaver = new SaveFile();
    $validation = new Validate();
    if (Input::exists()) {
        //regeln für das bild
        $validation->checkFile($_FILES, array('eventPicture' => array('name' => 'Picture', 'type' => 'picture', 'required' => true, 'maxFileSize' => 512 * 1000, 'maxWidth' => 1000, 'maxHeight' => 1000)));
        //regeln für die picture-description
        $validation->check($_POST, array('eventPictureDescription' => array('name' => 'Description of the EventPicture', 'required' => true, 'max' => 255)));
        if (!$validation->passed()) {
            foreach ($validation->errors() as $error) {
                echo $error . '<br>';
            }
        }
        if (!$validation->filePassed()) {
            foreach ($validation->fileErrors() as $error) {
                echo $error . '<br>';
            }
        }
        //wenn beides validiert werden konnte wird das bild gespeichert
        if ($validation->passed() && $validation->filePassed()) {
            $eventFileName = $fileSaver->savePicture($_FILES, 'eventPicture');
            try {
                //name des alten bildes wird abgerufen um es später löschen zu können
                $old = $db->get('event', array('id', '=', Input::get('eventId')))->first()->picture;
Example #15
0
 *
 */
?>

    <h1>This is upload</h1>
<?php 
$user = new User();
//Wenn ein Bild / datei ausgesucht wurde
if (Input::exists()) {
    // echo 'check.. input exists <br>';
    $validate = new Validate();
    //bild wird validiert
    $validate->checkFile($_FILES, array('fileUpload' => array('name' => 'Picture', 'type' => 'picture', 'required' => true, 'maxFileSize' => 3072 * 1000, 'maxWidth' => 4000, 'maxHeight' => 4000, 'minWidth' => 400, 'minHeight' => 400)));
    $validate->check($_POST, array('description' => array('name' => 'Picture Description', 'required' => true, 'min' => 5, 'max' => 1000)));
    //falls validierung erfolgreich war
    if ($validate->passed() && $validate->filePassed()) {
        $saver = new SaveFile();
        //echo 'file upload validation passed<br>';
        //echo ' dir erstellt <br>';
        //wem gehört das bild?
        $owner = $user->data()->id;
        // echo 'owner ermittelt '.$owner.'<br>';
        //bild wird gespeichert
        if ($saver->savePicture($_FILES, 'fileUpload', $owner, Input::get('description'))) {
            //Session::flash('picUpload','Your picture was successfully saved');
            //Redirect::to('index.php');
            echo 'upload successful<br>';
        } else {
            echo ' there was an error.. we are sorry <br>';
        }
    } else {
                     }
                 } else {
                     // Not valid login
                     Session::destroy();
                     $validate->addError('Wrong Username or Password');
                 }
             }
         } else {
             $validate->addError('Wrong Captcha');
         }
     }
 }
 if (Input::get('otpsubmit') != '') {
     $otp_validate = new Validate();
     $otp_validation = $otp_validate->check($_POST, array('OTP' => array('required' => true, 'min' => 8, 'max' => 8)));
     if ($otp_validate->passed() && Token::check(Input::get('token'))) {
         $otp = new OTP();
         if ($otp->verifyOTP(Input::get('OTP'))) {
             //$otp->verifyOTP(Input::get('OTP'))
             Session::deleteloginAttempt('OTP');
             Session::put('loggedIn', 1);
             $log = new Log();
             $log->loginLog('success');
             if (Input::get('nootp') == 1) {
                 $cookiename = 'sisnootp' . Session::get('mobile');
                 Cookie::put($cookiename, true, 15);
                 unset($cookiename);
             }
             Redirect::to('home.php');
         } else {
             $log = new Log();
<?php

/**
 * Created by Chris on 9/29/2014 3:53 PM.
 */
require_once 'core/init.php';
$user = new User();
if (!$user->isLoggedIn()) {
    Redirect::to('index.php');
}
if (Input::exists()) {
    if (Token::check(Input::get('token'))) {
        $validate = new Validate();
        $validation = $validate->check($_POST, array('current_password' => array('required' => true, 'min' => 6), 'new_password' => array('required' => true, 'min' => 6), 'new_password_again' => array('required' => true, 'min' => 6, 'matches' => 'new_password')));
        if ($validate->passed()) {
            if (Hash::make(Input::get('current_password'), $user->data()->salt) !== $user->data()->password) {
                Session::flash('error', 'Your current password is incorrect.');
                Redirect::to('changepassword.php');
            } else {
                $salt = Hash::salt(32);
                $user->update(array('password' => Hash::make(Input::get('new_password'), $salt), 'salt' => $salt));
                Session::flash('success', 'Your password has been changed!');
                Redirect::to('index.php');
            }
        } else {
            foreach ($validate->errors() as $error) {
                echo $error, '<br>';
            }
        }
    }
}
<?php

require_once '../../core/init.php';
if (Input::exists('post')) {
    $validate = new Validate();
    $_POST['mobile'] = (int) Input::get('mobile');
    $_POST['parents_mobile'] = (int) Input::get('parents_mobile');
    $validation = $validate->check($_POST, array('gender' => array('required' => true), 'programme' => array('required' => true), 'Category' => array('required' => true), 'mobile' => array('required' => true, 'min' => 10, 'max' => 10), 'parents_mobile' => array('required' => true, 'min' => 10, 'max' => 10), 'semester' => array('required' => true), 'department' => array('required' => true), 'courses' => array('required' => true), 'total_credits' => array('required' => true), 'hostel_address' => array('required' => true), 'home_address' => array('required' => true)));
    if ($validate->passed() && Token::check_a(Input::get('token'))) {
        $stud = new Student();
        $name = Session::get('displayname');
        $email = Session::get('student_email');
        $scholar_no = Session::get('sn');
        $session = Session::get('semester_session');
        $category = Input::get('Category');
        $gender = Input::get('gender');
        $programme = strtoupper(Input::get('programme'));
        $semester = Input::get('semester');
        $department = Input::get('department');
        $mobile = Input::get('mobile');
        $parents_mobile = Input::get('parents_mobile');
        $courses = Input::get('courses');
        $courses = explode(' ,', $courses);
        $courses = $courses[1];
        $courses_load = strtoupper(Input::get('loadcode1') . ',' . Input::get('loadcode2'));
        $courses_load = rtrim($courses_load, ',');
        $course_credits = Input::get('course_credits');
        $home_address = Input::get('home_address');
        $hostel_address = Input::get('hostel_address');
        $add = $stud->register($email, $name, $gender, $scholar_no, $category, $programme, $semester, $session, $department, $mobile, $parents_mobile, $courses, $courses_load, $home_address, $hostel_address);
        if ($add == 1) {