Пример #1
0
 /**
  * 合作机构基本信息
  */
 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]);
 }
Пример #2
0
 /**
  * 新增校友
  */
 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
0
 /**
  * 新增属性
  */
 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');
 }
Пример #4
0
 /**
  * 注册接口
  */
 public function registerAction()
 {
     $vars = ['mem_phone', 'pho_code', 'mem_account', 'mem_pwd', 'mem_head', 'login_system', 'login_number', 'mem_client_id', 'sign'];
     //获取数据
     list($mem_phone, $pho_code, $mem_account, $mem_pwd, $mem_head, $login_system, $login_number, $mem_client_id, $sign) = \Verify::getPost($vars);
     //验证参数
     if (\Verify::getMessage()) {
         $this->throwMessage(PARAMETER_FAIL, \Verify::getMessage());
     }
     //生产图片
     $mem_head = \Func::touchImg($mem_head, 'head');
     if (!$mem_head) {
         $this->throwMessage(ILLEGAL_IMAGE);
     }
     //验证签名
     if (!$this->verifyLoginSign($mem_account, $mem_pwd, $sign)) {
         $this->throwMessage(ILLEGAL_SIGN);
     }
     //注册,并登陆
     $member = (new \Member())->register($mem_phone, $pho_code, $mem_account, $mem_pwd, $mem_head, $login_system, $login_number, $mem_client_id);
     if (!is_array($member)) {
         \FileUtil::getInstance()->unlink(IMG_PATH . $mem_head);
         $this->throwMessage($member);
     }
     $this->throwMessage(OK, $member);
 }
Пример #5
0
 /**
  * 生成图片
  * @param string  $base64_source base64编码
  * @param string  $path_name 分目录
  * @param boolean $delete 图片生成错误时,是否删除已生成图片
  * @return false|string 成功返回图片路径,失败返回false
  */
 public static function touchImg($base64_source, $path_name, $delete = true)
 {
     //判断图片base64格式,并截取扩展名
     $pattern = '/^data:image\\/(?<ext>jpeg|png|gif|jpg);base64,(?<source>\\S+)/';
     if (!preg_match($pattern, $base64_source, $match) || !base64_decode($match['source'])) {
         return false;
     }
     //扩展名
     if ($match['ext'] != 'png' && $match['ext'] != 'gif' && $match['ext'] != 'jpg' || $match['ext'] == 'jpeg') {
         $match['ext'] = 'jpg';
     }
     //图片名称
     $img_name = md5(microtime(true) . mt_rand(1000, 9999)) . '.' . $match['ext'];
     //获取图片的服务器地址,以及存入数据库地址
     $data_path = '/images/' . $path_name . '/' . date('Ym/d', time()) . '/';
     $host_path = UPLOAD_PATH . $data_path;
     //创建目录
     if (!FileUtil::getInstance()->mkdir($host_path)) {
         die(json_encode([['error' => 'No file permissions']]));
     }
     //生成图片
     $host_img = $host_path . $img_name;
     file_put_contents($host_img, base64_decode($match['source']));
     //判断图片是否损坏
     if (!getimagesize($host_img) && $delete) {
         //删除算坏图片
         unlink($host_img);
         return false;
     }
     return $data_path . $img_name;
 }
Пример #6
0
 /**
  * 回答接口
  */
 public function addAction()
 {
     //取值,参数验证,签名验证
     $vars = ['mem_id', 'mem_mark', 'empty_ans_id', 'mem_relation_id', 'que_id', 'ans_content', 'is_img', 'sign'];
     $this->beforeGetVarExecVerify($vars, 'post');
     //判断是否是图片
     if ($this->data['is_img'] == 1) {
         $this->data['ans_content'] = \Func::touchImg($this->data['ans_content'], 'ans');
         if (!$this->data['ans_content']) {
             $this->throwMessage(ILLEGAL_IMAGE);
         }
     }
     //默认执行回答提问方法
     $func = 'addAnswer';
     //需要的字段
     $field = ['mem_id', 'mem_mark', 'mem_relation_id', 'que_id', 'ans_content'];
     //根据可空回答id,empty_ans_id判断是否执行追问方法
     if ($this->data['empty_ans_id']) {
         array_push($field, $this->data['empty_ans_id']);
         $func = 'addAnswerAsk';
     }
     //转义回答内容
     $this->data['ans_content'] = mb_substr(\Func::escape($this->data['ans_content']), 0, 250, 'utf-8');
     //获取执行状态,执行失败,并且是图片信息,则删除上传的图片
     $add_status = $this->callModelFunc('Answer', $func, $field);
     if ($add_status != OK && $this->data['is_img'] == 1) {
         \FileUtil::getInstance()->unlink(PUBLIC_PATH . $this->data['ans_content']);
     }
     $this->throwMessage($add_status);
 }
Пример #7
0
 /**
  * 申请智囊
  */
 public function applyAction()
 {
     //取值,参数验证,签名验证
     $vars = ['mem_id', 'mem_mark', 'sage_realname', 'sage_cardid', 'sage_pic_above', 'sage_pic_below', 'tag_ides', 'sign'];
     $this->beforeGetVarExecVerify($vars, 'post');
     //生成身份证正反面图片
     $this->data['sage_pic_above'] = \Func::touchImg($this->data['sage_pic_above'], 'sage');
     $this->data['sage_pic_below'] = \Func::touchImg($this->data['sage_pic_below'], 'sage');
     $images = [$this->data['sage_pic_above'], $this->data['sage_pic_below']];
     if (!$this->data['sage_pic_above'] || !$this->data['sage_pic_below']) {
         \FileUtil::getInstance()->unlink($images, PUBLIC_PATH);
         $this->throwMessage(ILLEGAL_IMAGE);
     }
     //需要的字段
     $field = ['mem_id', 'mem_mark', 'sage_realname', 'sage_cardid', 'sage_pic_above', 'sage_pic_below', 'tag_ides'];
     $add_status = $this->callModelFunc('Sage', 'addSage', $field);
     if ($add_status != OK) {
         \FileUtil::getInstance()->unlink($images, PUBLIC_PATH);
     }
     $this->throwMessage($add_status);
 }
Пример #8
0
 /**
  * 注册接口
  */
 public function registerAction()
 {
     $vars = ['mem_phone', 'pho_code', 'mem_account', 'mem_pwd', 'mem_head', 'login_system', 'login_number', 'mem_client_id', 'sign'];
     $this->beforeGetVarExecVerify($vars, 'post');
     //生产图片
     $this->data['mem_head'] = \Func::touchImg($this->data['mem_head'], 'head');
     if (!$this->data['mem_head']) {
         $this->throwMessage(ILLEGAL_IMAGE);
     }
     //密码加密
     $this->data['mem_pwd'] = $this->password($this->data['mem_pwd']);
     //调用模型方法所需字段
     $field = ['mem_phone', 'pho_code', 'mem_account', 'mem_pwd', 'mem_head', 'login_system', 'login_number', 'mem_client_id'];
     //注册,并登陆,如果失败,删除上传的头像
     $member = $this->callModelFunc('Member', 'register', $field);
     if (!is_array($member)) {
         \FileUtil::getInstance()->unlink(PUBLIC_PATH . $this->data['mem_head']);
         $this->throwMessage($member);
     }
     $this->throwMessage(OK, $member);
 }
Пример #9
0
 /**
  * 新增提问
  */
 public function addAction()
 {
     //取值,参数验证,签名验证
     $vars = ['mem_id', 'mem_mark', 'que_content', 'que_img', 'que_reward', 'tag_ides', 'sign'];
     $this->beforeGetVarExecVerify($vars, 'post');
     //图片操作
     $this->data['que_img'] = json_decode($this->data['que_img'], true);
     $this->data['que_img'] = is_array($this->data['que_img']) ? $this->data['que_img'] : [];
     $images = [];
     if (!empty($this->data['que_img'])) {
         $i = 1;
         foreach ($this->data['que_img'] as $key => $val) {
             //数组格式不合法
             if (!isset($val['img'])) {
                 \FileUtil::getInstance()->unlink($images, PUBLIC_PATH);
                 $this->throwMessage(ILLEGAL_ARRAY);
             }
             //非法的图片
             if (!($images[] = \Func::touchImg($val['img'], 'que'))) {
                 \FileUtil::getInstance()->unlink($images, PUBLIC_PATH);
                 $this->throwMessage(ILLEGAL_IMAGE);
             }
             //控制提问最多可上传的数量
             $i++;
             if ($i > QUESTION_MAX_IMAGE) {
                 break;
             }
         }
     }
     //处理字段
     $this->data['que_img'] = $images;
     $this->data['que_content'] = \Func::escape($this->data['que_content']);
     //所需字段
     $field = ["mem_id", "mem_mark", "que_content", "que_img", "que_reward", "tag_ides"];
     $add_status = $this->callModelFunc('Question', 'addQuestion', $field);
     if ($add_status != OK) {
         \FileUtil::getInstance()->unlink($images, PUBLIC_PATH);
     }
     $this->throwMessage($add_status);
 }
Пример #10
0
 /**
  * 新增高校教师
  */
 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]);
 }
Пример #11
0
 /**
  * 删除高校教师
  * @param int $man_id 管理员id
  * @param int $sch_tea_id 小初高教师id
  * @return int 删除状态
  */
 public function delTeacher($man_id, $col_tea_id)
 {
     //检查教师是否存在
     $sql = 'select col_tea_head from college_teacher where col_tea_id=? limit 1';
     $result = $this->fetchOne($sql, [$col_tea_id]);
     if (!$result) {
         return 404;
     }
     //删除教师
     $sql = 'delete from college_teacher where col_tea_id=:col_tea_id';
     $this->execute($sql, ['col_tea_id' => $col_tea_id]);
     if (!$this->affectedRows()) {
         return 500;
     }
     //删除教师头像图片
     if (is_file(UPLOAD_PATH . $result['col_tea_head'])) {
         \FileUtil::getInstance()->unlink(UPLOAD_PATH . $result['col_tea_head']);
     }
     //管理操作记录
     $this->log($man_id, 'del_col_tea', '删除高校教师:', $col_tea_id);
     return 200;
 }
Пример #12
0
 /**
  * 添加阳光宝贝
  */
 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]);
 }
Пример #13
0
 /**
  * 新增学校课程
  */
 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
0
 /**
  * 删除高校教师
  * @param int $man_id 管理员id
  * @param int $sch_tea_id 小初高教师id
  * @return int 删除状态
  */
 public function delAlumnus($man_id, $col_alu_id)
 {
     //检查校友是否存在
     $sql = 'select col_alu_head from college_alumnus where col_alu_id=? limit 1';
     $result = $this->fetchOne($sql, [$col_alu_id]);
     if (!$result) {
         return 404;
     }
     //删除校友
     $sql = 'delete from college_alumnus where col_alu_id=:col_alu_id';
     $this->execute($sql, ['col_alu_id' => $col_alu_id]);
     if (!$this->affectedRows()) {
         return 500;
     }
     //删除校友头像图片
     if (is_file(UPLOAD_PATH . $result['col_alu_head'])) {
         \FileUtil::getInstance()->unlink(UPLOAD_PATH . $result['col_alu_head']);
     }
     //管理操作记录
     $this->log($man_id, 'del_col_alu', '删除知名校友:', $col_alu_id);
     return 200;
 }
Пример #15
0
 /**
  * 删除合作机构数据
  * @param int $man_id 管理员id
  * @param int $uni_id 合作机构id
  * @return int 删除状态
  */
 public function delUnion($man_id, $uni_id)
 {
     //查询合作机构是否存在
     $sql = 'select uni_logo from unions where uni_id=? limit 1';
     $result = $this->fetchOne($sql, [$uni_id]);
     if (!$result) {
         return 404;
     }
     //删除合作机构数据
     $sql = 'delete from unions where uni_id=?';
     $this->execute($sql, [$uni_id]);
     if (!$this->affectedRows()) {
         return 500;
     }
     //删除合作机构logo图片
     if (is_file(UPLOAD_PATH . $result['uni_logo'])) {
         \FileUtil::getInstance()->unlink(UPLOAD_PATH . $result['uni_logo']);
     }
     $this->log($man_id, 'del_union', '删除合作机构:', $uni_id);
     return 200;
 }
Пример #16
0
 /**
  * 培训详情
  * parmar  $col_id 学校id
  */
 public function detailAction($tra_id)
 {
     //检查是否是ajax请求
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['tra_logo'] = $validate->getPost('tra_logo');
         //机构logo
         $data['tra_thumb'] = $validate->getPost('tra_thumb');
         //机构缩略图
         $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['tra_click'] = $validate->getPost('tra_click', \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,缩略图
         $tra_logo = \Func::touchImg($data['tra_logo'], 'tra_logo');
         $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'] && !$tra_logo || $data['tra_thumb'] && !$tra_thumb) {
             \FileUtil::getInstance()->unlink($img);
             $this->end(400);
         }
         $data['tra_logo'] = $tra_logo;
         $data['tra_thumb'] = $tra_thumb;
         if (!$tra_logo) {
             unset($data['tra_logo']);
         }
         if (!$tra_thumb) {
             unset($data['tra_thumb']);
         }
         //修改高校
         $result = (new \Train())->updateTrain($this->session->get('id'), $tra_id, $data);
         if ($result != 200) {
             \FileUtil::getInstance()->unlink($img);
         }
         $this->end($result);
     }
     //高校id
     $tra_id = (int) $tra_id;
     //获取学校基本信息
     $detail = (new \Train())->getDetail($tra_id);
     if ($detail == 404) {
         $this->dispatcher->forward(['controller' => 'error', 'action' => 'error404']);
     }
     //获取学校已存在属性
     $att_id = (new \College())->getAttId($tra_id);
     //获取省份数据
     $provinces = (new \Site())->getProvince();
     //城市数据
     $city = (new \Site())->getCity($detail['pro_code']);
     //区县数据
     $area = (new \Site())->getArea($detail['city_code']);
     //城市数据
     $district = (new \Site())->getDist($detail['city_code']);
     //工程属性
     $category = (new \Train())->getCategory();
     //   print_r($detail);die;
     //加载所需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-detail.js');
     // 加载公共部分
     $this->view->setLayout('train');
     $this->view->setVars(['provinces' => $provinces, 'city' => $city, 'area' => $area, 'district' => $district, 'category' => $category, 'detail' => $detail, 'att_id' => $att_id, 'tra_id' => $tra_id]);
 }
Пример #17
0
 /**
  * 删除阳光宝贝
  * @param int $man_id 管理员id
  * @param int $sch_star_id 阳光宝贝id
  * @return int 删除状态
  */
 public function delStar($man_id, $sch_star_id)
 {
     //检查阳光宝贝是否存在
     $sql = 'select sch_star_head from school_star where sch_star_id=? limit 1';
     $result = $this->fetchOne($sql, [$sch_star_id]);
     if (!$result) {
         return 404;
     }
     //删除阳光宝贝
     $sql = 'delete from school_star where sch_star_id=:sch_star_id';
     $this->execute($sql, ['sch_star_id' => $sch_star_id]);
     if (!$this->affectedRows()) {
         return 500;
     }
     //删除阳光宝贝头像图片
     if (is_file(UPLOAD_PATH . $result['sch_star_head'])) {
         \FileUtil::getInstance()->unlink(UPLOAD_PATH . $result['sch_star_head']);
     }
     //管理操作记录
     $this->log($man_id, 'del_star', '删除阳光宝贝:', $sch_star_id);
     return 200;
 }
Пример #18
0
 /**
  * 修改banner
  */
 public function detailAction($ban_id)
 {
     //判断是否是ajax
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['ban_id'] = $validate->getPost('ban_id', \Validate::int());
         //数据id
         $data['ban_sort'] = $validate->getPost('ban_sort', \Validate::between(99999999, 0));
         //图片排序
         $data['ban_url'] = $validate->getPost('ban_url', \Validate::regex('/^(http(s)?:\\/\\/)/'), ['slashes' => true, 'html' => true]);
         //图片url
         $data['ban_alt'] = $validate->getPost('ban_alt', \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{1,30}$/iu'));
         //图片介绍
         $data['ban_start_date'] = $validate->getPost('ban_start_date', \Validate::time('yyyy-mm-dd'));
         //开始时间
         $data['ban_end_date'] = $validate->getPost('ban_end_date', \Validate::time('yyyy-mm-dd'));
         //结束时间
         $ban_img = $validate->getPost('ban_img');
         //banner图片
         //验证参数
         if ($validate->getMessage()) {
             $this->end(400);
         }
         //生成banner图片
         if ($ban_img) {
             $ban_img = \Func::touchImg($ban_img, 'banner');
             if (!$ban_img) {
                 $this->end(400);
             }
         }
         //修改banner
         $result = (new \Banner())->updBanner($this->session->get('id'), $data, $ban_img);
         if ($result != 200) {
             \FileUtil::getInstance()->unlink(UPLOAD_PATH . $ban_img);
         }
         $this->end($result);
     }
     //数据id
     $ban_id = (int) $ban_id;
     //banner详情数据
     $basic = (new \Banner())->getBannerDetail($ban_id);
     //加载js
     $this->assets->addJs('backend/js/datetime/bootstrap-datepicker.js');
     $this->assets->addJs('backend/mt-js/banner.js');
     $this->view->setVars(['basic' => $basic]);
 }
Пример #19
0
 public function tralistAction($tra_id)
 {
     //判断是否是ajax
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $tra_scene = $validate->getPost('scene', \Validate::arr());
         $tra_id = (int) $tra_id;
         if ($validate->getMessage()) {
             $this->end(400);
         }
         //新增的图片
         $new_img = [];
         //处理图片
         foreach ($tra_scene as $key => $val) {
             //检查字段是否设置
             if (!isset($val['img']) || !isset($val['content']) || !isset($val['sort'])) {
                 \FileUtil::getInstance()->unlink($new_img);
                 $this->end(400);
             }
             //清除错误信息
             $validate->clearMessage();
             //验证字段
             $tra_scene[$key]['sort'] = (int) $val['sort'];
             //图片排序
             $tra_scene[$key]['content'] = $validate->execute($val['content'], \Validate::regex('/^[a-z0-9\\x{4e00}-\\x{9fa5}]{1,30}$/iu'));
             //图片介绍
             if ($validate->getMessage()) {
                 \FileUtil::getInstance()->unlink($new_img);
                 $this->end(400);
             }
             //创建学校风光图,并验证是否创建成功
             $tra_scene[$key]['img'] = \Func::touchImg($val['img'], 'tra_scene');
             if (!$val['img']) {
                 \FileUtil::getInstance()->unlink($new_img);
                 $this->end(400);
             }
             //将生成成功的图片存入数组
             $new_img[] = UPLOAD_PATH . $tra_scene[$key]['img'];
         }
         //修改风光图
         $result = (new \Scene())->updTrainScene($this->session->get('id'), $tra_id, $tra_scene);
         //未修改成功,则删除新增的图片
         if ($result != 200) {
             \FileUtil::getInstance()->unlink($new_img);
         }
         $this->end($result);
     }
     //学校id
     $tra_id = (int) $tra_id;
     //获取学校风光图
     $scene = (new \Scene())->getTrainScene($tra_id);
     //加载js
     $this->assets->addJs('backend/mt-js/scene-tralist.js');
     $this->view->setLayout("train");
     $this->view->setVars(['tra_id' => $tra_id, 'scene' => $scene]);
 }
Пример #20
0
 /**
  * 删除学校相关的信息
  * @param int $man_id 管理员id
  * @param int $sch_id 需要删除的学校id
  * @return int 删除状态
  */
 public function delSchool($man_id, $sch_id)
 {
     //取出需要删除的相关图片
     $sql = 'select sch_logo,sch_thumb from school where sch_id=?';
     $result['school'] = $this->fetchAll($sql, [$sch_id]);
     $sql = 'select sch_sce_img from school_scene where sch_id=?';
     $result['scene'] = $this->fetchAll($sql, [$sch_id]);
     $sql = 'select sch_tea_head from school_teacher where sch_id=?';
     $result['teacher'] = $this->fetchAll($sql, [$sch_id]);
     //开启事务
     $this->begin();
     //删除学校统计表
     $sql = 'delete from school_day where sch_id=?';
     if (!$this->execute($sql, [$sch_id])) {
         $this->rollback();
         return 500;
     }
     //删除学校动态
     $sql = 'delete from school_dynamic where sch_id=?';
     if (!$this->execute($sql, [$sch_id])) {
         $this->rollback();
         return 500;
     }
     //删除学校生活
     $sql = 'delete from school_life where sch_id=?';
     if (!$this->execute($sql, [$sch_id])) {
         $this->rollback();
         return 500;
     }
     //删除学校注册
     $sql = 'delete from school_register where sch_id=?';
     if (!$this->execute($sql, [$sch_id])) {
         $this->rollback();
         return 500;
     }
     //删除学校评论
     $sql = 'delete from school_review where sch_id=?';
     if (!$this->execute($sql, [$sch_id])) {
         $this->rollback();
         return 500;
     }
     //删除学校风光
     $sql = 'delete from school_scene where sch_id=?';
     if (!$this->execute($sql, [$sch_id])) {
         $this->rollback();
         return 500;
     }
     //删除学校教师
     $sql = 'delete from school_teacher where sch_id=?';
     if (!$this->execute($sql, [$sch_id])) {
         $this->rollback();
         return 500;
     }
     //删除学校
     $sql = 'delete from school where sch_id=?';
     if (!$this->execute($sql, [$sch_id])) {
         $this->rollback();
         return 500;
     }
     //删除相关图片
     foreach ($result as $val) {
         foreach ($val as $v) {
             foreach ($v as $v1) {
                 if (is_file(UPLOAD_PATH . $v1)) {
                     \FileUtil::getInstance()->unlink(UPLOAD_PATH . $v1);
                 }
             }
         }
     }
     //提交事务
     $this->commit();
     //管理操作记录
     $this->log($man_id, 'del_sch', '删除幼小初高:', $sch_id);
     return 200;
 }
Пример #21
0
 /**
  * 学校详情
  * parmar  $col_id 学校id
  */
 public function detailAction($col_id)
 {
     //检查是否是ajax请求
     if ($this->request->isAjax()) {
         $validate = new \Validate();
         $data['col_logo'] = $validate->getPost('col_logo');
         //学校logo
         $data['col_thumb'] = $validate->getPost('col_thumb');
         //学校缩略图
         $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::regex('/^(0|(-)?[1-9]\\d?)(\\.\\d{1,2})?$/'));
         //男生比例
         $data['col_job'] = $validate->getPost('col_job', \Validate::regex('/^(0|(-)?[1-9]\\d?0?)(\\.\\d{1,2})?$/'));
         //就业率
         $data['col_degree'] = $validate->getPost('col_degree', \Validate::regex('/^(0|(-)?[1-9]\\d?)(\\.\\d{1,2})?$/'));
         //报考难度
         $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(100000, 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(100000, 0), ['slashes' => true]);
         //收费情况
         $data['col_general'] = $validate->getPost('col_general', \Validate::length(100000, 0), ['slashes' => true]);
         //招生简章
         //验证数据
         if ($validate->getMessage()) {
             $this->end(400);
         }
         //生成学校logo,缩略图
         $col_logo = \Func::touchImg($data['col_logo'], 'col_logo');
         $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'] && !$col_logo || $data['col_thumb'] && !$col_thumb) {
             \FileUtil::getInstance()->unlink($img);
             $this->end(400);
         }
         $data['col_logo'] = $col_logo;
         $data['col_thumb'] = $col_thumb;
         if (!$col_logo) {
             unset($data['col_logo']);
         }
         if (!$col_thumb) {
             unset($data['col_thumb']);
         }
         //修改高校
         $result = (new \College())->updateCollege($this->session->get('id'), $col_id, $data);
         if ($result != 200) {
             \FileUtil::getInstance()->unlink($img);
         }
         $this->end($result);
     }
     //高校id
     $col_id = (int) $col_id;
     //获取学校基本信息
     $detail = (new \College())->getDetail($col_id);
     if ($detail == 404) {
         $this->dispatcher->forward(['controller' => 'error', 'action' => 'error404']);
     }
     //获取学校已存在属性
     $att_id = (new \College())->getAttId($col_id);
     //获取省份数据
     $provinces = (new \Site())->getProvince();
     //城市数据
     $city = (new \Site())->getCity($detail['pro_code']);
     //工程属性
     $attribute = (new \Attribute())->getList();
     //教学类型
     $genre = (new \Genre())->getList();
     //   print_r($detail);die;
     //加载所需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-detail.js');
     // 加载公共部分
     $this->view->setLayout('college');
     $this->view->setVars(['provinces' => $provinces, 'city' => $city, 'attribute' => $attribute, 'genre' => $genre, 'detail' => $detail, 'att_id' => $att_id, 'col_id' => $col_id]);
 }
Пример #22
0
 /**
  * 修改友情链接
  */
 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]);
 }
Пример #23
0
 /**
  * 新增小初高教师
  */
 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]);
 }
Пример #24
0
 /**
  * 删除友情链接
  * @param int .管理员id
  * @param int .热点文章Id
  * @return int
  */
 public function delLink($man_id, $link_id)
 {
     //获取原友情链接图片
     $sql = 'select link_logo from link where link_id=? limit 1';
     $result = $this->fetchOne($sql, [$link_id]);
     if (!$result) {
         return 404;
     }
     //删除数据
     $sql = 'delete from link where link_id=?';
     $this->execute($sql, [$link_id]);
     if (!$this->affectedRows()) {
         return 500;
     }
     //删除原友情链接图片
     if (is_file(UPLOAD_PATH . $result['link_logo'])) {
         \FileUtil::getInstance()->unlink(UPLOAD_PATH . $result['link_logo']);
     }
     //管理员操作记录
     $this->log($man_id, 'del_link', '删除友情链接:', $link_id);
     return 200;
 }
Пример #25
0
 /**
  * 删除首页banner
  * @param int $man_id 管理员id
  * @param int $ban_id banner id
  * @return int
  */
 public function delBanner($man_id, $ban_id)
 {
     //监测banner是否存在
     $sql = 'select ban_img from banner where ban_id=? limit 1';
     $result = $this->fetchOne($sql, [$ban_id]);
     if (!$result) {
         return 404;
     }
     //删除数据
     $sql = 'delete from banner where ban_id=?';
     $this->execute($sql, [$ban_id]);
     if (!$this->affectedRows()) {
         return 500;
     }
     //删除原banner图片
     if (is_file(UPLOAD_PATH . $result['ban_img'])) {
         \FileUtil::getInstance()->unlink(UPLOAD_PATH . $result['ban_img']);
     }
     //管理员操作记录
     $this->log($man_id, 'del_ban', '删除首页Banner:', $ban_id);
     return 200;
 }