本文整理汇总了PHP中EXEC_NICE函数的典型用法代码示例。如果您正苦于以下问题:PHP EXEC_NICE函数的具体用法?PHP EXEC_NICE怎么用?PHP EXEC_NICE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EXEC_NICE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scan_stored_items
function scan_stored_items($nopid = true)
{
$sock = new sockets();
$SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
if ($SquidPerformance < 3) {
die;
}
$unix = new unix();
if (system_is_overloaded(basename(__FILE__))) {
$php = $unix->LOCATE_PHP5_BIN();
ufdbguard_admin_events("Overloaded system... ask to run this task later...", __FUNCTION__, __FILE__, __LINE__, "proxy");
$unix->THREAD_COMMAND_SET("{$php} " . __FILE__ . " --scan");
}
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if ($nopid) {
$pid = @file_get_contents($pidfile);
$myfile = basename(__FILE__);
if ($unix->process_exists($pid, $myfile)) {
ufdbguard_admin_events("Task already running PID: {$pid}, aborting current task", __FUNCTION__, __FILE__, __LINE__, "proxy");
return;
}
}
$TimePid = $unix->file_time_min($pidTime);
if ($TimePid < 1440) {
ufdbguard_admin_events("Task cannot be used less than 14h currently ({$TimePid}Mn)", __FUNCTION__, __FILE__, __LINE__, "proxy");
return;
}
if (ScanPurgeexc()) {
ufdbguard_admin_events("Already Executed...", __FUNCTION__, __FILE__, __LINE__, "proxy");
return;
}
@unlink($pidTime);
@file_put_contents($pidTime, time());
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
$purge = $unix->find_program("purge");
if (strlen($purge) < 5) {
ufdbguard_admin_events("purge no such file, aborting task", __FUNCTION__, __FILE__, __LINE__, "proxy");
return;
}
$nice = EXEC_NICE();
$cmd = "{$nice}{$purge} -c /etc/squid3/squid.conf -e \".\" -P 0 -n >/var/cache/purge.calculated.db 2>&1";
if ($GLOBALS["VERBOSE"]) {
echo $cmd . "\n";
}
$t1 = time();
system(trim($cmd));
$took = $unix->distanceOfTimeInWords($t1, time());
if ($GLOBALS["VERBOSE"]) {
echo "done {$took}\n";
}
squid_admin_mysql(2, "Stored items: Extracting items information from cache done took:{$took}", null, __FILE__, __LINE__, "proxy");
inject_stored_items(true);
}
示例2: parse_logs
function parse_logs()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if (!$GLOBALS["VERBOSE"]) {
if ($unix->file_time_min($pidTime) < 45) {
return;
}
}
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
return;
}
@file_put_contents($pidfile, getmypid());
@unlink($pidTime);
@file_put_contents($pidTime, time());
$sock = new sockets();
$EnableNginxStats = $sock->GET_INFO("EnableNginxStats");
if (!is_numeric($EnableNginxStats)) {
$EnableNginxStats = 0;
}
if ($EnableNginxStats == 0) {
return;
}
if (system_is_overloaded(basename(__FILE__))) {
events("Overloaded system: {$GLOBALS["SYSTEM_INTERNAL_LOAD"]} aborting", __FUNCTION__, __LINE__);
return;
}
$nice = EXEC_NICE();
$sock = new sockets();
$kill = $unix->find_program("kill");
$NginxWorkLogsDir = $sock->GET_INFO("NginxWorkLogsDir");
if ($NginxWorkLogsDir == null) {
$NginxWorkLogsDir = "/home/nginx/logsWork";
}
$sys = new mysql_storelogs();
$files = $unix->DirFiles($NginxWorkLogsDir, "-([0-9\\-]+)\\.log");
while (list($filename, $line) = each($files)) {
if (!preg_match("#^(.+?)-[0-9]+-[0-9]+-[0-9]+-[0-9]+\\.log\$#", $filename, $re)) {
if ($GLOBALS["VERBOSE"]) {
echo "{$filename}, skip\n";
}
continue;
}
$servername = $re[1];
$fullpath = "{$NginxWorkLogsDir}/{$filename}";
ParseFile($servername, $fullpath);
}
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
shell_exec("{$nohup} {$php} " . __FILE__ . " --hosts >/dev/null 2>&1 &");
shell_exec("{$nohup} {$php} " . dirname(__FILE__) . "/exec.nginx-stats-day.php >/dev/null 2>&1 &");
}
示例3: ScanFile
function ScanFile($toScan)
{
if (!$GLOBALS["SAMBA_INSTALLED"]) {
return true;
}
$localdatabase = "/usr/share/artica-postfix/LocalDatabases";
$file = @file_get_contents($toScan);
$ext = Get_extension($file);
$nice = EXEC_NICE();
$database = "{$localdatabase}/samba.db";
if (!is_file($GLOBALS["omindex"])) {
return true;
}
$directory = dirname($file);
if ($GLOBALS["DIRS"]["{$directory}"]) {
return true;
}
$basename = basename($file);
$cmd = "{$nice}{$GLOBALS["omindex"]} -l 1 --follow -D {$database} -U \"{$directory}\" \"{$directory}\"";
$GLOBALS["DIRS"]["{$directory}"] = true;
exec($cmd, $results);
ParseLogs($results);
return true;
}
示例4: Execute
function Execute()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$myFile = basename(__FILE__);
$pid = @file_get_contents($pidfile);
if ($unix->process_exists($pid, $myFile)) {
WriteMyLogs("Already executed PID:{$pid}, die()", __FUNCTION__, __FILE__, __LINE__);
die;
}
$cachetime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$q = new mysql_squid_builder();
if ($q->COUNT_ROWS("framework_orders") == 0) {
if ($GLOBALS["VERBOSE"]) {
echo "Table framework_orders as no row\n";
}
die;
}
$php5 = $unix->LOCATE_PHP5_BIN();
$nice = EXEC_NICE();
$q = new mysql_squid_builder();
$results = $q->QUERY_SQL("SELECT * FROM framework_orders");
if (!$q->ok) {
if (strpos($q->mysql_error, "doesn't exist") > 0) {
$q->CheckTables();
$results = $q->QUERY_SQL("SELECT * FROM framework_orders");
}
}
if (!$q->ok) {
ufdbguard_admin_events("Fatal: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "framework");
die;
}
$reconfigure_plugins = false;
while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
if ($GLOBALS["VERBOSE"]) {
echo "ORDER: {$ligne["ORDER"]} -> {$ligne["zmd5"]}\n";
}
if (preg_match("#COMPILEDB:(.+)#", $ligne["ORDER"], $re)) {
if (preg_match("#english-(.+)#", $re[1])) {
$q->QUERY_SQL("DELETE FROM framework_orders WHERE zmd5='{$ligne["zmd5"]}'");
continue;
}
ufdbguard_admin_events("LAUNCH: category {$re[1]} compilation", __FUNCTION__, __FILE__, __LINE__, "framework");
$re[1] = trim($re[1]);
$table = "category_" . $q->category_transform_name($re[1]);
if ($GLOBALS["VERBOSE"]) {
echo "order to compile database {$re[1]} (table {$table})\n";
}
if (!$q->TABLE_EXISTS($table)) {
ufdbguard_admin_events("Fatal: {$table} no suche table, create it", __FUNCTION__, __FILE__, __LINE__, "framework");
$q->CreateCategoryTable(null, $table);
}
$cmd = "{$nice} {$php5} /usr/share/artica-postfix/exec.squidguard.php --compile-category \"{$re[1]}\"";
if ($GLOBALS["VERBOSE"]) {
echo "{$cmd}\n";
}
$q->QUERY_SQL("DELETE FROM framework_orders WHERE zmd5='{$ligne["zmd5"]}'");
if (!$q->ok) {
ufdbguard_admin_events("Fatal: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "framework");
die;
}
shell_exec($cmd);
$reconfigure_plugins = true;
}
}
if ($reconfigure_plugins) {
ufdbguard_admin_events("LAUNCH: filters reconfiguration", __FUNCTION__, __FILE__, __LINE__, "framework");
shell_exec("{$nice} {$php5} /usr/share/artica-postfix/exec.squidguard.php --build");
}
}
示例5: homes
function homes()
{
$GLOBALS["INDEXED"] = 0;
$GLOBALS["SKIPPED"] = 0;
$GLOBALS["DIRS"] = array();
$FOLDERS = array();
$RFOLDERS = array();
$unix = new unix();
$GLOBALS["omindex"] = $unix->find_program("omindex");
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid)) {
system_admin_events("Already instance executed pid:{$olpid}", __FUNCTION__, __FILE__, __LINE__, "xapian");
die;
}
@file_put_contents($pidfile, getmypid());
$nice = EXEC_NICE();
$t1 = time();
if (!is_file($GLOBALS["omindex"])) {
system_admin_events("omindex no such binary, aborting", __FUNCTION__, __FILE__, __LINE__, "xapian");
return;
}
$ldap = new clladp();
$attr = array("homeDirectory", "uid", "dn");
$pattern = "(&(objectclass=sambaSamAccount)(uid=*))";
$sock = new sockets();
$sock = new sockets();
$sr = @ldap_search($ldap->ldap_connection, "dc=organizations," . $ldap->suffix, $pattern, $attr);
$hash = ldap_get_entries($ldap->ldap_connection, $sr);
$sock = new sockets();
for ($i = 0; $i < $hash["count"]; $i++) {
$uid = $hash[$i]["uid"][0];
$homeDirectory = $hash[$i][strtolower("homeDirectory")][0];
if ($uid == null) {
writelogs("uid is null, SKIP ", __FUNCTION__, __FILE__, __LINE__);
continue;
}
if ($uid == "nobody") {
writelogs("uid is nobody, SKIP ", __FUNCTION__, __FILE__, __LINE__);
continue;
}
if ($uid == "root") {
writelogs("uid is root, SKIP ", __FUNCTION__, __FILE__, __LINE__);
continue;
}
if (substr($uid, strlen($uid) - 1, 1) == '$') {
writelogs("{$uid}:This is a computer, SKIP ", __FUNCTION__, __FILE__, __LINE__);
continue;
}
if ($homeDirectory == null) {
$homeDirectory = "/home/{$uid}";
}
if (!is_dir($homeDirectory)) {
continue;
}
$FOLDERS[$uid] = $homeDirectory;
$RFOLDERS[$homeDirectory] = true;
}
$SambaXapianAuth = unserialize(base64_decode($sock->GET_INFO("SambaXapianAuth")));
$username = $SambaXapianAuth["username"];
$password = $SambaXapianAuth["password"];
$domain = $SambaXapianAuth["domain"];
$comp = $SambaXapianAuth["ip"];
if (!isset($SambaXapianAuth["lang"])) {
$SambaXapianAuth["lang"] == "none";
}
$lang = $SambaXapianAuth["lang"];
if ($lang == null) {
$lang = "none";
}
$t1 = time();
$dirs = $unix->dirdir("/home");
$samba = new samba();
$localdatabase = "/usr/share/artica-postfix/LocalDatabases";
while (list($dir, $ligne) = each($dirs)) {
if ($dir == "/home/export") {
continue;
}
if ($dir == "/home/netlogon") {
continue;
}
if ($dir == "/home/artica") {
continue;
}
if ($dir == "/home/logs-backup") {
continue;
}
if (isset($RFOLDERS[$dir])) {
continue;
}
if (isset($samba->main_shared_folders[$dir])) {
continue;
}
$FOLDERS[basename($dir)] = $dir;
}
$count = 0;
while (list($uid, $directory) = each($FOLDERS)) {
$BaseUrl = $directory;
$database = "{$localdatabase}/xapian-{$uid}";
@mkdir($database, 0755, true);
//.........这里部分代码省略.........
示例6: execute_mysql
function execute_mysql($OnlyID = 0)
{
$GLOBALS["INDEXED"] = 0;
$GLOBALS["SKIPPED"] = 0;
$GLOBALS["DIRS"] = array();
$unix = new unix();
$httrack = $unix->find_program("httrack");
if (!is_file($httrack)) {
system_admin_events("httrack no such binary", __FUNCTION__, __FILE__, __LINE__, "webcopy");
return;
}
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
system_admin_events("Already instance executed pid:{$olpid}", __FUNCTION__, __FILE__, __LINE__, "webcopy");
return;
}
$getmypid = getmypid();
@file_put_contents($pidfile, $getmypid);
$q = new mysql();
$nice = EXEC_NICE();
$sql = "SELECT * FROM httrack_sites WHERE enabled=1";
$results = $q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
system_admin_events("Fatal: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "webcopy");
return;
}
$t1 = time();
$count = 0;
if ($OnlyID > 0) {
$ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT sitename FROM httrack_sites WHERE ID={$OnlyID}", "artica_backup"));
$log_exp = " only for [{$ligne2["sitename"]}] ";
}
system_admin_events("Starting executing WebCopy task {$log_exp} pid:{$getmypid}", __FUNCTION__, __FILE__, __LINE__, "webcopy");
while ($ligne = mysql_fetch_assoc($results)) {
if ($OnlyID > 0) {
if ($ligne["ID"] != $OnlyID) {
continue;
}
}
$t = time();
$count++;
$workingdir = $ligne["workingdir"];
$sitename = $ligne["sitename"];
$maxsize = $ligne["maxsize"];
$minrate = $ligne["minrate"];
$maxfilesize = $ligne["maxfilesize"];
$maxsitesize = $ligne["maxsitesize"];
$maxfilesize = $maxfilesize * 1000;
$maxsitesize = $maxsitesize * 1000;
$minrate = $minrate * 1000;
$update = null;
$resultsCMD = array();
if (!is_dir($workingdir)) {
@mkdir($workingdir, 0755, true);
}
if (is_file("{$workingdir}/hts-cache")) {
$update = " --update";
}
$cmdline = "{$httrack} \"{$sitename}\" --quiet{$update} --max-files={$maxfilesize} --max-size={$maxsitesize} --max-rate={$minrate} -O \"{$workingdir}\" 2>&1";
if ($GLOBALS["VERBOSE"]) {
echo "{$cmdline}\n";
}
exec($cmdline, $resultsCMD);
if ($GLOBALS["VERBOSE"]) {
echo @implode("\n", $resultsCMD);
}
$dirsize = $unix->DIRSIZE_BYTES($workingdir);
$took = $unix->distanceOfTimeInWords($t, time(), true);
$dirsizeText = round($dirsize / 1024 / 1000, 2);
system_admin_events("{$sitename} scrapped took {$took} size={$dirsizeText} MB", __FUNCTION__, __FILE__, __LINE__, "webcopy");
$q->QUERY_SQL("UPDATE httrack_sites SET size='{$dirsize}' WHERE ID={$ligne["ID"]}", "artica_backup");
}
$took = $unix->distanceOfTimeInWords($t1, time(), true);
system_admin_events("{$count} web sites scrapped took {$took}", __FUNCTION__, __FILE__, __LINE__, "webcopy");
}
示例7: scanarp
//.........这里部分代码省略.........
return;
}
events("Scanning ARP table....", __FUNCTION__, __LINE__);
$ArpdArray["LAST"] = $last_modified;
exec("{$GLOBALS["arpd"]} -l 2>&1", $results);
events("{$GLOBALS["arpd"]} -l return " . count($results) . " element(s)", __FUNCTION__, __LINE__);
while (list($num, $ligne) = each($results)) {
if (preg_match("#unexpected file type or format#", $ligne)) {
@unlink($GLOBALS["ARP_DB"]);
@unlink($GLOBALS["CACHE_DB"]);
shell_exec("/etc/init.d/arpd restart");
die;
}
if (!preg_match("#^[0-9]+\\s+\\s+(.+?)\\s+(.+)#", $ligne, $re)) {
if ($GLOBALS["VERBOSE"]) {
echo "line: {$num}, unexpected line..\n";
}
continue;
}
if (preg_match("#FAILED:#", $re[2])) {
continue;
}
$mac = $re[2];
$ipaddr = $re[1];
if ($GLOBALS["VERBOSE"]) {
echo "line: {$num}, MAC:{$mac} -> {$ipaddr}\n";
}
if (isset($ArpdArray["MACS"][$mac])) {
if ($GLOBALS["VERBOSE"]) {
echo "MAC:{$mac} Already cached, aborting....\n";
}
continue;
}
$ArpdArray["MACS"][$mac] = true;
$cmp = new computers();
$uid = $cmp->ComputerIDFromMAC($mac);
if ($GLOBALS["VERBOSE"]) {
echo "line: {$num}, MAC:{$mac} -> {$uid}\n";
}
if ($uid == null) {
$res2 = array();
$computer_name = null;
events("It is time to add {$mac}/{$ipaddr} in database", __FUNCTION__, __LINE__);
exec("{$GLOBALS["arp"]} -a {$ipaddr} 2>&1", $res2);
if (preg_match("#^(.+?)\\s+\\(#", trim(@implode("", $res2)), $rz)) {
$computer_name = $rz[1];
}
if (strlen($computer_name) < 3) {
$computer_name = $ipaddr;
}
$cmp->uid = "{$computer_name}\$";
$cmp->ComputerIP = $ipaddr;
$cmp->ComputerMacAddress = $mac;
system_admin_events("adding/editing {$computer_name} with MAC:{$mac}", __FUNCTION__, __FILE__, __LINE__, "network");
$cmp->Add();
} else {
if ($GLOBALS["FLUSH"]) {
$res2 = array();
$cmp = new computers($uid);
$computer_name = null;
events("It is time to edit {$uid}/{$mac}/{$ipaddr} in database", __FUNCTION__, __LINE__);
exec("{$GLOBALS["arp"]} -a {$ipaddr} 2>&1", $res2);
if ($GLOBALS["VERBOSE"]) {
echo "{$GLOBALS["arp"]} -a {$ipaddr} 2>&1 = >" . trim(@implode("", $res2));
}
if (preg_match("#^(.+?)\\s+\\(#", trim(@implode("", $res2)), $rz)) {
$computer_name = $rz[1];
} else {
if ($GLOBALS["VERBOSE"]) {
echo "Unable to find computer name\n";
}
}
if (strlen($computer_name) < 3) {
$computer_name = $ipaddr;
}
if ($GLOBALS["VERBOSE"]) {
echo "line: {$num}, UID:{$mac} -> {$uid}\n";
}
if ($GLOBALS["VERBOSE"]) {
echo "line: {$num}, NAME:{$computer_name} -> {$uid}\n";
}
system_admin_events("adding/editing {$computer_name} with MAC:{$mac}", __FUNCTION__, __FILE__, __LINE__, "network");
$cmp->ComputerIP = $ipaddr;
$cmp->ComputerMacAddress = $mac;
$cmp->Add();
}
}
if (system_is_overloaded(basename(__FILE__))) {
@file_put_contents($GLOBALS["CACHE_DB"], base64_encode(serialize($ArpdArray)));
system_admin_events("Overloaded system, aborting the task...", __FUNCTION__, __FILE__, __LINE__, "network");
return;
}
@file_put_contents($GLOBALS["CACHE_DB"], base64_encode(serialize($ArpdArray)));
$nice = EXEC_NICE();
$unix = new unix();
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
shell_exec("{$nohup} {$nice} {$php5} " . __FILE__ . " --tomysql schedule-id={$GLOBALS["SCHEDULE_ID"]} >/dev/null 2>&1 &");
}
}
示例8: CheckUserCount
function CheckUserCount()
{
$unix = new unix();
$cachefile = "/etc/artica-postfix/UsersNumber";
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
$nice = EXEC_NICE();
if (!is_file($cachefile)) {
shell_exec("{$nohup} {$nice} {$php} /usr/share/artica-postfix/exec.samba.php --users >/dev/null 2>&1 &");
return 0;
}
$usersN = @file_get_contents($cachefile);
if ($unix->file_time_min($cachefile) > 3600) {
@unlink($cachefile);
shell_exec("{$nohup} {$nice} {$php} /usr/share/artica-postfix/exec.samba.php --users >/dev/null 2>&1 &");
return $usersN;
}
return $usersN;
}
示例9: ParseLoadQeues
function ParseLoadQeues()
{
$unix = new unix();
$du = $unix->find_program("du");
$rm = $unix->find_program("rm");
$EXEC_NICE = EXEC_NICE();
exec("{$EXEC_NICE}{$du} -b -s /etc/artica-postfix/loadavg.queue 2>&1", $results);
$tmp = trim(@implode("", $results));
if (preg_match("#[0-9]+\\s+#", $tmp, $re)) {
$size = $re[1] / 1024;
$size = $size / 1000;
if ($size > 100) {
shell_exec("/bin/rm -rf /etc/artica-postfix/loadavg.queue/*");
return;
}
}
if (!is_dir('/etc/artica-postfix/loadavg.queue')) {
@mkdir("/etc/artica-postfix/loadavg.queue", true);
}
if ($handle = opendir("/etc/artica-postfix/loadavg.queue")) {
while (false !== ($file = readdir($handle))) {
if ($file == "." && $file == "..") {
continue;
}
$filename = "/etc/artica-postfix/loadavg.queue/{$file}";
$filebase = basename($filename);
if ($GLOBALS["VERBOSE"]) {
echo "parse {$filename}\n";
}
sleep(1);
if (preg_match("#^([0-9]+)\\.([0-9]+)\\.queue\$#", $filebase, $re)) {
$filebase = "{$re[1]}.{$re[2]}.0.queue";
}
if (preg_match("#([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.queue\$#", $filebase, $re)) {
if (system_is_overloaded()) {
$unix->events(basename(__FILE__) . ": ParseLoadQeues() system is overloaded aborting for {$filename}");
return;
}
$datas = loadavg_table($filename, $lsof);
if (is_file("{$filename}.lsof")) {
$lsofTEXT = ParseLsof("{$filename}.lsof");
@unlink("{$filename}.lsof");
} else {
if ($GLOBALS["VERBOSE"]) {
echo "{$filename}.lsof no such file\n";
}
}
if (is_file("{$filename}.iotop")) {
$IoText = ParseIotOp("{$filename}.lsof");
@unlink("{$filename}.iotop");
} else {
if ($GLOBALS["VERBOSE"]) {
echo "{$filename}.iotop no such file\n";
}
}
$time = date("Y-m-d H:i:s", $re[1]);
$load = "{$re[2]},{$re[3]}";
$q = new mysql();
$datas = mysql_escape_string2($datas);
$lsofTEXT = mysql_escape_string2($lsofTEXT);
$IoText = mysql_escape_string2($IoText);
$sql = "INSERT IGNORE INTO avgreports (`zDate`,`loadavg`,`psreport`,`lsofreport`,`iotopreport`) VALUES ('{$time}','{$load}','{$datas}','{$lsofTEXT}','{$IoText}')";
$q->QUERY_SQL($sql, "artica_events");
if ($GLOBALS["VERBOSE"]) {
echo "{$time}: {$load}\n";
}
$unix->send_email_events("System Load - {$load} - exceed rule (processes)", $datas, "system", $time);
if (strlen($lsofTEXT) > 50) {
$unix->send_email_events("System Load - {$load} - exceed rule (opened files)", $lsofTEXT, "system", $time);
}
if (strlen($IoText) > 50) {
$unix->send_email_events("System Load - {$load} - exceed rule (Disk perfs)", $IoText, "system", $time);
}
@unlink($filename);
} else {
echo "{$filebase} did not match ([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.queue\n";
@unlink($filename);
}
}
}
}
示例10: GetUpdates
function GetUpdates()
{
if (system_is_overloaded(basename(__FILE__))) {
system_admin_events("This system is too many overloaded, die()", __FUNCTION__, __FILE__, __LINE__, "system-update");
die;
}
$sock = new sockets();
$EnableSystemUpdates = $sock->GET_INFO("EnableSystemUpdates");
if (!is_numeric($EnableSystemUpdates)) {
$EnableSystemUpdates = 0;
}
if ($EnableSystemUpdates == 0) {
clean_upgrade();
return;
}
@mkdir("/usr/share/artica-postfix/ressources/logs/web", 0755, true);
@unlink("/usr/share/artica-postfix/ressources/logs/web/debian.update.html");
$unix = new unix();
if (is_file("/etc/artica-postfix/FROM_ISO")) {
$time = $unix->file_time_min("/etc/artica-postfix/FROM_ISO");
if ($time < 60) {
return;
}
}
$tmpf = $unix->FILE_TEMP();
exim_remove();
CheckSourcesList();
wsgate_debian();
$sock = new sockets();
$ini = new Bs_IniHandler();
$users = new usersMenus();
$configDisk = trim($sock->GET_INFO('ArticaAutoUpdateConfig'));
$ini->loadString($configDisk);
$AUTOUPDATE = $ini->_params["AUTOUPDATE"];
$EXEC_NICE = EXEC_NICE();
$nohup = $unix->find_program("nohup");
if (trim($AUTOUPDATE["auto_apt"]) == null) {
$AUTOUPDATE["auto_apt"] = "no";
}
$q = new mysql();
php_fpm();
if ($GLOBALS["VERBOSE"]) {
system_admin_events("Running apt-check", __FUNCTION__, __FILE__, __LINE__, "system-update");
}
exec("{$_GET["APT-GET"]} check 2>&1", $results);
if ($GLOBALS["VERBOSE"]) {
system_admin_events("Running apt-check -> " . count($results) . " items", __FUNCTION__, __FILE__, __LINE__, "update");
}
while (list($num, $line) = each($results)) {
if ($GLOBALS["VERBOSE"]) {
system_admin_events("apt-check: {$line}", __FUNCTION__, __FILE__, __LINE__, "update");
}
if (preg_match("#dpkg --configure -a#", $line)) {
$cmd = "DEBIAN_FRONTEND=noninteractive dpkg --configure -a --force-confold 2>&1";
if ($GLOBALS["VERBOSE"]) {
system_admin_events("apt-check: Executing {$cmd}", __FUNCTION__, __FILE__, __LINE__, "update");
}
exec("{$cmd}", $results1);
while (list($num1, $line1) = each($results1)) {
if (preg_match("#hardlink between a file in.+?backuppc#", $line1)) {
if ($GLOBALS["VERBOSE"]) {
system_admin_events("apt-check: remove backuppc", __FUNCTION__, __FILE__, __LINE__, "update");
}
shell_exec("{$_GET["APT-GET"]} -y remove backuppc --force-yes ");
}
}
system_admin_events("dpkg was interrupted\nReconfigure has been performed\n" . @implode("\n", $results1), __FUNCTION__, __FILE__, __LINE__, "update", "update");
if ($GLOBALS["VERBOSE"]) {
system_admin_events("apt-check: reconfigure:\n" . @implode("\n", $results1), __FUNCTION__, __FILE__, __LINE__, "update");
}
return;
}
}
exec("{$_GET["APT-GET"]} update 2>&1", $results);
while (list($num, $line) = each($results)) {
if ($GLOBALS["VERBOSE"]) {
system_admin_events("update: {$line}", __FUNCTION__, __FILE__, __LINE__, "system-update");
}
}
$results = array();
exec("{$_GET["APT-GET"]} -f install --force-yes 2>&1", $results);
while (list($num, $line) = each($results)) {
if (preg_match("#hardlink between a file in.+?backuppc#", $line)) {
if ($GLOBALS["VERBOSE"]) {
system_admin_events("apt-check: remove backuppc \"{$_GET["APT-GET"]} remove backuppc --force-yes\"", __FUNCTION__, __FILE__, __LINE__, "system-update");
}
shell_exec("{$_GET["APT-GET"]} -y remove backuppc --force-yes ");
}
if ($GLOBALS["VERBOSE"]) {
system_admin_events("-f install: {$line}", __FUNCTION__, __FILE__, __LINE__, "system-update");
}
}
if (COUNT_REPOS() == 0) {
if ($GLOBALS["VERBOSE"]) {
system_admin_events(" -> INSERT_DEB_PACKAGES()", __FUNCTION__, __FILE__, __LINE__, "system-update");
}
INSERT_DEB_PACKAGES();
}
shell_exec("{$_GET["APT-GET"]} -f install --force-yes >/dev/null 2>&1");
shell_exec("{$_GET["APT-GET"]} upgrade -s >{$tmpf} 2>&1");
//.........这里部分代码省略.........
示例11: ParseLocalQueue
function ParseLocalQueue()
{
if (is_file("/etc/artica-postfix/orders.queue")) {
$size = @filesize("/etc/artica-postfix/orders.queue");
if ($size > 0) {
events("Loading /etc/artica-postfix/orders.queue {$size} bytes");
$orders_queue = explode("\n", @file_get_contents("/etc/artica-postfix/orders.queue"));
if (is_array($orders_queue)) {
while (list($num, $ligne) = each($orders_queue)) {
if (trim($ligne) == null) {
continue;
}
$orders[md5($ligne)] = $ligne;
}
}
}
@unlink("/etc/artica-postfix/orders.queue");
}
if (is_file("/etc/artica-postfix/background")) {
$size = @filesize("/etc/artica-postfix/background");
if ($size > 0) {
events("Loading /etc/artica-postfix/background {$size} bytes");
$background = explode("\n", @file_get_contents("/etc/artica-postfix/background"));
if (is_array($background)) {
while (list($num, $ligne) = each($background)) {
if (trim($ligne) == null) {
continue;
}
$orders[md5($ligne)] = $ligne;
}
}
}
@unlink("/etc/artica-postfix/background");
}
if (count($orders) == 0) {
return null;
}
$nice = EXEC_NICE();
shell_exec('export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11');
$nohup = LOCATE_NOHUP() . " ";
$orders_number = count($orders);
$count_max = $orders_number;
if ($count_max > 2) {
$count_max = 2;
}
if ($orders_number > 10) {
if (!$GLOBALS["OVERLOAD"]) {
$count_max = 10;
}
}
while (list($num, $cmd) = each($orders)) {
$count = $count + 1;
$devnull = " >/dev/null 2>&1";
if (strpos($cmd, ">") > 0) {
$devnull = null;
}
if ($GLOBALS["OVERLOAD"]) {
if ($count >= $count_max) {
break;
}
unset($orders[$num]);
events("[OVERLOAD]:: running in overload mode {$cmd}");
shell_exec("{$nohup}{$nice}{$cmd}{$devnull}");
continue;
}
events("[NORMAL]:: running in normal mode {$cmd}");
shell_exec("{$nohup}{$nice}{$cmd}{$devnull} &");
unset($orders[$num]);
if ($count >= $count_max) {
break;
}
}
events("{$count}/{$orders_number} order(s) executed...end;");
if (is_array($orders)) {
if (count($orders) > 0) {
reset($orders);
$fh = fopen("/etc/artica-postfix/background", 'w') or die("can't open file");
while (list($num, $cmd) = each($orders)) {
$datas = "{$cmd}\n";
fwrite($fh, $datas);
}
fclose($fh);
events("Queued " . count($orders) . " order(s)");
}
}
}
示例12: ParseGzSqlFile
function ParseGzSqlFile($filepath){
if($GLOBALS["MYSQLCOMMAND"]==null){
$unix=new unix();
$mysql=$unix->find_program("mysql");
$q=new mysql();
if($q->mysql_password<>null){
$password=" --password=$q->mysql_password";
}
$nice=EXEC_NICE();
$cmd="$nice$mysql --batch --user=$q->mysql_admin $password --port=$q->mysql_port";
$cmd=$cmd." --host=$q->mysql_server --database=artica_backup";
$cmd=$cmd." --max_allowed_packet=500M";
$GLOBALS["MYSQLCOMMAND"]=$cmd;
}else{
$cmd=$GLOBALS["MYSQLCOMMAND"];
}
//echo $cmd." <$filepath\n";
echo "Starting......: [ParseGzSqlFile]:: Artica database community running importation (". basename($filepath).")\n";
exec("$cmd <$filepath 2>&1",$results);
if(count($results)>0){
while (list ($num, $ligne) = each ($results) ){
if(!preg_match("#Duplicate entry#",$ligne)){
echo "Starting......: Artica database community $ligne\n";
if(preg_match("#ERROR\s+[0-9]+#",$ligne)){
echo "Starting......: Artica database community error detected\n";
$GLOBALS["NEWFILES"][]=$ligne;
$unix->send_email_events("Web community mysql error", "Unable to import data file $filepath\n$ligne","proxy");
return false;
}
}
}
}
return true;
@unlink($filepath);
}
示例13: apache_config
function apache_config()
{
$sock = new sockets();
$unix = new unix();
$EnablePHPFPM = 0;
@mkdir("/var/run/squid", 0755, true);
@mkdir("/var/run/squid", 0755, true);
$APACHE_SRC_ACCOUNT = "squid";
$APACHE_SRC_GROUP = "squid";
$APACHE_MODULES_PATH = $unix->APACHE_MODULES_PATH();
if (!isset($GLOBALS["HyperCacheStoragePath"])) {
$sock = new sockets();
$GLOBALS["HyperCacheStoragePath"] = $sock->GET_INFO("HyperCacheStoragePath");
if ($GLOBALS["HyperCacheStoragePath"] == null) {
$GLOBALS["HyperCacheStoragePath"] = "/home/artica/proxy-cache";
}
}
$SquidEnforceRules = intval($sock->GET_INFO("SquidEnforceRules"));
$HyperCacheHTTPListenPort = $sock->GET_INFO("HyperCacheHTTPListenPort");
$HyperCacheHTTPListenPortSSL = $sock->GET_INFO("HyperCacheHTTPListenPortSSL");
$HyperCacheHTTPListenPortSSLEnabled = intval($sock->GET_INFO("HyperCacheHTTPListenPortSSLEnabled"));
if (!is_numeric($HyperCacheHTTPListenPort)) {
$HyperCacheHTTPListenPort = 8700;
}
if (!is_numeric($HyperCacheHTTPListenPortSSL)) {
$HyperCacheHTTPListenPortSSL = 8900;
}
$HyperCacheListenAddr = $sock->GET_INFO("HyperCacheListenAddr");
$unix = new unix();
$NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
unset($NETWORK_ALL_INTERFACES["lo"]);
if ($HyperCacheListenAddr == null) {
$HyperCacheListenAddr = $unix->NETWORK_DEFAULT_LISTEN_ADDR();
$sock->SET_INFO("HyperCacheListenAddr", $HyperCacheListenAddr);
}
if ($unix->NETWORK_IS_LISTEN_ADDR_EXISTS($HyperCacheListenAddr)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} {$HyperCacheListenAddr} doesn't exists...\n";
}
$HyperCacheListenAddr = $unix->NETWORK_DEFAULT_LISTEN_ADDR();
$sock->SET_INFO("HyperCacheListenAddr", $HyperCacheListenAddr);
}
$ipaddr = $HyperCacheListenAddr;
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
$php = $unix->LOCATE_PHP5_BIN();
$EnableArticaApachePHPFPM = $sock->GET_INFO("EnableArticaApachePHPFPM");
if (!is_numeric($EnableArticaApachePHPFPM)) {
$EnableArticaApachePHPFPM = 0;
}
if (!is_file($phpfpm)) {
$EnableArticaApachePHPFPM = 0;
}
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/run/squid");
$apache_LOCATE_MIME_TYPES = $unix->apache_LOCATE_MIME_TYPES();
if ($EnableArticaApachePHPFPM == 1) {
if (!is_file("{$APACHE_MODULES_PATH}/mod_fastcgi.so")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} mod_fastcgi.so is required to use PHP5-FPM\n";
}
$EnableArticaApachePHPFPM = 0;
}
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Listen address: {$ipaddr}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Run as {$APACHE_SRC_ACCOUNT}:{$APACHE_SRC_GROUP}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} HTTP Port: {$HyperCacheHTTPListenPort} SSL Port: {$HyperCacheHTTPListenPortSSL}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} PHP-FPM: {$EnablePHPFPM}\n";
}
$q = new mysql_squid_builder();
$nice = EXEC_NICE();
$sql = "SELECT * FROM artica_caches_mirror WHERE enabled=1 AND `ToDelete`=0";
$results = $q->QUERY_SQL($sql);
$HyperCache = new HyperCache();
while ($ligne = mysql_fetch_assoc($results)) {
$t = time();
$sitename = $ligne["sitename"];
$sitename_path = $HyperCache->HyperCacheUriToHostname($sitename);
$workingdir = $GLOBALS["HyperCacheStoragePath"] . "/mirror/{$sitename_path}";
if (!is_dir($workingdir)) {
@mkdir($workingdir, 0755, true);
}
@chown("{$GLOBALS["HyperCacheStoragePath"]}/mirror", "squid");
@chgrp("{$GLOBALS["HyperCacheStoragePath"]}/mirror", "squid");
@chown("{$GLOBALS["HyperCacheStoragePath"]}/mirror/{$sitename_path}", "squid");
@chgrp("{$GLOBALS["HyperCacheStoragePath"]}/mirror/{$sitename_path}", "squid");
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} build folder for mirrored {$sitename_path}\n";
}
$mirrors[] = "";
$mirrors_aliases[] = "alias /{$sitename_path} {$workingdir}";
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: alias /{$sitename_path} {$workingdir}\n";
}
$mirrors[] = "";
//.........这里部分代码省略.........
示例14: basename
echo "/etc/artica-postfix/settings/Daemons/CyrusAVConfig no such file...\n";
die;
}
@mkdir("/etc/artica-postfix/pids");
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$unix = new unix();
if ($unix->process_exists(@file_get_contents($pidfile))) {
echo "Process already exists...\n";
die;
}
@file_put_contents($pidfile, getmypid());
$t1 = time();
$time = date('Y-m-d') . "_" . date('h:i');
$ini = new Bs_IniHandler();
$ini->loadFile("/etc/artica-postfix/settings/Daemons/CyrusAVConfig");
$nice = EXEC_NICE();
$clamscan = $unix->find_program("clamscan");
if (!is_file($clamscan)) {
die;
}
$partition_default = $unix->IMAPD_GET("partition-default");
if (!is_dir($partition_default)) {
send_email_events("Mailboxes antivirus scanning failed", "partition-default: \"{$partition_default}\"\nno such directory", "mailbox");
echo "partition-default: no such directory\n";
die;
}
@mkdir("/var/log/artica-postfix/antivirus/cyrus-imap", 0755, true);
$time = date('Y-m-d') . "_" . date('h:I');
$cmd = "{$nice} /usr/bin/clamscan --recursive=yes --infected ";
$cmd = $cmd . "--max-filesize=10M --max-scansize=10M --max-recursion=5 --max-dir-recursion=10 ";
$cmd = $cmd . "--log=/log/artica-postfix/antivirus/cyrus-imap/{$time}.scan {$partition_default}";
示例15: UFDBGUARD_COMPILE_SINGLE_DB
function UFDBGUARD_COMPILE_SINGLE_DB($path)
{
$timeStart = time();
$OriginalDirename = dirname($path);
$unix = new unix();
$path = str_replace(".ufdb", "", $path);
$pidpath = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . md5($path) . ".pid";
$pid = @file_get_contents($pidpath);
if ($unix->process_exists($pid)) {
events_ufdb_tail("Check \"{$path}\"... Already process PID \"{$pid}\" running task has been aborted");
return;
}
$category = null;
$ufdbGenTable = $unix->find_program("ufdbGenTable");
if (!is_file($ufdbGenTable)) {
writelogs("ufdbGenTable no such binary", __FUNCTION__, __FILE__, __LINE__);
return;
}
events_ufdb_tail("Check \"{$path}\"...", __LINE__);
if (preg_match("#\\/var\\/lib\\/squidguard\\/(.+?)\\/(.+?)/(.+?)\$#", $path, $re)) {
$category = $re[2];
$domain_path = "/var/lib/squidguard/{$re[1]}/{$re[2]}/domains";
}
if ($category == null) {
if (preg_match("#\\/var\\/lib\\/squidguard\\/(.+?)\\/domains#", $path, $re)) {
$category = $re[1];
$domain_path = "/var/lib/squidguard/{$re[1]}/domains";
}
}
if (preg_match("#web-filter-plus\\/BL\\/(.+?)\\/domains#", $path, $re)) {
$category = $re[1];
$domain_path = "/var/lib/squidguard/web-filter-plus/BL/{$category}/domains";
}
if (preg_match("#blacklist-artica\\/(.+?)\\/(.+?)\\/domains#", $path, $re)) {
events_ufdb_tail("find double category \"{$re[1]}-{$re[2]}\"...", __LINE__);
$category = "{$re[1]}-{$re[2]}";
$domain_path = "/var/lib/squidguard/blacklist-artica/{$re[1]}/{$re[2]}/domains";
}
if (preg_match("#blacklist-artica\\/sex\\/(.+?)\\/domains#", $path, $re)) {
$category = $re[1];
$domain_path = "/var/lib/squidguard/blacklist-artica/sex/{$category}/domains";
}
if ($category == null) {
events_ufdb_tail("exec.squidguard.php:: \"{$path}\" cannot understand...");
}
events_ufdb_tail("exec.squidguard.php:: Found category \"{$category}\"", __LINE__);
if (!is_file($path)) {
events_ufdb_tail("exec.squidguard.php:{$category}: \"{$path}\" no such file, build it", __LINE__);
@file_put_contents($domain_path, " ");
}
$category_compile = substr($category, 0, 15);
if (strlen($category_compile) > 15) {
$category_compile = str_replace("recreation_", "recre_", $category_compile);
$category_compile = str_replace("automobile_", "auto_", $category_compile);
$category_compile = str_replace("finance_", "fin_", $category_compile);
if (strlen($category_compile) > 15) {
$category_compile = str_replace("_", "", $category_compile);
if (strlen($category_compile) > 15) {
$category_compile = substr($category_compile, strlen($category_compile) - 15, 15);
}
}
}
events_ufdb_tail("exec.squidguard.php:: category \"{$category}\" retranslated to \"{$category_compile}\"", __LINE__);
if (is_file("{$domain_path}.ufdb")) {
events_ufdb_tail("exec.squidguard.php:: removing \"{$domain_path}.ufdb\" ...");
@unlink("{$domain_path}.ufdb");
}
if (!is_file($domain_path)) {
events_ufdb_tail("exec.squidguard.php:: {$domain_path} no such file, create an empty one", __LINE__);
@mkdir(dirname($domain_path), 0755, true);
@file_put_contents($domain_path, "#");
}
$urlcmd = null;
$d = " -d {$domain_path}";
if (is_file("{$OriginalDirename}/urls")) {
$urlssize = @filesize("{$OriginalDirename}/urls");
events_ufdb_tail("exec.squidguard.php:: {$OriginalDirename}/urls {$urlssize} bytes...", __LINE__);
if ($urlssize > 50) {
$urlcmd = " -u {$OriginalDirename}/urls";
}
}
$NICE = EXEC_NICE();
$cmd = "{$NICE}{$ufdbGenTable} -n -D -W -t {$category_compile}{$d}{$urlcmd} 2>&1";
events_ufdb_tail("exec.squidguard.php:{$category}:{$cmd}");
$time = time();
exec($cmd, $results);
exec($cmd, $results);
while (list($a, $b) = each($results)) {
if (strpos($b, "is not added because it was already matched")) {
continue;
}
if (strpos($b, "has optimised subdomains")) {
continue;
}
events_ufdb_tail("exec.squidguard.php:{$category}:{$b}");
}
$tookrecompile = $unix->distanceOfTimeInWords($time, time());
events_ufdb_tail("exec.squidguard.php:{$category_compile}: execution {$tookrecompile}", __LINE__);
events_ufdb_tail("exec.squidguard.php:{$category}:done..");
$user = GetSquidUser();
//.........这里部分代码省略.........