//Check if we have the file, and it is the correct size. incorrect size implies corruption if (file_exists($fname)) { $fsize = @filesize($fname); if ($fsize == $length) { readfile($fname); WLOG("DELIVER {$fname}", __LINE__); logdata("DELIVER", $url, $fname); exit(0); } else { WLOG("{$fname} size {$fsize} did not match requested {$length}", __LINE__); } } else { WLOG("{$fname} no such file", __LINE__); } if (is_file($lockfile)) { $lockfileSec = file_time_sec($lockfile); if ($lockfileSec < 5) { WLOG("{$lockfile} exists ({$lockfileSec} seconds) -> send anyway", __LINE__); readfile($fname); WLOG("DELIVER {$fname}", __LINE__); logdata("DELIVER", $url, $fname); exit(0); } } //file not in cache? Get it, send it & save it $url = $url . "&artica-time-stamp-" . time() . "=1"; logdata("DOWNLOAD", $url, $fname); $basename = basename($fname); $fileptr = fopen($fname, "w"); //no validity check, simply don't write the file if we can't open it. prevents noticeable failure/ $c = 0;
function MASTER_GET_SOURCE_CONNECT($host, $ID) { $file = "/etc/artica-postfix/croned.1/" . md5($host) . ".vol"; $timefile = file_time_sec($file); if (file_time_sec($file) < 30) { writelogs("MASTER::{$host}, {$file} {$timefile} seconds, need 30s aborting", __FUNCTION__, __FILE__, __LINE__); return; } @unlink($file); @file_put_contents($file, "#"); $curl = new ccurl("https://{$host}/exec.gluster.php"); $curl->parms["bricks"] = "yes"; if (!$curl->get()) { return null; } if (!preg_match("#<SOURCES>(.+?)</SOURCES>#s", $curl->data, $re)) { writelogs("MASTER::{$host}, unable to preg_match", __FUNCTION__, __FILE__, __LINE__); MASTER_SEND_LOGS($host, "Error parsing sources"); return null; } writelogs($re[1], __FUNCTION__, __FILE__, __LINE__); $paths = unserialize(base64_decode($re[1])); writelogs("MASTER::{$host}, receive " . count($paths) . " directories", __FUNCTION__, __FILE__, __LINE__); $array["PATHS"] = $paths; $based = base64_encode(serialize($array)); $sql = "UPDATE glusters_servers SET parameters='{$based}' WHERE ID={$ID}"; $q = new mysql(); $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { writelogs("MASTER::{$host}, {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__); MASTER_SEND_LOGS($host, "Mysql Error {$q->mysql_error}"); return; } MASTER_SEND_LOGS($host, "success receive clustered directories"); $sock = new sockets(); $sock->getFrameWork("cmd.php?gluster-mounts=yes"); }
function group10s() { $fileTime = "/etc/artica-postfix/cron.2/executor." . __FUNCTION__; if (file_time_sec($fileTime) < 10) { return; } if (is_array($array)) { while (list($index, $file) = each($array)) { $cmd = "{$_GET["PHP5"]} /usr/share/artica-postfix/{$file}"; @sys_THREAD_COMMAND_SET($cmd); } } if ($GLOBALS["cpuLimitEnabled"]) { $array2[] = "process1 --cpulimit"; } if (is_array($array2)) { while (list($index, $file) = each($array2)) { $cmd = "/usr/share/artica-postfix/bin/{$file}"; sys_THREAD_COMMAND_SET($cmd); } } @unlink($fileTime); @file_put_contents($fileTime, "#"); if ($GLOBALS["VERBOSE"]) { events(__FUNCTION__ . ":: die..."); } }
function setup_center() { if (!$GLOBALS["FORCE"]) { if (!Build_pid_func(__FILE__, __FUNCTION__)) { return false; } $time_file = "/etc/artica-postfix/croned.2/" . md5(__FILE__ . __FUNCTION__); $tt = file_time_sec($time_file); if ($tt < 30) { events(__FUNCTION__ . " {$tt} seconds, please wait 30s"); return null; } } include_once dirname(__FILE__) . '/setup.index.php'; error_log("Starting " . __FUNCTION__ . " in " . __FILE__); BuildingExecStatus("Setup center:: statistics...", 52); stat_packages(); BuildingExecStatus("Setup center:: SMTP...", 54); smtp_packages(); BuildingExecStatus("Setup center:: WEB...", 56); web_packages(); BuildingExecStatus("Setup center:: Proxy...", 58); proxy_packages(); BuildingExecStatus("Setup center:: Samba...", 60); samba_packages(); BuildingExecStatus("Setup center:: System...", 62); system_packages(); BuildingExecStatus("Setup center:: Xapian...", 64); xapian_packages(); BuildingExecStatus("Setup center:: done...", 68); events(__FUNCTION__ . "() done.."); }