开发者

Detect the minimum permissions PHP needs to write to a directory: 0777, 0770 or 0700?

Imagine some script & its folders was uploaded with FTP. Usually, the folder permissions are wrong and the script should suggest which permissions to set. Certainly, it's not good to set 0777 for everything I'm going to write to. But there're 3 possible webserver configurations:

开发者_运维百科
  1. PHP user = user FTP. Thus, writing needs 0700
  2. The user is different, but it belongs to the same group. It's 0770
  3. PHP runs from nobody or there's no common GID: it's 0777

Is there a way to detect what permissions octets are enough for the script to function?

The PCNTL extension is not welcome because some configurations lack it.


posix_access()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜