优化问题反馈和域名协议判断

This commit is contained in:
taoser 2021-03-18 16:21:27 +08:00
parent e911a7798b
commit 945e470915
2 changed files with 14 additions and 5 deletions

View File

@ -23,17 +23,20 @@ class Index extends AdminController
*/ */
public function __construct() public function __construct()
{ {
// 控制器初始化显示左侧导航菜单
parent::initialize();
$this->sys_version = Config::get('taoler.version'); $this->sys_version = Config::get('taoler.version');
$this->sys = Db::name('system')->where('id',1)->find(); $this->sys = Db::name('system')->where('id',1)->find();
//域名转换为无http协议
$this->domain = Request::scheme().'://'.$this->sys['domain']; $www = stripos($this->sys['domain'],'://') ? substr(stristr($this->sys['domain'],'://'),3) : $this->sys['domain'];
$this->domain = Request::scheme().'://'. $www;
$this->api = $this->sys['api_url']; $this->api = $this->sys['api_url'];
if(empty($this->api)){ if(empty($this->api)){
$baseUrl = $this->sys['base_url']; $baseUrl = $this->sys['base_url'];
$this->api = strstr($baseUrl,'/v',true); $this->api = strstr($baseUrl,'/v',true);
} }
// 控制器初始化显示左侧导航菜单
parent::initialize();
} }
@ -99,7 +102,8 @@ class Index extends AdminController
$res['msg'] = ''; $res['msg'] = '';
$res['count'] = $count; $res['count'] = $count;
foreach($forumList as $k=>$v){ foreach($forumList as $k=>$v){
$res['data'][]= ['id'=>str_replace("admin","index",$this->domain.(string) url('article/detail',['id'=>$v['aid']])),'title'=>$v['title'],'name'=>$v['name'],'catename'=>$v['catename'],'pv'=>$v['pv']]; $url = (string) str_replace("admin","index",$this->domain.url('article/detail',['id'=>$v['aid']]));
$res['data'][]= ['id'=>$url,'title'=>$v['title'],'name'=>$v['name'],'catename'=>$v['catename'],'pv'=>$v['pv']];
} }
} else { } else {
$res = ['code'=>-1,'msg'=>'本周还没有发帖!']; $res = ['code'=>-1,'msg'=>'本周还没有发帖!'];
@ -162,11 +166,13 @@ class Index extends AdminController
//$mail = Db::name('system')->where('id',1)->value('auth_mail'); // bug邮件发送 //$mail = Db::name('system')->where('id',1)->value('auth_mail'); // bug邮件发送
if(Request::isAjax()){ if(Request::isAjax()){
$data = Request::only(['type','title','content']); $data = Request::only(['type','title','content']);
$data['poster'] = 3; //公共id $data['poster'] = 3; //公共id
$apiRes = Api::urlPost($url,$data); $apiRes = Api::urlPost($url,$data);
if($apiRes){ if($apiRes){
//halt($data);
$res = Cunsult::create($data); $res = Cunsult::create($data);
if($res->id){ if($res->id){
//$result = mailto($mail,$data['title'],'我的问题类型是'.$data['type'].$data['content']); //$result = mailto($mail,$data['title'],'我的问题类型是'.$data['type'].$data['content']);

View File

@ -15,6 +15,9 @@ class Api
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 20); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); // 设置超时限制 防止死循环
//curl_setopt($ch, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$res = curl_exec($ch); $res = curl_exec($ch);
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE); $httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch); curl_close($ch);