123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
-
-
- namespace app\api\controller;
-
- use think\Db;
-
- class Diyajax extends Base
- {
-
-
- public function _initialize() {
- parent::_initialize();
- }
-
-
-
- public function check_userinfo()
- {
- if (IS_AJAX) {
- \think\Session::pause();
- $ajaxLogic = new \app\api\logic\AjaxLogic;
- $result = $ajaxLogic->check_userinfo();
- if (!empty($result['data']['ey_is_login'])) {
- $assignData = [
- 'users' => $result['users'],
- ];
- $this->assign($assignData);
-
- $filename = './template/'.THEME_STYLE_PATH.'/'.'system/users_info.htm';
- if (file_exists($filename)) {
- $html = $this->fetch($filename);
- } else {
- $html = '缺少模板文件:'.ltrim($filename, '.');
- }
- $result['data']['html'] = $html;
- }
- respose(['code'=>1, 'msg'=>'请求成功', 'data'=>$result['data']]);
- }
- to_index("404");
- }
-
-
-
- public function downFile(){
-
- $id = request()->get('id',0);
-
-
- if((int)$id === 0){
- respose(['code'=>0, 'msg'=>'请求失败!', 'data'=>[]]);
- }
-
- $one = Db::name('users_down')->where(['id'=>$id])->find();
-
- if((int)$one['num'] >= 3){
- respose(['code'=>0, 'msg'=>'该链接请求下载次数不能超过3次,链接已失效!', 'data'=>[]]);
- }
-
- if((int)$one['expire_time'] < time()){
-
- respose(['code'=>0, 'msg'=>'下载链接已失效!', 'data'=>[]]);
- }
-
-
- $artData = Db::name('zczygz_content')->where('aid', $one['aid'])
- ->find();
- if(empty($artData) || empty($artData['down'])){
- respose(['code'=>0, 'msg'=>'文档不存在!', 'data'=>[]]);
- }
-
-
- $filename = $one['title'];
- $file = $artData['down'];
-
-
- if(!empty($file)){
- header("Content-type:application/octet-stream");
- header("Content-Disposition:attachment;filename = ".$filename);
- header("Accept-ranges:bytes");
- header("Accept-length:".filesize($file));
- readfile($file);
-
-
- Db::name('users_down')->where(['id'=>$id])->setInc('num');
-
- }else{
- respose(['code'=>0, 'msg'=>'文件下载地址不存在!', 'data'=>[]]);
- }
- }
- }
|