本文整理汇总了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";
}
//.........这里部分代码省略.........