当前位置: 首页>>代码示例>>PHP>>正文


PHP Validate::check方法代码示例

本文整理汇总了PHP中Validate::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::check方法的具体用法?PHP Validate::check怎么用?PHP Validate::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validate的用法示例。


在下文中一共展示了Validate::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getipaddress

 public static function getipaddress($ip = null)
 {
     if ($ip) {
         $validate = new Validate(["ip" => "ip"]);
         if (!$validate->check($ip)) {
             //验证无法通过
             $ip = null;
         }
     }
     self::$config = array_merge(self::$config, ["ip" => $ip]);
     $class = '\\think\\driver\\' . ucwords(self::$config["type"]);
     self::$handler = new $class(self::$config);
     return self::$handler->getipaddress();
 }
开发者ID:wapele,项目名称:ipaddress,代码行数:14,代码来源:Ipaddress.php

示例2: set

 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();
 }
开发者ID:Jay-En,项目名称:BonePHP,代码行数:14,代码来源:Mapper.php

示例3: save_step2

 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";
     }
 }
开发者ID:CCNITSilchar,项目名称:Social-Login-Plugin,代码行数:15,代码来源:install.php

示例4: validate

 /**
  * 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;
 }
开发者ID:simudream,项目名称:caffeine,代码行数:18,代码来源:html_form.php

示例5: action_recover

 public function action_recover()
 {
     $get = new Validate($_GET);
     $get->rules('id', array('not_empty' => array(), 'numeric' => array()));
     $get->rules('key', array('not_empty' => array(), 'alpha_numeric' => array()));
     if ($get->check()) {
         $user = ORM::factory('user')->where('id', '=', $get['id'])->where('activation_key', '=', $get['key'])->where('activation_expire', '>=', date('YmdHis'))->find();
         if ($user->loaded()) {
             $user->activation_key = null;
             $user->activation_expire = null;
             $user->save();
             $this->authentic->force_login($user);
             $this->request->redirect('settings');
         }
     }
     throw new Kohana_404_Exception('Bad Request');
 }
开发者ID:battle-io,项目名称:web-php,代码行数:17,代码来源:login.php

示例6: install

 /**
  * 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.');
             }
         }
     }
 }
开发者ID:simudream,项目名称:caffeine,代码行数:20,代码来源:admin.php

示例7: createPage

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;
}
开发者ID:Wicloz,项目名称:UniversityWebsite,代码行数:45,代码来源:login.php

示例8: action_verify

 public function action_verify()
 {
     $get = new Validate($_GET);
     $get->rules('id', array('not_empty' => array(), 'numeric' => array()));
     $get->rules('key', array('not_empty' => array(), 'alpha_numeric' => array()));
     if ($get->check()) {
         $user = ORM::factory('user')->where('id', '=', $get['id'])->where('activation_key', '=', $get['key'])->find();
         if ($user->loaded()) {
             $user->activation_key = null;
             $user->activation_expire = null;
             $user->email_verified = 'True';
             $user->save();
             $this->authentic->force_login($user);
             $this->request->redirect('settings');
         }
     }
     $this->request->redirect('login');
 }
开发者ID:battle-io,项目名称:web-php,代码行数:18,代码来源:register.php

示例9: register

 public function register()
 {
     if ($this->isPost()) {
         $email = trim($_POST['email']);
         $password = trim($_POST['password']);
         $password2 = trim($_POST['password_repeat']);
         if ($password != $password2) {
             $this->putErrorMsg('两次密码不一致');
         }
         if (!preg_match('/[0-9a-zA-Z_\\.\\@\\#\\$\\%]{6,18}/', $password)) {
             $this->putErrorMsg('/[0-9a-zA-Z_\\.\\@\\#\\$\\%]{6,18}/');
         }
         if (empty($email)) {
             $this->putErrorMsg('email不能为空');
         } else {
             if (true != Validate::check($email, 'varchar', '1_email')) {
                 $this->putMsg('不是email');
             }
         }
         if ($this->isErrorMsgEmpty()) {
             $userModelDB = new UserModelDB();
             $r = $userModelDB->save($email, sha1($password));
             $uid = $userModelDB->insertId();
             if ($r) {
                 $this->putmsg('注册成功');
                 $um = new UserModel();
                 $succ = $um->setUserCookie(array('email' => $email, 'uid' => $uid));
                 if (!$succ) {
                     $this->putErrorMsg('您居然把cookie关了...');
                 }
             } else {
                 $this->putErrorMsg('注册失败' . $r);
             }
         }
     }
     var_dump($this->getMsg());
     var_dump($this->getErrorMsg());
     $this->setView('msg', $this->getMsg());
     $this->setView('errorMsg', $this->getErrorMsg());
     $this->display('register.html');
 }
开发者ID:guojianing,项目名称:dagger2,代码行数:41,代码来源:UserController.php

示例10: action_upload

 /**
  * Processes an uploaded image
  *
  * @return null
  */
 public function action_upload()
 {
     // Validate the upload first
     $validate = new Validate($_FILES);
     $validate->rules('image', array('Upload::not_empty' => null, 'Upload::valid' => null, 'Upload::size' => array('4M'), 'Upload::type' => array(array('jpg', 'png', 'gif'))));
     if ($validate->check(true)) {
         // Shrink the image to the lowest max dimension
         $image = Image::factory($_FILES['image']['tmp_name']);
         $constraints = Kohana::config('image')->constraints;
         $image->resize($constraints['max_width'], $constraints['max_height']);
         $image->save(APPPATH . 'photos/' . $_FILES['image']['name']);
         $photo = new Model_Vendo_Photo();
         $photo->file = APPPATH . 'photos/' . $_FILES['image']['name'];
         $photo->save();
         unlink(APPPATH . 'photos/' . $_FILES['image']['name']);
         $this->request->redirect('admin/photo');
     } else {
         Session::instance()->set('errors', $validate->errors('validate'));
         $this->request->redirect('admin/photo');
     }
 }
开发者ID:vendo,项目名称:admin,代码行数:26,代码来源:photo.php

示例11: changePassword

 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');
         }
     }
 }
开发者ID:Jay-En,项目名称:BonePHP-starter,代码行数:21,代码来源:profileController.php

示例12: validate

 public function validate($method = self::REQUEST)
 {
     /**
      * Контейнер который будет модержать в себе имена проверяемых полей и
      * результат проверки в виде:
      * name => true, name2 => false
      */
     $a_valid = [];
     // Статус валидации
     $this->_status = true;
     $validate = new Validate();
     $validate->setMethod($method);
     foreach ($this->_fields as $name => $field) {
         $valid = $validate->check($field);
         $a_valid[$name] = (bool) $valid;
         if (!$valid) {
             $this->_status = false;
         }
     }
     $this->_valid_status = $a_valid;
     return $this->_status;
 }
开发者ID:deale,项目名称:dt,代码行数:22,代码来源:Group.php

示例13: signup

 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";
     }
 }
开发者ID:Jay-En,项目名称:BonePHP-starter,代码行数:24,代码来源:userController.php

示例14: Validate

</head>
<body>
  
    <form action="" method="post">
        <h1>Log in</h1>
        <div class="inset">
        <?php
        if (Input::exists('post')) {
            if (Token::check(Input::get('token'))) {

                $validate = new Validate();
                $validation = $validate->check($_POST, array(
                    'username' => array(
                        'required' => true,
                        'name' => 'username'
                    ),
                    'password' => array(
                        'required' => true,
                        'name' => 'password'
                    )
                ));

                if ($validation->passed()) {
                    $user = new User();

                    $remember = (Input::get('remember') === 'on') ? true : false;
                    $login = $user->login(Input::get('username'), Input::get('password'), $remember);

                    if ($login) {
                        Redirect::to('index.php');
                    } else {
                        echo '<p>Sorry, logging in failed </p>';
开发者ID:ChenXL581X,项目名称:distributedcourse,代码行数:32,代码来源:login1.php

示例15: User

<?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>';
            }
        }
    }
}
开发者ID:TalehFarzaliey,项目名称:PHP-OOP-User-System-with-Bootstrap-Material-Design,代码行数:31,代码来源:changepassword.php


注:本文中的Validate::check方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。