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


PHP validation::addSource方法代码示例

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


在下文中一共展示了validation::addSource方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
        }
    }
}
开发者ID:ashutoshSce,项目名称:adminPanel,代码行数:28,代码来源:adminLogin.php

示例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'));
     }
 }
开发者ID:santonil2004,项目名称:ovc,代码行数:28,代码来源:loginController.php

示例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;
     }
 }
开发者ID:pqzada,项目名称:wp-test,代码行数:15,代码来源:Model.php

示例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();
        }
    }
}
开发者ID:ashutoshSce,项目名称:adminPanel,代码行数:39,代码来源:adminDashboard.php

示例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;
         }
     }
 }
开发者ID:ashutoshSce,项目名称:adminPanel,代码行数:37,代码来源:adminLogin.php

示例6: validation

                 } else {
                     $error_course_add = $tr->__("Please select at least one author");
                 }
             } else {
                 $error_course_add = $tr->__("Please select at least one category");
             }
         }
     } 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) {
开发者ID:Cossumo,项目名称:studypress,代码行数:31,代码来源:course.controller.php

示例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']);
开发者ID:Cossumo,项目名称:studypress,代码行数:31,代码来源:domain.controller.php

示例8: validation

<?php

require_once '_AutoLoadClassAjax.php';
if (isset($_POST['id']) && !empty($_POST['id'])) {
    $v = new validation();
    $v->addSource($_POST);
    $v->addRule('id', 'numeric', true, 1, 99999, true);
    $v->run();
    if (sizeof($v->errors) === 0) {
        $managerLesson = new LessonManager();
        $managerQuiz = new QuizManager();
        $activity = $managerLesson->getById($v->sanitized['id']);
        if (!$activity) {
            $activity = $managerQuiz->getById($v->sanitized['id']);
        }
        if ($activity) {
            if (StudyPressUserWP::isLoggedIn()) {
                $currentUserId = new StudyPressUserWP();
                $currentUserId = $currentUserId->id();
                $managerLesson->setVisitedActivity($currentUserId, $activity->getId());
            }
        }
    }
}
开发者ID:Cossumo,项目名称:studypress,代码行数:24,代码来源:visite.php

示例9: validation

                 if (isset($_POST['course']['groupsBP'])) {
                     $course->setGroupsBP($v4->sanitized);
                 }
                 if (isset($v1->sanitized['pictureId'])) {
                     $course->setPictureId($v1->sanitized['pictureId']);
                 }
                 $managerCourse->update($course->getId(), $course);
             }
         }
     } else {
         $error_course_update = $tr->__("Please select at least one author") . "<br/>" . $tr->__("Please select at least one category") . "<br/>" . $tr->__("Please enter a valid name");
     }
 } else {
     // if is an author
     $v = new validation();
     $v->addSource($_POST['course']);
     $v->AddRules(array('id' => array('type' => 'numeric', "required" => true, 'min' => '1', 'max' => '999999', 'trim' => true), 'description' => array('type' => 'string', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true)));
     if (isset($_POST['course']['pictureId']) && !empty($_POST['course']['pictureId'])) {
         $v->addRule('pictureId', 'numeric', true, 1, 999999, true);
     }
     $v->run();
     if (sizeof($v->errors)) {
         $error_course_update = $v->getMessageErrors();
     } else {
         if ($course = $managerCourse->getById($v->sanitized['id'])) {
             $course->setDescription($v->sanitized['description']);
             if (isset($v->sanitized['pictureId'])) {
                 $course->setPictureId($v->sanitized['pictureId']);
             }
             $managerCourse->update($course->getId(), $course);
         }
开发者ID:Cossumo,项目名称:studypress,代码行数:31,代码来源:modCourse.controller.php

示例10: slide_presentation_quiz

    exit;
}
$spConfiguration = new Configuration();
$spConfiguration = $spConfiguration->getConfig();
global $tr;
function slide_presentation_quiz(Quiz $quiz, $name)
{
    global $tr;
    $manageCourse = new CourseManager();
    $c = $manageCourse->getById($quiz->getCourseId());
    return "<div class='sp-presentation-content'>\r\n            <div>\r\n                <h4><strong>" . $tr->__("Author") . "</strong>: " . $name . "</h4>\r\n                <h4><strong>" . $tr->__("Course") . "</strong>: " . $c->getName() . "</h4>\r\n                <h4><strong>" . $tr->__("Duration") . "</strong>: " . $quiz->getDuration() . " min</h4>\r\n            </div>\r\n            <h2>" . $quiz->getName() . "</h2>\r\n\r\n        </div>";
}
if ($id !== null) {
    $currentUser = new StudyPressUserWP();
    $v = new validation();
    $v->addSource(array('id' => $id));
    $v->AddRules(array('id' => array('type' => 'numeric', 'required' => 'true', 'min' => '1', 'max' => '999999', 'trim' => 'true')));
    $v->run();
    if (sizeof($v->errors) > 0) {
        $tr->_e("The value of the identifier of the shortcode is incorrect");
    } else {
        $managerQuiz = new QuizManager();
        $quiz = $managerQuiz->getById($v->sanitized['id']);
        if ($quiz) {
            $sp_btn_share = "<button class='btn-share' title='" . $tr->__("Share") . "'>" . $tr->__("Share") . "</button>";
            $btn_buddypress_share = "";
            $btn_social_share = "";
            $v = $currentUser->isLoggedIn() ? sha1($currentUser->id()) : "";
            $path_json = "Public/Quiz/" . $quiz->getId() . $v . ".json";
            $json_file = __ROOT_PLUGIN__ . $path_json;
            $sp_user = new StudyPressUserWP($quiz->getAuthorId());
开发者ID:Cossumo,项目名称:studypress,代码行数:31,代码来源:player-quiz.controller.php

示例11: CourseManager

$managerCourse = new CourseManager();
$quiz = null;
$error_quiz_update = "";
$error_quiz_add_question = "";
if (isset($_GET['id']) && !empty($_GET['id'])) {
    $v = new validation();
    $v->addSource($_GET);
    $v->addRule('id', 'numeric', true, 1, 9999999, true);
    $v->run();
    if (!sizeof($v->errors) > 0) {
        $quiz = $managerQuiz->getById($v->sanitized['id']);
        if ($quiz) {
            if (isset($_POST['update'])) {
                //var_dump($_POST);
                $v = new validation();
                $v->addSource($_POST['quiz']);
                $v->AddRules(array('id' => array('type' => 'numeric', "required" => true, 'min' => '1', 'max' => '999999', 'trim' => true), 'name' => array('type' => 'string', "required" => true, 'min' => '1', 'max' => '400', 'trim' => true), 'description' => array('type' => 'string', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true), 'duree' => array('type' => 'numeric', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true), 'pictureurl' => array('type' => 'numeric', "required" => false, 'min' => '0', 'max' => '999999', 'trim' => true), 'courseId' => array('type' => 'numeric', "required" => false, 'min' => '0', 'max' => '999999', 'trim' => true)));
                $v->run();
                $notes = isset($_POST['quiz']['note']) ? json_encode($_POST['quiz']['note']) : "";
                $glossaires = isset($_POST['quiz']['glossary']) ? json_encode($_POST['quiz']['glossary']) : "";
                if (sizeof($v->errors) > 0) {
                    $error_quiz_update = $v->getMessageErrors();
                } else {
                    $currentUser = new StudyPressUserWP();
                    if ($managerCourse->getCoursesByAuthor($currentUser->id())) {
                        $quiz = $managerQuiz->getById($v->sanitized['id']);
                        $quiz->setName($v->sanitized['name']);
                        $quiz->setCourseId($v->sanitized['courseId']);
                        $quiz->setDescription($v->sanitized['description']);
                        $quiz->setDuration($v->sanitized['duree']);
                        $quiz->setPictureUrl($v->sanitized['pictureurl']);
开发者ID:Cossumo,项目名称:studypress,代码行数:31,代码来源:modQuiz.controller.php

示例12: foreach

            foreach ($vv->sanitized as $key => $value) {
                $managerProp->add(new Proposition(array('content' => $vv->sanitized[$key], 'questionId' => $question->getId(), 'type' => $checked[$key])));
            }
            echo "true";
        }
    } else {
        header("HTTP/1.0 400 Bad Request");
        $tr->_e("Please fill in all fields");
    }
    exit;
}
if (isset($_POST['type']) && $_POST['type'] === "order-question") {
    if (isset($_POST['order']) && !empty($_POST['order'])) {
        $managerQuestion = new QuestionManager();
        $v = new validation();
        $v->addSource($_POST['order']);
        foreach ($_POST['order'] as $key => $value) {
            if (preg_match('/^[0-9]{1,}$/', $key)) {
                $v->addRule($key, 'numeric', true, 1, 9999999, true);
            }
        }
        $v->run();
        if (sizeof($v->errors) > 0) {
            header("HTTP/1.0 400 Bad Request");
            echo $v->getMessageErrors();
        } else {
            $re = array();
            foreach ($v->sanitized as $ordre => $id) {
                $re[$id] = $ordre + 1;
            }
            $managerQuestion->updateOrders($re);
开发者ID:Cossumo,项目名称:studypress,代码行数:31,代码来源:question.controller.php

示例13: 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);
开发者ID:xiangku7890,项目名称:basic,代码行数:26,代码来源:server.php

示例14: LessonManager

$managerLesson = new LessonManager();
$managerCourse = new CourseManager();
$lesson = null;
$error_lesson_update = "";
$error_lesson_add_slide = "";
if (isset($_GET['id']) && !empty($_GET['id'])) {
    $v = new validation();
    $v->addSource($_GET);
    $v->addRule('id', 'numeric', true, 1, 9999999, true);
    $v->run();
    if (!sizeof($v->errors) > 0) {
        $lesson = $managerLesson->getById($v->sanitized['id']);
        if ($lesson) {
            if (isset($_POST['update'])) {
                $v = new validation();
                $v->addSource($_POST['lesson']);
                $v->AddRules(array('id' => array('type' => 'numeric', "required" => true, 'min' => '1', 'max' => '999999', 'trim' => true), 'name' => array('type' => 'string', "required" => true, 'min' => '1', 'max' => '400', 'trim' => true), 'description' => array('type' => 'string', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true), 'duree' => array('type' => 'numeric', "required" => true, 'min' => '0', 'max' => '999999', 'trim' => true), 'pictureurl' => array('type' => 'numeric', "required" => false, 'min' => '0', 'max' => '999999', 'trim' => true), 'courseId' => array('type' => 'numeric', "required" => false, 'min' => '0', 'max' => '999999', 'trim' => true)));
                $v->run();
                $notes = isset($_POST['lesson']['note']) ? json_encode($_POST['lesson']['note']) : "";
                $glossaires = isset($_POST['lesson']['glossary']) ? json_encode($_POST['lesson']['glossary']) : "";
                if (sizeof($v->errors) > 0) {
                    $error_lesson_update = $v->getMessageErrors();
                } else {
                    $currentUser = new StudyPressUserWP();
                    if ($managerCourse->getCoursesByAuthor($currentUser->id())) {
                        $lesson = $managerLesson->getById($v->sanitized['id']);
                        $lesson->setName($v->sanitized['name']);
                        $lesson->setCourseId($v->sanitized['courseId']);
                        $lesson->setDescription($v->sanitized['description']);
                        $lesson->setDuration($v->sanitized['duree']);
                        $lesson->setPictureUrl($v->sanitized['pictureurl']);
开发者ID:Cossumo,项目名称:studypress,代码行数:31,代码来源:modLesson.controller.php


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