goahead服务器在网页请求之前向网页发送数据

我爱c语言 发布于 2014/08/13 14:38
阅读 1K+
收藏 0

代码如下:

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="/src/jquery-1.8.1.min.js?v=3039"></script>
<script type="text/javascript" src="/src/jquery.artDialog.js?skin=blueskin"></script>
<script type="text/javascript" src="/src/jquery.autocomplete.js?v=3039"></script>
<script type="text/javascript" src="/src/jquery.autocomplete.data.js?v=3039"></script>
<script type="text/javascript" src="/src/jquery.cookie.min.js?v=3039"></script>
<script type="text/javascript" src="/src/interface.js?v=3039"></script>
<script type="text/javascript" src="/src/iframeTools.source.js?v=3039"></script>
<script type="text/javascript" src="/src/util.js?v=3039"></script>
<script type="text/javascript" src="/lang/b28n.js"></script>
<link rel="stylesheet" href="/style/style.css?v=3039" type="text/css">


<script language="JavaScript" type="text/javascript">
Butterlate.setTextDomain("admin");


var http_request = false;


function style_display_on()
{
if (window.ActiveXObject)
{ // IE
return "block";
}
else if (window.XMLHttpRequest)
{ // Mozilla, Safari,...
return "table-row";
}
}


function makeRequest(url, content) {
    http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = alertContents;
    http_request.open('POST', url, true);
    http_request.send(content);
}


function alertContents() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
// refresh
window.location.reload();
        } else {
            alert('There was a problem with the request.');
        }
    }
}






function atoi(str, num)
{
    i=1;
    if(num != 1 ){
        while (i != num && str.length != 0){
            if(str.charAt(0) == '.'){
                i++;
            }
            str = str.substring(1);
        }
        if(i != num )
            return -1;
    }


    for(i=0; i<str.length; i++){
        if(str.charAt(i) == '.'){
            str = str.substring(0, i);
            break;
        }
    }
    if(str.length == 0)
        return -1;
    return parseInt(str, 10);
}


function isAllNum(str)
{
for (var i=0; i<str.length; i++){
   if((str.charAt(i) >= '0' && str.charAt(i) <= '9') || (str.charAt(i) == '.' ))
continue;
return 0;
}
return 1;
}






function NTPFormCheck()
{
document.cookie="language="+document.NTP.langSelection.value+"; path=/";
window.parent.location.reload();
return true;
}






function disableTextField (field)
{
  if(document.all || document.getElementById){
    field.disabled = true;
  }else {
    field.oldOnFocus = field.onfocus;
    field.onfocus = skip;
  }
}


function enableTextField (field)
{
  if(document.all || document.getElementById)
    field.disabled = false;
  else {
    field.onfocus = field.oldOnFocus;
  }
}


function update()
{
var isneedupdate = "<% isneedupgrade(); %>";
if(isneedupdate == "0"){
alert("it is the newest version. need not to update");
return true;
}
else{
art.dialog.open("../phone/netset/ap_upgrade2.asp",{id:"func_box", title:"",width:300, height:100, lock:true,cancel: false});
window.UploadFirmware.action = "/goform/upgrade";
return true;
}
return false;
}




function initTranslation()
{
var e = document.getElementById("manTitle");
e.innerHTML = _("man title");


e = document.getElementById("manSelectLang");
e.innerHTML = _("man select language");


e = document.getElementById("manNTPTimeZone");
e.innerHTML = _("man ntp timezone");
e = document.getElementById("manNTPMidIsland");
e.innerHTML = _("man ntp mid island");
e = document.getElementById("manNTPHawaii");
e.innerHTML = _("man ntp hawaii");
e = document.getElementById("manNTPAlaska");
e.innerHTML = _("man ntp alaska");
e = document.getElementById("manNTPPacific");
e.innerHTML = _("man ntp pacific");
e = document.getElementById("manNTPMountain");
e.innerHTML = _("man ntp mountain");
e = document.getElementById("manNTPArizona");
e.innerHTML = _("man ntp arizona");
e = document.getElementById("manNTPCentral");
e.innerHTML = _("man ntp central");
e = document.getElementById("manNTPMidUS");
e.innerHTML = _("man ntp mid us");
e = document.getElementById("manNTPIndianaEast");
e.innerHTML = _("man ntp indiana east");
e = document.getElementById("manNTPEastern");
e.innerHTML = _("man ntp eastern");
e = document.getElementById("manNTPAtlantic");
e.innerHTML = _("man ntp atlantic");
e = document.getElementById("manNTPBolivia");
e.innerHTML = _("man ntp bolivia");
e = document.getElementById("manNTPGuyana");
e.innerHTML = _("man ntp guyana");
e = document.getElementById("manNTPBrazilEast");
e.innerHTML = _("man ntp brazil east");
e = document.getElementById("manNTPMidAtlantic");
e.innerHTML = _("man ntp mid atlantic");
e = document.getElementById("manNTPAzoresIslands");
e.innerHTML = _("man ntp azores islands");
e = document.getElementById("manNTPGambia");
e.innerHTML = _("man ntp gambia");
e = document.getElementById("manNTPEngland");
e.innerHTML = _("man ntp england");
e = document.getElementById("manNTPCzechRepublic");
e.innerHTML = _("man ntp czech republic");
e = document.getElementById("manNTPGermany");
e.innerHTML = _("man ntp germany");
e = document.getElementById("manNTPTunisia");
e.innerHTML = _("man ntp tunisia");
e = document.getElementById("manNTPGreece");
e.innerHTML = _("man ntp greece");
e = document.getElementById("manNTPSouthAfrica");
e.innerHTML = _("man ntp south africa");
e = document.getElementById("manNTPIraq");
e.innerHTML = _("man ntp iraq");
e = document.getElementById("manNTPMoscowWinter");
e.innerHTML = _("man ntp moscow winter");
e = document.getElementById("manNTPArmenia");
e.innerHTML = _("man ntp armenia");
e = document.getElementById("manNTPPakistan");
e.innerHTML = _("man ntp pakistan");
e = document.getElementById("manNTPBangladesh");
e.innerHTML = _("man ntp bangladesh");
e = document.getElementById("manNTPThailand");
e.innerHTML = _("man ntp thailand");
e = document.getElementById("manNTPChinaCoast");
e.innerHTML = _("man ntp chinacoast");
e = document.getElementById("manNTPSingapore");
e.innerHTML = _("man ntp singapore");
e = document.getElementById("manNTPAustraliaWA");
e.innerHTML = _("man ntp australia wa");
e = document.getElementById("manNTPJapan");
e.innerHTML = _("man ntp japan");
e = document.getElementById("manNTPKorean");
e.innerHTML = _("man ntp korean");
e = document.getElementById("manNTPGuam");
e.innerHTML = _("man ntp guam");
e = document.getElementById("manNTPAustraliaQLD");
e.innerHTML = _("man ntp australia qld");
e = document.getElementById("manNTPSolomonIslands");
e.innerHTML = _("man ntp solomon islands");
e = document.getElementById("manNTPFiji");
e.innerHTML = _("man ntp fiji");
e = document.getElementById("manNTPNewZealand");
e.innerHTML = _("man ntp newzealand");
e = document.getElementById("manNTPServer");
e.innerHTML = _("man ntp server");
e = document.getElementById("manNTPApply");
e.value = _("admin apply");
e = document.getElementById("manNTPCancel");
e.value = _("admin cancel");


e = document.getElementById("manNTPCurrentTime");
e.innerHTML = _("man ntp current time");
e = document.getElementById("manNTPSyncWithHost");
e.value = _("man ntp sync with host");


e = document.getElementById("upload");
e.innerHTML = _("upload");
e = document.getElementById("uploadFWApply");
e.value = _("upload apply");


e = document.getElementById("setmanLoadFactDefaultButton");
e.innerHTML = _("setman load factory default button");
e = document.getElementById("setmanLoadDefault");
e.value = _("setman load default");


}


function initValue()
{
var tz = "<% getCfgGeneral(1, "TZ"); %>";
var ddns_provider = "<% getCfgGeneral(1, "DDNSProvider"); %>";
var lang_element = document.getElementById("langSelection");
var lang_en = "<% getLangBuilt("en"); %>";
var lang_zhtw = "<% getLangBuilt("zhtw"); %>";
var lang_zhcn = "<% getLangBuilt("zhcn"); %>";
var dateb = "<% getDATEBuilt(); %>";
initTranslation();
lang_element.options.length = 0;
if (lang_en == "1")
lang_element.options[lang_element.length] = new Option('English', 'en');
if (lang_zhcn == "1")
lang_element.options[lang_element.length] = new Option('简体中文', 'zhcn');




if (document.cookie.length > 0) {
var s = document.cookie.indexOf("language=");
var e = document.cookie.indexOf(";", s);
var lang = "en";
var i;


if (s != -1) {
if (e == -1)
lang = document.cookie.substring(s+9);
else
lang = document.cookie.substring(s+9, e);
}
for (i=0; i<lang_element.options.length; i++) {
if (lang == lang_element.options[i].value) {
lang_element.options.selectedIndex = i;
break;
}
}
}


if (tz == "UCT_-11")
document.NTP.time_zone.options.selectedIndex = 0;
else if (tz == "UCT_-10")
document.NTP.time_zone.options.selectedIndex = 1;
else if (tz == "NAS_-09")
document.NTP.time_zone.options.selectedIndex = 2;
else if (tz == "PST_-08")
document.NTP.time_zone.options.selectedIndex = 3;
else if (tz == "MST_-07")
document.NTP.time_zone.options.selectedIndex = 4;
else if (tz == "MST_-07")
document.NTP.time_zone.options.selectedIndex = 5;
else if (tz == "CST_-06")
document.NTP.time_zone.options.selectedIndex = 6;
else if (tz == "UCT_-06")
document.NTP.time_zone.options.selectedIndex = 7;
else if (tz == "UCT_-05")
document.NTP.time_zone.options.selectedIndex = 8;
else if (tz == "EST_-05")
document.NTP.time_zone.options.selectedIndex = 9;
else if (tz == "AST_-04")
document.NTP.time_zone.options.selectedIndex = 10;
else if (tz == "UCT_-04")
document.NTP.time_zone.options.selectedIndex = 11;
else if (tz == "UCT_-03")
document.NTP.time_zone.options.selectedIndex = 12;
else if (tz == "EBS_-03")
document.NTP.time_zone.options.selectedIndex = 13;
else if (tz == "NOR_-02")
document.NTP.time_zone.options.selectedIndex = 14;
else if (tz == "EUT_-01")
document.NTP.time_zone.options.selectedIndex = 15;
else if (tz == "UCT_000")
document.NTP.time_zone.options.selectedIndex = 16;
else if (tz == "GMT_000")
document.NTP.time_zone.options.selectedIndex = 17;
else if (tz == "MET_001")
document.NTP.time_zone.options.selectedIndex = 18;
else if (tz == "MEZ_001")
document.NTP.time_zone.options.selectedIndex = 19;
else if (tz == "UCT_001")
document.NTP.time_zone.options.selectedIndex = 20;
else if (tz == "EET_002")
document.NTP.time_zone.options.selectedIndex = 21;
else if (tz == "SAS_002")
document.NTP.time_zone.options.selectedIndex = 22;
else if (tz == "IST_003")
document.NTP.time_zone.options.selectedIndex = 23;
else if (tz == "MSK_003")
document.NTP.time_zone.options.selectedIndex = 24;
else if (tz == "UCT_004")
document.NTP.time_zone.options.selectedIndex = 25;
else if (tz == "UCT_005")
document.NTP.time_zone.options.selectedIndex = 26;
else if (tz == "UCT_006")
document.NTP.time_zone.options.selectedIndex = 27;
else if (tz == "UCT_007")
document.NTP.time_zone.options.selectedIndex = 28;
else if (tz == "CST_008")
document.NTP.time_zone.options.selectedIndex = 29;
else if (tz == "SST_008")
document.NTP.time_zone.options.selectedIndex = 30;
else if (tz == "AWS_008")
document.NTP.time_zone.options.selectedIndex = 31;
else if (tz == "JST_009")
document.NTP.time_zone.options.selectedIndex = 32;
else if (tz == "KST_009")
document.NTP.time_zone.options.selectedIndex = 33;
else if (tz == "UCT_010")
document.NTP.time_zone.options.selectedIndex = 34;
else if (tz == "AES_010")
document.NTP.time_zone.options.selectedIndex = 35;
else if (tz == "UCT_011")
document.NTP.time_zone.options.selectedIndex = 36;
else if (tz == "UCT_012")
document.NTP.time_zone.options.selectedIndex = 37;
else if (tz == "NZS_012")
document.NTP.time_zone.options.selectedIndex = 38;
}


function firm()
{
if(confirm("是否确定恢复出厂设置")){
document.LoadDefaultSettings.action="/goform/LoadDefaultSettings";
alert("恢复出厂设置将导致系统重启,如需再次登陆设置界面,请耐心等待其重启完成");
window.parent.location.href="../login.asp";
}
else{
}
}


function syncWithHost()
{
var currentTime = new Date();


var seconds = currentTime.getSeconds();
var minutes = currentTime.getMinutes();
var hours = currentTime.getHours();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();


var seconds_str = " ";
var minutes_str = " ";
var hours_str = " ";
var month_str = " ";
var day_str = " ";
var year_str = " ";


if(seconds < 10)
seconds_str = "0" + seconds;
else
seconds_str = ""+seconds;


if(minutes < 10)
minutes_str = "0" + minutes;
else
minutes_str = ""+minutes;


if(hours < 10)
hours_str = "0" + hours;
else
hours_str = ""+hours;


if(month < 10)
month_str = "0" + month;
else
month_str = ""+month;


if(day < 10)
day_str = "0" + day;
else
day_str = day;


var tmp = month_str + day_str + hours_str + minutes_str + year + " ";
makeRequest("/goform/NTPSyncWithHost", tmp);
}
</script>
</head>


<body onload="initValue()">
<div class="title" style="width:580">
<h1 id="manTitle">System Management</h1>
</div>
<div class="sheet">
<!-- ================= Langauge and NTP Settings ================= -->
<ul class="unit">
<form method="post" name="NTP" action="/goform/NTP_language">
  <table width="500">
  <tr height="30px">
<td id="manSelectLang">Select Language</td>
      <td align=left><select name="langSelection" id="langSelection">
        <!-- added by initValue -->
      </select><td>
  </tr>
 <tr height="30px">
<td id="manNTPCurrentTime">Current Time</td>
<td align=left>
<input size="24" name="ntpcurrenttime" value="<% getCurrentTimeASP(); %>" type="text" readonly="1" style="width:200px">
<input type="button" value="Sync with host" id="manNTPSyncWithHost" name="manNTPSyncWithHost" onClick="syncWithHost()">
</td>
</tr>
<tr height="30px">
  <td id="manNTPTimeZone">Time Zone:</td>
    <td align=left><select name="time_zone" style="width:200px"> 
      <option value="UCT_-11" id="manNTPMidIsland">(GMT-11:00) Midway Island, Samoa</option>
      <option value="UCT_-10" id="manNTPHawaii">(GMT-10:00) Hawaii</option>
      <option value="NAS_-09" id="manNTPAlaska">(GMT-09:00) Alaska</option>
      <option value="PST_-08" id="manNTPPacific">(GMT-08:00) Pacific Time</option>
      <option value="MST_-07" id="manNTPMountain">(GMT-07:00) Mountain Time</option>
      <option value="MST_-07" id="manNTPArizona">(GMT-07:00) Arizona</option>
      <option value="CST_-06" id="manNTPCentral">(GMT-06:00) Central Time</option>
      <option value="UCT_-06" id="manNTPMidUS">(GMT-06:00) Middle America</option>
      <option value="UCT_-05" id="manNTPIndianaEast">(GMT-05:00) Indiana East, Colombia</option>
      <option value="EST_-05" id="manNTPEastern">(GMT-05:00) Eastern Time</option>
      <option value="AST_-04" id="manNTPAtlantic">(GMT-04:00) Atlantic Time, Brazil West</option>
      <option value="UCT_-04" id="manNTPBolivia">(GMT-04:00) Bolivia, Venezuela</option>
      <option value="UCT_-03" id="manNTPGuyana">(GMT-03:00) Guyana</option>
      <option value="EBS_-03" id="manNTPBrazilEast">(GMT-03:00) Brazil East, Greenland</option>
      <option value="NOR_-02" id="manNTPMidAtlantic">(GMT-02:00) Mid-Atlantic</option>
      <option value="EUT_-01" id="manNTPAzoresIslands">(GMT-01:00) Azores Islands</option>
      <option value="UCT_000" id="manNTPGambia">(GMT) Gambia, Liberia, Morocco</option>
      <option value="GMT_000" id="manNTPEngland">(GMT) England</option>
      <option value="MET_001" id="manNTPCzechRepublic">(GMT+01:00) Czech Republic, N</option>
      <option value="MEZ_001" id="manNTPGermany">(GMT+01:00) Germany</option>
      <option value="UCT_001" id="manNTPTunisia">(GMT+01:00) Tunisia</option>
      <option value="EET_002" id="manNTPGreece">(GMT+02:00) Greece, Ukraine, Turkey</option>
      <option value="SAS_002" id="manNTPSouthAfrica">(GMT+02:00) South Africa</option>
      <option value="IST_003" id="manNTPIraq">(GMT+03:00) Iraq, Jordan, Kuwait</option>
      <option value="MSK_003" id="manNTPMoscowWinter">(GMT+03:00) Moscow Winter Time</option>
      <option value="UCT_004" id="manNTPArmenia">(GMT+04:00) Armenia</option>
      <option value="UCT_005" id="manNTPPakistan">(GMT+05:00) Pakistan, Russia</option>
      <option value="UCT_006" id="manNTPBangladesh">(GMT+06:00) Bangladesh, Russia</option>
      <option value="UCT_007" id="manNTPThailand">(GMT+07:00) Thailand, Russia</option>
      <option value="CST_008" id="manNTPChinaCoast">(GMT+08:00) beijing</option>
      <option value="SST_008" id="manNTPSingapore">(GMT+08:00) Singapore</option>
      <option value="AWS_008" id="manNTPAustraliaWA">(GMT+08:00) Australia (WA)</option>
      <option value="JST_009" id="manNTPJapan">(GMT+09:00) Japan, Korea</option>
      <option value="KST_009" id="manNTPKorean">(GMT+09:00) Korean</option>
      <option value="UCT_010" id="manNTPGuam">(GMT+10:00) Guam, Russia</option>
      <option value="AES_010" id="manNTPAustraliaQLD">(GMT+10:00) Australia (QLD, TAS,NSW,ACT,VIC)</option>
      <option value="UCT_011" id="manNTPSolomonIslands">(GMT+11:00) Solomon Islands</option>
      <option value="UCT_012" id="manNTPFiji">(GMT+12:00) Fiji</option>
      <option value="NZS_012" id="manNTPNewZealand">(GMT+12:00) New Zealand</option>
    </select></td>
</tr>
<tr height="30px">
  <td id="manNTPServer">NTP Server</td>
  <td><input size="32" maxlength="64" name="NTPServerIP" value="<% getCfgGeneral(1, "NTPServerIP"); %>" type="text" style="width:200px">
</td>
</tr>
</table>
<table  width="300" border="0" cellspacing="0" cellpadding="0">
<tr align=center height="50px">
<td align=center>
     <input type=submit style="{width:120px;}" value="Apply" id="manNTPApply" onClick="return NTPFormCheck()"> &nbsp; &nbsp;
     <input type=reset  style="{width:120px;}" value="Cancel"id="manNTPCancel" onClick="art.dialog.close();">
</td>
</tr>
</table>
</form>
</ul>
<ul class="unit">
<form method="post" name="UploadFirmware" action="">
<table>
<tr height="30px">
<td id="upload" width="130px">upload</td>
<td align=left>
<input value="Apply" id="uploadFWApply" name="UploadFirmwareSubmit" type="submit" style="{width:120px;}" onClick="update();">
</td>
</tr>
</table>
</form>
</ul>
<ul class="unit">
<form method="post" name="LoadDefaultSettings" action="" >
<table>
<tr height="30px">
<td id="setmanLoadFactDefaultButton">Load Factory Defaults</td>
<td><input value="Load Default" id="setmanLoadDefault" name="LoadDefault" style="{width:120px;}" type="submit" onClick="firm()"></td>
</tr>
</table>
</form>
</ul>
</div>
</body></html>


其中的var isneedupdate = "<% isneedupgrade(); %>";本应该在点击确认后执行,可我刷新这个页面时就会执行isneedupgrade()这个函数,但update()这个函数不会执行,这是为什么?isneedupgrade()是goahead中的c语言函数。

加载中
0
福尔饺斯
福尔饺斯

e.value = _("setman load default"); 

为什么后面要用 一个 _("")这个  来把内容括起来!!!!

返回顶部
顶部