首页 | 心情日记 | 建站心得 | 编程技术 | 大盘分析 | 股市信息 | 学习园地 | 电脑技巧 | 物流外贸 | 另类其它 | 站长推荐 | 给我留言 | 相册

用户登陆
用户:
密码:
 
不保存保存一天
保存一月保存一年

站点日历
73 2024 - 4 48
 123456
78910111213
14151617181920
21222324252627
282930


站点统计

最新评论

日志搜索

 标题   内容


ASP过滤禁止注册的用户名,ASP过滤特殊字符号 Utf-8和Gb2312乱码问题的终结
未知 ASP-批量生成静态页面源代码   [ 日期:2009-12-17 10:43:46 ]   [ 来自:本站原创 ]

海外邮件中继,海外退信中继,美国高速VPS,不限流量VPN,邮局维护和管理,邮件网关,EMOS邮件中继,POSTFIX邮件中继,Winwebmail邮件中继,Winmail邮件中继,DBMail邮件中继,JDMail邮件中继,Exchange邮件中继,MDaemon邮件中继 淘宝店:http://shantan.taobao.com 云邮科技官网:www.yunrelay.com

【字体设置:
批量生成静态页面 
1 info_html.asp 
2 info_html_sure.asp 


info_html.asp 
========================================================= 
<%if session("admin")="" then 
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆!');window.location.href='login.asp';</script>" 
response.End 
else 
if session("flag")>1 then 
response.Write "<p align=center><font color=red>您没有此项目管理权限!</font></p>" 
response.End 
end if 
end if 
%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>批量生成静态页面----进度条</title> 

<style> 
div,body{font-size:12px} 
#load{z-index:1;width:500px;height:11px;border:1px #82AF2C solid;} 
#loading{position:absolute;z-index:2;height:11px; background-color:#B4C96B; overflow:hidden;} 
#div1{position:absolute;z-index:3;width:100%;height:100%;line-height:13px;text-align:center;} 
.red_font {color: #FF0000} 
.green_font {color: #669900} 
</style> 
</head> 

<body> 


<script language="javascript"> 
//创建XMLHttpRequest对象 
var temp_id; 
var request = false; 
try { 
request = new XMLHttpRequest(); 

catch (trymicrosoft) { 
try { 
request = new ActiveXObject("Msxml2.XMLHTTP"); 

catch (othermicrosoft) { 
try { 
request = new ActiveXObject("Microsoft.XMLHTTP"); 

catch (failed) { 
request = false; 



if (!request)alert("Error initializing XMLHttpRequest!"); 
//获取信息 
function kaishi(btn) 

btn.disabled = true; 
btn.value = "批量生成中.."; 
document.bg.location.href="info_html_sure.asp"; 
temp_id=setInterval("getInfo()",1000) 
document.getElementById("tong_ji").style.display=""; 


function stop_read() 

clearInterval(temp_id); 
document.getElementById("btn").value="开始批量生成静态页面"; 
document.getElementById("btn").disabled= false; 

function getInfo() { 
var url = "/news_html.txt?id=" + Math.random(); 
request.open("GET", url, true); 
request.onreadystatechange = updatePage; 
request.send(null); 

//更新页面 
function updatePage() { 
if (request.readyState == 4) { 
if (request.status == 200) { 
var response = request.responseText.split(","); 

document.getElementById("div1").innerText = response[0]; 
document.getElementById("loading").style.width = response[0]; 
document.getElementById("now_page").innerText = response[1]; 
document.getElementById("all_page").innerText = response[2]; 
if(response[0]=="100.00%") 

stop_read(); 



else if(request.status == 404) { 
alert ("Requested URL is not found."); 

else if (request.status == 403) { 
alert("Access denied."); 

else 
alert("status is " + request.status); 


</script> 


<table width="511" border="0" align="center" cellpadding="0" cellspacing="0"> 
<tr> 
<td width="511" height="50"> </td> 
</tr> 

<tr> 
<td height="96">  <div id="load"><div id="loading"></div><div id="div1"> </div> 
</div></td> 
</tr> 
<tr> 
<td height="75" align="center" valign="top" class="green_font" id="tong_ji" style="display:none">已生成 <span class="red_font" id="now_page"> </span> 页静态页面,共 <span class="red_font" id="all_page"> </span> 页需要生成。</td> 
</tr> 
<tr> 
<td height="30" align="center"><input name="btn" style="border:1px solid #333333;height:25px" type="button" id="btn" value="开始批量生成静态页面" onclick="kaishi(this);" /></td> 
</tr> 
<tr> 
<td height="150" align="center"> </td> 
</tr> 
</table> 
<iframe width="0" height="0" id="bg" name="bg" ></iframe> 
</body> 
</html> 


info_html_sure.asp 
================================================================== 
<% 
if session("admin")="" then 
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆!');window.location.href='login.asp';</script>" 
response.End 
else 
if session("flag")>1 then 
response.Write "<p align=center><font color=red>您没有此项目管理权限!</font></p>" 
response.End 
end if 
end if 


session("help")=int((10-1+1)*Rnd + 1) 
server.ScriptTimeout=9999 
function getHTTPPage(url) 
dim Http 
set Http=server.createobject("MSXML2.XMLHTTP") 
Http.open "GET",url,false 
Http.send() 
if Http.readystate<>4 then 
exit function 
end if 
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312") 
set http=nothing 
if err.number<>0 then err.Clear 
end function 
'''''''''''''''''''''''''''''''''' 
Function BytesToBstr(body,Cset) 
dim objstream 
set objstream = Server.CreateObject("adodb.stream") 
objstream.Type = 1 
objstream.Mode =3 
objstream.Open 
objstream.Write body 
objstream.Position = 0 
objstream.Type = 2 
objstream.Charset = Cset 
BytesToBstr = objstream.ReadText 
objstream.Close 
set objstream = nothing 
End Function 
''''''''''''''''''''这里是conn对象打开数据库的动作,asp代码需要自己改造,本文不作解释''''''''' 
set conn=server.createobject("adodb.connection") 
str="Driver={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath("/")&"/datec/#mtccc.asp" 
conn.open str 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
set tp=server.CreateObject("adodb.recordset") 
tp.open "select newsid from inform",conn,1,1 
if not tp.bof and not tp.eof then 
for ixi=1 to tp.recordcount 
if not tp.bof and not tp.eof then 
call make_html(tp("newsid")) 
''''''''''''''''''''''在此往gaga.txt文件写入进度信息''''''''''''''''''''''''''''''''''''''''' 
set temp_fso=Server.CreateObject("Scripting.FileSystemObject") 
Set temp_file=temp_fso.OpenTextfile(server.MapPath("/")&"/news_html.txt",2,true) 'true为不存在自行建立 
temp_file.writeline(formatnumber((ixi/tp.recordcount)*100,2)&"%,"&ixi&","&tp.recordcount) 
Set temp_file=nothing 
''''''''''''''''''''''''''''将这些信息以逗号连接在一起,ajax读取后js再分开''''''''''''' 
tp.movenext 
else 
exit for 
end if 
next 

end if 
tp.close 
set tp=nothing 
function make_html(chuan_id) 
temp_id=chuan_id 
set rs=server.CreateObject("adodb.recordset") 
rs.open "select * from inform where newsid="&temp_id,conn,1,1 
if not rs.bof and not rs.eof then 

'''''''''''''''''''此处是要生成的静态页的地址'''''''''''''''''''''''''''''''''''''''''' 
txtURL="http://"&Request.ServerVariables("server_name")&"/info_html_jt.asp?id="&temp_id 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
sText = getHTTPPage(txtURL) 
Set FileObject=Server.CreateObject("Scripting.FileSystemObject") 
filename=server.MapPath("/")&"/news/info_"&temp_id&".html" 

Set openFile=FileObject.OpenTextfile(filename,2,true) 'true为不存在自行建立 
openFile.writeline(sText) 
Set OpenFile=nothing 
rs.close 
set rs=nothing 
end if 
end function 
function checksql(kustr) 
checksql=server.htmlencode(replace(replace(replace(kustr,"<>"," "),"* from "," "),"="," ")) 
end function 
%>


暂时没有评论
   发表评论 - 不要忘了输入验证码哦!
作者: 用户:  密码:  我要注册 验证码: 
为防止广告注册机程序,验证码不会自动显示,请点击此处显示或者(刷新)验证码!
评论:

禁止表情
禁止UBB
禁止图片
识别链接
识别关键字
确定发布?
最多可以输入200个字,目前你已经输入了0个字;你今日还可以发表10条评论!
 
   

CopyRight © 2008-2010 广东金融学院030904班 All Rights Reserved
Powered by www.030904.com