本文整理匯總了PHP中Validate::length方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validate::length方法的具體用法?PHP Validate::length怎麽用?PHP Validate::length使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Validate
的用法示例。
在下文中一共展示了Validate::length方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: detailAction
/**
* 修改考試日曆
*/
public function detailAction($cal_id)
{
//判斷是否是ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['cal_id'] = $validate->getPost('cal_id', \Validate::int());
//考試日曆id
$data['cal_year'] = $validate->getPost('cal_year', \Validate::scope(range(2014, 2020)));
//考試年份
$data['cal_month'] = $validate->getPost('cal_month', \Validate::scope(range(1, 12)));
//考試月份
$data['cal_date'] = $validate->getPost('cal_date', \Validate::length(30, 1), ['slashes' => true, 'html' => true]);
//具體考試時間
$data['cal_name'] = $validate->getPost('cal_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
//考試名稱
$data['cal_sort'] = $validate->getPost('cal_sort', \Validate::between(99999999, 0));
//分類介紹
//驗證參數
if ($validate->getMessage()) {
$this->end(400);
}
//修改banner
$result = (new \Calendar())->updCalendar($this->session->get('id'), $data);
$this->end($result);
}
//數據id
$cal_id = (int) $cal_id;
//考試日曆詳情數據
$basic = (new \Calendar())->getCalenderDetail($cal_id);
//加載js
$this->assets->addJs('backend/mt-js/calendar.js');
$this->view->setVars(['basic' => $basic]);
}
示例2: detailAction
/**
* 高校教師的詳細信息
*/
public function detailAction($col_news_id)
{
//判斷是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['col_id'] = $validate->getPost('col_id', \Validate::int());
//學校id
$data['col_news_thumb'] = $validate->getPost('col_news_thumb');
//教師頭像
$data['col_news_id'] = $validate->getPost('col_news_id', \Validate::int());
//動態id
$data['col_news_title'] = $validate->getPost('col_news_title', \Validate::length(30, 2));
//教師名稱
$data['col_news_content'] = $validate->getPost('col_news_content', \Validate::length(100000, 0));
//教師簡介
//驗證參數
if ($validate->getMessage()) {
$this->end(400);
}
//生成教師頭像
if ($data['col_news_thumb']) {
$data['col_news_thumb'] = \Func::touchImg($data['col_news_thumb'], 'col_news_thumb');
if (!$data['col_news_thumb']) {
$this->end(400);
}
}
$this->end((new \CollegeNews())->updNews($this->session->get('id'), $data));
}
//教師id
$col_news_id = (int) $col_news_id;
//教師數據
$detail = (new \CollegeNews())->getNewsDetail($col_news_id);
$this->view->setVars(['col_news_id' => $col_news_id, 'detail' => $detail, 'col_id' => $detail['col_id']]);
}
示例3: detailAction
public function detailAction()
{
if ($this->isMobile()) {
$this->response->redirect(HOST . '/single/wap');
}
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['name'] = $validate->getPost('name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{1,30}$/iu'));
$data['phone'] = $validate->getPost('phone', \Validate::regex('/^1[358]\\d{9}$/iu'));
$data['record'] = $validate->getPost('record', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{1,30}$/iu'));
$data['hope'] = $validate->getPost('hope', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{1,30}$/iu'));
$data['review'] = $validate->getPost('review', \Validate::length(800, 0), ['slashes' => true]);
if ($validate->getMessage()) {
$this->end(400);
}
$this->end((new \Single())->addRegister($data));
}
$this->tag->setTitle('四川高職單招院校-四川高職單招考試-四川高職單招試卷|51升學網');
$web_key = "四川高職單招院校,四川高職單招考試,四川高職單招試卷,51升學網";
$web_desc = "高職單招,大部分人的選擇。51升學網為你提供了四川高職單招院校,提供往年的四川高職單招考試的試卷,四川高考單招試卷免費下載,更有在線的高職單招考試的報名。";
$this->assets->addCss("fontend/css/danzhao/danzhao.css");
$this->assets->addJs("fontend/js/lib/jquery.velocity.min.js");
$this->assets->addJs("fontend/js/danzhao.js");
$this->view->setVars(['web_key' => $web_key, 'web_desc' => $web_desc]);
}
示例4: detailAction
/**
* 修改小初高動態
*/
public function detailAction($sch_dny_id)
{
//判斷是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['sch_id'] = $validate->getPost('sch_id', ['int']);
//學校id
$data['sch_dny_id'] = $validate->getPost('sch_dny_id', ['int']);
//動態id
$data['sch_dny_title'] = $validate->getPost('sch_dny_title', \Validate::length(60, 1), ['slashes' => true, 'html' => true]);
//動態標題
$data['sch_dny_content'] = $validate->getPost('sch_dny_content', \Validate::nil(), ['slashes' => true]);
//動態內容
//驗證參數
if ($validate->getMessage()) {
$this->end(400);
}
$this->end((new \Dynamic())->updDynamic($this->session->get('id'), $data));
}
//動態id
$sch_dny_id = (int) $sch_dny_id;
//小初高學校動態數據
$dynamic = (new \Dynamic())->getDynamicDetail($sch_dny_id);
//獲取學校類型
$sch_dny_type = (new \Dynamic())->getDnyType($sch_dny_id);
if ($sch_dny_type['sch_type'] == 1) {
$this->view->setLayout("kindergarten");
} else {
$this->view->setLayout("school");
}
$this->view->setVars(['sch_dny_id' => $sch_dny_id, 'dynamic' => $dynamic, 'sch_id' => $dynamic['sch_id'], 'sch_dny_type' => $sch_dny_type]);
}
示例5: newAction
/**
* 新增隸屬部門
*/
public function newAction()
{
//判斷是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['dep_name'] = $validate->getPost('dep_name', \Validate::length(15, 2));
//入學途徑名稱
$data['dep_sort'] = $validate->getPost('dep_sort', \Validate::int());
//入學途徑排序
//驗證參數
if ($validate->getMessage()) {
$this->end(400);
}
//新增動態
$this->end((new \Department())->addDepartment($this->session->get('id'), $data));
}
//加載js
$this->assets->addJs('backend/mt-js/school-department.js');
}
示例6: updpwdAction
/**
* 修改管理員密碼
*/
public function updpwdAction()
{
//判斷是否是ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$old_pwd = $validate->getPost('old_pwd', \Validate::length(30, 6));
//舊密碼
$new_pwd = $validate->getPost('new_pwd', \Validate::length(30, 6));
//舊密碼
//驗證參數
if ($validate->getMessage()) {
$this->end(400);
}
//加密
$old_pwd = $this->password($old_pwd);
$new_pwd = $this->password($new_pwd);
//修改密碼
$this->end((new \Manager())->updPassword($this->session->get('id'), $old_pwd, $new_pwd));
}
//加載js
$this->assets->addJs('backend/mt-js/pwd.js');
}
示例7: praiseAction
public function praiseAction($id)
{
//判斷是否是ajax請求
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['cou_id'] = (int) $id;
$data['ip'] = $this->getClientIp();
$data['content'] = $validate->getPost('content', \Validate::length(255, 0), ['slashes' => true, 'html' => true]);
$data['star'] = $validate->getPost('star', \Validate::int());
if ($validate->getMessage()) {
$this->end(404);
}
$this->end((new \Course())->Review($data));
}
$id = (int) $id;
if (!$id) {
$this->notFound();
}
$detail = (new \Course())->getDetail($id);
if ($detail == 404) {
$this->notFound();
}
$praise = (new \Course())->getPraise($id);
foreach ($praise['list'] as $key => $val) {
$praise['list'][$key]['cou_rev_ip'] = $this->ipGetCity($val['cou_rev_ip']) == 404 ? "未知網友" : $this->ipGetCity($val['cou_rev_ip']);
}
//好評差評率
$good = $praise['good'];
$bad = $praise['bad'];
//設置標題
$this->tag->setTitle($detail['cou_name'] . "-51升學網");
//引入css js
$this->assets->addCss("fontend/css/train/train-comment.css");
// $this->assets->addCss("fontend/css/org/course-praise.css");
$this->assets->addJs("fontend/js/org_praise.js");
$this->view->setVars(['detail' => $detail, 'praise' => $praise['list'], 'id' => $id, 'good' => $good, 'bad' => $bad]);
}
示例8: detailAction
/**
* 知名校友的詳細信息
*/
public function detailAction($col_alu_id)
{
//判斷是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['col_id'] = $validate->getPost('col_id', \Validate::int());
//學校id
$data['alu_id'] = $validate->getPost('alu_id', \Validate::int());
//校友id
$data['alu_name'] = $validate->getPost('alu_name', \Validate::length(15, 2));
//校友名稱
$data['alu_desc'] = $validate->getPost('alu_desc', \Validate::length(255, 2));
//校友簡介
$data['alu_src'] = $validate->getPost('alu_src');
//資料來源
$data['alu_head'] = $validate->getPost('alu_head');
//校友頭像
//驗證參數
if ($validate->getMessage()) {
$this->end(400);
}
//生成校友頭像
if ($data['alu_head']) {
$data['alu_head'] = \Func::touchImg($data['alu_head'], 'alu_head');
if (!$data['alu_head']) {
$this->end(400);
}
}
$this->end((new \CollegeAlumnus())->updAlumnus($this->session->get('id'), $data));
}
//校友id
$col_alu_id = (int) $col_alu_id;
//校友數據
$alumnus = (new \CollegeAlumnus())->getAlumnusDetail($col_alu_id);
$this->view->setVars(['col_alu_id' => $col_alu_id, 'alumnus' => $alumnus, 'col_id' => $alumnus['col_id']]);
}
示例9: detailAction
/**
* 修改陽光寶貝詳情
*/
public function detailAction($sch_star_id)
{
//判斷是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['sch_id'] = $validate->getPost('sch_id', \Validate::int());
//學校id
$data['star_id'] = $validate->getPost('star_id', \Validate::int());
//陽光寶貝id
$data['star_head'] = $validate->getPost('star_head');
//學員頭像
$data['star_name'] = $validate->getPost('star_name', \Validate::length(15, 2));
//學員名稱
$data['star_sort'] = $validate->getPost('star_sort', \Validate::length(99999999, 0));
//排序
//驗證參數
if ($validate->getMessage()) {
$this->end(4001);
}
//生成陽光寶貝頭像
if ($data['star_head']) {
$data['star_head'] = \Func::touchImg($data['star_head'], 'star_head');
if (!$data['star_head']) {
$this->end(400);
}
}
$this->end((new \Kindergarten())->updStar($this->session->get('id'), $data));
}
//陽光寶貝id
$sch_star_id = (int) $sch_star_id;
//陽光寶貝數據
$stars = (new \Kindergarten())->getStarDetail($sch_star_id);
//加載js
$this->assets->addJs('backend/mt-js/kindergarten-star.js');
$this->view->setLayout('kindergarten');
$this->view->setVars(['sch_star_id' => $sch_star_id, 'stars' => $stars, 'sch_id' => $stars['sch_id']]);
}
示例10: detailAction
/**
* 高校教師的詳細信息
*/
public function detailAction($col_tea_id)
{
//判斷是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['col_id'] = $validate->getPost('col_id', \Validate::int());
//學校id
$data['tea_id'] = $validate->getPost('tea_id', \Validate::int());
//教師id
$data['tea_name'] = $validate->getPost('tea_name', \Validate::length(15, 2));
//教師名稱
$data['tea_degree'] = $validate->getPost('tea_degree', \Validate::length(10, 2));
//教師學位
$data['tea_position'] = $validate->getPost('tea_position', \Validate::length(20, 2));
//教師職位
$data['tea_college'] = $validate->getPost('tea_college', \Validate::length(30, 2));
//畢業學校
$data['tea_sort'] = $validate->getPost('tea_sort', \Validate::length(99999999, 0));
//排序
$data['tea_summary'] = $validate->getPost('tea_summary', \Validate::length(255, 2));
//教師簡介
$data['tea_head'] = $validate->getPost('tea_head');
//教師頭像
//驗證參數
if ($validate->getMessage()) {
$this->end(400);
}
//生成教師頭像
if ($data['tea_head']) {
$data['tea_head'] = \Func::touchImg($data['tea_head'], 'tea_head');
if (!$data['tea_head']) {
$this->end(400);
}
}
$this->end((new \CollegeTeacher())->updTeacher($this->session->get('id'), $data));
}
//教師id
$col_tea_id = (int) $col_tea_id;
//教師數據
$teacher = (new \CollegeTeacher())->getTeacherDetail($col_tea_id);
$this->view->setVars(['col_tea_id' => $col_tea_id, 'teacher' => $teacher, 'col_id' => $teacher['col_id']]);
}
示例11: get_errors
* @return array
*/
public function get_errors()
{
return $this->_error;
}
/**
* Privately collects errors
* @param string $details
*/
private function _error($details)
{
$this->_error[] = $details;
}
}
echo "<hr />";
$val = new Validate();
echo "<br />";
$val->max_length("Sebastian", 2);
echo "<br />";
$val->min_length("Sebastian", 12);
echo "<br />";
$val->length("Sebastian", [9, 12]);
$val->is_alpha("dog");
$val->is_alphanum("dog");
$val->is_numeric("sebastian");
if (!$val->submit()) {
$errors = $val->get_errors();
echo "<pre>";
print_r($errors);
}
示例12: colhandleAction
/**
* 大學報名處理
*/
public function colhandleAction($col_reg_id)
{
//判斷是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['col_id'] = $validate->getPost('col_id', \Validate::int());
//學校id
$data['col_reg_id'] = $validate->getPost('col_reg_id', \Validate::int());
//報名id
$data['col_reg_remark'] = $validate->getPost('col_reg_remark', \Validate::length(255, 2));
//處理記錄
//驗證參數
if ($validate->getMessage()) {
$this->end(400);
}
$this->end((new \Register())->handleCollegeRegister($this->session->get('id'), $data));
}
//回複id
$col_reg_id = (int) $col_reg_id;
//報名數據
$detail = (new \Register())->getCollgeRegister($col_reg_id);
//加載js
$this->assets->addJs('backend/mt-js/register-college.js');
$this->view->setVars(['col_reg_id' => $col_reg_id, 'detail' => $detail]);
}
示例13: praiseAction
/**
* 口碑評價
*/
public function praiseAction($col_id)
{
//判斷是否是ajax請求
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['col_id'] = $col_id;
$data['ip'] = $this->getClientIp();
$data['content'] = $validate->getPost('content', \Validate::length(255, 0), ['slashes' => true, 'html' => true]);
$data['star'] = $validate->getPost('star', \Validate::int());
if ($validate->getMessage()) {
$this->end(404);
}
$this->end((new \College())->addReview($data));
}
//獲取大學基本信息
$model = new \College();
$college = $model->getCollegeBasic($col_id);
if (!$college) {
$this->notFound();
}
$praise = $model->getPraise($col_id);
//計算評分
$praise['num'] = 0;
foreach ($praise['sco'] as $v) {
$praise['num'] += $v['col_rev_star'];
$praise['score'] = $praise['num'] / count($praise['list']);
}
//大家都在評論
foreach ($praise['common_id'] as $item) {
$praise['common'][] = $model->getPraiseDesc($item['col_id']);
}
$common = $praise['common'];
$good = $praise['good'];
$bad = $praise['bad'];
$score = $praise['score'];
foreach ($praise['list'] as $key => $val) {
$praise['list'][$key]['col_rev_ip'] = $this->ipGetCity($val['col_rev_ip']) == 404 ? "未知網友" : $this->ipGetCity($val['col_rev_ip']);
}
//設置標題
$this->tag->setTitle($college['col_name'] . "-51升學網");
$web_desc = strip_tags($college['col_summary']);
//引入css 和js
$this->assets->addCss("fontend/css/org2/university/publish-praise.css");
$this->assets->addJs("fontend/js/org_praise.js");
$this->view->setVars(['college' => $college, 'praise' => $praise['list'], 'good' => $good, 'bad' => $bad, 'score' => $score, 'common' => $common, 'web_desc' => $web_desc]);
}
示例14: appendAction
/**
* 新增權限分組
*/
public function appendAction()
{
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['gro_name'] = $validate->getPost('gro_name', \Validate::length(20, 1));
//權限分組名稱
$data['aut_id'] = $validate->getPost('aut_id');
//驗證參數
if ($validate->getMessage()) {
$this->end(400);
}
$this->end((new \Authority())->addAuthorityGroup($this->session->get('id'), $data));
}
//獲取權限分類數據
$aut_cats = (new \Authority())->getAutCats();
//獲取權限信息
$authoritys = (new \Authority())->getAuthoritys();
//加載js
$this->assets->addJs('backend/mt-js/authority-group.js');
$this->view->setVars(['aut_cats' => $aut_cats, 'authoritys' => $authoritys]);
}
示例15: detailAction
/**
* 新增學校課程
*/
public function detailAction($tra_id, $cou_id)
{
//檢查是否是ajax請求
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['tra_id'] = (int) $tra_id;
//學校ID
$data['cou_id'] = (int) $cou_id;
//課程ID
$data['cou_thumb'] = $validate->getPost('cou_thumb');
//學校縮略圖
$data['spe_id'] = $validate->getPost('spe_id', \Validate::int());
//分類ID
$data['cou_name'] = $validate->getPost('cou_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
//課程名稱
$data['cou_sort'] = $validate->getPost('cou_sort', \Validate::int());
//課程排序
$data['cou_price'] = $validate->getPost('cou_price', \Validate::regex('/^[a-z0-9\\.\\/\\(\\)\\(\\)\\x{4e00}-\\x{9fa5}]{0,30}$/iu'));
//課程價格
$data['cou_system'] = $validate->getPost('cou_system', \Validate::int());
//上課類型
$data['is_hot'] = $validate->getPost('is_hot', \Validate::int());
//是否熱門
$data['cou_summary'] = $validate->getPost('cou_summary', \Validate::nil(), ['slashes' => true]);
//課程簡介
$data['cou_key'] = $validate->getPost('cou_key', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{1,10}([\\s,][a-z0-9\\x{4e00}-\\x{9fa5}]{1,10}){0,9}$/iu'));
//關鍵詞
$data['cou_desc'] = $validate->getPost('cou_desc', \Validate::length(250, 2), ['slashes' => true, 'html' => true]);
//描述
$data['cou_trait'] = $validate->getPost('cou_trait', \Validate::length(250, 2), ['slashes' => true, 'html' => true]);
//優勢
$data['tea_id'] = $validate->getPost('tea_id');
$data['cou_addr'] = $validate->getPost('cou_addr');
//驗證數據
if ($validate->getMessage()) {
$this->end(400);
}
//驗證機構是否存在
if (!(new \Train())->getDetail($tra_id)) {
$this->end(404);
}
//生成課程縮略圖
$cou_thumb = \Func::touchImg($data['cou_thumb'], 'cou_thumb');
//將生成的圖片地址存入img,用戶失敗時刪除
$img = [UPLOAD_PATH . $data['cou_thumb']];
//監測圖片是否全部生成成功
if ($data['cou_thumb'] && !$cou_thumb) {
\FileUtil::getInstance()->unlink($img);
$this->end(400);
}
$data['cou_thumb'] = $cou_thumb;
//修改高校課程
$result = (new \Course())->UpdateCourse($this->session->get('id'), $data);
if ($result != 200) {
$this->end($result);
}
$this->end($result);
}
//獲取參數
$cou_id = (int) $cou_id;
$tra_id = (int) $tra_id;
//獲取詳細信息
$detail = (new \Course())->getDetail($cou_id);
if ($detail == 404) {
$this->end(404);
}
//獲取一級分類
$categorys = (new \Course())->getCategory();
//獲取教師列表
$teachers = (new \TrainTeacher())->getTeacherList($tra_id)['list'];
//獲取課程教師
$tea_id = (new \Course())->getTeacher($cou_id);
//獲取地址列表
$cou_addr = (new \Course())->getAddress($cou_id);
$address = '';
foreach ($cou_addr as $val) {
$address .= ',' . $val['cou_add_content'];
}
//加載所需js
$this->assets->addJs('backend/js/editors/summernote/summernote.js');
$this->assets->addJs('backend/mt-js/bootstrap-tagsinput.js');
$this->assets->addJs('backend/mt-js/course-detail.js');
$this->view->setLayout('train');
$this->view->setVars(['detail' => $detail, 'tra_id' => $tra_id, 'categorys' => $categorys, 'teachers' => $teachers, 'tea_id' => $tea_id, 'cou_addr' => $cou_addr, 'address' => $address]);
}