function ntpdserverdelete() { $ntp = new ntpd(); unset($ntp->servers[$_GET["ntpdserverdelete"]]); $ntp->SaveToLdap(); }
function set_current_date_page() { $user = new usersMenus(); $page = CurrentPageName(); $tpl = new templates(); $bytab = false; $titleabout = $tpl->_ENGINE_parse_body("{server_time2}::{about_this_section}"); if (!$user->AsArticaAdministrator) { die; } $sock = new sockets(); exec("/bin/date \"+%d-%m %H:%M:%S\"", $results); $time = @implode("", $results); if (isset($_GET["bytab"])) { $bytab = true; } $ntp = new ntpd(true); $sock = new sockets(); $arrayTimzone = $ntp->timezonearray(); $timezone_def = trim($sock->GET_INFO('timezones')); for ($i = 1; $i < 13; $i++) { if ($i < 10) { $month_text = "0{$i}"; } else { $month_text = $i; } $months[$month_text] = $month_text; } for ($i = 1; $i < 32; $i++) { if ($i < 10) { $day_text = "0{$i}"; } else { $day_text = $i; } $days[$day_text] = $day_text; } for ($i = 0; $i < 24; $i++) { if ($i < 10) { $hours_text = "0{$i}"; } else { $hours_text = $i; } $hours[$hours_text] = $hours_text; } for ($i = 0; $i < 60; $i++) { if ($i < 10) { $mins_text = "0{$i}"; } else { $mins_text = $i; } $mins[$mins_text] = $mins_text; $secs[$mins_text] = $mins_text; } for ($i = 2009; $i < 2050; $i++) { $years_value = $i - 2000; if ($years_value < 10) { $years_value = "0{$years_value}"; } else { $years_value = $i; } $years[$years_value] = $i; } if (preg_match("#([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):([0-9]+)#", $time, $re)) { $defday = $re[1]; $defmonth = $re[2]; $defhour = $re[3]; $defmin = $re[4]; $defsec = $re[5]; } $ntplink = "\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-24.png'></td>\n\t\t<td nowrap><a href=\"javascript:blur();\" OnClick=\"Loadjs('ntpd.index.php');\" \n\t\t\tstyle='font-size:14px;text-decoration:underline'>{APP_NTPD}</a></td>\n\t</tr>"; if ($bytab) { $ntplink = null; } $t = time(); $headstyle = "style='font-weight:bold;font-size:14px'"; $form = "\n\t<div style='width:98%' class=form>\n\t<table style='width:99%'>\n\t<tr>\n\t\t<td {$headstyle} align='center'>{year}</th>\n\t\t<td {$headstyle} align='center'>{month}</th>\n\t\t<td {$headstyle} align='center'>{day}</th>\n\t\t<td {$headstyle} align='center'>{hours}</th>\n\t\t<td {$headstyle} align='center'>{minutes}</th>\n\t\t<td {$headstyle} align='center'>{seconds}</th>\n\t</tr>\n\t<tr>\n\t\t<td align='center'>" . Field_array_Hash($years, 'year', date('Y'), "style:font-size:20px;padding:5px") . "</td>\t\n\t\t<td align='center'>" . Field_array_Hash($months, 'month', $defmonth, "style:font-size:20px;padding:5px") . "</td>\n\t\t<td align='center'>" . Field_array_Hash($days, 'day', $defday, "style:font-size:20px;padding:5px") . "</td>\n\t\t<td align='center'>" . Field_array_Hash($hours, 'hour', $defhour, "style:font-size:20px;padding:5px") . "</td>\n\t\t<td align='center'>" . Field_array_Hash($mins, 'minute', $defmin, "style:font-size:20px;padding:5px") . "</td>\n\t\t<td align='center'>" . Field_array_Hash($secs, 'seconds', $defsec, "style:font-size:20px;padding:5px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=6 align='right' style='padding-top:10px'>" . Field_text("quick-hour-{$t}", "{$defhour}:{$defmin}:{$defsec}", "font-size:22px;width:120px", null, null, null, false, "QuickChange{$t}(event)") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=6 align='right'><hr>" . button("{apply}", "SaveServerTime()", "18px") . "</td>\n\t</tr>\n\t</table>\n\t</div>\t\t\n\t<div style='width:98%' class=form>\t\n\t<table style='width:99%;margin-top:15px'>\t\t\t\n\t<tr>\n\t\t<td valign='middle' class=legend nowrap style='font-size:20px'>{timezone}:</td>\n\t\t<td valign='top'>" . Field_array_Hash($arrayTimzone, "timezones{$t}", $timezone_def, null, null, "style:font-size:20px;padding:3px") . "</td>\n\t</tr>\t\t\t\t\n\t<tr>\n\t\t<td colspan=6 align='right'><hr>" . button("{apply}", "SaveTimeZone{$t}()", "18px") . "</td>\n\t</tr>\n\t</table>\t\t\t\t\n\t</div>\n\t<div style='text-align:right;width:100%'>" . imgtootltip("20-refresh.png", "{refresh}", "LoadTimeParams()") . "</div>"; $html = "\n\n\t<div id='servertimediv'>\n\t{$form}\n\t</div>\n\t<table style='width:50%'>\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-24.png'></td>\n\t\t<td nowrap><a href=\"javascript:blur();\" OnClick=\"javascript:HelpTime();\" \n\t\tstyle='font-size:14px;text-decoration:underline'>{about_this_section}</a></td>\n\t</tr>\n{$ntplink}\n\t</table>\n\t\t\n\t<script>\n\t\tfunction HelpTime(){\n\t\t\tYahooWinBrowse('550','{$page}?about=yes','{$titleabout}');\n\t\t\n\t\t}\n\t\t\n\t\tfunction QuickChange{$t}(e){\n\t\t\tif(!checkEnter(e)){return;}\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('quick-change',document.getElementById('quick-hour-{$t}').value);\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_SaveServerTime);\n\t\t\t\n\t\t}\n\t\t\n\t\tfunction SaveTimeZone{$t}(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('timezone',document.getElementById('timezones{$t}').value);\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_SaveServerTime);\t\t\n\t\t}\n\t</script>\n\t\n\t"; $tpl = new templates(); echo $tpl->_ENGINE_parse_body($html); }
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 ntpdserverdelete() { $ntp = new ntpd(); $ntp->DeleteServer($_GET["ntpdserverdelete"]); }