本文整理汇总了PHP中Validate::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isValid方法的具体用法?PHP Validate::isValid怎么用?PHP Validate::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::isValid方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginAction
public function loginAction()
{
$userInfo = Session::get('user');
if ($userInfo['login'] == true && $userInfo['time'] + TIME_LOGIN >= time()) {
URL::redirect('admin', 'index', 'index');
}
$this->_templateObj->setFolderTemplate('admin/main/');
$this->_templateObj->setFileTemplate('login.php');
$this->_templateObj->setFileConfig('template.ini');
$this->_templateObj->load();
$this->_view->_title = 'Login';
if (@$this->_arrParam['form']['token'] > 0) {
$validate = new Validate($this->_arrParam['form']);
$username = @$this->_arrParam['form']['username'];
$password = md5(@$this->_arrParam['form']['passwd']);
$query = "SELECT `id` FROM `user` WHERE `username` = '{$username}' AND `password` = '{$password}'";
$validate->addRule('username', 'existRecord', array('database' => $this->_model, 'query' => $query));
$validate->run();
if ($validate->isValid() == true) {
$infoUser = $this->_model->infoItem($this->_arrParam);
$arraySession = array('login' => true, 'info' => $infoUser, 'time' => time(), 'group_acp' => $infoUser['group_acp']);
Session::set('user', $arraySession);
URL::redirect('admin', 'index', 'index');
} else {
$this->_view->errors = $validate->showErrors();
}
}
$this->_view->render('index/login', true);
}
示例2: loginAction
public function loginAction()
{
$userInfo = Session::get('user');
if ($userInfo['login'] == true && $userInfo['time'] + TIME_LOGIN >= time()) {
URL::redirect('default', 'user', 'index');
}
$this->_view->_title = 'Login';
if (@$this->_arrParam['form']['token'] > 0) {
$validate = new Validate($this->_arrParam['form']);
$email = $this->_arrParam['form']['email'];
$password = md5($this->_arrParam['form']['password']);
$query = "SELECT `id` FROM `user` WHERE `email` = '{$email}' AND `password` = '{$password}'";
$validate->addRule('email', 'existRecord', array('database' => $this->_model, 'query' => $query));
$validate->run();
if ($validate->isValid() == true) {
$infoUser = $this->_model->infoItem($this->_arrParam);
$arraySession = array('login' => true, 'info' => $infoUser, 'time' => time(), 'group_acp' => $infoUser['group_acp']);
Session::set('user', $arraySession);
URL::redirect('default', 'user', 'index');
} else {
$this->_view->errors = $validate->showErrorsPublic();
}
}
$this->_view->render('index/login');
}
示例3: formAction
public function formAction()
{
$this->_view->_title = 'User : Add';
$this->_view->slbGroup = $this->_model->itemInSelectBox($this->_arrParam);
if (isset($this->_arrParam['id'])) {
$this->_view->_title = 'User : Edit';
$this->_arrParam['form'] = $this->_model->infoItem($this->_arrParam);
if (empty($this->_arrParam['form'])) {
URL::redirect('admin', 'user', 'index');
}
}
if (@$this->_arrParam['form']['token'] > 0) {
$task = 'add';
$requirePass = true;
$queryUserName = "SELECT `id` FROM `" . TBL_USER . "` WHERE `username` = '{$this->_arrParam['form']['username']}'";
$queryEmail = "SELECT `email` FROM `" . TBL_USER . "` WHERE `email` = '{$this->_arrParam['form']['email']}'";
if (isset($this->_arrParam['form']['id'])) {
$task = 'edit';
$requirePass = false;
$queryUserName .= " AND `id` <> '" . $this->_arrParam['form']['id'] . "'";
$queryEmail .= " AND `id` <> '" . $this->_arrParam['form']['id'] . "'";
}
$validate = new Validate($this->_arrParam['form']);
$validate->addRule('username', 'string-notExistRecord', array('database' => $this->_model, 'query' => $queryUserName, 'min' => 3, 'max' => 25))->addRule('email', 'email-notExistRecord', array('database' => $this->_model, 'query' => $queryEmail))->addRule('password', 'password', array('action' => $task), $requirePass)->addRule('ordering', 'int', array('min' => 1, 'max' => 100))->addRule('status', 'status', array('deny' => array('default')))->addRule('group_id', 'status', array('deny' => array('default')));
$validate->run();
$this->_arrParam['form'] = $validate->getResult();
if ($validate->isValid() == false) {
$this->_view->errors = $validate->showErrors();
} else {
$task = isset($this->_arrParam['form']['id']) ? 'edit' : 'add';
// Insert to Database
$id = $this->_model->saveItem($this->_arrParam, array('task' => $task));
$type = $this->_arrParam['type'];
if ($type == 'save-close') {
URL::redirect('admin', 'user', 'index');
}
if ($type == 'save-new') {
URL::redirect('admin', 'user', 'form');
}
if ($type == 'save') {
URL::redirect('admin', 'user', 'form', array('id' => $id));
}
}
}
$this->_view->arrParam = $this->_arrParam;
$this->_view->render('user/form', true);
}
示例4: formAction
public function formAction()
{
$this->_view->_title = 'Book : Add';
$this->_view->slbCategory = $this->_model->itemInSelectBox($this->_arrParam);
if (!empty($_FILES)) {
$this->_arrParam['form']['picture'] = $_FILES['picture'];
}
if (isset($this->_arrParam['id'])) {
$this->_view->_title = 'Book : Edit';
$this->_arrParam['form'] = $this->_model->infoItem($this->_arrParam);
if (empty($this->_arrParam['form'])) {
URL::redirect('admin', 'book', 'index');
}
}
if (@$this->_arrParam['form']['token'] > 0) {
$task = 'add';
if (isset($this->_arrParam['form']['id'])) {
$task = 'edit';
}
$validate = new Validate($this->_arrParam['form']);
$validate->addRule('name', 'string', array('min' => 1, 'max' => 255))->addRule('picture', 'file', array('min' => 100, 'max' => 1000000, 'extension' => array('jpg', 'png')), false)->addRule('ordering', 'int', array('min' => 1, 'max' => 100))->addRule('status', 'status', array('deny' => array('default')))->addRule('special', 'status', array('deny' => array('default')))->addRule('category_id', 'status', array('deny' => array('default')))->addRule('sale_off', 'int', array('min' => 0, 'max' => 100))->addRule('price', 'int', array('min' => 1000, 'max' => 1000000));
$validate->run();
$this->_arrParam['form'] = $validate->getResult();
if ($validate->isValid() == false) {
$this->_view->errors = $validate->showErrors();
} else {
$task = isset($this->_arrParam['form']['id']) ? 'edit' : 'add';
// Insert to Database
$id = $this->_model->saveItem($this->_arrParam, array('task' => $task));
$type = $this->_arrParam['type'];
if ($type == 'save-close') {
URL::redirect('admin', 'book', 'index');
}
if ($type == 'save-new') {
URL::redirect('admin', 'book', 'form');
}
if ($type == 'save') {
URL::redirect('admin', 'book', 'form', array('id' => $id));
}
}
}
$this->_view->arrParam = $this->_arrParam;
$this->_view->render('book/form', true);
}
示例5: formAction
public function formAction()
{
$this->_view->_title = 'User Category : Add';
if (!empty($_FILES)) {
$this->_arrParam['form']['picture'] = $_FILES['picture'];
}
if (isset($this->_arrParam['id'])) {
$this->_view->_title = 'User Category : Edit';
$this->_arrParam['form'] = $this->_model->infoItem($this->_arrParam);
if (empty($this->_arrParam['form'])) {
URL::redirect('admin', 'category', 'index');
}
}
if (@$this->_arrParam['form']['token'] > 0) {
/*echo '<pre>';
print_r($this->_arrParam);
echo '</pre>';
die("Function die is called");*/
$validate = new Validate($this->_arrParam['form']);
$validate->addRule('name', 'string', array('min' => 3, 'max' => 255))->addRule('ordering', 'int', array('min' => 1, 'max' => 100))->addRule('status', 'status', array('deny' => array('default')))->addRule('picture', 'file', array('min' => 100, 'max' => 1000000, 'extension' => array('jpg', 'png')), false);
$validate->run();
$this->_arrParam['form'] = $validate->getResult();
if ($validate->isValid() == false) {
$this->_view->errors = $validate->showErrors();
} else {
echo $task = isset($this->_arrParam['form']['id']) ? 'edit' : 'add';
// Insert to Database
$id = $this->_model->saveItem($this->_arrParam, array('task' => $task));
$type = $this->_arrParam['type'];
if ($type == 'save-close') {
URL::redirect('admin', 'category', 'index');
}
if ($type == 'save-new') {
URL::redirect('admin', 'category', 'form');
}
if ($type == 'save') {
URL::redirect('admin', 'category', 'form', array('id' => $id));
}
}
}
$this->_view->arrParam = $this->_arrParam;
$this->_view->render('category/form', true);
}
示例6: login
public function login()
{
if (Session::get('loggedIn') == true) {
$this->redirect('group', 'index');
}
if (isset($_POST['submit'])) {
$source = array('username' => $_POST['username']);
$validate = new Validate($source);
$query = "SELECT `id` FROM `user` WHERE `nickname` = '{$_POST['username']}' AND `position` = '{$_POST['password']}'";
$validate->addRule('username', 'existRecord', array('database' => $this->db, 'query' => $query));
$validate->run();
$error = $validate->getError();
if ($validate->isValid() == true) {
Session::set('loggedIn', true);
$this->redirect('group', 'index');
} else {
$this->view->errors = $validate->showErrors();
}
}
$this->view->render('user/login');
}
示例7: indexAction
public function indexAction()
{
$this->_view->_title = 'Login';
$userInfo = Session::get('user');
if (@$this->_arrParam['loginForm']['token'] > 0) {
$validate = new Validate($this->_arrParam['loginForm']);
$username = @$this->_arrParam['loginForm']['username'];
$password = md5(@$this->_arrParam['loginForm']['password']);
$query = "SELECT `id` FROM `user` WHERE `nickname` = '{$username}' AND `password` = '{$password}'";
$validate->addRule('username', 'existRecord', array('database' => $this->_model, 'query' => $query));
$validate->run();
if ($validate->isValid() == true) {
$infoUser = $this->_model->infoItem($this->_arrParam);
$arraySession = array('login' => true, 'info' => $infoUser, 'time' => time(), 'admin_control' => $infoUser['admin_control']);
Session::set('user', $arraySession);
URL::redirect(URL::createLink('default', 'index', 'index'));
} else {
$this->_view->errors = $validate->showErrors(false);
}
}
$this->_view->render('login/index', true);
}
示例8: formAction
public function formAction()
{
$this->_view->_title = 'Category Manager : Add';
if (isset($this->_arrParam['id'])) {
$this->_view->_title = 'Category Manager : Edit';
$this->_arrParam['form'] = $this->_model->infoItem($this->_arrParam);
if (empty($this->_arrParam['form'])) {
URL::redirect(URL::createLink('admin', 'category', 'index'));
}
}
if (@$this->_arrParam['form']['token'] > 0) {
$validate = new Validate($this->_arrParam['form']);
$validate->addRule('name', 'string', array('min' => 3, 'max' => 255))->addRule('ordering', 'int', array('min' => 1, 'max' => 100))->addRule('status', 'status', array('deny' => array('default')));
$validate->run();
$this->_arrParam['form'] = $validate->getResult();
if ($validate->isValid() == false) {
$this->_view->errors = $validate->showErrors();
} else {
echo $task = isset($this->_arrParam['form']['id']) ? 'edit' : 'add';
// Insert to Database
$id = $this->_model->saveItem($this->_arrParam, array('task' => $task));
$type = $this->_arrParam['type'];
if ($type == 'save-close') {
URL::redirect(URL::createLink('admin', 'category', 'index'));
}
if ($type == 'save-new') {
URL::redirect(URL::createLink('admin', 'category', 'form'));
}
if ($type == 'save') {
URL::redirect(URL::createLink('admin', 'category', 'form', array('id' => $id)));
}
}
}
$this->_view->arrParam = $this->_arrParam;
$this->_view->render('category/form', true);
}
示例9: resetPwd
public function resetPwd($token)
{
if (!empty($_POST)) {
$validate = new Validate($_POST);
$validate->doubleCheck("password", "confirmation", "les mots de passe ne sont pas identiques");
if ($validate->isValid() && $this->user->setNewPassword($token)) {
$vue = new Vue("Success", "User");
$vue->render(['msg' => "Le mot de passe a été modifié avec succès."]);
} else {
$vue = new Vue("Reset", "User");
$vue->setScript('verif.js');
$vue->render(['errors' => $validate->errors]);
}
} else {
$this->user->resetPwd($token);
$vue = new Vue("Reset", "User");
$vue->setScript('verif.js');
$vue->render();
}
}
示例10: json_encode
<?php
require_once "class/Validate.class.php";
$flagType = 'error';
$error = '';
$source = array('name' => $_POST['name'], 'email' => $_POST['email'], 'message' => $_POST['message'], 'file' => $_FILES['attach']);
$validate = new Validate($source);
$validate->addRule('name', 'string', array('min' => 2, 'max' => 50))->addRule('email', 'email')->addRule('message', 'string', array('min' => 5, 'max' => 500))->addRule('file', 'file', array('extension' => array('png', 'jpg'), 'min' => 50, 'max' => 9000000), false);
$validate->run();
if ($validate->isValid() == false) {
$error = $validate->getError();
} else {
$flagType = 'success';
}
$response = array('type' => $flagType, 'message' => $error);
echo json_encode($response);
示例11: unset
}
if (!empty($_POST)) {
if ($_SESSION['token'] == $_POST['token']) {
// refresh page
unset($_SESSION['token']);
header('location: ' . $linkForm);
exit;
} else {
$_SESSION['token'] = $_POST['token'];
}
$source = array('username' => $_POST['username'], 'email' => $_POST['email'], 'password' => $_POST['password'], 'birthday' => $_POST['birthday'], 'status' => $_POST['status'], 'groupid' => $_POST['groupid'], 'ordering' => $_POST['ordering']);
$validate = new Validate($source);
$validate->addRule('username', 'string', 2, 50)->addRule('email', 'email')->addRule('password', 'password')->addRule('birthday', 'birthday')->addRule('groupid', 'status')->addRule('ordering', 'int', 1, 10)->addRule('status', 'status');
$validate->run();
$outValidate = $validate->getResult();
if (!$validate->isValid()) {
$error = $validate->showErrors();
} else {
if ($action == 'edit') {
$where = array(array('id', $id));
$database->update($outValidate, $where);
} else {
if ($action == 'add') {
$database->insert($outValidate);
$outValidate = array();
}
}
$success = '<div class="success">Success</div>';
}
}
//Select Status
示例12: modificationEnTete
public function modificationEnTete($id)
{
if (!empty($_POST)) {
$validate = new Validate($_POST);
$validate->notEmpty('name_grp', "Veuiller rentrer un nom de groupe");
// $validate->notEmpty('sport', "Vous n'avez pas ajouté de sport à votre groupe");
// $validate->isVille('lieu', "Votre localisation n'est pas valide");
// $validate->notEmpty('description_grp',"Ajoutez une description à votre groupe");
if ($validate->isValid()) {
$this->group->updateEnTete($_POST, $id);
Router::redirect("groupe", ['id' => $id]);
}
}
}