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