切换导航条
此项目
正在载入...
登录
周海龙
/
globalso-v6-c-customer
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
李小龙
3 months ago
提交
ffe8d7c389d8e77b3563b4da94193f735870ae65
1 个父辈
04701bcd
客户端程序新增生成robots接口
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
37 行增加
和
0 行删除
app/Http/Controllers/Api/NoticeController.php
routes/api.php
app/Http/Controllers/Api/NoticeController.php
查看文件 @
ffe8d7c
...
...
@@ -720,6 +720,41 @@ public function search(Request $request)
}
/**
* 生成robots.txt
* @param Request $request
*/
public
function
updateRobots
(
Request
$request
){
$req
[
"domain"
]
=
$request
->
getHost
();
//转发data
$transmitUrl
=
env
(
"API_URL"
);
$resp
=
$this
->
httpPost
(
$transmitUrl
.
"api/get_robots_content/"
,
json_encode
(
$req
));
$robotsContent
=
$resp
[
"data"
][
"content"
];
$robotTxtPath
=
public_path
(
$req
[
"domain"
]
.
"/robots.txt"
);
$this
->
putSitemapFile
(
$robotTxtPath
,
$robotsContent
);
$this
->
response
(
"success"
,
self
::
SUCCESS
,
$resp
[
"data"
]
??
[]);
}
/**
* 放内容
* @param $sitemapPath
* @param $sitemapXmlDom
* @return false|int
*/
public
function
putSitemapFile
(
$sitemapPath
,
$sitemapXmlDom
)
{
if
(
file_exists
(
$sitemapPath
))
{
$this
->
deleteDirectory
(
$sitemapPath
);
}
$res
=
file_put_contents
(
$sitemapPath
,
$sitemapXmlDom
);
try
{
chmod
(
$sitemapPath
,
0777
);
}
catch
(
\Exception
$e
)
{
return
1
;
}
return
$res
;
}
/**
* 输出处理日志
* @param $message
* @return bool
...
...
routes/api.php
查看文件 @
ffe8d7c
...
...
@@ -34,5 +34,7 @@
Route
::
any
(
'/Hjoh59552'
,[
NoticeController
::
class
,
'getRandInquiryText'
]);
//通知拉取代码
Route
::
any
(
'/pullCode'
,[
NoticeController
::
class
,
'pullCode'
]);
//生成robots.txt
Route
::
get
(
'/update_robots'
,
[
NoticeController
::
class
,
'updateRobots'
]);
});
...
...
请
注册
或
登录
后发表评论