protected function _saveTestimoni()
 {
     $record = array();
     $record['nama'] = $this->post['nama'];
     $record['no_telepon'] = $this->post['no_telepon'];
     $record['email'] = $this->post['email'];
     $record['isi'] = $this->post['isi'];
     $rules = array(array('field' => 'nama', 'label' => 'Nama', 'rules' => 'required'), array('field' => 'no_telepon', 'label' => 'No. Telephone', 'rules' => 'phone'), array('field' => 'email', 'label' => 'Email', 'rules' => 'email'), array('field' => 'isi', 'label' => 'Testimonials', 'rules' => 'required'));
     $validation = new FormValidation($rules);
     if ($validation->run() == FALSE) {
         $this->SetFlash('row_testimoni', $record);
         $this->SetFlash('err_msg', $validation->GetError());
         URL::Redirect();
     }
     $this->setLogRecord($record, $id);
     $record['is_approve'] = 0;
     $return = $this->model_testimoni->Insert($record);
     if ($return) {
         $this->SetFlash('suc_msg', "Terima kasih {$record['nama']} atas testimoni yang Anda berikan.");
     } else {
         $this->SetFlash('row_testimoni', $record);
         $this->SetFlash('err_msg', "Maaf {$record['nama']}, testimoni Anda gagal disimpan.");
     }
     URL::Redirect();
 }
Ejemplo n.º 2
0
 function IsValid($record)
 {
     $rules = array(array('field' => 'judul', 'label' => 'Judul', 'rules' => 'required'), array('field' => 'isi', 'label' => 'Isi', 'rules' => 'required'));
     $validation = new FormValidation($rules);
     if ($validation->run() == FALSE) {
         $this->data['err_msg'] = $validation->GetError();
     }
     if ($this->data['err_msg']) {
         $this->data['row'] = $record;
         $this->View($this->viewdetail);
         exit;
     }
 }
Ejemplo n.º 3
0
 function IsValid($record)
 {
     $rules = array(array('field' => 'id_member', 'label' => 'ID Member', 'rules' => 'required'), array('field' => 'nama', 'label' => 'Nama', 'rules' => 'required'), array('field' => 'tgl_lahir', 'label' => 'Tgl Lahir', 'rules' => 'required'), array('field' => 'anggota_sejak', 'label' => 'Anggota Sejak', 'rules' => 'required'), array('field' => 'tgl_registrasi', 'label' => 'Tgl Registrasi', 'rules' => 'required'), array('field' => 'berlaku_sampai', 'label' => 'Berlaku Sampai', 'rules' => 'required'), array('field' => 'jenis_kelamin', 'label' => 'Jenis Kelamin', 'rules' => 'required'), array('field' => 'alamat', 'label' => 'Alamat', 'rules' => 'required'), array('field' => 'kode_pos', 'label' => 'Kode Pos', 'rules' => 'required'), array('field' => 'alamat_surat', 'label' => 'Alamat Surat', 'rules' => 'required'), array('field' => 'no_hp', 'label' => 'No Hp', 'rules' => 'phone'), array('field' => 'no_identitas', 'label' => 'No. Identitas', 'rules' => 'required'), array('field' => 'no_identitas', 'label' => 'No. Identitas', 'rules' => 'number'), array('field' => 'catatan', 'label' => 'Catatan', 'rules' => 'required'), array('field' => 'email', 'label' => 'Email', 'rules' => 'email'), array('field' => 'password', 'label' => 'Password', 'rules' => 'required'));
     $validation = new FormValidation($rules);
     if ($validation->run() == FALSE) {
         $this->data['err_msg'] = $validation->GetError();
     }
     if ($this->data['err_msg']) {
         $this->data['row'] = $record;
         $this->View($this->viewdetail);
         exit;
     }
 }
Ejemplo n.º 4
0
 public function form_validation()
 {
     global $database;
     $valid = new FormValidation();
     $valid->validate_presences(self::$required_fields);
     if (!isset($this->id)) {
         $valid->unique_category();
     }
     //        $sql="SELECT * FROM" . " ".self::$table_name."WHERE category ";
     //        $find_unique=$this->find_by_sql();
     $valid->is_numeric('unit_price', ['min' => 0]);
     return $valid;
 }
Ejemplo n.º 5
0
 function IsValid($record)
 {
     $rules = array(array('field' => 'nama', 'label' => 'Nama', 'rules' => 'required'), array('field' => 'tgl_pinjam', 'label' => 'Tgl. Pinjam', 'rules' => 'required'), array('field' => 'tgl_kembali', 'label' => 'Tgl. Kembali', 'rules' => 'required'), array('field' => 'jaminan', 'label' => 'Jaminan', 'rules' => 'required'), array('field' => 'kode_jaminan', 'label' => 'Kode Jaminan', 'rules' => 'required'));
     $validation = new FormValidation($rules);
     if ($validation->run() == FALSE) {
         $this->data['err_msg'] = $validation->GetError();
     }
     if ($this->data['err_msg']) {
         $this->data['row'] = $record;
         $this->View($this->viewdetail);
         exit;
     }
 }
Ejemplo n.º 6
0
 function isValid($record)
 {
     $rules = array(array('field' => 'nm_pasien', 'label' => 'Nama', 'rules' => 'required'), array('field' => 'alm_pasien', 'label' => 'Alamat', 'rules' => 'required'), array('field' => 'telp_pasien', 'label' => 'No. Telp.', 'rules' => 'required'), array('field' => 'komentar', 'label' => 'Kritik dan Saran', 'rules' => 'required'), array('field' => 'telp_pasien', 'label' => 'No. Telp.', 'rules' => 'phone'));
     $validation = new FormValidation($rules);
     $error_msg = '';
     if ($validation->run() == FALSE) {
         $error_msg .= $validation->GetError();
     }
     if ($error_msg) {
         $this->SetFlash('row_komentar', $record);
         $this->SetFlash('err_msg', $error_msg);
         URL::Redirect('#kritiksaran');
         exit;
     }
 }
Ejemplo n.º 7
0
 function IsValid($record)
 {
     $rules = array(array('field' => 'nama', 'label' => 'Nama', 'rules' => 'required'), array('field' => 'jk', 'label' => 'Jenis Kelamin', 'rules' => 'required'), array('field' => 'tgl_lahir', 'label' => 'Tgl. Lahir', 'rules' => 'required'), array('field' => 'telp', 'label' => 'Telepon', 'rules' => 'required'), array('field' => 'alamat', 'label' => 'Alamat', 'rules' => 'required'), array('field' => 'username', 'label' => 'Username', 'rules' => 'required'));
     $validation = new FormValidation($rules);
     if ($validation->run() == FALSE) {
         $this->data['err_msg'] = $validation->GetError();
     }
     if ($this->post['password'] != $this->post['confirmpassword']) {
         $this->data['err_msg'] .= "Konfirmasi password salah";
     }
     if ($this->data['err_msg']) {
         $this->data['row'] = $record;
         $this->View($this->viewdetail);
         exit;
     }
 }
Ejemplo n.º 8
0
 public function form_validation()
 {
     $valid = new FormValidation();
     $valid->validate_presences(self::$required_fields);
     isset($this->email) ? $valid->validate_email('email') : "";
     if (isset($this->pseudo)) {
         $valid->validate_min_lengths(['pseudo' => 1]);
         $valid->validate_max_lengths(['pseudo' => 10]);
     }
     $this->website ? $valid->validate_website('website') : "";
     $valid->is_numeric('liste_rank', ['min' => 0]);
     if (!isset($this->id)) {
         $valid->unique_name('pseudo', get_class($this));
     }
     return $valid;
 }
Ejemplo n.º 9
0
 protected function validateForm()
 {
     $validator = FormValidation::make();
     $validator->set_rules('title', 'Title', 'required|xss_clean');
     $validator->set_rules('source', 'Source', 'required|numeric|xss_clean');
     $validator->set_rules('price', 'Price', 'required|numeric|xss_clean');
     $validator->set_rules('img', 'Img', 'required|max_length[512]|xss_clean');
     $validator->set_rules('status', 'Status', 'required|integer|xss_clean');
     $validator->set_rules('desc', 'Desc', 'required|xss_clean');
     return $validator;
 }
Ejemplo n.º 10
0
 public function form_validation()
 {
     $valid = new FormValidation();
     $valid->validate_presences(self::$required_fields);
     isset($this->email) ? $valid->validate_email('email') : "";
     if (isset($this->project_code)) {
         $valid->validate_min_lengths(['project_code' => 4]);
         $valid->validate_max_lengths(['project_code' => 10]);
     }
     //   ($this->website) ? $valid->validate_website('website') : "";
     if (isset($this->currency_iso)) {
         $valid->validate_min_lengths(['currency_iso' => 3]);
         $valid->validate_max_lengths(['currency_iso' => 3]);
     }
     $valid->validate_Date('start_date');
     if (!empty($this->end_date) || !$this->end_date) {
         $valid->validate_Date('end_date');
     }
     return $valid;
 }
Ejemplo n.º 11
0
 public function form_validation()
 {
     $valid = new FormValidation();
     $valid->validate_presences(self::$required_fields);
     $valid->is_numeric('gross_amount', array());
     $valid->is_numeric('vat', array());
     $valid->is_numeric('amount', array());
     $valid->validate_Date('invoice_date');
     $valid->validate_Date('payment_date');
     if (!empty($this->payment_date) || !$this->payment_date) {
         $valid->validate_Date('payment_date');
         if ($this->payment_date < $this->invoice_date) {
             $valid->errors['date Dif'] = " payment_date cannot be before invoice_date";
         }
     }
     return $valid;
 }
Ejemplo n.º 12
0
 function _isValidProfile()
 {
     $rules = array(array('field' => 'username', 'label' => 'Username', 'rules' => 'required'), array('field' => 'name', 'label' => 'name Lengkap', 'rules' => 'required'));
     if ($isnew == "true") {
         $rules[] = array('field' => 'password', 'label' => 'Password', 'rules' => 'required');
     }
     $validation = new FormValidation($rules);
     $error_msg = '';
     if ($validation->run() == FALSE) {
         $error_msg .= $validation->GetError();
     }
     if ($this->post['password'] != $this->post['confirmpassword']) {
         if ($error_msg) {
             $error_msg .= "<br/>";
         }
         $error_msg .= "Konfirmasi password salah";
     }
     if ($error_msg) {
         $this->data['row'] = $this->post;
         $this->SetFlash('err_msg', $error_msg);
         return false;
     }
     return true;
 }
Ejemplo n.º 13
0
 public function form_validation()
 {
     $valid = new FormValidation();
     $valid->validate_presences(self::$required_fields);
     //        if(!isset($this->id)){$valid->unique_category();}
     $valid->is_numeric('rate', ['min' => 0]);
     $valid->validate_min_lengths(array('currency' => 3));
     $valid->validate_max_lengths(array('currency' => 3));
     return $valid;
 }
Ejemplo n.º 14
0
 public function form_validation()
 {
     $valid = new FormValidation();
     $valid->validate_presences(self::$required_fields);
     $valid->validate_min_lengths(['category_1' => 1]);
     $valid->validate_max_lengths(['category_1' => 20]);
     if (!isset($this->id)) {
         $valid->unique_name('category_1', get_class($this));
     }
     return $valid;
 }
Ejemplo n.º 15
0
 public function form_validation()
 {
     $valid = new FormValidation();
     $valid->validate_presences(self::$required_fields);
     if (isset($this->web_address) && !empty($this->web_address)) {
         $valid->validate_website('web_address');
     }
     isset($this->done) ? $valid->is_numeric(['done']) : "";
     isset($this->progress) ? $valid->is_numeric(['progress']) : "";
     return $valid;
 }
Ejemplo n.º 16
0
 public function form_validation()
 {
     $valid = new FormValidation();
     $valid->validate_presences(self::$required_fields);
     if (isset($this->name)) {
         $valid->validate_min_lengths(['name' => 1]);
         $valid->validate_max_lengths(['name' => 80]);
     }
     if (!isset($this->category) && isset($this->category_id)) {
         $category = LinksCategory::find_by_id($this->category_id);
         $this->category = $category->category;
     }
     $this->web_address ? $valid->validate_website('web_address') : "";
     $valid->is_numeric('rank', ['min' => 0]);
     !isset($this->privacy) ? $this->privacy = 0 : $this->privacy;
     return $valid;
 }
Ejemplo n.º 17
0
 public function form_validation()
 {
     $valid = new FormValidation();
     $valid->validate_presences(self::$required_fields);
     $valid->is_numeric('quantity', array('min' => 1));
     $valid->validate_Date('start_date');
     if (!empty($this->end_date) || !$this->end_date) {
         $valid->validate_Date('end_date');
         if ($this->end_date < $this->start_date) {
             $valid->errors['date Dif'] = " End Date cannot be before Start Date";
         }
     }
     return $valid;
 }
Ejemplo n.º 18
0
 public function create_configuration($configuration)
 {
     $b = FALSE;
     $names = array();
     $directorio = get_configuration_directory();
     foreach (glob($directorio . "*.ini") as $value) {
         $ini_array = parse_ini_file($value);
         array_push($names, $ini_array['name']);
         if ($ini_array['name'] == $configuration) {
             $b = TRUE;
         }
     }
     if ($b) {
         return parent::create_configuration($configuration);
     } else {
         echo "Configuración incorrecta. Configuraciones permitidas: ";
         $print_names = implode(" - ", $names);
         echo $print_names;
         return null;
     }
 }
<?php

require_once "../../includes/initialize.php";
$username = null;
$server_name = $_SERVER['PHP_SELF'];
$new_password = null;
if (request_is_post() && request_is_same_domain()) {
    if (!csrf_token_is_valid() || !csrf_token_is_recent()) {
        $message = "Sorry, request was not valid.";
    } else {
        $username = trim($_POST['username']);
        $valid = new FormValidation();
        $valid->validate_presences('username');
        if (empty($valid->errors)) {
            $user = User::find_by_username($username);
            if ($user) {
                $user->delete_reset_token();
                $user->create_reset_token();
                $user->send_email();
            } else {
                // Username was not found; don't do anything
            }
            // Message returned is the same whether the user
            // was found or not, so that we don't reveal which
            // usernames exist and which do not.
            $message = "A link to reset your password has been sent to the email address on file.";
        } else {
            $message = "Please enter a username.";
        }
    }
}
Ejemplo n.º 20
0
 public function form_validation()
 {
     $valid = new FormValidation();
     $valid->validate_presences(self::$required_fields);
     return $valid;
 }
 /**
  * validate function.
  *
  * Validates the rule against an appropriate function.
  * 
  * @access public
  * @param mixed $value
  * @return void
  */
 public function validate($value)
 {
     switch ($this->rule) {
         case 'required':
             $this->valid = FormValidation::isRequired($value);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be empty';
             break;
         case 'equal_to':
             $this->valid = FormValidation::isEqualTo($value, $this->options);
             $this->message = !empty($this->message) ? $this->message : 'Field must be equal to ' . $this->options;
             break;
         case 'less_than':
             $this->valid = FormValidation::isLessThan($value, $this->options);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be greater than ' . ($this->options - 1);
             break;
         case 'greater_than':
             $this->valid = FormValidation::isGreaterThan($value, $this->options);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be less than ' . ($this->options + 1);
             break;
         case 'between':
             $this->valid = FormValidation::isBetween($value, $this->options[0], $this->options[1]);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be less than ' . $this->options[0] . ' or greater than ' . $this->options[1];
             break;
         case 'shorter_than':
             $this->valid = FormValidation::isShorterThan($value, $this->options);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be longer than ' . ($this->options - 1) . ' characters';
             break;
         case 'longer_than':
             $this->valid = FormValidation::isLongerThan($value, $this->options);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be shorter than ' . ($this->options + 1) . ' characters';
             break;
         case 'length_between':
             $this->valid = FormValidation::isLengthBetween($value, $this->options[0], $this->options[1]);
             $this->message = !empty($this->message) ? $this->message : 'Field cannot be shorter than ' . $this->options[0] . ' or longer than ' . $this->options[1] . ' characters';
             break;
         case 'date':
             $this->valid = FormValidation::isDate($value);
             $this->message = !empty($this->message) ? $this->message : 'Not a valid date';
             break;
         case 'numeric':
             $this->valid = FormValidation::isNumeric($value);
             $this->message = !empty($this->message) ? $this->message : 'Field must contain numbers only';
             break;
         case 'alphabetic':
             $this->valid = FormValidation::isAlphabetic($value);
             $this->message = !empty($this->message) ? $this->message : 'Field must contain letters only';
             break;
         case 'alphanumeric':
             $this->valid = FormValidation::isAlphaNumeric($value);
             $this->message = !empty($this->message) ? $this->message : 'Field must contain numbers and letters only';
             break;
         case 'email':
             $this->valid = FormValidation::isEmail($value);
             $this->message = !empty($this->message) ? $this->message : 'Not a valid email';
             break;
         case 'website':
             $this->valid = FormValidation::isWebsite($value);
             $this->message = !empty($this->message) ? $this->message : 'Not a valid website';
             break;
         case 'uri':
             $this->valid = FormValidation::isURI($value);
             $this->message = !empty($this->message) ? $this->message : 'Not a valid URI';
             break;
         case 'postcode':
             $this->valid = FormValidation::isPostcode($value);
             $this->message = !empty($this->message) ? $this->message : 'Not a valid postcode';
             break;
         case 'custom':
             $this->valid = FormValidation::checkCustomError($this->options);
             $this->message = !empty($this->message) ? $this->message : 'Error';
             break;
     }
 }
Ejemplo n.º 22
0
 /**
  * 表单验证
  */
 protected function validateForm()
 {
     $validator = FormValidation::make();
     $validator->set_rules('register_id', 'Register_id', 'required|integer|xss_clean');
     $validator->set_rules('wxid', 'Wxid', 'required|xss_clean');
     $validator->set_rules('flowers', 'Flowers', 'integer|xss_clean');
     $validator->set_rules('eggs', 'Eggs', 'integer|xss_clean');
     $validator->set_rules('grade', 'Grade', 'numeric|xss_clean');
     $validator->set_rules('status', 'Status', 'integer|xss_clean');
     $validator->set_rules('digest', 'Digest', 'xss_clean');
     $validator->set_rules('content', 'content', 'required|xss_clean');
     return $validator;
 }
Ejemplo n.º 23
0
 protected function IsValid($record)
 {
     $rules = $this->Rules();
     $validation = new FormValidation($rules);
     if ($validation->run() == FALSE) {
         $this->data['err_msg'] = $validation->GetError();
     }
     if ($this->data['err_msg']) {
         $this->data['row'] = $record;
         $this->View($this->viewdetail);
         exit;
     }
 }
Ejemplo n.º 24
0
 /**
  * Parses and converts music files
  * @method parse
  * @param id the ID of the media object to parse
  */
 public function parse($params)
 {
     if ($this->ensureLocalhost() === false) {
         return $this->formatOutput(__('You have no access to this method'), self::METHOD_NOT_AVAILABLE);
     }
     if (FormValidation::isDigit($params['id'])) {
         return $this->formatOutput(__('Not a valid numerical value provided for the media ID'), self::INVALID_PARAMETER_VALUE);
     }
     //Fetch media object with provided ID
     $media = Media::find($params['id']);
     //Make sure the requested media object exists
     if (!$media instanceof Media) {
         return $this->formatOutput(__('No media object with the provided ID exists'), self::ITEM_NOT_FOUND);
     }
     if ($media->status === Media::STATUS_FINISHED) {
         return $this->formatOutput(__('This media object has already been parsed'), self::ERROR_IN_REQUEST);
     }
     //Set our media file to the processing status
     $media->save(array('status' => Media::STATUS_PROCESSING));
     //Initialize our parser class
     $parser = new Parser();
     //Our main storage path
     $path = $parser->getMediaDir();
     //Get the path from the file in the temporary Directory
     $filepath = $parser->getTempMediaDir() . '/' . $media->filename;
     //Make sure our root path exists and is writable
     if (!is_dir($path) && !mkdir($path) || !is_writable($path)) {
         return $this->formatOutput(__('Directory ' . $path . ' is not writable, Permission denied'), self::ERROR_IN_REQUEST);
     }
     //Make sure our file exists
     if (!file_exists($filepath)) {
         return $this->formatOutput(__('Media file ' . $filepath . ' does not exist'), self::ERROR_IN_REQUEST);
     }
     //Make sure our file is readable
     if (!is_readable($filepath)) {
         return $this->formatOutput(__('Cannot read media file ' . $filepath . ', Permission denied'), self::ERROR_IN_REQUEST);
     }
     //Since its just an audio file, parse immediately
     $media->status = $parser->parse($media);
     //If the parse succeeded, save it in the database
     if ($media->status == Media::STATUS_FINISHED || $media->status == Media::STATUS_ERROR) {
         $media->save();
     }
     //If the parse failed, the status will be set to the relevant code. Also no need to save the record
     /*
         @TODO
         Perhaps implement some form of converting to mp3 here?
         Or preserve this method for downloading of youtube videos, and converting those to mp3's
     */
     return $this->formatOutput((array) $media);
 }
Ejemplo n.º 25
0
<?php

require_once "../../includes/initialize.php";
$username = null;
$server_name = $_SERVER['PHP_SELF'];
$new_password = null;
if (request_is_post() && request_is_same_domain()) {
    if (!csrf_token_is_valid() || !csrf_token_is_recent()) {
        $message = "Sorry, request was not valid.";
    } else {
        $username = trim($_POST['email']);
        $valid = new FormValidation();
        $valid->validate_presences('email');
        $valid->validate_email('email');
        if (empty($valid->errors)) {
            $user = User::find_by_email($username);
            if ($user) {
                $user->delete_reset_token();
                $user->create_reset_token();
                $user->send_email();
            } else {
                // Username was not found; don't do anything
            }
            // Message returned is the same whether the user
            // was found or not, so that we don't reveal which
            // usernames exist and which do not.
            $message = "A link to reset your password has been sent to the email address on file.";
        } else {
            $message = "Please enter your email.";
        }
    }
Ejemplo n.º 26
0
        }
    }
}
if (request_is_post() && request_is_same_domain()) {
    if (!csrf_token_is_valid(2) || !csrf_token_is_recent(2)) {
        $message = "Sorry, request was not valid. 2";
    } else {
        if (isset($_POST['submit']) && $_POST['submit'] === "Update Info") {
            $user = UpdateUserProfile::find_by_id($session->user_id);
            $expected_fields = UpdateUserProfile::get_table_field();
            foreach ($expected_fields as $field) {
                if (isset($_POST[$field])) {
                    $user->{$field} = trim($_POST[$field]);
                }
            }
            $valid = new FormValidation();
            //            $user->unset_required_fields("username","password",'nom','email',);
            $user->unset_required_fields("password", 'nom', 'user_type_id');
            $valid->validate_presences("first_name", "last_name", "email");
            $valid->validate_email(array('email'));
            $user->unset_table_fields(array("hashed_password", "user_image", "username", "nom"));
            if (empty($valid->errors)) {
                if (!$user->save()) {
                    $session->message("Username" . $user->username . " " . "other info for ID (" . $user->id . ")");
                    $session->ok(true);
                    unset($_POST);
                    redirect_to("profile.php");
                } else {
                    unset($_POST);
                    $session->message("User: "******" " . "edit failed");
                }
Ejemplo n.º 27
0
 protected function validateForm()
 {
     $validator = FormValidation::make();
     $validator->set_rules('nickname', 'Nickname', 'required|xss_clean');
     $validator->set_rules('wxid', 'Wxid', 'required|xss_clean');
     $validator->set_rules('gender', 'Gender', 'required|integer|xss_clean');
     $validator->set_rules('mobile', 'Mobile', 'required|integer|max_length[13]|numeric|xss_clean');
     $validator->set_rules('academy', 'Academy', 'required|xss_clean');
     $validator->set_rules('major', 'Major', 'required|xss_clean');
     $validator->set_rules('status', 'Status', 'integer|xss_clean');
     return $validator;
 }
Ejemplo n.º 28
0
// Confirm that the token sent is valid
$user = User::find_by_reset_token($token);
if (!isset($user) || !$user) {
    // Token wasn't sent or didn't match a user.
    $session->message("Did not find you try again");
    redirect_to('login_forgot_password_username.php');
}
if (request_is_post() && request_is_same_domain()) {
    if (!csrf_token_is_valid() || !csrf_token_is_recent()) {
        $message = "Sorry, request was not valid.";
    } else {
        // CSRF tests passed--form was created by us recently.
        // retrieve the values submitted via the form
        $password = trim($_POST['password']);
        $password_confirm = trim($_POST['password_confirm']);
        $valid = new FormValidation();
        $valid->validate_presences(array('password', 'password_confirm'));
        if ($password !== $password_confirm) {
            $valid->errors['password_confirmation'] = "Password confirmation does not match password.";
        }
        if (empty($valid->errors)) {
            $user->password = $password;
            $user->save();
            $user->delete_reset_token();
            redirect_to('login.php');
        }
        //
        //		if(!has_presence($password) || !has_presence($password_confirm)) {
        //			$message = "Password and Confirm Password are required fields.";
        //		} elseif(!has_length($password, ['min' => 8])) {
        //			$message = "Password must be at least 8 characters long.";
Ejemplo n.º 29
0
$blacklist_ip = new BlacklistIp();
$blacklist_ip->block_blacklisted_ips();
if ($session->is_logged_in()) {
    redirect_to("index.php");
}
$username = "";
$password = "";
// Remember to give your form's submit tag a name="submit" attribute!
if (request_is_post() && request_is_same_domain()) {
    if (!csrf_token_is_valid() || !csrf_token_is_recent()) {
        $message = "Sorry, request was not valid.";
    } else {
        // CSRF tests passed--form was created by us recently.
        $username = trim($_POST['username']);
        $password = trim($_POST['password']);
        $valid = new FormValidation();
        $valid->validate_presences('username', 'password');
        $failed_login = new FailedLogin();
        if (empty($valid->errors)) {
            $throttle_delay = $failed_login->throttle_failed_logins($username);
            if ($throttle_delay > 0) {
                $message = "Too many attempted login. ";
                $message .= "You must wait {$throttle_delay} minutes before you can attempt another login or ask to reset your password.";
            } else {
                // Check database to see if username/password exist.
                $found_user = User::authenticate($username, $password);
                if ($found_user) {
                    $failed_login->clear_failed_logins($username);
                    $session->login($found_user);
                    log_action('Login', "{$found_user->username} logged in.");
                    if (User::is_visitor()) {
Ejemplo n.º 30
0
// Confirm that the token sent is valid
$user = User::find_by_reset_token($token);
if (!isset($user) || !$user) {
    // Token wasn't sent or didn't match a user.
    $session->message("Did not find you try again");
    redirect_to('login_forgot_password_user.php');
}
if (request_is_post() && request_is_same_domain()) {
    if (!csrf_token_is_valid() || !csrf_token_is_recent()) {
        $message = "Sorry, request was not valid.";
    } else {
        // CSRF tests passed--form was created by us recently.
        // retrieve the values submitted via the form
        $password = trim($_POST['password']);
        $password_confirm = trim($_POST['password_confirm']);
        $valid = new FormValidation();
        $valid->validate_presences(array('password', 'password_confirm'));
        if ($password !== $password_confirm) {
            $valid->errors['password_confirmation'] = "Password confirmation does not match password.";
        }
        if (empty($valid->errors)) {
            $user->password = $password;
            $user->save();
            $user->delete_reset_token();
            redirect_to('login.php');
        }
        //
        //		if(!has_presence($password) || !has_presence($password_confirm)) {
        //			$message = "Password and Confirm Password are required fields.";
        //		} elseif(!has_length($password, ['min' => 8])) {
        //			$message = "Password must be at least 8 characters long.";