本文整理汇总了PHP中validation::run方法的典型用法代码示例。如果您正苦于以下问题:PHP validation::run方法的具体用法?PHP validation::run怎么用?PHP validation::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validation
的用法示例。
在下文中一共展示了validation::run方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forgotPwd
function forgotPwd()
{
global $req;
global $connection;
global $module;
$req->hasParams("email");
$email = $req->getParam("email");
$POST = array('email' => $email);
$val = new validation();
$val->addSource($POST);
$val->addRule('email', 'email', true, 2, 100, true);
$val->run();
if (sizeof($val->errors) > 0) {
$connection->close();
$errors = implode(" <br/> ", $val->errors);
Res::sendInvalid("Error: " . $errors);
} else {
$POST = $val->sanitized;
$email = $module->escape($POST['email']);
$output = $module->forgotPwd($email);
if (is_bool($output)) {
Res::sendInvalid($module->message);
} else {
$res = new Res();
$res->send();
}
}
}
示例2: dologinAction
public function dologinAction()
{
Db::connect();
$bean = R::dispense('user');
// the redbean model
$required = ['Name' => 'name', 'Email' => 'email', 'User_Name' => ['rmnl', 'az_lower'], 'Password' => 'password_hash'];
\RedBeanFVM\RedBeanFVM::registerAutoloader();
// for future use
$fvm = \RedBeanFVM\RedBeanFVM::getInstance();
$fvm->generate_model($bean, $required);
//the magic
R::store($bean);
$val = new validation();
$val->addSource($_POST)->addRule('email', 'email', true, 1, 255, true)->addRule('password', 'string', true, 10, 150, false);
$val->run();
if (count($val->errors)) {
Debug::r($val->errors);
foreach ($val->errors as $error) {
Notification::setMessage($error, Notification::TYPE_ERROR);
}
$this->redirect(Request::createUrl('login', 'login'));
} else {
Notification::setMessage("Welcome back !", Notification::TYPE_SUCCESS);
Debug::r($val->sanitized);
session::set('user', ['sanil']);
$this->redirect(Request::createUrl('index', 'index'));
}
}
示例3: _validate
public function _validate($data, $rules_array = array())
{
$val = new validation();
$val->addSource($data);
$val->AddRules($rules_array);
$val->run();
// exit();
if (sizeof($val->errors) > 0) {
$this->valid = false;
return $val->errors;
} else {
$this->valid = true;
return $val->sanitized;
}
}
示例4: addUsers
function addUsers()
{
global $req;
global $connection;
$req->hasParams("adminUName", "adminFName", "adminGender", "adminEMail", "adminPassword", "adminPhone");
$adminUName = $req->getParam("adminUName");
$adminFName = $req->getParam("adminFName");
$adminGender = $req->getParam("adminGender");
$adminEMail = $req->getParam("adminEMail");
$adminPassword = $req->getParam("adminPassword");
$adminPhone = $req->getParam("adminPhone");
$POST = array('adminUName' => $adminUName, 'adminFName' => $adminFName, 'adminGender' => $adminGender, 'adminEMail' => $adminEMail, 'adminPassword' => $adminPassword, 'adminPhone' => $adminPhone);
$genderValues = array('m', 'f', 'u');
$val = new validation();
$val->addSource($POST);
$val->addRule('adminUName', 'string', true, 2, 50, true)->addRule('adminFName', 'string', true, 2, 50, true)->addRule('adminGender', 'string', true, 1, 1, true)->addRule('adminEMail', 'email', true, 5, 100, true)->addRule('adminPassword', 'string', true, 4, 35, true)->addRule('adminPhone', 'string', true, 4, 20, true);
$val->run();
if (sizeof($val->errors) > 0) {
$errors = implode(" <br/> ", $val->errors);
Res::sendInvalid("Errors:" . $errors);
} else {
$POST = $val->sanitized;
$adminTable = new adminTable($connection);
$adminUName = $adminTable->escape($POST['adminUName']);
$adminFName = $adminTable->escape($POST['adminFName']);
$adminGender = $adminTable->escape($POST['adminGender']);
$adminEMail = $adminTable->escape($POST['adminEMail']);
$adminPassword = $adminTable->escape($POST['adminPassword']);
$adminPhone = $adminTable->escape($POST['adminPhone']);
$adminId = $adminTable->insertUsers($adminUName, $adminFName, $adminGender, $adminEMail, $adminPassword, $adminPhone);
if (is_bool($adminId)) {
Res::sendInvalid("Errors:" . $adminTable->message);
} else {
$res = new Res();
$res->addData("adminId", $adminId);
$res->send();
}
}
}
示例5: login
function login($user, $pwd, $rem)
{
global $adminSession;
global $adminCookieUser;
global $adminCookiePassword;
global $invalidUserIdOrPassword;
$POST = array('user' => $user, 'pwd' => $pwd, 'rem' => $rem);
$val = new validation();
$val->addSource($POST);
$val->addRule('user', 'string', true, 1, 35, true)->addRule('pwd', 'string', true, 1, 35, true)->addRule('rem', 'bool');
$val->run();
if (sizeof($val->errors) > 0) {
$connection->close();
$errors = implode(" <br/> ", $val->errors);
return "Error: " . $errors;
} else {
$POST = $val->sanitized;
$user = $this->escape($POST['user']);
$pwd = $this->escape($POST['pwd']);
$rem = $this->escape($POST['rem']);
$adminTable = new adminTable($this->connection);
$result = $adminTable->verifyAdminLogin($user, $pwd);
if (is_bool($result)) {
return $invalidUserIdOrPassword;
} else {
if (!isset($_SESSION)) {
session_start();
}
$_SESSION[$adminSession] = $result;
if ($rem) {
setcookie($adminCookieUser, $user, time() + 10 * 365 * 24 * 60 * 60, "/");
setcookie($adminCookiePassword, $pwd, time() + 10 * 365 * 24 * 60 * 60, "/");
}
return true;
}
}
}
示例6: validation
}
}
} else {
$error_course_add = $tr->__("Please select a category");
}
}
if (isset($_POST['remove'])) {
if (isset($_POST['id']) && !empty($_POST['id'])) {
$v1 = new validation();
$rules = array();
$v1->addSource($_POST['id']);
for ($i = 0; $i < count($_POST['id']); ++$i) {
$rules[] = array('type' => 'numeric', "required" => true, 'min' => '0', 'max' => '10000', 'trim' => true);
}
$v1->AddRules($rules);
$v1->run();
foreach ($v1->sanitized as $id) {
if ($managerCourse->hasActivities($id)) {
$v1->errors['HasLesson'] = $tr->__('The course you want to remove is attached to one or more lessons. Please, first delete these lessons');
break;
}
}
if (sizeof($v1->errors) > 0) {
$error_course_remove = $v1->getMessageErrors();
} else {
foreach ($v1->sanitized as $id) {
$managerCourse->delete($id);
}
}
} else {
$error_course_remove = $tr->__("Please select the fields to delete");
示例7: DomainManager
}
} else {
if (!defined('ABSPATH')) {
exit;
}
global $tr;
$managerDomain = new DomainManager();
$error_domain_add = "";
$error_domain_remove = "";
if (isset($_POST)) {
$validation = new validation();
}
if (isset($_POST['add'])) {
$validation->addSource($_POST);
$validation->AddRules(array('name' => array('type' => 'string', "required" => true, 'min' => '1', 'max' => '200', 'trim' => true), 'desc' => array('type' => 'string', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true)));
$validation->run();
if (sizeof($validation->errors) > 0) {
$error_domain_add = $validation->getMessageErrors();
} else {
$managerDomain->add(new Domain(array('name' => $validation->sanitized['name'], 'description' => $validation->sanitized['desc'])));
if ($managerDomain->isError()) {
$error_domain_add = $tr->__("This name already exist");
}
}
}
if (isset($_POST['remove'])) {
if (isset($_POST['id']) && !empty($_POST['id'])) {
$rules = array();
$validation->addSource($_POST['id']);
for ($i = 0; $i < count($_POST['id']); ++$i) {
$rules[] = array('type' => 'numeric', "required" => true, 'min' => '0', 'max' => '10000', 'trim' => true);
示例8: StudyPressUserWP
$v->addRule('courseId', 'numeric', true, 1, 99999, true);
} else {
$v->errors['courseId'] = $tr->__("You must create a course");
}
$v->run();
if (sizeof($v->errors) > 0) {
$error_quiz_add = $v->getMessageErrors();
} else {
$currentUser = new StudyPressUserWP();
$id_quiz = $managerQuiz->add(new Quiz(array('pictureUrl' => isset($v->sanitized['pictureurl']) ? $v->sanitized['pictureurl'] : '', 'name' => $v->sanitized['name'], 'author' => $currentUser->displayName(), 'authorId' => $currentUser->id(), 'courseId' => $v->sanitized['courseId'])));
}
}
}
if (isset($_POST['remove'])) {
if (isset($_POST['id']) && !empty($_POST['id'])) {
$v = new validation();
$v->addSource($_POST['id']);
foreach ($_POST['id'] as $key => $value) {
$v->addRule($key, 'numeric', true, 1, 9999999, true);
}
$v->run();
if (sizeof($v->errors) > 0) {
$error_quiz_remove = $v->getMessageErrors();
} else {
foreach ($v->sanitized as $value) {
$managerQuiz->delete($value);
}
}
}
}
require_once __ROOT_PLUGIN__ . "Views/admin/quiz.view.php";
示例9: array
<?php
require_once 'validationController.php';
//$_POST['userphone'] = (int) $_POST['userphone'];
//var_dump($_POST);
$POST = array('name' => 'Fred Scuttle', 'age' => 42, 'contact_email' => ' fred@example.com', 'url' => 'http://phpro.org');
/*** an array of rules ***/
$rules_array = array('username' => array('type' => 'string', 'required' => true, 'min' => 6, 'max' => 20, 'trim' => true), 'useremail' => array('type' => 'string', 'required' => true, 'min' => 1, 'max' => 60, 'trim' => true));
// 'userphone'=>array('type'=>'numeric', 'required'=>true, 'min'=>10000000000, 'max'=>20000000000, 'trim'=>true));
/*** a new validation instance ***/
$val = new validation();
/*** use POST as the source ***/
$val->addSource($_POST);
/*** add a form field rule ***/
//$val->addRule('contact_email', 'email', true, 1, 255, true)
// ->addRule('url', 'url', false, 10, 150, false);
/*** add an array of rules ***/
$val->addRules($rules_array);
/*** run the validation rules ***/
$val->run();
/*** if there are errors show them ***/
if (sizeof($val->errors) > 0) {
print_r($val->errors);
}
/*** show the array of validated and sanitized variables ***/
print_r($val->sanitized);