linux - php文件有没有办法限制只能用命令来访问

WBOY
Release: 2016-06-06 20:07:32
Original
872 people have browsed it

某些定时脚本,用 php命令执行
在服务器上可以通过限制服务器软件权限,php文件执行权限来实现。
我想知道php自身能不能做到只能用命令执行?
就像一个文件,只能是 post访问,判断如果不是 post,就返回403

回复内容:

某些定时脚本,用 php命令执行
在服务器上可以通过限制服务器软件权限,php文件执行权限来实现。
我想知道php自身能不能做到只能用命令执行?
就像一个文件,只能是 post访问,判断如果不是 post,就返回403

在入口文件做处理

判断下 是cli模式下执行代码 还是来自浏览器的http请求

可以利用这个函数 php_sapi_name()

<code>if (PHP_SAPI !== "cli") {
    die;
}</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!