【问题标题】:Email notify if any one change server file & folder permission电子邮件通知是否有任何人更改服务器文件和文件夹权限
【发布时间】:2019-04-25 07:05:26
【问题描述】:

如果有人更改文件和文件夹权限,我需要通过电子邮件通知。请让我知道如何在 wordpress php 中执行此操作?

【问题讨论】:

  • 请阅读How to Ask,并相应地编辑您的问题。

标签: php email permissions


【解决方案1】:
  1. 写一个脚本来记录当前文件的状态,比如权限,比如第一次运行脚本,得到775之类的权限,存到一个文件中;
  2. 每次运行脚本时,检查现在的权限是否与上次存储在该文件中的权限不同,如果是,请给用户发送电子邮件;
  3. 代码如下:
$last_permission = file_get_contents("permission.txt");
if(!$last_permission){
    $permission = fileperms("file_to_trace.txt");
}else{
    if($permission != fileperms("file_to_trace.txt"){
        mail("user@user.com", "contents");
    }
}
file_put_contents("file_to_trace.txt", $permission);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-17
    • 1970-01-01
    • 2020-10-30
    • 1970-01-01
    • 2010-09-21
    • 1970-01-01
    • 1970-01-01
    • 2014-12-07
    相关资源
    最近更新 更多