本文整理汇总了PHP中Validate::base64方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::base64方法的具体用法?PHP Validate::base64怎么用?PHP Validate::base64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::base64方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newAction
/**
* 新增合作机构
*/
public function newAction()
{
//检查是否是ajax请求
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['union_logo'] = $validate->getPost('union_logo', \Validate::base64());
//机构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,缩略图
$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);
}
//新增机构
$result = (new \Union())->addUnion($this->session->get('id'), $data);
if ($result != 200) {
\FileUtil::getInstance()->unlink(UPLOAD_PATH . $data['union_logo']);
}
$this->end($result);
}
//加载js
$this->assets->addJs('backend/mt-js/union.js');
$this->view->setVars([]);
}
示例2: newAction
/**
* 新增校友
*/
public function newAction($col_id)
{
//判断是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['col_id'] = $validate->getPost('col_id', \Validate::int());
//学校id
$data['alu_head'] = $validate->getPost('alu_head', \Validate::base64());
//校友头像
$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', \Validate::length(255, 2));
//资料来源
//验证参数
if ($validate->getMessage()) {
$this->end(400);
}
//生成校友头像
$data['alu_head'] = \Func::touchImg($data['alu_head'], 'alu_head');
//监测图片是否生成成功
if (!$data['alu_head']) {
\FileUtil::getInstance()->unlink(UPLOAD_PATH . $data['alu_head']);
$this->end(400);
}
//新增动态
$this->end((new \CollegeAlumnus())->addAlumnus($this->session->get('id'), $data));
}
$this->view->setVars(['col_id' => $col_id]);
}
示例3: newAction
/**
* 新增banner新闻
*/
public function newAction()
{
//判定是否是ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['news_id'] = $validate->getPost('news_id', \Validate::int());
//新闻id
$data['news_ban_img'] = $validate->getPost('news_ban_img', \Validate::base64());
//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图片
$data['news_ban_img'] = \Func::touchImg($data['news_ban_img'], 'news_ban');
if (!$data['news_ban_img']) {
$this->end(400);
}
$result = (new \NewsBanner())->addNewsBanner($this->session->get('id'), $data);
if ($result != 200) {
unlink(UPLOAD_PATH . $data['news_ban_img']);
}
$this->end($result);
}
}
示例4: 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');
}
示例5: newAction
/**
* 新增小初高教师
*/
public function newAction($sch_id)
{
//判断是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['sch_id'] = $validate->getPost('sch_id', \Validate::int());
//学校id
$data['tea_head'] = $validate->getPost('tea_head', \Validate::base64());
//教师头像
$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));
//教师简介
// print_r($data);
//验证参数
if ($validate->getMessage()) {
$this->end(400);
}
//生成教师头像
$data['tea_head'] = \Func::touchImg($data['tea_head'], 'tea_head');
//监测图片是否生成成功
if (!$data['tea_head']) {
\FileUtil::getInstance()->unlink(UPLOAD_PATH . $data['tea_head']);
$this->end(400);
}
//新增动态
$this->end((new \Teacher())->addTeacher($this->session->get('id'), $data));
}
//获取学校类型
$sch_type = (new \School())->getSchoolBasic($sch_id);
if ($sch_type['sch_type'] == 1) {
$this->view->setLayout("kindergarten");
} else {
$this->view->setLayout("school");
}
$this->view->setVars(['sch_id' => $sch_id]);
$this->view->setVars(['sch_id' => $sch_id, 'sch_type' => $sch_type]);
}
示例6: newAction
/**
* 新增新闻
*/
public function newAction()
{
//判定是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['news_title'] = $validate->getPost('news_title', \Validate::length(50, 1), ['slashes' => true]);
//新闻标题
$data['news_cat_id'] = $validate->getPost('news_cat_id', \Validate::int());
//新闻分类
$data['news_thumb'] = $validate->getPost('news_thumb', \Validate::base64());
//新闻缩略图
$data['news_source'] = $validate->getPost('news_source', \Validate::regex('/^[a-z\\d\\x{4e00}-\\x{9fa5}]{0,10}$/iu'));
//新闻来源
$data['news_content'] = $validate->getPost('news_content', \Validate::nil(), ['slashes' => true]);
//新闻标题
$data['news_key'] = $validate->getPost('news_key', \Validate::length(30, 0), ['slashes' => true, 'html' => true]);
//关键词
$data['news_desc'] = $validate->getPost('news_desc', \Validate::length(250, 0), ['slashes' => true, 'html' => true]);
//描述
//验证参数
if ($validate->getMessage()) {
$this->end(400);
}
//生成缩略图
$data['news_thumb'] = \Func::touchImg($data['news_thumb'], 'news_thumb');
if (!$data['news_thumb']) {
$this->end(400);
}
$result = (new \News())->addNews($this->session->get('id'), $data);
if ($result != 200) {
//删除生成的图片
unlink(UPLOAD_PATH . $data['news_thumb']);
}
$this->end($result);
}
//新闻分类
$categories = (new \News())->getCategorylist();
//加载js
$this->assets->addJs('backend/js/editors/summernote/summernote.js');
$this->view->setVars(['categories' => $categories]);
}
示例7: newAction
/**
* 新增高校教师
*/
public function newAction($tra_id)
{
//判断是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['tra_id'] = $validate->getPost('tra_id', \Validate::int());
//学校id
$data['is_hot'] = $validate->getPost('is_hot', \Validate::int());
//热门
$data['tea_head'] = $validate->getPost('tea_head', \Validate::base64());
//教师头像
$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));
//教师简介
//验证参数
if ($validate->getMessage()) {
$this->end(400);
}
//生成教师头像
$data['tea_head'] = \Func::touchImg($data['tea_head'], 'tea_head');
//监测图片是否生成成功
if (!$data['tea_head']) {
\FileUtil::getInstance()->unlink(UPLOAD_PATH . $data['tea_head']);
$this->end(400);
}
//新增动态
$this->end((new \TrainTeacher())->addTeacher($this->session->get('id'), $data));
}
$this->view->setVars(['tra_id' => $tra_id]);
}
示例8: newAction
/**
* 新增学校
*/
public function newAction()
{
//检查是否是ajax请求
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['col_logo'] = $validate->getPost('col_logo', \Validate::base64());
//学校logo
$data['col_thumb'] = $validate->getPost('col_thumb', \Validate::base64());
//学校缩略图
$data['col_name'] = $validate->getPost('col_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}\\(\\)()]{2,30}$/iu'));
//学校名称
$data['col_code'] = $validate->getPost('col_code', \Validate::regex('/^(\\d{3,6})?$/'));
//学校code
$data['col_build'] = $validate->getPost('col_build', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}\\(\\)\\-()]{0,30}$/iu'));
//学校创建时间
$data['att_id'] = $validate->getPost('att_id');
//学校属性
$data['col_department'] = $validate->getPost('col_department', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
//隶属部门
$data['gen_id'] = $validate->getPost('gen_id', \Validate::int());
//教学类型
$data['is_join'] = $validate->getPost('is_join', \Validate::scopeCall('Setting', 'getJoin'));
//官方合作
$data['is_fine'] = $validate->getPost('is_fine', \Validate::scopeCall('Setting', 'getFine'));
//官方合作
$data['is_honesty'] = $validate->getPost('is_honesty', \Validate::scopeCall('Setting', 'getFine'));
//官方合作
$data['public_type'] = $validate->getPost('public_type', \Validate::scopeCall('Setting', 'getPublic'));
//办学性质
$data['hire_type'] = $validate->getPost('hire_type', \Validate::scopeCall('Setting', 'getHire'));
//办学性质
$data['col_type'] = $validate->getPost('col_type', \Validate::scopeCall('Setting', 'getColType'));
//学校类型
$data['col_tel'] = $validate->getPost('col_tel', \Validate::length(60, 0), ['slashes' => true, 'html' => true]);
//联系电话
$data['col_mail'] = $validate->getPost('col_mail', \Validate::length(80, 0), ['slashes' => true, 'html' => true]);
//邮箱
$data['col_url'] = $validate->getPost('col_url', \Validate::length(80, 0), ['slashes' => true, 'html' => true]);
//学校官网
$data['col_enroll_url'] = $validate->getPost('col_enroll_url', \Validate::length(80, 0), ['slashes' => true, 'html' => true]);
//学校招生官网
$data['col_man'] = $validate->getPost('col_man', \Validate::int());
//男生比例
$data['col_degree'] = $validate->getPost('col_degree', \Validate::int());
//报考难度
$data['col_job'] = $validate->getPost('col_job', \Validate::int());
//报考难度
$data['col_academician'] = $validate->getPost('col_academician', \Validate::int());
//院士数量
$data['col_test'] = $validate->getPost('col_test', \Validate::int());
//国家实验室数量
$data['col_stress'] = $validate->getPost('col_stress', \Validate::int());
//重点专业数量
$data['col_master'] = $validate->getPost('col_master', \Validate::int());
//硕士点数
$data['col_doctor'] = $validate->getPost('col_doctor', \Validate::int());
//院士点数
$data['pro_code'] = $validate->getPost('pro_code', \Validate::regex('/^[1-9]\\d{5}$/'));
//学校所在省份编码
$data['city_code'] = $validate->getPost('city_code', \Validate::regex('/^[1-9]\\d{5}$/'));
//学校所在城市编码
$data['col_addr'] = $validate->getPost('col_addr', \Validate::length(60, 0), ['slashes' => true, 'html' => true]);
//详细地址
$data['col_summary'] = $validate->getPost('col_summary', \Validate::length(10000, 0), ['slashes' => true]);
//学校简介
$data['col_key'] = $validate->getPost('col_key', \Validate::length(100, 0), ['slashes' => true, 'html' => true]);
//关键词
$data['col_desc'] = $validate->getPost('col_desc', \Validate::length(250, 0), ['slashes' => true, 'html' => true]);
//描述
$data['col_cost'] = $validate->getPost('col_cost', \Validate::length(10000, 0), ['slashes' => true]);
//收费情况
$data['col_general'] = $validate->getPost('col_general', \Validate::length(10000, 0), ['slashes' => true]);
//招生简章
//验证数据
if ($validate->getMessage()) {
$this->end(400);
}
//生成学校logo,缩略图
$data['col_logo'] = \Func::touchImg($data['col_logo'], 'col_logo');
$data['col_thumb'] = \Func::touchImg($data['col_thumb'], 'col_thumb');
//将生成的图片地址存入img,用户失败时删除
$img = [UPLOAD_PATH . $data['col_logo'], UPLOAD_PATH . $data['col_thumb']];
//监测图片是否全部生成成功
if (!$data['col_logo'] || !$data['col_thumb']) {
\FileUtil::getInstance()->unlink($img);
}
//新增高校
$result = (new \College())->addCollege($this->session->get('id'), $data);
if ($result != 200) {
\FileUtil::getInstance()->unlink($img);
}
$this->end($result);
}
//加载所需js
$this->assets->addJs('backend/js/datetime/bootstrap-datepicker.js');
$this->assets->addJs('backend/js/editors/summernote/summernote.js');
$this->assets->addJs('backend/mt-js/college-new.js');
//.........这里部分代码省略.........
示例9: newAction
/**
* 新增学校课程
*/
public function newAction($tra_id)
{
//检查是否是ajax请求
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['tra_id'] = (int) $tra_id;
//学校ID
$data['cou_thumb'] = $validate->getPost('cou_thumb', \Validate::base64());
//学校缩略图
$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, 0), ['slashes' => true, 'html' => true]);
//描述
$data['cou_trait'] = $validate->getPost('cou_trait', \Validate::length(250, 0), ['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);
}
//生成课程缩略图
$data['cou_thumb'] = \Func::touchImg($data['cou_thumb'], 'cou_thumb');
//将生成的图片地址存入img,用户失败时删除
$img = [UPLOAD_PATH . $data['cou_thumb']];
//监测图片是否全部生成成功
if (!$data['cou_thumb']) {
\FileUtil::getInstance()->unlink($img);
}
//新增机构课程
$result = (new \Course())->addCourse($this->session->get('id'), $data);
if ($result != 200) {
$this->end($result);
}
$this->end($result);
}
//获取一级分类
$cate1 = (new \Course())->getCategory();
//获取机构教师
$teachers = (new \TrainTeacher())->getTeacherList($tra_id, 1, 999)['list'];
//加载所需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-new.js');
$this->view->setLayout('train');
$this->view->setVars(['tra_id' => $tra_id, 'cate1' => $cate1, 'teachers' => $teachers]);
}
示例10: newAction
/**
* 新增培训
*/
public function newAction()
{
//检查是否是ajax请求
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['tra_logo'] = $validate->getPost('tra_logo', \Validate::base64());
//机构logo
$data['tra_thumb'] = $validate->getPost('tra_thumb', \Validate::base64());
//机构缩略图
$data['tra_name'] = $validate->getPost('tra_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{2,30}$/iu'));
//学校名称
$data['tra_cat_id'] = $validate->getPost('tra_cat_id', \Validate::int());
//机构分类
$data['tra_system'] = $validate->getPost('tra_system', \Validate::int());
//上课类型
$data['is_join'] = $validate->getPost('is_join', \Validate::scopeCall('Setting', 'getJoin'));
//官方合作
$data['home_type'] = $validate->getPost('is_home', \Validate::scopeCall('Setting', 'getHome'));
//包住宿
$data['hire_type'] = $validate->getPost('is_hire', \Validate::scopeCall('Setting', 'getHire'));
//包就业
$data['tra_tel'] = $validate->getPost('tra_tel', \Validate::length(60, 0), ['slashes' => true, 'html' => true]);
//联系电话
$data['tra_url'] = $validate->getPost('tra_url', \Validate::regex('/^(http(s)?:\\/\\/[^\'"\\s]+)?$/'));
//机构官网
$data['pro_code'] = $validate->getPost('pro_code', \Validate::regex('/^[1-9]\\d{5}$/'));
//机构所在省份编码
$data['city_code'] = $validate->getPost('city_code', \Validate::regex('/^[1-9]\\d{5}$/'));
//机构所在城市编码
$data['area_code'] = $validate->getPost('area_code', \Validate::regex('/^[1-9]\\d{5}$/'));
//机构所在区县编码
$data['dist_code'] = $validate->getPost('dist_code', \Validate::regex('/^0|(^[1-9]\\d{5})$/'));
//机构所在城市编码
$data['tra_addr'] = $validate->getPost('tra_addr', \Validate::length(100, 0), ['slashes' => true, 'html' => true]);
//详细地址
$data['tra_summary'] = $validate->getPost('tra_summary', \Validate::length(100000, 0), ['slashes' => true]);
//机构简介
$data['tra_key'] = $validate->getPost('tra_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['tra_desc'] = $validate->getPost('tra_desc', \Validate::length(250, 0), ['slashes' => true, 'html' => true]);
//描述
//验证数据
if ($validate->getMessage()) {
$this->end(400);
}
//生成机构logo,缩略图
$data['tra_logo'] = \Func::touchImg($data['tra_logo'], 'tra_logo');
$data['tra_thumb'] = \Func::touchImg($data['tra_thumb'], 'tra_thumb');
//将生成的图片地址存入img,用户失败时删除
$img = [UPLOAD_PATH . $data['tra_logo'], UPLOAD_PATH . $data['tra_thumb']];
//监测图片是否全部生成成功
if (!$data['tra_logo'] || !$data['tra_thumb']) {
\FileUtil::getInstance()->unlink($img);
}
//新增高校
$result = (new \Train())->addTrain($this->session->get('id'), $data);
if ($result != 200) {
\FileUtil::getInstance()->unlink($img);
}
$this->end($result);
}
//加载所需js
$this->assets->addJs('backend/js/datetime/bootstrap-datepicker.js');
$this->assets->addJs('backend/js/editors/summernote/summernote.js');
$this->assets->addJs('backend/mt-js/train-new.js');
//获取省份数据
$provinces = (new \Site())->getProvince();
//工程属性
$category = (new \Train())->getCategory();
//教学类型
$genre = (new \Genre())->getList();
$this->view->setVars(['provinces' => $provinces, 'category' => $category, 'genre' => $genre]);
}
示例11: newAction
/**
* 新增小初高学校
*/
public function newAction()
{
//检查是否是ajax请求
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['sch_logo'] = $validate->getPost('sch_logo', \Validate::base64());
//学校logo
$data['sch_thumb'] = $validate->getPost('sch_thumb', \Validate::base64());
//学校缩略图
$data['sch_name'] = $validate->getPost('sch_name', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}\\(\\)()]{2,30}$/iu'));
//学校名称
$data['sch_build'] = $validate->getPost('sch_build', \Validate::regex('/^([a-z0-9\\x{4e00}-\\x{9fa5}\\(\\)\\-()]{2,30})?$/iu'));
//学校创建时间
$data['sch_way'] = $validate->getPost('sch_way', \Validate::length(60, 0), ['slashes' => true]);
//入学途径
$data['sch_department'] = $validate->getPost('sch_department', \Validate::length(60, 0), ['slashes' => true]);
//隶属部门
$data['is_join'] = $validate->getPost('is_join', \Validate::scopeCall('Setting', 'getJoin'));
//官方合作
$data['public_type'] = $validate->getPost('public_type', \Validate::scopeCall('Setting', 'getPublic'));
//办学性质
$data['home_type'] = $validate->getPost('home_type', \Validate::scopeCall('Setting', 'getHome'));
//住宿情况
$data['exam_type'] = $validate->getPost('exam_type', \Validate::scopeCall('Setting', 'getExam'));
//入学考试
$data['stress_type'] = $validate->getPost('stress_type', \Validate::scopeCall('Setting', 'getSchStress'));
//重点情况
$data['sch_type'] = $validate->getPost('sch_type', \Validate::scopeCall('Setting', 'getSchType'));
//学校类型
$data['sch_tel'] = $validate->getPost('sch_tel', \Validate::length(60, 0), ['slashes' => true]);
//联系电话
$data['pro_code'] = $validate->getPost('pro_code', \Validate::regex('/^[1-9]\\d{5}$/'));
//学校所在省份编码
$data['city_code'] = $validate->getPost('city_code', \Validate::regex('/^[1-9]\\d{5}$/'));
//学校所在城市编码
$data['area_code'] = $validate->getPost('area_code', \Validate::regex('/^[1-9]\\d{5}$/'));
//学校所在区县编码
$data['sch_addr'] = $validate->getPost('sch_address', \Validate::length(60, 0), ['slashes' => true, 'html' => true]);
//详细地址
$data['sch_summary'] = $validate->getPost('sch_summary', \Validate::length(100000, 0), ['slashes' => true]);
//学校简介
$data['sch_key'] = $validate->getPost('sch_key', \Validate::regex('/^([a-z0-9\\x{4e00}-\\x{9fa5}]{1,20}([\\s,][a-z0-9\\x{4e00}-\\x{9fa5}]{1,10}){0,9})?$/iu'));
//关键词
$data['sch_desc'] = $validate->getPost('sch_desc', \Validate::length(250, 0), ['slashes' => true, 'html' => true]);
//描述
$data['sch_cost'] = $validate->getPost('sch_cost', \Validate::length(100000, 0), ['slashes' => true]);
//收费情况
$data['sch_lesson'] = $validate->getPost('sch_lesson', \Validate::length(200, 0), ['slashes' => true]);
//课程体系
$data['sch_fruit'] = $validate->getPost('sch_fruit', \Validate::length(100000, 0), ['slashes' => true]);
//办学成果
$data['sch_power'] = $validate->getPost('sch_power', \Validate::length(100000, 0), ['slashes' => true]);
//师资力量
//验证参数
if ($validate->getMessage()) {
$this->end(400);
}
//生成学校logo,缩略图
$data['sch_logo'] = \Func::touchImg($data['sch_logo'], 'sch_logo');
$data['sch_thumb'] = \Func::touchImg($data['sch_thumb'], 'sch_thumb');
//将生成的图片地址存入img,用户失败时删除
$img = [UPLOAD_PATH . $data['sch_logo'], UPLOAD_PATH . $data['sch_thumb']];
//监测图片是否全部生成成功
if (!$data['sch_logo'] || !$data['sch_thumb']) {
\FileUtil::getInstance()->unlink($img);
$this->end(400);
}
//新增学校
$result = (new \School())->addSchool($this->session->get('id'), $data);
if ($result != 200) {
\FileUtil::getInstance()->unlink($img);
}
$this->end($result);
}
//获取省份数据
$provinces = (new \Site())->getProvince();
//加载js
$this->assets->addJs('backend/js/editors/summernote/summernote.js');
$this->assets->addJs('backend/js/datetime/bootstrap-datepicker.js');
$this->assets->addJs('backend/mt-js/school-new.js');
$this->view->setVars(['provinces' => $provinces]);
}
示例12: addAction
/**
* 添加阳光宝贝
*/
public function addAction($sch_id)
{
//判断是否ajax
if ($this->request->isAjax()) {
$validate = new \Validate();
$data['sch_id'] = $validate->getPost('sch_id', \Validate::int());
//学校id
$data['star_head'] = $validate->getPost('star_head', \Validate::base64());
//学员头像
$data['star_name'] = $validate->getPost('star_name', \Validate::length(15, 2));
//学员名称
$data['star_sort'] = $validate->getPost('star_sort', \Validate::length(99999999, 0));
//排序
// print_r($data);
//验证参数
if ($validate->getMessage()) {
$this->end(400);
}
//生成教师头像
$data['star_head'] = \Func::touchImg($data['star_head'], 'star_head');
//监测图片是否生成成功
if (!$data['star_head']) {
\FileUtil::getInstance()->unlink(UPLOAD_PATH . $data['star_head']);
$this->end(400);
}
//新增动态
$this->end((new \Kindergarten())->addStar($this->session->get('id'), $data));
}
//加载js
$this->assets->addJs('backend/mt-js/kindergarten-star.js');
$this->view->setLayout('kindergarten');
$this->view->setVars(['sch_id' => $sch_id]);
}