本文整理汇总了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]);
}