function xtstart() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidtimeNTP = "/etc/artica-postfix/pids/exec.squid.watchdog.php.start_watchdog.ntp.time"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "ReStarting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n"; } return; } @file_put_contents($pidfile, getmypid()); $sock = new sockets(); $NtpdateAD = intval($sock->GET_INFO("NtpdateAD")); $NTPDClientEnabled = intval($sock->GET_INFO("NTPDClientEnabled")); if ($NtpdateAD == 1) { $NTPDClientEnabled = 1; } if ($NTPDClientEnabled == 0) { return; } $NTPDClientPool = intval($sock->GET_INFO("NTPDClientPool")); if ($NTPDClientPool == 0) { $NTPDClientPool = 120; } $pidtimeNTPT = $unix->file_time_min($pidtimeNTP); if (!$GLOBALS["FORCE"]) { if ($pidtimeNTPT < $NTPDClientPool) { return; } } @unlink($pidtimeNTP); @file_put_contents($pidtimeNTP, time()); if ($NtpdateAD == 1) { $nohup = $unix->find_program("nohup"); $php = $unix->LOCATE_PHP5_BIN(); shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.kerbauth.php --ntpdate >/dev/null 2>&1 &"); return; } $ntpdate = $unix->find_program("ntpdate"); $q = new mysql(); $sql = "SELECT * FROM ntpd_servers ORDER BY `ntpd_servers`.`order` ASC"; $results = $q->QUERY_SQL($sql, "artica_backup"); if (mysql_num_rows($results) == 0) { $ntp = new ntpd(); $ntp->builddefaults_servers(); $results = $q->QUERY_SQL($sql, "artica_backup"); } if (!$q->ok) { echo "{$q->mysql_error}<br>"; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $serv = trim($ligne["ntp_servers"]); if ($serv == null) { continue; } $serv2 = explode(" ", $serv); if (count($serv2) > 1) { $f[] = $serv2[0]; } else { $f[] = $ligne["ntp_servers"]; } } if (count($f) == 0) { return; } $SERVERS = @implode(" ", $f); exec("{$ntpdate} -v {$SERVERS} 2>&1", $results); while (list($num, $text) = each($results)) { $unix->ToSyslog($text, false, "ntpd"); } $hwclock = $unix->find_program("hwclock"); if (is_file($hwclock)) { $unix->ToSyslog("sync the Hardware time with {$hwclock}", false, "ntpd"); shell_exec("{$hwclock} --systohc"); } }
function main_server_list() { $ntp = new ntpd(); $q = new mysql(); $html = "\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%;margin-top:10px'>\n<thead class='thead'>\n\t<tr>\n\t<th colspan=3> </th>\n\t<th> </th>\n\t</tr>\n</thead>\n<tbody class='tbody'>"; $sql = "SELECT * FROM ntpd_servers ORDER BY `ntpd_servers`.`order` ASC"; $results = $q->QUERY_SQL($sql, "artica_backup"); if (mysql_num_rows($results) == 0) { $ntp->builddefaults_servers(); $results = $q->QUERY_SQL($sql, "artica_backup"); } if (!$q->ok) { echo "{$q->mysql_error}<br>"; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { if ($classtr == "oddRow") { $classtr = null; } else { $classtr = "oddRow"; } $order = $ligne["order"]; $html = $html . "<tr class={$classtr}>\n\t\t<td nowrap><strong><code style='font-size:14px'>[{$order}] {$ligne["ntp_servers"]}</code></strong></td>\n\t\t<td width=1% valign='middle'>" . imgtootltip('arrow-down-32.png', '{down}', "ntpdservermove('{$ligne["ntp_servers"]}','down')") . "</TD>\n\t\t<td width=1% valign='middle'>" . imgtootltip('arrow-up-32.png', '{up}', "ntpdservermove('{$ligne["ntp_servers"]}','up')") . "</TD>\n\t\t<td width=1% valign='middle'>" . imgtootltip('delete-32.png', '{delete}', "ntpdserverdelete('{$ligne["ntp_servers"]}')") . "</TD>\t\t\n\t\t</tr>\n\t\t"; } $html = $html . "</table>"; return $html; }