当前位置: 首页>>代码示例>>PHP>>正文


PHP sockets::EnableClamavDaemon方法代码示例

本文整理汇总了PHP中sockets::EnableClamavDaemon方法的典型用法代码示例。如果您正苦于以下问题:PHP sockets::EnableClamavDaemon方法的具体用法?PHP sockets::EnableClamavDaemon怎么用?PHP sockets::EnableClamavDaemon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sockets的用法示例。


在下文中一共展示了sockets::EnableClamavDaemon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: start

function start($aspid = false)
{
    $unix = new unix();
    $sock = new sockets();
    $Masterbin = $unix->find_program("clamd");
    if (!is_file($Masterbin)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, clamd not installed\n";
        }
        return;
    }
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $pid = PID_NUM();
    if ($unix->process_exists($pid)) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
        }
        return;
    }
    $EnableClamavDaemon = $sock->EnableClamavDaemon();
    if ($EnableClamavDaemon == 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see sock->EnableClamavDaemon)\n";
        }
        return;
    }
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $aa_complain = $unix->find_program('aa-complain');
    if (is_file($aa_complain)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} add clamd Profile to AppArmor..\n";
        }
        shell_exec("{$aa_complain} {$Masterbin} >/dev/null 2>&1");
    }
    @mkdir("/var/clamav", 0755, true);
    @mkdir("/var/run/clamav", 0755, true);
    @mkdir("/var/lib/clamav", 0755, true);
    @mkdir("/var/log/clamav", 0755, true);
    $unix->chown_func("clamav", "clamav", "/var/clamav");
    $unix->chown_func("clamav", "clamav", "/var/run/clamav");
    $unix->chown_func("clamav", "clamav", "/var/lib/clamav");
    $unix->chown_func("clamav", "clamav", "/var/log/clamav");
    $clamd_version = clamd_version();
    $cmd = "{$nohup} {$Masterbin} --config-file=/etc/clamav/clamd.conf >/dev/null 2>&1 &";
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service version {$clamd_version}\n";
    }
    shell_exec($cmd);
    for ($i = 1; $i < 5; $i++) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} waiting {$i}/5\n";
        }
        sleep(1);
        $pid = PID_NUM();
        if ($unix->process_exists($pid)) {
            break;
        }
    }
    $pid = PID_NUM();
    if ($unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success PID {$pid}\n";
        }
        sleep(1);
        for ($i = 1; $i < 5; $i++) {
            if ($unix->is_socket("/var/run/clamav/clamav.sock")) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Apply permissions on clamav.sock\n";
                }
                @chmod("/var/run/clamav/clamav.sock", 0777);
                break;
            } else {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} waiting for socket... {$i}/4\n";
                }
                sleep(1);
            }
        }
        if ($unix->is_socket("/var/run/clamav/clamav.sock")) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Apply permissions on clamav.sock\n";
            }
            @chmod("/var/run/clamav/clamav.sock", 0777);
        } else {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} socket failed\n";
            }
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.clamd.php


注:本文中的sockets::EnableClamavDaemon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。