本文整理汇总了PHP中Validate::regex方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::regex方法的具体用法?PHP Validate::regex怎么用?PHP Validate::regex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::regex方法的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: loginAction
/**
* 后台登陆页面
*/
public function loginAction()
{
//判断是否已登陆,已登陆跳转到后天首页
if ($this->session->get('id')) {
$this->response->redirect(ADMIN_HOST . '/home/index');
}
//ajax登陆
if ($this->request->isAjax()) {
$validate = new \Validate();
$man_account = $validate->getPost('username', \Validate::regex('/^[a-z0-9-\\_\\.\\@]{6,30}$/i'));
//用户名
$man_password = $validate->getPost('password', \Validate::length(30, 6));
//密码
//验证参数
if ($validate->getMessage()) {
$this->end(['state' => 400], true);
}
//查询管理员
$result = (new \Manager())->login($man_account, $this->password($man_password), $this->getClientIp());
if ($result == 404) {
$this->end(['state' => 404], true);
}
//将管理员id,及昵称存入session
$this->session->set('id', $result['man_id']);
$this->session->set('nickname', $result['man_nickname']);
//返回后台首页地址
$this->end(['url' => ADMIN_HOST . '/home/index', 'state' => 200], true);
}
//不采用任何布局
$this->view->setLayout('');
}
示例3: detailAction
/**
* 修改新闻推荐
*/
public function detailAction($news_com_id)
{
//判定是否是ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['news_com_id'] = $validate->getPost('news_com_id', \Validate::int());
//新闻推荐id
$data['news_id'] = $validate->getPost('news_id', \Validate::int());
//新闻id
$data['news_com_sort'] = $validate->getPost('news_com_sort', \Validate::regex('/^(0|[1-9]\\d{0,7})$/'));
//新闻推荐排序
$data['news_com_status'] = $validate->getPost('news_com_status', \Validate::scopeCall('Setting', 'getStatus'));
//显示状态
//验证参数
if ($validate->getMessage()) {
$this->end(400);
}
$this->end((new \NewsCommand())->updNewsCommand($this->session->get('id'), $data));
}
//新闻推荐id
$news_com_id = (int) $news_com_id;
//获取新闻推荐详情
$detail = (new \NewsCommand())->getDetail($news_com_id);
if ($detail == 404) {
$this->notFound();
}
$this->view->setVars(['detail' => $detail]);
}
示例4: basicAction
/**
* 合作机构基本信息
*/
public function basicAction($uni_id)
{
//判断是否是ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['union_logo'] = $validate->getPost('union_logo');
//机构logo
$data['union_name'] = $validate->getPost('union_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
//机构名称
//验证参数
if ($validate->getMessage()) {
$this->end(400);
}
//生成机构logo,缩略图
if ($data['union_logo']) {
$data['union_logo'] = \Func::touchImg($data['union_logo'], 'union_logo');
//监测图片是否生成成功
if (!$data['union_logo']) {
\FileUtil::getInstance()->unlink(UPLOAD_PATH . $data['union_logo']);
$this->end(400);
}
}
$this->end((new \Union())->updUnionBasic($this->session->get('id'), $uni_id, $data));
}
//机构id
$uni_id = (int) $uni_id;
//获取基本数据
$basic = (new \Union())->getUnionBasic($uni_id);
//加载js
$this->assets->addJs('backend/mt-js/union.js');
$this->view->setVars(['uni_id' => $uni_id, 'basic' => $basic]);
}
示例5: newAction
/**
* 新增属性
*/
public function newAction()
{
//检查是否是ajax请求
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['att_img'] = $validate->getPost('att_img', \Validate::base64());
//属性图
$data['att_name'] = $validate->getPost('att_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
//属性名称
$data['att_sort'] = $validate->getPost('att_sort', \Validate::int());
//排序
//验证数据
if ($validate->getMessage()) {
$this->end(400);
}
//生成学校logo,缩略图
$data['att_img'] = \Func::touchImg($data['att_img'], 'att_img');
//将生成的图片地址存入img,用户失败时删除
$img = [UPLOAD_PATH . $data['att_img'], UPLOAD_PATH . $data['att_img']];
//监测图片是否全部生成成功
if (!$data['att_img']) {
\FileUtil::getInstance()->unlink($img);
}
//新增高校
$result = (new \Attribute())->addAttribute($this->session->get('id'), $data);
if ($result != 200) {
\FileUtil::getInstance()->unlink($img);
}
$this->end($result);
}
//加载所需js
$this->assets->addJs('backend/mt-js/attribute-new.js');
}
示例6: set_lang
/**
* @param string $lang hould be an ISO 639 Language Code (either 2 or 3 letters).
* Exception: For Chinese, please use zh-cn for Simplified Chinese or zh-tw for
* Traditional Chinese.
*
* @see http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
public function set_lang($lang)
{
if ('zh-cn' !== $lang and 'zh-tw' !== $lang) {
if (!Validate::regex($lang, '/^[a-z]{2,3}$/')) {
throw new InvalidArgumentException('Invalid language code');
}
}
$this->_publication['lang'] = $lang;
return $this;
}
示例7: newAction
/**
* 新增专题分类
*/
public function newAction()
{
//检查是否是ajax请求
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['top_cat_name'] = $validate->getPost('top_cat_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
//分类名称
//验证数据
if ($validate->getMessage()) {
$this->end(400);
}
//新增分类
$result = (new \TopicCategory())->addCategory($this->session->get('id'), $data);
$this->end($result);
}
//加载js
$this->assets->addJs('backend/mt-js/topiccat.js');
}
示例8: detailAction
/**
* 修改banner新闻
*/
public function detailAction($news_com_id)
{
//判定是否是ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['news_ban_id'] = $validate->getPost('news_ban_id', \Validate::int());
//banner新闻id
$data['news_id'] = $validate->getPost('news_id', \Validate::int());
//新闻id
$data['news_ban_img'] = $validate->getPost('news_ban_img');
//banner图片
$data['news_ban_alt'] = $validate->getPost('news_ban_alt', \Validate::regex('/^[\\da-z\\x{4e00}-\\x{9fa5}]{1,30}$/iu'));
//banner图片介绍
$data['news_ban_sort'] = $validate->getPost('news_ban_sort', \Validate::regex('/^(0|[1-9]\\d{0,7})$/'));
//banner新闻排序
$data['news_ban_status'] = $validate->getPost('news_ban_status', \Validate::scopeCall('Setting', 'getStatus'));
//显示状态
//验证参数
if ($validate->getMessage()) {
$this->end(400);
}
//创建banner图片
$img = $data['news_ban_img'];
$data['news_ban_img'] = \Func::touchImg($img, 'news_ban');
if ($img && !$data['news_ban_img']) {
$this->end(400);
}
$result = (new \NewsBanner())->updNewsBanner($this->session->get('id'), $data);
if ($result != 200 && is_file(UPLOAD_PATH . $img)) {
unlink(UPLOAD_PATH . $img);
}
$this->end($result);
}
//新闻推荐id
$news_com_id = (int) $news_com_id;
//获取新闻推荐详情
$detail = (new \NewsBanner())->getDetail($news_com_id);
if ($detail == 404) {
$this->notFound();
}
$this->view->setVars(['detail' => $detail]);
}
示例9: newAction
/**
* 新增属性
*/
public function newAction()
{
//检查是否是ajax请求
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['att_name'] = $validate->getPost('att_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
//属性名称
$data['att_sort'] = $validate->getPost('att_sort', \Validate::int());
//排序
//验证数据
if ($validate->getMessage()) {
$this->end(400);
}
//新增高校
$result = (new \MajorKeywords())->addKeywords($this->session->get('id'), $data);
$this->end($result);
}
//加载所需js
$this->assets->addJs('backend/mt-js/keywords.js');
}
示例10: detailAction
/**
* 修改友情链接
*/
public function detailAction($link_id)
{
//判断是否是ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['link_id'] = $validate->getPost('link_id', \Validate::int());
//数据id
$data['link_name'] = $validate->getPost('link_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{1,30}$/iu'));
//友情链接名称
$data['link_url'] = $validate->getPost('link_url', \Validate::regex('/^(http(s)?:\\/\\/)/'), ['slashes' => true, 'html' => true]);
//链接url
$data['link_sort'] = $validate->getPost('link_sort', \Validate::between(99999999, 0));
//友情链接排序
$data['link_logo'] = $validate->getPost('link_logo');
//友情链接logo
//验证参数
if ($validate->getMessage()) {
$this->end(400);
}
//生成友情链接logo
if ($data['link_logo']) {
$data['link_logo'] = \Func::touchImg($data['link_logo'], 'link_logo');
if (!$data['link_logo']) {
$this->end(400);
}
}
//修改友情链接
$result = (new \Link())->updLink($this->session->get('id'), $data);
if ($result != 200) {
\FileUtil::getInstance()->unlink(UPLOAD_PATH . $data['link_logo']);
}
$this->end($result);
}
//数据id
$link_id = (int) $link_id;
//热点文章详情数据
$basic = (new \Link())->getLinkDetail($link_id);
//加载js
$this->assets->addJs('backend/mt-js/link.js');
$this->view->setVars(['basic' => $basic]);
}
示例11: wapAction
public function wapAction()
{
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'] = '';
if ($validate->getMessage()) {
$this->end(400);
}
$this->end((new \Single())->addRegister($data));
}
$get_url = 'http://' . $this->request->getHttpHost() . $this->request->getURI();
$share_url = 'http://www.51sxwang.com/single/wap';
if ($get_url != $share_url) {
$this->response->redirect($share_url);
}
$this->view->setLayout('');
$data = $this->getSignature($share_url);
$this->view->setVar('wx_config', $data);
}
示例12: basicAction
/**
* 权限相关详情信息
*/
public function basicAction($aut_id)
{
//判断是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['aut_name'] = $validate->getPost('aut_name', \Validate::length(20, 1));
//权限名称
$data['aut_code'] = $validate->getPost('aut_code', \Validate::regex('/^(add|del|upd)(_[a-z]{3,4})+$/i', '请填写以add_或者del_或者upd_开头后接数据表名的前三或四位的正确格式权限码'));
//权限码
$data['aut_cat_id'] = $validate->getPost('aut_cat_id', \Validate::int());
//权限分类id
$data['aut_id'] = $validate->getPost('aut_id', \Validate::int());
//验证参数
if ($validate->getMessage()) {
$this->end(400);
}
//修改权限分类
$this->end((new \Authority())->updAuthority($this->session->get('id'), $data));
}
$aut_id = (int) $aut_id;
//获取权限信息
$basic = (new \Authority())->getAuthority($aut_id);
//获取权限分类数据
$aut_cats = (new \Authority())->getAutCats();
//加载js
$this->assets->addJs('backend/mt-js/authority.js');
$this->view->setVars(['basic' => $basic, 'aut_cats' => $aut_cats]);
}
示例13: 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]);
}
示例14: newsAction
public function newsAction()
{
//获取搜索词
$validate = new \Validate();
$keys = $validate->getQuery('keys', \Validate::regex('/^\\S+$/'));
$page = (int) $validate->getQuery('page') < 1 ? 1 : (int) $validate->getQuery('page');
if ($validate->getMessage()) {
$this->notFound();
}
$news = (new \Search())->allNews($keys);
//全部
$data = $news;
$limit = 10;
$hotkeys = (new \Search())->getHotKeys(10);
//设置标题
$this->tag->setTitle("查询新闻");
//加载css 和js
$this->assets->addCss("fontend/css/major/search-detail-all.css");
$this->assets->addJs("fontend/js/search_detail-all.js");
$this->assets->addJs("fontend/js/common.js");
$this->view->setVars(['data' => $data, 'hotkeys' => $hotkeys, 'keys' => $keys]);
}
示例15: detailAction
/**
* 修改学校课程
*/
public function detailAction($col_id, $col_maj_id)
{
//检查是否是ajax请求
if ($this->request->isAjax()) {
$validate = new \Validate();
$col_id = (int) $col_id;
//学校ID
$data['col_maj_id'] = (int) $col_maj_id;
//学校专业关联id
$data['maj_id'] = $validate->getPost('maj_id', \Validate::int());
//专业ID
$data['maj_par_id'] = $validate->getPost('maj_par_id', \Validate::int());
//专业分类ID
$data['maj_par_par_id'] = $validate->getPost('maj_par_par_id', \Validate::int());
//专业学科ID
$data['maj_sort'] = $validate->getPost('maj_sort', \Validate::int());
//专业排序
$data['maj_click'] = $validate->getPost('maj_click', \Validate::int());
//专业点击量
$data['is_stress'] = $validate->getPost('is_stress', \Validate::int());
//国家重点
$data['is_brand'] = $validate->getPost('is_brand', \Validate::int());
//国家专题
$data['is_province'] = $validate->getPost('is_province', \Validate::int());
//省部重点
$data['col_maj_name'] = $validate->getPost('col_maj_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}\\(\\)()]{2,30}$/iu'));
//专业名称
$data['col_maj_faculty'] = $validate->getPost('col_maj_faculty', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}\\(\\)()]{2,30}$/iu'));
//专业学院
$data['maj_summary'] = $validate->getPost('maj_summary', \Validate::length(1000000, 0), ['slashes' => true]);
//招生简章
//验证数据
if ($validate->getMessage()) {
$this->end(400);
}
//验证高校专业是否存在
$result = (new \College())->getMajor($col_id, $data['col_maj_id']);
if ($result == 404) {
$this->end(404);
}
//修改高校课程
$result = (new \College())->UpdateMajor($this->session->get('id'), $data);
if ($result != 200) {
$this->end(400);
}
$this->end($result);
}
//获取参数
$col_maj_id = (int) $col_maj_id;
$col_id = (int) $col_id;
//获取详细信息
$detail = (new \College())->getMajor($col_id, $col_maj_id);
if ($detail == 404) {
$this->end(404);
}
//获取一级分类
$categorys = (new \Major())->getCategory();
//湖区专业分类列表
$major_parent = (new \Major())->getParent($detail['maj_par_par_id']);
//获取专业列表
$major = (new \Major())->getMajor($detail['maj_par_id']);
//教学类型
$genre = (new \Genre())->getList();
//加载所需js
$this->assets->addJs('backend/js/editors/summernote/summernote.js');
$this->assets->addJs('backend/mt-js/major-detail.js');
$this->view->setLayout('college');
$this->view->setVars(['detail' => $detail, 'col_id' => $col_id, 'categorys' => $categorys, 'major_parent' => $major_parent, 'major' => $major, 'genre' => $genre]);
}