Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
function ntpd_main_config()
{
    $ntp = new ntpd(true);
    $sock = new sockets();
    $array = $ntp->ServersList();
    $arrayTimzone = $ntp->timezonearray();
    $timezone_def = trim($sock->GET_INFO('timezones'));
    $t = time();
    while (list($num, $val) = each($array)) {
        $i[$num] = $num;
    }
    $i[null] = "{choose}";
    $choose = Field_array_Hash($i, 'ntpd_servers_choosen', null, null, null, 0, 'font-size:14px;padding:3px');
    $page = CurrentPageName();
    $form = "\n\t <table style='width:99%' class=form>\n\t <tr>\n\t \t<td valign='middle' class=legend nowrap style='font-size:14px'>{servers}:</td>\n\t \t<td valign='top' style='width:2%;padding-top:5px'>{$choose}</td>\n\t \t\n\t </tr>\n\t<tr>\n\t\t<td valign='middle' class=legend nowrap style='font-size:14px'>{timezone}:</td>\n\t\t<td valign='top'>" . Field_array_Hash($arrayTimzone, "timezones{$t}", $timezone_def, null, null, "style:font-size:14px;padding:3px") . "</td>\n\t\t\n\t</tr> \n\t<tr>\n\t\t<td colspan=2 align='right'>\n\t\t\t\t<div style='font-size:11px;text-align:right'><i>{today}: " . date("{l} d {F} Y H:i:s") . "</i></div>\n\t\t\t\t<hr>" . button('{apply}', "ntpd_choose_server()", 14) . "</td>\n\t</tr>\n\t\t\t\t\n\t\t\t\t\n\t </table>\n\t <div class=text-info>{how_to_find_timeserver}</div><hr>\n\n\t \n\t\n\t\t<div style='text-align:right;width:100%'>" . button("{add}", "ntpdAdd()") . "&nbsp;|&nbsp;" . button("{ntpd_apply}", "ntpdSave()") . "</div>\n\t \t<div id=serverlist style='width:100%;height:250px;overflow:auto'>" . main_server_list() . "</div>\n\t \t<hr>\n\t \t<div style='text-align:right;width:100%'></div>\n\t \t\n\t \t\n\t \t<script>\n\t \t\tfunction ntpd_choose_server(){\n\t\t\t\tvar XHR = new XHRConnection();\n\t      \t\tXHR.appendData('country',document.getElementById('ntpd_servers_choosen').value);\n\t      \t\tXHR.appendData('timezones',document.getElementById('timezones{$t}').value);\n\t      \t\tAnimateDiv('serverlist');\n\t      \t\tXHR.sendAndLoad('{$page}', 'POST',X_ntpd_choose_server);    \n\t\t\t}\n\t \t\t\n\t\tvar X_ntpd_choose_server= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){alert(results);}\n\t\t\tRefreshTab('ntpd_main_config');\n\t\t\t}\t\t\n\t\t\n\t\n\t \t\t\n\t \t</script>\n\t\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body("{$entete}{$form}");
}