• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP validate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中validate函数的典型用法代码示例。如果您正苦于以下问题:PHP validate函数的具体用法?PHP validate怎么用?PHP validate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: register

 public function register()
 {
     if (is_post()) {
         $this->loadHelper('Validator');
         if (captcha()) {
             $data = ['email' => validate('email', 'email'), 'username' => validate('required', 'username'), 'password' => password_hash(validate('required', 'register_token'), PASSWORD_BCRYPT), 'token' => str_rand(40)];
             if (validator($data)) {
                 if ($this->user->checkExistUser($data['email'])) {
                     $data2 = ['firstname' => validate('required', 'firstname'), 'lastname' => validate('required', 'lastname'), 'nickname' => validate('required', 'nickname'), 'major' => validate('required', 'major')];
                     if (validator($data2)) {
                         $this->user->createUser($data, $data2);
                         $validate = $this->user->validate($data['email'], $_POST['register_token']);
                         if (!empty($validate)) {
                             $_SESSION['auth'] = $validate;
                             $_SESSION['user'] = $this->user->getDetail($validate['id']);
                             cache_forgot('user.members.' . user('major'));
                             cache_forgot('user.get.members.' . user('major'));
                         }
                     }
                 }
             }
         }
     }
     return redirect('');
 }
开发者ID:Jakkarin,项目名称:Anchor-system-for-branch-or-group,代码行数:25,代码来源:AuthController.php


示例2: login

 function login()
 {
     $post = $this->post;
     if (count($post)) {
         $phone = $post['phone'];
         $pass = $post['pass'];
         if (!validate('phone', $phone)) {
             $this->redirect(_HOST . "login");
         }
         if (!validate('pass', $pass)) {
             $this->redirect(_HOST . "login");
         }
         $result = $this->load('employee')->login($phone, secret($pass));
         if ($result) {
             $per = $result['permissions'];
             if (!empty($per)) {
                 $result['permissions'] = array_map("strtolower", unserialize($per));
             }
             $this->session['user'] = $result;
             $this->redirect('index');
         } else {
             $this->redirect("login");
         }
     } else {
         return $this->view(V_PATH . "login.html", array("css" => CSS, 'host' => _HOST));
     }
 }
开发者ID:nongfuguoyuan,项目名称:accountant,代码行数:27,代码来源:TouristController.php


示例3: form_process

function form_process()
{
    global $forms;
    if (!isset($_REQUEST['form_id'])) {
        return;
    }
    $f = $forms[$_REQUEST['form_id']];
    $valid = true;
    foreach ($f['params'] as $k => $v) {
        $t = explode(';', $v['type']);
        $value = $t[0] == 'file' ? $_FILES[$k] : $_REQUEST[$k];
        $result = validate($value, $v['type'], $k);
        if ($result === true) {
            $GLOBALS[$k] = $value;
        } else {
            form_add_error($_REQUEST['form_id'], $result);
            $valid = false;
        }
    }
    if ($f['method'] == 'post') {
        form_validate();
    }
    if ($valid && $f['action']) {
        $f['action']();
    }
}
开发者ID:darwinkim,项目名称:onlinesequencer,代码行数:26,代码来源:functions.form.php


示例4: index

 function index()
 {
     $id = $this->u['id'];
     // update password
     $conf = array('password' => 'required|comparetopwd', 'repassword' => 'required');
     $err = validate($conf);
     if ($err === TRUE) {
         if (!load('m/user_m')->checkpwd($id, $_POST['oldpassword'])) {
             redirect(BASE . 'account/', '原密码错误');
         }
         $_POST['post_time'] = $_POST['update_time'] = time();
         load('m/user_m')->update_user($id);
         redirect(BASE . 'account/', '修改成功');
     } else {
         if (isset($_POST['email']) || isset($_POST['username'])) {
             $_POST['post_time'] = $_POST['update_time'] = time();
             load('m/user_m')->update($id);
             redirect(BASE . 'account', '修改成功');
         } else {
             $param['val'] = array_merge($_POST, load('m/user_m')->get($id));
             $param['err'] = $err;
             $this->display('v/user/add', $param);
         }
     }
     // update password
 }
开发者ID:grewumi,项目名称:erp.jianqu.org,代码行数:26,代码来源:account.php


示例5: create

 public function create($options = array())
 {
     $valid = validate($options, $this->data_types, array('name'));
     // Make sure all the options are valid
     if ($valid === true) {
         // See if this record already exists
         $options['slug'] = generateSlug($options['name']);
         $tag = $this->read("tags.slug = '" . $options['slug'] . "'", 1, 1);
         // If not, add it
         if (!isset($tag->tag_id)) {
             $q = $this->db->insert_string($this->table, $options);
             $res = $this->db->query($q);
             // Check for errors
             $this->sendException();
             // If good, return full label
             if ($res === true) {
                 $tag_id = $this->db->insert_id();
                 return $this->read($tag_id);
             }
             // Else return error
             return false;
         }
         // If already exists, just return it
         return $tag;
     }
     return formatErrors($valid);
 }
开发者ID:iweave,项目名称:unmark,代码行数:27,代码来源:tags_model.php


示例6: __construct

 function __construct($conn, $peer_id, $prjm_id = 0, $selName = 'prjm_id')
 {
     global $_SESSION;
     global $_REQUEST;
     $this->dbConn = $conn;
     $this->peer_id = $peer_id;
     $this->prjm_id = $prjm_id;
     $this->selectorName = $selName;
     if (isset($_SESSION[$this->selectorName])) {
         $this->prjm_id = $_SESSION[$this->selectorName];
     }
     if (isset($_REQUEST[$this->selectorName])) {
         $newSelect = validate($_REQUEST[$this->selectorName], 'integer', $this->prjm_id);
         if ($this->prjm_id != $newSelect) {
             $this->selectionChanged = true;
         }
         $this->prjm_id = $newSelect;
     }
     if ($this->prjm_id === 0) {
         // only guess if undefined.
         $this->prjm_id = $this->guessPrjMid($this->peer_id);
     }
     if (hasCap(CAP_SELECT_ALL)) {
         $this->isAdmin = 'true';
     } else {
         //$this->whereClause =" tutor_id={$peer_id} ";
         //$this->extraJoin = " tutor_my_project_milestones({$peer_id}) tmpm on(pm.prjm_id=tmpm.prjm_id) ";
     }
 }
开发者ID:homberghp,项目名称:peerweb,代码行数:29,代码来源:prjMilestoneSelector2.php


示例7: handleLogin

 public function handleLogin(Request $request, UserRepository $users)
 {
     $this->validate($request, ['identification' => 'required', 'password' => 'required|min:6|max:16']);
     $identification = $request->input('identification');
     // guess type of identification
     $auth_type = validate($identification, 'email') ? "email" : "username";
     event(new Events\UserTryToLogin($identification, $auth_type));
     // Get user instance from repository.
     // If the given identification is not registered yet,
     // it will return a null value.
     $user = $users->get($identification, $auth_type);
     if (session('login_fails', 0) > 3) {
         if (strtolower($request->input('captcha')) != strtolower(session('phrase'))) {
             return json(trans('auth.validation.captcha'), 1);
         }
     }
     if (!$user) {
         return json(trans('auth.validation.user'), 2);
     } else {
         if ($user->checkPasswd($request->input('password'))) {
             Session::forget('login_fails');
             Session::put('uid', $user->uid);
             Session::put('token', $user->getToken());
             // time in minutes
             $time = $request->input('keep') == true ? 10080 : 60;
             event(new Events\UserLoggedIn($user));
             return json(trans('auth.login.success'), 0, ['token' => $user->getToken()])->withCookie('uid', $user->uid, $time)->withCookie('token', $user->getToken(), $time);
         } else {
             Session::put('login_fails', session('login_fails', 0) + 1);
             return json(trans('auth.validation.password'), 1, ['login_fails' => session('login_fails')]);
         }
     }
 }
开发者ID:printempw,项目名称:blessing-skin-server,代码行数:33,代码来源:AuthController.php


示例8: testDobAgeMin

 function testDobAgeMin()
 {
     $input['dob'] = '01/01/' . (date('Y') - 15);
     $valid = array('dob' => array('type' => 'dob', 'min' => 18));
     validate($valid, $input, $errors);
     $this->assertTrue(!empty($errors['dob']));
 }
开发者ID:m1ke,项目名称:easy-site-utils,代码行数:7,代码来源:test_functions_db_validate.php


示例9: nav

function nav()
{
    unset($_SESSION['index_class']);
    unset($_SESSION['editmix_class']);
    unset($_SESSION['validate_class']);
    unset($_SESSION['makemix_class']);
    unset($_SESSION['mwbedocs_class']);
    unset($_SESSION['upfiles_class']);
    if ($_SESSION['action'] == "index") {
        index();
    } elseif ($_SESSION['action'] == "makemix") {
        makemix();
    } elseif ($_SESSION['action'] == "upfiles") {
        upfiles();
    } elseif ($_SESSION['action'] == "verify") {
        verify();
    } elseif ($_SESSION['action'] == "validate") {
        validate();
    } elseif ($_SESSION['action'] == "editmix") {
        editmix();
    } elseif ($_SESSION['action'] == "mwbedocs") {
        mwbedocs();
    } elseif ($_SESSION['action'] == "delmix") {
        delmix();
    } else {
        index();
    }
}
开发者ID:romeosidvicious,项目名称:MixWidget-Back-End,代码行数:28,代码来源:functions.php


示例10: validateAndSave

 private function validateAndSave($options, $overwriteCreatedOn)
 {
     $valid = validate($options, $this->data_types, array('title', 'url'));
     // Make sure all the options are valid
     if ($valid === true) {
         // Make sure url doesn't already exist
         $md5 = md5($options['url']);
         $mark = $this->read("url_key = '" . $md5 . "'", 1, 1);
         // If not found, add it
         if (!isset($mark->mark_id)) {
             if ($overwriteCreatedOn || empty($options['created_on'])) {
                 $options['created_on'] = date('Y-m-d H:i:s');
             }
             $options['url_key'] = $md5;
             $q = $this->db->insert_string('marks', $options);
             $res = $this->db->query($q);
             // Check for errors
             $this->sendException();
             // Return mark_id
             if ($res === true) {
                 $mark_id = $this->db->insert_id();
                 return $this->read($mark_id);
             }
             return false;
         }
         // If already exists, just return it
         return $mark;
     }
     return formatErrors($valid);
 }
开发者ID:iweave,项目名称:unmark,代码行数:30,代码来源:marks_model.php


示例11: calculate

function calculate($goal, $distance, $isKM, $showKM) {
    if (!validate($goal)) {
        echo "Invalid time format. Please enter MM:SS or HH:MM:SS.";   
        return;
    }    
    
    $goalInSec = convertToSeconds($goal);
    $numSplits = getNumSplits($distance, $isKM, $showKM);
    $averagePaceInSec = getAveragePaceInSeconds($goalInSec, $numSplits);
    
    echo "Distance: ";
    echo $numSplits . ($showKM ? "km" : " miles");
    echo "<br/>";
    
    echo "Goal: " . $goal;
    echo "<br/>";
    echo "<br/>";
    
    echo "Average pace: " . convertToHHMMSS($averagePaceInSec);
    echo "/" . ($showKM ? "km" : "mile");
    echo "<br/>";
    
    getSplits($averagePaceInSec, $numSplits);
    
    if (floor($numSplits) != $numSplits) {
        echo "Finish: " . $goal;   
    }    
}
开发者ID:EntirelyAmelia,项目名称:PaceCalculator,代码行数:28,代码来源:PaceCalculator.php


示例12: create

 public function create($options = array())
 {
     $smart_label = isset($options['domain']) ? true : false;
     // If a smart label, set the required fields
     if ($smart_label === true) {
         $required = array('smart_label_id', 'domain', 'smart_key');
     } else {
         $required = array('name', 'slug');
     }
     $valid = validate($options, $this->data_types, $required);
     // Make sure all the options are valid
     if ($valid === true) {
         // If not, add it
         $options['created_on'] = date('Y-m-d H:i:s');
         $q = $this->db->insert_string($this->table, $options);
         $res = $this->db->query($q);
         // Check for errors
         $this->sendException();
         // If good, return full label
         if ($res === true) {
             $cache_key = isset($options['user_id']) ? $this->cache_id . $options['user_id'] . '-*' : $this->cache_id . 'labels-*';
             $this->removeCacheKey($cache_key);
             $label_id = $this->db->insert_id();
             return self::readComplete($label_id);
         }
         // Else return error
         return false;
     }
     return formatErrors($valid);
 }
开发者ID:iweave,项目名称:unmark,代码行数:30,代码来源:labels_model.php


示例13: create

 /**
  * Creates new token
  * @param array $options Token data
  * @return Ambigous <boolean, mixed, array>
  */
 public function create($options = array())
 {
     $required = array('token_type');
     $valid = validate($options, $this->data_types, $required);
     // Make sure all the options are valid
     if ($valid === true) {
         // If you made it this far, we need to add the record to the DB
         $options['created_on'] = date("Y-m-d H:i:s");
         $confExpireTime = $this->config->item('forgot_password_token_valid_seconds');
         $options['valid_until'] = date("Y-m-d H:i:s", time() + (empty($confExpireTime) ? self::DEFAULT_TOKEN_VALID_TIME_SECONDS : $confExpireTime));
         // Generate random token
         $this->load->library('uuid');
         do {
             $options['token_value'] = $this->uuid->v4(true) . $this->uuid->v4(true);
             $total = $this->count("token_value = '" . $options['token_value'] . "'");
         } while ($total > 0);
         // This should never happen according to UUID generation
         // Add record
         $q = $this->db->insert_string('tokens', $options);
         $res = $this->db->query($q);
         // Check for errors
         $this->sendException();
         if ($res === true) {
             $token_id = $this->db->insert_id();
             return $this->read($token_id);
         } else {
             return formatErrors('Eek this is akward, sorry. Something went wrong. Please try again.');
         }
     }
     return formatErrors($valid);
 }
开发者ID:iweave,项目名称:unmark,代码行数:36,代码来源:tokens_model.php


示例14: validateAndSave

 private function validateAndSave($options, $overwriteCreatedOn)
 {
     $valid = validate($options, $this->data_types, array('user_id', 'mark_id'));
     // Make sure all the options are valid
     if ($valid === true) {
         if ($overwriteCreatedOn || empty($options['created_on'])) {
             $options['created_on'] = date('Y-m-d H:i:s');
         }
         $q = $this->db->insert_string('users_to_marks', $options);
         $res = $this->db->query($q);
         // Check for errors
         $this->sendException();
         // If good, return full record
         if ($res === true) {
             // Remove cache for this user
             $this->removeCacheKey($this->cache_id . $options['user_id'] . '-*');
             // Get info and return it
             $user_mark_id = $this->db->insert_id();
             return $this->readComplete($user_mark_id);
         }
         // Else return error
         return false;
     }
     return formatErrors($valid);
 }
开发者ID:iweave,项目名称:unmark,代码行数:25,代码来源:users_to_marks_model.php


示例15: get

 function get()
 {
     $phone = $this->post["phone"];
     if (validate("phone", $phone)) {
         $result = $this->load("guest")->findPhone($phone);
         if ($result) {
             //send sms
             $sms = create_sms_code(6);
             $this->session["sms"] = $sms;
             $send_result = send_sms_code($phone, "验证码" . $sms);
             // ok == 1
             if ($send_result == 1) {
                 $this->session['sms'] = $sms;
                 $this->session['phone'] = $phone;
                 return json_encode(array('error_code' => 0));
             } else {
                 return json_encode(array('error_code' => 4));
             }
         } else {
             return json_encode(array("error_code" => 2));
         }
     } else {
         return json_encode(array("error_code" => 3));
     }
 }
开发者ID:nongfuguoyuan,项目名称:accountant,代码行数:25,代码来源:sms.php


示例16: send

    public function send()
    {
        $content = array();
        $response = array("response" => "fail", "fields" => array());
        $send = true;
        foreach ($_POST as $key => $value) {
            $v = validate($key, $value);
            $response["fields"][$key] = $v;
            $content[$key] = trim($value);
            if ($v == false) {
                $send = false;
            }
        }
        if ($send) {
            $to = "[email protected]";
            $subject = "Mail enviado desde la pagina";
            $body = <<<HTML
    {$content["name"]} te envio un mail, su numero de telefono es : {$content["tel"]}, <br >
    su email es : {$content["email"]} <br >
    <h3>Mensaje:</h3>
    <p>{$content["userMessage"]}</p>
HTML;
            $headers = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
            if (mail($to, $subject, $body, $headers)) {
                $response["response"] = "success";
            }
        }
    }
开发者ID:ramirog89,项目名称:framework-php,代码行数:29,代码来源:Mail.php


示例17: execute

/**
 * 
 * 
 * @return be_vse_data
 */
function execute()
{
    $registeredEntry = new be_vse_data();
    try {
        $access = "RW";
        include './inc/incWebServiceAPIKeyValidation.php';
        $entryToAdd = new be_vse_data();
        $entryToAdd->app_id = filter_input(INPUT_GET, "app_id");
        $entryToAdd->vse_label = filter_input(INPUT_GET, "label");
        $entryToAdd->vse_value = filter_input(INPUT_GET, "value");
        $entryToAdd->vse_type = filter_input(INPUT_GET, "type");
        $entryToAdd->vse_annotations = filter_input(INPUT_GET, "annotations");
        $entryToAdd->captured_datetime = filter_input(INPUT_GET, "captured_datetime");
        if (!isset($entryToAdd->captured_datetime) || $entryToAdd->captured_datetime == '') {
            $dateX = new DateTime();
            $entryToAdd->captured_datetime = $dateX->format("Y-m-d H:i:s.u");
        }
        if (validate($entryToAdd)) {
            $registeredEntry = da_vse_data::AddEntry($entryToAdd);
        } else {
            die("Parámetros Inválidos");
        }
    } catch (Exception $ex) {
        die("EXCEPTION " . $ex->getCode());
    }
    return $registeredEntry;
}
开发者ID:JulioOrdonezV,项目名称:pvcloud,代码行数:32,代码来源:vse_add_value.php


示例18: create

 public function create($options = array())
 {
     $valid = validate($options, $this->data_types, array('tag_id', 'user_id', 'users_to_mark_id'));
     // Make sure all the options are valid
     if ($valid === true) {
         // See if this record already exists
         $tag = $this->read("tag_id = '" . $options['tag_id'] . "' AND user_id = '" . $options['user_id'] . "' AND users_to_mark_id = '" . $options['users_to_mark_id'] . "'", 1, 1, 'tag_id');
         // If not, add it
         if (!isset($tag->tag_id)) {
             $q = $this->db->insert_string($this->table, $options);
             $res = $this->db->query($q);
             // Check for errors
             $this->sendException();
             if ($res === true) {
                 $mark_to_tag_id = $this->db->insert_id();
                 return $this->read($mark_to_tag_id);
             }
             // Return true or false
             return false;
         }
         // If already exists, just return it
         return $tag;
     }
     return formatErrors($valid);
 }
开发者ID:iweave,项目名称:unmark,代码行数:25,代码来源:user_marks_to_tags_model.php


示例19: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('custom_array', function ($attribute, $value, $parameters, $validator) {
         if (!is_array($value)) {
             if (!is_array(explode(',', $value))) {
                 return FALSE;
             }
             $values_array = explode(',', $value);
         }
         if (!isset($values_array)) {
             $values_array = $value;
         }
         $validation_rules = preg_split('*:*', $parameters[0]);
         foreach ($values_array as $input) {
             foreach ($validation_rules as $rule) {
                 if (!validate($input, $rule)) {
                     return FALSE;
                 }
             }
         }
         return TRUE;
     });
     Validator::replacer('custom_array', function ($message, $attribute, $rule, $parameters) {
         return "The field {$attribute} was not filled properly.";
     });
 }
开发者ID:CbCaio,项目名称:pwebdev,代码行数:31,代码来源:ValidatorServiceProvider.php


示例20: register

 public function register()
 {
     if (isset($_GET['returnto']) && Strings::startsWith($_GET['returnto'], '/')) {
         $returnto = $_GET['returnto'];
     } else {
         $returnto = (string) new URL();
     }
     $query = db()->table('attribute')->get('writable', array('public', 'groups', 'related', 'me'));
     $query->addRestriction('required', true);
     $attributes = $query->fetchAll();
     try {
         if (!$this->request->isPost()) {
             throw new HTTPMethodException();
         }
         /*
          * We need to validate the data the user sends. This is a delicate process
          * and therefore requires quite a lot of attention
          */
         $validatorUsername = validate()->addRule(new MinLengthValidationRule(4, 'Username must be more than 3 characters'));
         $validatorUsername->addRule(new RegexValidationRule('/^[a-zA-z][a-zA-z0-9\\-\\_]+$/', 'Username must only contain characters, numbers, underscores and hyphens'));
         $validatorEmail = validate()->addRule(new FilterValidationRule(FILTER_VALIDATE_EMAIL, 'Invalid email found'));
         $validatorPassword = validate()->addRule(new MinLengthValidationRule(8, 'Password must have 8 or more characters'));
         validate($validatorEmail->setValue(_def($_POST['email'], '')), $validatorUsername->setValue(_def($_POST['username'], '')), $validatorPassword->setValue(_def($_POST['password'], '')));
         if (db()->table('username')->get('name', $_POST['username'])->addRestriction('expires', null, 'IS')->fetch()) {
             throw new ValidationException('Username is taken', 0, array('Username is taken'));
         }
         if (db()->table('user')->get('email', $_POST['email'])->fetch()) {
             throw new ValidationException('Email is taken', 0, array('Email is already in use'));
         }
         /**
          * Once we validated the data, let's move onto the next step, store the 
          * data.
          */
         $user = db()->table('user')->newRecord();
         $user->email = $_POST['email'];
         $user->password = $_POST['password'];
         $user->verified = false;
         $user->created = time();
         $user->store();
         $username = db()->table('username')->newRecord();
         $username->user = $user;
         $username->name = $_POST['username'];
         $username->store();
         foreach ($attributes as $attribute) {
             $userattribute = db()->table('user\\attribute')->newRecord();
             $userattribute->user = $user;
             $userattribute->attr = $attribute;
             $userattribute->value = $_POST[$attribute->_id];
             $userattribute->store();
         }
         $s = Session::getInstance();
         $s->lock($user->_id);
         return $this->response->getHeaders()->redirect($returnto);
     } catch (HTTPMethodException $e) {
         /*Do nothing, we'll show the form*/
     } catch (ValidationException $e) {
         $this->view->set('messages', $e->getResult());
     }
     $this->view->set('attributes', $attributes);
 }
开发者ID:Csardelacal,项目名称:PHPAuthServer,代码行数:60,代码来源:user.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP validateActivationToken函数代码示例发布时间:2022-05-23
下一篇:
PHP validar_user函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap