本文整理汇总了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');
}
示例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]);
}
示例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;
}
示例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]);
}
示例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']]);
}
示例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));
}
}
示例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']]);
}
示例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');
}
示例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]);
}
示例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');
}
示例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('专题添加成功');
}
示例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]);
}
示例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]);
}
示例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]);
}
示例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']]);
}