限制已在 php 中与 ftp 连接的用户


Restrict the user that is already connected with ftp in php

我将每 10 秒运行一次 cron 作业来连接和复制文件,然后删除。我不会在复制文件等时运行 cron,最好的方法是什么?

我可以限制已连接的用户吗?

try {
    $con = ftp_connect($server);
    if (false === $con) {
        throw new Exception('Unable to connect');
    }
    $loggedIn = ftp_login($con,  $username,  $password);
    if (true === $loggedIn) {
        echo 'Success!';
    } else {
        throw new Exception('Unable to log in');
    }
    print_r(ftp_nlist($con, "."));
    ftp_close($con);
} catch (Exception $e) {
    echo "Failure: " . $e->getMessage();
}
if a certain file doesnt exist
    make the file
    do stuff
    delete file
else if the file exists, but its very old
    recreate the file
    do stuff
    delete file
else
    its busy

如果ftp软件本身允许您限制这一点,我不会感到惊讶。可能想要检查。