本文整理匯總了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";
}
//.........這裏部分代碼省略.........