function status() { $unix = new unix(); $sock = new sockets(); $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance"); if (!is_numeric($EnableRemoteStatisticsAppliance)) { $EnableRemoteStatisticsAppliance = 0; } $pidof = $unix->find_program("pidof"); $squidbin = $unix->find_program("squid"); if (!is_file($squidbin)) { $squidbin = $unix->find_program("squid3"); } exec("{$pidof} {$squidbin} 2>&1", $results); $tb = explode(" ", @implode("", $results)); while (list($num, $pid) = each($tb)) { $pid = trim($pid); $other = null; $other1 = "<i>{main}</i>"; if (!is_numeric($pid)) { continue; } $filename = "/proc/{$pid}/cmdline"; if (!is_file($filename)) { continue; } $names = @file_get_contents($filename); if (preg_match("#^\\((.*?)\\)#", $names, $re)) { $other = ":" . $re[1]; $other1 = "<i>Proc:{$re[1]}</i>"; } $l[] = "[SQUID{$other}]"; $l[] = "service_name=APP_SQUID"; $l[] = "master_version=" . squid_master_status_version(); $l[] = "service_cmd=squid-cache"; $l[] = "service_disabled=1"; $l[] = "watchdog_features=1"; $l[] = "binpath={$squidbin}"; $l[] = "explain=SQUID_CACHE_TINYTEXT"; $l[] = "remove_cmd=--squid-remove"; $l[] = "family=squid"; $l[] = "other={$other1}"; $l[] = "running=1"; $l[] = $unix->GetMemoriesOfChild($pid, true); } echo @implode("\n", $l); }
function squid_master_status() { if (!$GLOBALS["CLASS_USERS"]->SQUID_INSTALLED) { if ($GLOBALS["VERBOSE"]) { echo __FUNCTION__ . " squid is not installed\n"; } return null; } else { if ($GLOBALS["VERBOSE"]) { echo __FUNCTION__ . " squid is installed\n"; } } $SQUIDEnable = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("SQUIDEnable"); if (!is_numeric($SQUIDEnable)) { $SQUIDEnable = 1; $GLOBALS["CLASS_SOCKETS"]->SET_INFO("SQUIDEnable", 1); } exec("/usr/share/artica-postfix/bin/artica-install --export-version squid 2>&1", $results); $version = trim(implode("", $results)); if ($SQUIDEnable == 1) { if (preg_match("#^2\\.#", $version)) { if ($GLOBALS["VERBOSE"]) { echo "#^2\\.# detected in {$version}, squid is disabled...\n"; } $GLOBALS["CLASS_SOCKETS"]->SET_INFO("SQUIDEnable", 0); $SQUIDEnable = 0; } } $sqdbin = $GLOBALS["CLASS_UNIX"]->find_program("squid"); if (!is_file($sqdbin)) { $sqdbin = $GLOBALS["CLASS_UNIX"]->find_program("squid3"); } $l[] = "[SQUID]"; $l[] = "service_name=APP_SQUID"; $l[] = "master_version=" . squid_master_status_version(); $l[] = "service_cmd=squid-cache"; $l[] = "service_disabled={$SQUIDEnable}"; $l[] = "watchdog_features=1"; $l[] = "binpath={$sqdbin}"; $l[] = "explain=SQUID_CACHE_TINYTEXT"; $l[] = "remove_cmd=--squid-remove"; $l[] = "family=squid"; if ($GLOBALS["CLASS_USERS"]->SQUID_ICAP_ENABLED) { if ($GLOBALS["VERBOSE"]) { echo "SQUID_ICAP_ENABLED OK\n"; } $l[] = "icap_enabled=1"; } if (!is_file("/var/log/squid/cache.log")) { shell_exec("/etc/init/d/artica-postfix restart squid-cache >/dev/null 2>&1 &"); } $pidpath = squid_pid_path(); if ($SQUIDEnable == 0) { $l[] = "running=0\ninstalled=1"; return implode("\n", $l); return; } if ($GLOBALS["VERBOSE"]) { echo "Check {$pidpath}\n"; } $pid = trim(@file_get_contents($pidpath)); if (!$GLOBALS["CLASS_UNIX"]->process_exists($pid)) { $pid = $GLOBALS["CLASS_UNIX"]->PIDOF($sqdbin); if ($GLOBALS["CLASS_UNIX"]->process_exists($pid)) { @file_put_contents($pidpath, $pid); } } if (!$GLOBALS["CLASS_UNIX"]->process_exists($pid)) { WATCHDOG("APP_SQUID", "squid-cache"); $l[] = "running=0\ninstalled=1"; $l[] = ""; return implode("\n", $l); return; } $l[] = "running=1"; $l[] = GetMemoriesOf($pid); $l[] = ""; return implode("\n", $l); return; }