當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Validate::int方法代碼示例

本文整理匯總了PHP中Validate::int方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validate::int方法的具體用法?PHP Validate::int怎麽用?PHP Validate::int使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Validate的用法示例。


在下文中一共展示了Validate::int方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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');
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:36,代碼來源:AttributeController.php

示例2: 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]);
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:31,代碼來源:NewscomController.php

示例3: listened

 /**
  * Adds a playlists to user history
  * increments playlist play count
  * @return [type] [description]
  */
 private function listened()
 {
     Base::requireLogged();
     $ret = array('status' => 0);
     if (empty($_GET['id']) || !Validate::int($_GET['id'])) {
         return $ret;
     }
     $id = (int) $_GET['id'];
     // Checks if the play is unique
     $play = UserListened::where('playlist_id', $id)->where('user_id', LOGGED)->findOne();
     if ($play) {
         return $ret;
     }
     // Adds playlist to user listening history
     $history = UserListened::create();
     $history->user_id = LOGGED;
     $history->playlist_id = $id;
     $history->save();
     // Increment play count
     $playlist = Playlist::findOne($id);
     if (!$playlist) {
         return $ret;
     }
     $playlist->played_count++;
     $playlist->save();
     // Everything went right
     $ret['status'] = 1;
     return $ret;
 }
開發者ID:nytr0gen,項目名稱:plur-music-explorer,代碼行數:34,代碼來源:request.php

示例4: 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]);
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:36,代碼來源:CalendarController.php

示例5: 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']]);
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:37,代碼來源:ColnewsController.php

示例6: newAction

 public function newAction()
 {
     //判定是否是ajax
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['que_id'] = $validate->getPost('que_id', \Validate::int());
         //新聞id
         $data['que_content'] = $validate->getPost('que_content', \Validate::nil(), ['slashes' => true]);
         //測試題內容
         //驗證參數
         if ($validate->getMessage()) {
             $this->end(400);
         }
         $this->end((new \Questions())->addQuestions($this->session->get('id'), $data));
     }
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:16,代碼來源:QuestionsController.php

示例7: detailAction

 /**
  * 高校教師的詳細信息
  */
 public function detailAction($tra_tea_id)
 {
     //判斷是否ajax
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['tra_id'] = $validate->getPost('tra_id', \Validate::int());
         //學校id
         $data['tea_id'] = $validate->getPost('tea_id', \Validate::int());
         //教師id
         $data['is_hot'] = $validate->getPost('is_hot', \Validate::int());
         //熱門
         $data['tea_name'] = $validate->getPost('tea_name', \Validate::length(15, 2));
         //教師名稱
         $data['tea_specialty'] = $validate->getPost('tea_specialty', \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 \TrainTeacher())->updTeacher($this->session->get('id'), $data));
     }
     //教師id
     $tra_tea_id = (int) $tra_tea_id;
     //教師數據
     $teacher = (new \TrainTeacher())->getTeacherDetail($tra_tea_id);
     $this->view->setVars(['tra_tea_id' => $tra_tea_id, 'teacher' => $teacher, 'tra_id' => $teacher['tra_id']]);
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:47,代碼來源:TrateacherController.php

示例8: 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');
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:22,代碼來源:DepartmentController.php

示例9: 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]);
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:45,代碼來源:NewsbanController.php

示例10: 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');
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:23,代碼來源:MajorkeyController.php

示例11: formAction

 /**
  * 新增專題
  */
 public function formAction()
 {
     //定義js匿名函數
     $execJs = function ($msg) {
         $js = "<script type='text/javascript'>\r\n                        //禁止回退\r\n                        window.history.forward(1);\r\n                            alert('{$msg}');\r\n                        location.href = history.go(-1);\r\n                    </script>";
         die($js);
     };
     $validate = new \Validate();
     $data['file_cat_id'] = $validate->getPost('file_cat_id', \Validate::int());
     //專題類型
     //驗證參數
     if ($validate->getMessage()) {
         $execJs('參數錯誤');
     }
     //驗證文件
     if (!isset($_FILES['doc'])) {
         $execJs('非法操作');
     }
     //驗證zip壓縮文件
     $doc = new File($_FILES['doc']);
     if ($doc->getExtension() != 'doc' && $doc->getExtension() != 'docx' && $doc->getExtension() != 'ppt' && $doc->getExtension() != 'pptx') {
         $execJs('請上傳doc、docx、ppt、pptx類型的文件');
     }
     $file_name = $doc->getName();
     //創建目錄
     $file_path = FILE_PATH . '/file/' . $data['file_cat_id'];
     $util = new \FileUtil();
     $util->mkdir($file_path);
     $data['file_url'] = '/file/' . $data['file_cat_id'] . '/' . md5($file_name . time()) . '.' . $doc->getExtension();
     $file_url = FILE_PATH . $data['file_url'];
     $data['file_name'] = $file_name;
     //移動資源文件,並重命名,與phtml文件相同
     $doc->moveTo($file_url);
     $result = (new \File())->addFile($this->session->get('id'), $data);
     if ($result != 200) {
         //刪除所有專題相關文件
         $this->unlink($file_url);
         $execJs('上傳失敗');
     }
     $execJs('專題添加成功');
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:44,代碼來源:FileController.php

示例12: 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]);
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:44,代碼來源:LinkController.php

示例13: detailAction

 public function detailAction($id)
 {
     //判定是否是ajax
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['maj_id'] = $validate->getPost('maj_id', \Validate::int());
         //專業ID
         $data['maj_kidney'] = $validate->getPost('maj_kidney', \Validate::int());
         //性格專業
         //驗證參數
         if ($validate->getMessage()) {
             $this->end(400);
         }
         $this->end((new \QuestionsMajor())->updateMajor($this->session->get('id'), $data));
     }
     $id = (int) $id;
     $detail = (new \QuestionsMajor())->getDetail($id);
     if (empty($detail)) {
         $this->notFound();
     }
     $this->view->setVars(['detail' => $detail]);
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:22,代碼來源:QuestionsmajController.php

示例14: 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]);
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:37,代碼來源:CourseController.php

示例15: 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']]);
 }
開發者ID:xw716825,項目名稱:git_back,代碼行數:39,代碼來源:ColalumnusController.php


注:本文中的Validate::int方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。