本文整理汇总了PHP中system_admin_events函数的典型用法代码示例。如果您正苦于以下问题:PHP system_admin_events函数的具体用法?PHP system_admin_events怎么用?PHP system_admin_events使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了system_admin_events函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
function start()
{
$sock = new sockets();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$unix = new unix();
$me = basename(__FILE__);
if ($unix->process_exists(@file_get_contents($pidfile), $me)) {
if ($GLOBALS["VERBOSE"]) {
echo " --> Already executed.. " . @file_get_contents($pidfile) . " aborting the process\n";
}
system_admin_events("--> Already executed.. " . @file_get_contents($pidfile) . " aborting the process", __FUNCTION__, __FILE__, __LINE__, "zarafa");
die;
}
@file_put_contents($pidfile, getmypid());
$WordpressBackupParams = unserialize(base64_decode($sock->GET_INFO("WordpressBackupParams")));
if (!isset($WordpressBackupParams["FTP_ENABLE"])) {
$WordpressBackupParams["FTP_ENABLE"] = 0;
}
if (!isset($WordpressBackupParams["DEST"])) {
$WordpressBackupParams["DEST"] = "/home/wordpress-backup";
}
if ($WordpressBackupParams["DEST"] == null) {
$WordpressBackupParams["DEST"] = "/home/wordpress-backup";
}
ScanFreeWebs($WordpressBackupParams);
$t = time();
build_progress_fullback("{backup} FTP ?", 95);
ftp_backup($WordpressBackupParams);
sizes_backup();
build_progress_fullback("{done}", 100);
}
示例2: restart_lighttpd
function restart_lighttpd()
{
$t = time();
exec("/etc/init.d/artica-webinterface restart 2>&1", $results);
$unix = new unix();
$took = $unix->distanceOfTimeInWords($t, time());
system_admin_events("Restart Web interface service done took:{$took}\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "system");
}
示例3: ScanFoldders
function ScanFoldders()
{
$sock = new sockets();
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pid = file_get_contents("{$pidfile}");
if ($GLOBALS["VERBOSE"]) {
echo "{$timefile}\n";
}
if (system_is_overloaded(basename(__FILE__))) {
die;
}
if ($unix->process_exists($pid, basename(__FILE__))) {
$timeMin = $unix->PROCCESS_TIME_MIN($pid);
if ($timeMin > 240) {
system_admin_events("Too many TTL, {$pid} will be killed", __FUNCTION__, __FILE__, __LINE__, "logrotate");
$kill = $unix->find_program("kill");
unix_system_kill_force($pid);
} else {
die;
}
}
if (!$GLOBALS["FORCE"]) {
$TimeExec = $unix->file_time_min($timefile);
if ($TimeExec < 240) {
return;
}
}
@unlink($timefile);
@file_put_contents($timefile, time());
$LogRotatePath = $sock->GET_INFO("LogRotatePath");
$SystemLogsPath = $sock->GET_INFO("SystemLogsPath");
$BackupMaxDaysDir = $sock->GET_INFO("BackupMaxDaysDir");
$maillogStoragePath = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/maillogStoragePath"));
if ($GLOBALS["VERBOSE"]) {
echo "Starting Main\n";
}
$q = new mysql();
$q->QUERY_SQL("DROP TABLE `sysstorestatus`", "artica_events");
$sql = "CREATE TABLE IF NOT EXISTS `sysstorestatus` (\n\t\t\t `filepath` VARCHAR(255) NOT NULL,\n\t\t\t `filesize` BIGINT UNSIGNED NOT NULL,\n\t\t\t `zDate` DATETIME,\n\t\t\t PRIMARY KEY (`filepath`),\n\t\t\t KEY `zDate` (`zDate`),\n\t\t\t KEY `filesize` (`filesize`)\n\t\t\n\t\t\t)";
$q->QUERY_SQL($sql, "artica_events");
if (!$q->ok) {
echo $q->mysql_error;
return;
}
ScanThis("/home/postfix/maillog");
ScanThis("/home/logrotate");
ScanThis("/home/logrotate_backup");
ScanThis("/home/logs-backup");
ScanThis("/home/backup/postfix");
ScanThis($LogRotatePath);
ScanThis($SystemLogsPath);
ScanThis($maillogStoragePath);
}
示例4: launch_tests
function launch_tests()
{
$unix = new unix();
$php = $unix->LOCATE_PHP5_BIN();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
return;
}
if (system_is_overloaded(basename(__FILE__))) {
system_admin_events("Overloaded, aborting task...", __FUNCTION__, __FILE__, __LINE__, "system");
$unix->THREAD_COMMAND_SET("{$php} " . __FILE__);
return;
}
@file_put_contents($pidfile, getmypid());
$datafile = "/etc/artica-postfix/settings/Daemons/HdparmInfos";
writelogs("Testing hard drives ({$datafile})", __FUNCTION__, __FILE__, __LINE__);
$timenum = file_time_min($datafile);
if (is_file($datafile)) {
if (file_time_min($datafile) < 61) {
writelogs("{$timenum}Mn executed, waiting 60Mn", __FUNCTION__, __FILE__, __LINE__);
die;
}
}
if ($GLOBALS["FIND_HDPARM"] == null) {
writelogs("Unable to stat 'hdparm'", __FUNCTION__, __FILE__, __LINE__);
die;
}
$disks = GetDisks();
if (!is_array($disks)) {
return null;
}
while (list($index, $line) = each($disks)) {
unset($results);
exec("{$GLOBALS["FIND_HDPARM"]} -t {$index}", $results);
while (list($num, $line_result) = each($results)) {
if (preg_match("#=\\s+([0-9\\.]+)\\s+MB\\/sec\$#", $line_result, $re)) {
if (preg_match("#.+?\\/(.+)\$#", $index, $ri)) {
system_admin_events("{$ri[1]}:{$re[1]}MB/sec", __FUNCTION__, __FILE__, __LINE__, "system");
writelogs("testing disk {$ri[1]}:{$re[1]}MB/sec...", __FUNCTION__, __FILE__, __LINE__);
$array[$ri[1]] = $re[1];
}
}
}
}
@unlink($datafile);
@file_put_contents($datafile, base64_encode(serialize($array)));
if (!is_file($datafile)) {
writelogs("{$datafile} no such file or directory", __FUNCTION__, __FILE__, __LINE__);
}
}
示例5: DELETE_TABLE
function DELETE_TABLE($table)
{
if (!function_exists("mysql_connect")) {
return 0;
}
if (function_exists("system_admin_events")) {
$trace = @debug_backtrace();
if (isset($trace[1])) {
$called = "called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}";
}
system_admin_events("MySQL table {$this->database}/{$table} was deleted {$called}", __FUNCTION__, __FILE__, __LINE__, "mysql-delete");
}
$this->QUERY_SQL("DROP TABLE `{$table}`", $this->database);
}
示例6: start
function start()
{
$sock = new sockets();
$unix = new unix();
if (!$GLOBALS["VERBOSE"]) {
$pidtime = "/etc/artica-postfix/pids/exec.mimedefang.quarantine.php.start.time";
if ($unix->file_time_min($pidtime) < 5) {
return;
}
@unlink($pidtime);
@file_put_contents($pidtime, time());
}
$postgres = new postgres_sql();
$postgres->SMTP_TABLES();
$storage_path = "/var/spool/MD-Quarantine";
$unix = new unix();
$pidpath = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidpath);
if ($unix->process_exists($pid)) {
system_admin_events("Already process {$pid} running.. Aborting", __FUNCTION__, __FILE__, __LINE__, "postfix");
return;
}
@file_put_contents($pidpath, getmypid());
$c = 0;
$q = new postgres_sql();
$q->SMTP_TABLES();
if ($handle = opendir($storage_path)) {
while (false !== ($file = readdir($handle))) {
if ($file == "." && $file == "..") {
continue;
}
if (substr($file, 0, 1) == '.') {
continue;
}
if (!preg_match("#^qdir-#", $file)) {
continue;
}
$path = "{$storage_path}/{$file}";
if (!is_file("{$path}/ENTIRE_MESSAGE")) {
continue;
}
import_quarantine($path);
}
}
CleanDatabase();
}
示例7: parseQueue
function parseQueue()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
$sock = new sockets();
if ($unix->process_exists($pid, basename(__FILE__))) {
$pidTime = $unix->PROCCESS_TIME_MIN($pid);
events("Already process PID: {$pid} running since {$pidTime} minutes", __FUNCTION__, __FILE__, __LINE__, "postfix-stats");
return;
}
@file_put_contents($pidfile, getmypid());
if (system_is_overloaded(basename(__FILE__))) {
events("Overloaded system, aborting", __FUNCTION__, __FILE__, __LINE__, "postfix-stats");
return;
}
$EnableArticaSMTPStatistics = $sock->GET_INFO("EnableArticaSMTPStatistics");
if (!is_numeric($EnableArticaSMTPStatistics)) {
$EnableArticaSMTPStatistics = 0;
}
$directory = "/var/log/artica-mail";
if (!is_dir($directory)) {
return;
}
if (!($handle = @opendir($directory))) {
return;
}
$q = new mysql_postfix_builder();
$q->CheckTables();
events("open {$directory}");
while (false !== ($filename = readdir($handle))) {
if ($EnableArticaSMTPStatistics == 0) {
@unlink("{$directory}/{$filename}");
continue;
}
if (!preg_match("#(.+?)\\.[0-9]+\\.aws#", $filename, $re)) {
continue;
}
$instancename = $re[1];
ParseFile("{$directory}/{$filename}");
if (system_is_overloaded(basename(__FILE__))) {
system_admin_events("Overloaded system, aborting", __FUNCTION__, __FILE__, __LINE__, "postfix-stats");
return;
}
}
}
示例8: mailboxes_ou_lang
function mailboxes_ou_lang($ou)
{
$unix = new unix();
$sock = new sockets();
$t = time();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$unix = new unix();
$me = basename(__FILE__);
if ($unix->process_exists(@file_get_contents($pidfile), $me)) {
if ($GLOBALS["VERBOSE"]) {
echo " --> Already executed.. " . @file_get_contents($pidfile) . " aborting the process\n";
}
system_admin_events("--> Already executed.. " . @file_get_contents($pidfile) . " aborting the process", __FUNCTION__, __FILE__, __LINE__, "zarafa");
die;
}
@file_put_contents($pidfile, getmypid());
$oumd5 = md5(strtolower(trim($ou)));
$OuDefaultLang = $sock->GET_INFO("zarafaMBXLang{$oumd5}");
if ($OuDefaultLang == null) {
system_admin_events("`{$ou}` no such default language, aborting", __FUNCTION__, __FILE__, __LINE__, "zarafa");
return;
}
$ldap = new clladp();
$members = $ldap->hash_users_ou($ou);
$CountMembers = count($members);
system_admin_events("{$ou} {$CountMembers} to change to {$OuDefaultLang}", __FUNCTION__, __FILE__, __LINE__, "zarafa");
$c = 0;
while (list($uid, $name) = each($members)) {
$ct = new user($uid);
if ($ct->zarafaMbxLang == null) {
$ct->SaveZarafaMbxLang($OuDefaultLang);
$c++;
$sock->getFrameWork("cmd.php?zarafa-admin=yes");
$sock->getFrameWork("zarafa.php?zarafa-user-create-store={$uid}&lang={$OuDefaultLang}");
$sock->getFrameWork("zarafa.php?foldersnames=yes&uid={$uid}&lang={$OuDefaultLang}");
}
}
$took = $unix->distanceOfTimeInWords($t, time(), true);
system_admin_events("{$ou} {$c}/{$CountMembers} changed to {$OuDefaultLang} done took: {$took}", __FUNCTION__, __FILE__, __LINE__, "zarafa");
}
示例9: scanarp_mysql
function scanarp_mysql()
{
$unix = new unix();
$t = time();
if (systemMaxOverloaded()) {
return;
}
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$unix = new unix();
$me = basename(__FILE__);
$pid = @file_get_contents($pidfile);
if ($unix->process_exists($pid, $me)) {
if ($GLOBALS["VERBOSE"]) {
echo " --> Already executed.. {$pid} aborting the process\n";
}
system_admin_events("--> Already executed.. {$pid} aborting the process", __FUNCTION__, __FILE__, __LINE__, "network");
die;
}
$sock = new sockets();
$EnableArpDaemon = $sock->GET_INFO("EnableArpDaemon");
$ArpdKernelLevel = $sock->GET_INFO("ArpdKernelLevel");
if (!is_numeric($EnableArpDaemon)) {
$EnableArpDaemon = 1;
}
$articastatus_pidfile = "/etc/artica-postfix/exec.status.php.pid";
$pid = $unix->get_pid_from_file($articastatus_pidfile);
if (!$unix->process_exists($pid)) {
syslog_status("artica status doesn't run, start it, old pid was: {$pid}");
shell_exec("/etc/init.d/artica-status start");
}
$list = $unix->PIDOF_PATTERN_ALL($me);
if (count($list) > 2) {
system_admin_events("--> Already executed.." . count($list) . " Processes executed");
die;
}
@file_put_contents($pidfile, getmypid());
$arpbin = $unix->find_program("arp");
$arpdbin = $unix->find_program("arpd");
if (!is_file($arpbin)) {
echo "arp, no such binary...\n";
return;
}
exec("{$arpbin} -a 2>&1", $results);
if ($GLOBALS["VERBOSE"]) {
echo "{$arpbin} -a 2>&1\n";
}
$prefix = "INSERT INTO arpcache (`mac`,`ipaddr`,`hostname`,`HWtype`,`iface`) VALUES ";
while (list($num, $ligne) = each($results)) {
if (preg_match("#^(.+?)\\s+\\((.+?)\\)\\s+.+?\\s+(.+?)\\s+\\[(.+?)\\]\\s+.+?\\s+(.+)#", $ligne, $re)) {
$mac = trim($re[3]);
$hostname = trim($re[1]);
$ipaddr = trim($re[2]);
$HWtype = trim($re[4]);
$iface = trim($re[5]);
if ($GLOBALS["VERBOSE"]) {
echo "MATCH `{$ligne}` '{$mac}','{$ipaddr}','{$hostname}','{$HWtype}','{$iface}'\n";
}
$f[] = "('{$mac}','{$ipaddr}','{$hostname}','{$HWtype}','{$iface}')";
continue;
}
if (preg_match("#^([a-z0-9\\.\\-\\_\\?]+)\\s+\\((.+?)\\).+?incomplete.+?[a-z]+\\s+(.+)\$#", $ligne, $re)) {
$mac = null;
$hostname = trim($re[1]);
$ipaddr = trim($re[2]);
$HWtype = null;
$iface = trim($re[3]);
if ($GLOBALS["VERBOSE"]) {
echo "MATCH `{$ligne}` '{$mac}','{$ipaddr}','{$hostname}','{$HWtype}','{$iface}'\n";
}
$f[] = "('{$mac}','{$ipaddr}','{$hostname}','{$HWtype}','{$iface}')";
continue;
}
if ($GLOBALS["VERBOSE"]) {
echo "No match `{$ligne}`\n";
}
}
if (is_file($arpdbin)) {
$results = array();
exec("{$arpdbin} -l 2>&1", $results);
while (list($num, $ligne) = each($results)) {
if (preg_match("#^[0-9]+\\s+([0-9\\.]+)\\s+(.+)#", $ligne, $re)) {
$mac = trim($re[2]);
if (preg_match("#FAILED:#", $mac)) {
$mac = null;
}
$hostname = null;
$ipaddr = trim($re[1]);
$HWtype = null;
$iface = "arpd";
$f[] = "('{$mac}','{$ipaddr}','{$hostname}','{$HWtype}','{$iface}')";
continue;
}
}
}
if (count($f) > 0) {
$q = new mysql();
$q->QUERY_SQL("TRUNCATE TABLE `arpcache`", "artica_backup");
if ($GLOBALS["VERBOSE"]) {
echo count($f) . " entries\n";
}
//.........这里部分代码省略.........
示例10: logrotatelogs
function logrotatelogs($nopid = false)
{
$unix = new unix();
$sock = new sockets();
if ($nopid) {
$pidpath = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidpath);
if ($unix->process_exists($pid)) {
$pidtime = $unix->PROCCESS_TIME_MIN($pid);
system_admin_events(basename(__FILE__) . ":: " . __FUNCTION__ . " Already process {$pid} running since {$pidtime} Mn.. Aborting", __FUNCTION__, __FILE__, __LINE__);
return;
}
@file_put_contents($pidpath, getmypid());
}
$echo = $unix->find_program("echo");
$LogsRotateDeleteSize = $sock->GET_INFO("LogsRotateDeleteSize");
if (!is_numeric($LogsRotateDeleteSize)) {
$LogsRotateDeleteSize = 5000;
}
include_once dirname(__FILE__) . "/ressources/class.mysql.syslog.inc";
if ($GLOBALS["VERBOSE"]) {
echo __FUNCTION__ . " line:" . __LINE__ . "\n";
}
$q = new mysql_syslog();
if ($q->COUNT_ROWS("logrotate") == 0) {
$q->CheckDefaults();
}
$sql = "SELECT RotateFiles FROM logrotate WHERE enabled=1";
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
echo $q->mysql_error;
}
while ($ligne = mysql_fetch_assoc($results)) {
$filepath = $ligne["RotateFiles"];
if (strpos($filepath, "*") > 0) {
if ($GLOBALS["VERBOSE"]) {
echo __FUNCTION__ . ":: Scanning {$filepath} line:" . __LINE__ . "\n";
}
foreach (glob($filepath) as $filename) {
$size = $unix->file_size($filename);
$size = $size / 1024;
$size = round($size / 1000, 2);
$ARRAY[$filename] = $size;
}
} else {
if (is_file($filepath)) {
$size = $unix->file_size($filepath);
$size = $size / 1024;
$size = round($size / 1000, 2);
$ARRAY[$filepath] = $size;
}
if (is_dir($filepath)) {
while (list($num, $filename) = each($f)) {
$filepath = "/var/log/{$filename}";
$f = $unix->DirFiles("{$filepath}");
$size = $unix->file_size($filepath);
$size = $size / 1024;
$size = round($size / 1000, 2);
$ARRAY[$filepath] = $size;
}
}
}
}
$f = $unix->DirFiles("/var/log");
while (list($num, $filename) = each($f)) {
$filepath = "/var/log/{$filename}";
$size = $unix->file_size($filepath);
$size = $size / 1024;
$size = round($size / 1000, 2);
$ARRAY[$filepath] = $size;
}
$f = $unix->DirFiles("/var/log/artica-postfix");
while (list($num, $filename) = each($f)) {
$filepath = "/var/log/artica-postfix/{$filename}";
$size = $unix->file_size($filepath);
$size = $size / 1024;
$size = round($size / 1000, 2);
$ARRAY[$filepath] = $size;
}
$restart = false;
while (list($filepath, $sizeM) = each($ARRAY)) {
if ($sizeM > $LogsRotateDeleteSize) {
shell_exec("{$echo} \"\" >{$filepath}");
$restart = true;
$unix->send_email_events("{$filepath} was cleaned ({$sizeM}M)", "It exceed maximal size {$LogsRotateDeleteSize}M", "system");
}
}
if ($restart) {
shell_exec("/etc/init.d/syslog restart");
shell_exec("/etc/init.d/artica-syslog restart");
shell_exec("/etc/init.d/auth-tail restart");
shell_exec("/etc/init.d/postfix-logger restart");
}
}
示例11: repair_action
function repair_action($database, $tablename, $expl)
{
$unix = new unix();
$q = new mysql();
if (preg_match("#Can.*?t find file#", $expl)) {
system_admin_events("{$tablename} is destroyed, remove it..", __FUNCTION__, __FILE__, __LINE__);
echo "Removing table {$database}/{$tablename}\n";
$q->DELETE_TABLE($tablename, $database);
return;
}
if (preg_match("#is marked as crashed#", $expl)) {
$results = array();
$t = time();
if (is_file("/var/lib/mysql/{$database}/{$tablename}.TMD")) {
@copy("/var/lib/mysql/{$database}/{$tablename}.TMD", "/var/lib/mysql/{$database}/{$tablename}.TMD-" . time());
@unlink("/var/lib/mysql/{$database}/{$tablename}.TMD");
}
$myisamchk = $unix->find_program("myisamchk");
$cmd = "{$myisamchk} -r /var/lib/mysql/{$database}/{$tablename}.MYI";
if ($GLOBALS["VERBOSE"]) {
echo "{$cmd}\n";
}
exec($cmd, $results);
$took = $unix->distanceOfTimeInWords($t, time());
system_admin_events("{$tablename} repaired took: {$took}", @implode("\r\n", $results), __FUNCTION__, __FILE__, __LINE__);
return;
}
if ($GLOBALS["VERBOSE"]) {
echo "{$tablename} nothing to do...\n";
}
}
示例12: 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");
}
示例13: install_package
function install_package($filename, $expected = null)
{
$unix = new unix();
$sock = new sockets();
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
$rm = $unix->find_program("rm");
$RebootAfterArticaUpgrade = $sock->GET_INFO("RebootAfterArticaUpgrade");
if (!is_numeric($RebootAfterArticaUpgrade)) {
$RebootAfterArticaUpgrade = 0;
}
events("Starting......: " . date("H:i:s") . " install_package() Extracting package {$filename}, please wait... ");
echo "Starting......: " . date("H:i:s") . " install_package() Extracting package {$filename}, please wait... \n";
$tarbin = $unix->find_program("tar");
$killall = $unix->find_program("killall");
echo "Starting......: " . date("H:i:s") . " tar: {$tarbin}\n";
echo "Starting......: " . date("H:i:s") . " killall: {$killall}\n";
@file_put_contents("/usr/share/artica-postfix/download_progress", 10);
events("Starting......: " . date("H:i:s") . " install_package() Testing Package");
echo "Starting......: " . date("H:i:s") . " Testing Package " . basename($filename) . "\n";
if (!$unix->TARGZ_TEST_CONTAINER($filename)) {
echo "Starting......: " . date("H:i:s") . " Testing Package " . basename($filename) . " failed\n";
_artica_update_event(0, "Compressed package seems corrupted", null, __FILE__, __LINE__);
events("Fatal, Compressed package seems corrupted");
events($GLOBALS["TARGZ_TEST_CONTAINER_ERROR"]);
@unlink($filename);
@file_put_contents("/usr/share/artica-postfix/download_progress", 100);
return false;
}
events("Starting......: " . date("H:i:s") . " Purge directories...");
@file_put_contents("/usr/share/artica-postfix/download_progress", 40);
system("{$rm} -f /usr/share/artica-postfix/ressources/logs/*");
system("{$rm} -f /usr/share/artica-postfix/ressources/logs/web/*");
if (is_dir("/usr/share/artica-postfix/ressources/conf/upload")) {
system("{$rm} -f /usr/share/artica-postfix/ressources/conf/upload/*");
}
if (is_dir("/usr/share/artica-postfix/ressources/conf/meta/hosts/uploaded")) {
system("{$rm} -f /usr/share/artica-postfix/ressources/conf/meta/hosts/uploaded/*");
}
events("Starting......: " . date("H:i:s") . " Extracting...");
exec("{$tarbin} xf {$filename} -C /usr/share/ 2>&1", $results);
if (is_file("{$killall}")) {
shell_exec("{$killall} artica-install >/dev/null 2>&1");
}
@unlink($filename);
shell_exec("{$nohup} {$php} " . dirname(__FILE__) . "/exec.checkfolder-permissions.php --force >/dev/null 2>&1 &");
$MyCurrentVersion = GetCurrentVersionString();
if ($expected != null) {
if ($MyCurrentVersion != $expected) {
_artica_update_event(1, "install_package(): Expected version:{$expected} does not match {$MyCurrentVersion}", $results, __FILE__, __LINE__);
return;
}
}
_artica_update_event(2, "install_package(): Success updating to a new version v{$MyCurrentVersion}", $results, __FILE__, __LINE__);
if ($RebootAfterArticaUpgrade == 1) {
@file_put_contents("/usr/share/artica-postfix/download_progress", 100);
_artica_update_event(1, "install_package() Reboot the server in 10s...", null, __FILE__, __LINE__);
events("Reboot the server in 10s...");
system_admin_events("Warning: Reboot the server in 10s...", __FUNCTION__, __FILE__, __LINE__, "artica-update");
$shutdown = $unix->find_program("shutdown");
shell_exec("shutdown -r -t 10");
return true;
}
_artica_update_event(2, "install_package(): restart dedicated services...", null, __FILE__, __LINE__);
system_admin_events("Warning: Restart Artica dedicated services after an upgrade...", __FUNCTION__, __FILE__, __LINE__, "artica-update");
RestartDedicatedServices();
_artica_update_event(2, "install_package(): finish", null, __FILE__, __LINE__);
return true;
}
示例14: remove_squid
@unlink($squid3);
}
echo "Removing squid last install\n";
remove_squid();
echo "Make install\n";
shell_exec("echo \"**************************************\" >>/root/squid-{$v}-configure.log 2>&1");
shell_exec("echo \"\" >>/root/squid-{$v}-configure.log 2>&1");
if ($GLOBALS["VERBOSE"]) {
system("make install");
}
if (!$GLOBALS["VERBOSE"]) {
shell_exec("make install >>/root/squid-{$v}-configure.log 2>&1");
}
}
if (!is_file("/usr/sbin/squid")) {
system_admin_events("Installing the new squid-cache {$v} failed", __FUNCTION__, __FILE__, __LINE__, "software");
echo "Failed\n";
}
if (!$GLOBALS["NO_COMPILE"]) {
shell_exec("/bin/rm -rf /usr/share/squid3/errors/templates/*");
}
shell_exec("/bin/chown -R squid:squid /usr/share/squid3");
echo "Compiling ufdbcat....\n";
compile_ufdbcat();
echo "Creating package....\n";
create_package_squid($t);
function DebianVersion()
{
$ver = trim(@file_get_contents("/etc/debian_version"));
preg_match("#^([0-9]+)\\.#", $ver, $re);
if (preg_match("#squeeze\\/sid#", $ver)) {
示例15: NoIp
function NoIp()
{
$sock = new sockets();
$EnableNoIpService = $sock->GET_INFO("EnableNoIpService");
if (!is_numeric($EnableNoIpService)) {
$EnableNoIpService = 0;
}
if ($EnableNoIpService == 0) {
return;
}
$Config = unserialize(base64_decode($sock->GET_INFO("NoipConf")));
$curl = new ccurl("http://dynupdate.no-ip.com/nic/update?hostname={$Config["NoIPHostname"]}");
$curl->authname = $Config["NoIPUsername"];
$curl->authpass = $Config["NoIPPassword"];
$curl->NoHTTP_POST = true;
if (!$curl->get()) {
system_admin_events("Fatal {$curl->error} !!", __FUNCTION__, __FILE__, __LINE__, "system");
return;
}
$results = explode("\n", $curl->data);
while (list($num, $line) = each($results)) {
$line = trim($line);
if ($line == null) {
continue;
}
if (preg_match("#good\\s+([0-9\\.]+)#", $line, $re)) {
system_admin_events("OK For {$re[1]}", __FUNCTION__, __FILE__, __LINE__, "system");
writelogs("OK for {$re[1]}", __FUNCTION__, __FILE__);
$myip = $re[1];
break;
}
if (preg_match("#nochg\\s+([0-9\\.]+)#", $line, $re)) {
writelogs("OK no changes {$re[1]}", __FUNCTION__, __FILE__);
$myip = $re[1];
break;
}
if (preg_match("#nochg\\s+([0-9\\.]+)#", $line, $re)) {
writelogs("OK no changes {$re[1]}", __FUNCTION__, __FILE__);
$myip = $re[1];
break;
}
if (preg_match("#abuse\\s+(.+)#", $line, $re)) {
writelogs("Fatal: Abuse!!!! {$re[1]}", __FUNCTION__, __FILE__);
break;
}
}
if ($myip != null) {
@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/myIP.conf", $myip);
@chmod("/usr/share/artica-postfix/ressources/logs/web/myIP.conf", 775);
$sock->SET_INFO("PublicIPAddress", $myip);
}
}