正文

asp自动生成静态页面代码2007-07-10 08:43:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/sovf/27432.html

分享到:

<!--#include virtual="/Admin/include/ConnOpen.Inc"--><%'上边这个是导入的数据库连接文件timer1=timerset xmlhttp=server.CreateObject("Microsoft.XMLHTTP")set ado=Server.CreateObject("ADODB.Stream")Set FSO = CreateObject("Scripting.FileSystemObject")set rs=server.CreateObject("adodb.recordset")servername=Request.ServerVariables("HTTP_HOST") '这里是需要生成页面站点的名称'response.write servernametypex=trim(request("type"))%><html><head><title>生成静态页面 by greatsolon</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><style type="text/css"><!--body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px;}body,td,th { font-size: 12px;}.scroll_bar { border: 1px solid #0080BD; background-color: #FFFEF2;}.input1 { border-bottom-width: 1px; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-bottom-color: #999999; line-height: 14px; height: 14px;}#line_bar { position: absolute; height: 12px; width: 100%; font-weight: bold;}.img_bar { filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr='#CEDFF6', endColorStr='#4B92D9', gradientType='1') background-color: #0198D1;}a:link { color: #666666; text-decoration: none;}a:visited { text-decoration: none; color: #999999;}a:hover { text-decoration: underline; color: #999999;}a:active { text-decoration: none; color: #CCCCCC;}--></style><%if typex="date" then%><script language="javascript" src="calendar.js"></script><%end if%></head><body><%idx=trim(saferequest("id",1))num=trim(request("num"))startx=trim(saferequest("startx",0))endx=trim(saferequest("endx",0))list=trim(saferequest("list",1))iner=trim(saferequest("iner",0))createnum=trim(saferequest("createnum",1))if createnum="" then createnum=0if not isnumeric(num) then num=""if num="" and createnum=0 and request("action")="create" Thensql="select tbnc_CMSarticle.article_id,tbnc_CMSarticle.isnew,tbnc_CMSarticle.Article_inputer,tbnc_CMScolumn.column_layer,tbnc_CMScolumn.column_name, tbnc_CMScolumn.column_id, tbnc_CMSarticle.Column_id AS Expr1, tbnc_CMSarticle.Article_datetime FROM tbnc_CMSarticle INNER JOIN tbnc_CMScolumn ON tbnc_CMSarticle.Column_id = tbnc_CMScolumn.column_id" sql=sql & " where 1=1" if idx<>"" then  sql=sql & " and tbnc_CMSarticle.article_id>=" & idx end if if iner<>"" then  sql=sql & " and tbnc_CMSarticle.Article_inputer='" & iner & "'" end if sql=sql & " ORDER BY tbnc_CMSarticle.Article_id" rs.open sql,conn,1,1 if not rs.eof and not rs.bof then  num=clng(rs.recordcount) else  num=1 end if rs.close()end ifif trim(request("action"))="create"thenif request("ci")="1" thenif num<>createnum then if typex<>"date" then  sql="select top 1 tbnc_CMSarticle.article_title,tbnc_CMSarticle.isnew,tbnc_CMSarticle.Article_inputer,tbnc_CMScolumn.column_layer, tbnc_CMSarticle.Article_id,tbnc_CMScolumn.column_name, tbnc_CMScolumn.column_id, tbnc_CMSarticle.Column_id AS Expr1, tbnc_CMSarticle.Article_datetime FROM tbnc_CMSarticle INNER JOIN tbnc_CMScolumn ON tbnc_CMSarticle.Column_id = tbnc_CMScolumn.column_id"  sql=sql & " where 1=1"  if idx<>"" then   if createnum=0 then    sql=sql & " and tbnc_CMSarticle.article_id>=" & idx   else    sql=sql & " and tbnc_CMSarticle.article_id>" & idx   end if  end if  if iner<>"" then   sql=sql & " and tbnc_CMSarticle.Article_inputer='" & iner & "'"  end if  sql=sql & " ORDER BY tbnc_CMSarticle.Article_id" end if 'response.Write sql 'response.End() rs.open sql,conn,1,1 if not rs.eof and not rs.bof then  title=trim(rs("Article_title"))  layer=trim(rs("column_layer"))  id=trim(rs("Article_id"))  column_id=trim(rs("column_id"))  namex=trim(rs("column_name"))  da=year(trim(rs("article_datetime"))) & "-" & month(trim(rs("article_datetime")))  if trim(rs("isnew"))=1 then   call checkpath(server.MapPath("/newpage"))   call checkpath(server.MapPath("/newpage/" & da))   call checkpath(server.MapPath("/newpage/" & da & "/" & column_id))   path=da & "/" & column_id  else   path=""  end if  pathx="/newpage/" & path & "/" & id & ".htm"  strUrl = "http://" & servername & "/list.asp?id=" & id & "&column_id=" & column_id & "&column_layer=" & layer & "&column_name=" & namex  'response.Write strUrl  'response.End()  call creatPage(id,strUrl,path)  createnum=createnum+1  lastid=id else  createnum=createnum+1  lastid=idx end if  set xmlhttp=nothing set ado=nothing Conn.Close Set Conn=Nothingend ifelse if typex="date" then  sql="SELECT"  if num<>"" then   sql=sql & " top " & num  end if  sql=sql & " tbnc_CMSarticle.isnew,tbnc_CMSarticle.Article_inputer,tbnc_CMScolumn.column_layer, tbnc_CMSarticle.Article_id,tbnc_CMScolumn.column_name, tbnc_CMScolumn.column_id, tbnc_CMSarticle.Column_id AS Expr1, tbnc_CMSarticle.Article_datetime FROM tbnc_CMSarticle INNER JOIN tbnc_CMScolumn ON tbnc_CMSarticle.Column_id = tbnc_CMScolumn.column_id"  if startx<>"" or endx<>"" or list<>"" or iner<>"" then   sql=sql & " where"  end if  if startx<>"" then   sql=sql & " tbnc_CMSarticle.Article_datetime>='" & startx & "'"  end if  if startx<>"" and endx<>"" then   sql=sql & " and tbnc_CMSarticle.Article_datetime<='" & endx & "'"  elseif startx="" and endx<>"" then   sql=sql & " tbnc_CMSarticle.Article_datetime<='" & endx & "'"  end if  if iner<>"" and (startx<>"" or endx<>"") then   sql=sql & " and tbnc_CMSarticle.Article_inputer='" & iner & "'"  elseif iner<>"" and startx="" and endx="" then   sql=sql & " tbnc_CMSarticle.Article_inputer='" & iner & "'"  end if  if list<>"0" and (startx<>"" or endx<>"" or iner<>"") then   sql=sql & " and tbnc_CMScolumn.column_id='" & list & "'"  elseif list<>"0" and startx="" and endx="" and iner="" then   sql=sql & " tbnc_CMScolumn.column_id='" & list & "'"  end if  sql=sql & " ORDER BY tbnc_CMSarticle.Article_datetime" else  sql="SELECT"  if num<>"" then   sql=sql & " top " & num  end if  sql=sql & " tbnc_CMSarticle.Article_datetime,tbnc_CMSarticle.isnew,tbnc_CMSarticle.Article_inputer,tbnc_CMScolumn.column_layer, tbnc_CMSarticle.Article_id, tbnc_CMScolumn.column_name, tbnc_CMScolumn.column_id, tbnc_CMSarticle.Column_id AS Expr1 FROM tbnc_CMSarticle INNER JOIN tbnc_CMScolumn ON tbnc_CMSarticle.Column_id = tbnc_CMScolumn.column_id"  if idx<>"" or iner<>"" then   sql=sql & " where"  end if  if idx<>"" then   sql=sql & " tbnc_CMSarticle.Article_id>='" & idx & "'"  end if  if idx<>"" and iner<>"" then   sql=sql & " and tbnc_CMSarticle.Article_inputer='" & iner & "'"  elseif idx="" and iner<>"" then   sql=sql & " tbnc_CMSarticle.Article_inputer='" & iner & "'"  end if  sql=sql & " ORDER BY tbnc_CMSarticle.Article_id" end if 'response.Write sql 'response.End() rs.open sql,conn,1,1 do until rs.eof  layer=trim(rs("column_layer"))  id=trim(rs("Article_id"))  column_id=trim(rs("column_id"))  namex=trim(rs("column_name"))  da=year(trim(rs("article_datetime"))) & "-" & month(trim(rs("article_datetime")))  if trim(rs("isnew"))=1 then   call checkpath(server.MapPath("/newpage"))   call checkpath(server.MapPath("/newpage/" & da))   call checkpath(server.MapPath("/newpage/" & da & "/" & column_id))   path=da & "/" & column_id  else   path=""  end if  strUrl = "http://" & servername & "/list.asp?id=" & id & "&column_id=" & column_id & "&column_layer=" & layer & "&column_name=" & namex  'response.Write strUrl  'response.End()  call creatPage(id,strUrl,path)  rs.movenext  createnum=createnum+1  lastid=id loop if typex="date" then  response.Write "<script language='javascript'>alert('生成成功!\n共生成了" & createnum & "个页面!');</script>" else  response.Write "<script language='javascript'>alert('生成成功!\n共生成了" & createnum & "个页面!');document.getElementById('id').value='" & lastid+1 & "';</script>" end if set xmlhttp=nothing set ado=nothing Conn.Close Set Conn=Nothingend ifend ifselect case typex case "date"  call orderDate() case ""  call orderId() case else  call orderId()end selectsub orderId()%><form action="?action=create" method="post" name="form1"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <% if request("ci")<>"1" then %>  <tr>    <td height="44" align="center"><a href="?">按id生成</a>&nbsp;&nbsp;<a href="?type=date">按日期生成</a></td>  </tr> <% end if %>  <tr>    <td align="center"> <% if request("ci")<>"1" then %> <table width="60%" border="0" cellspacing="0" cellpadding="0">      <tr>        <td align="center">导入人          <input name="iner" type="text" class="input1" id="iner" value="<%=request("iner")%>" size="8" />从id<input name="id" type="text" class="input1" id="id" value="<%=request("id")%>" size="8" />开始生成<input name="num" type="text" class="input1" id="num" value="<%=request("num")%>" size="8" />条<input name="ci" type="checkbox" id="ci" value="1">按次序生成</td>      </tr>    </table> <%end if%>      <br><%if request("ci")="1" thenline=abs(clng(createnum)/clng(num))*100line=formatnumber(line,2)if line<1 then line="0" & lineend if'response.Write line'response.End()%><table width="500" border="0" cellpadding="3" cellspacing="1" bgcolor="#E8E8E8">  <tr>    <td bordercolor="#FFFFFF" bgcolor="#FFFFFF">当前进度:      <%if num<>createnum then%>生成到第 <%=createnum%>/<%=num%> 条<br>当 前 ID:<input name="textfield" type="text" class="input1" value="<%=lastid%>" size="8"><br>文章标题:  [<font color="#4B92D9"><%=cutstr(title,60)%></font>]<br>生成路径: <a href="<%=pathx%>" target="_blank"><%=pathx%></a><%else%>生成完成![<a href="createpage.asp">返回</a>]<%end if%><br>完成时间: <%=year(now()) & "年" & month(now()) & "月" & day(now()) & "日 " & time()%> </td>  </tr>  <tr>    <td align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="scroll_bar">      <tr>        <td><div id="line_bar" align="center"><%=line%>%</div>        <table width="<%=line%>%" border="0" cellspacing="0" cellpadding="0">          <tr>            <td height="12" class="img_bar"></td>          </tr>        </table></td>      </tr>    </table></td>  </tr></table><%end if%></td>  </tr>  <tr>    <td height="39" align="center"><%if request("ci")<>"1" then%><input type="submit" name="Submit" value="生 成" /><%end if%></td>  </tr></table></form><%if request("ci")="1" and num<>createnum then response.Write "<script language='javascript'>location.replace('?action=create&ci=1&id=" & lastid & "&createnum=" & createnum & "&num=" & num & "&iner=" & iner & "');</script>"end ifend subsub orderDate()%><form action="?action=create&type=date" method="post" name="form1"><table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr>    <td height="44" align="center"><a href="?">按id生成</a>&nbsp;&nbsp;<a href="?type=date">按日期生成</a></td>  </tr>  <tr>    <td align="center">从      <INPUT name="startx" class="input1" id="startx" onFocus="this.select()" onClick="fPopCalendar(startx,startx);return false" size="10" readOnly="readOnly" mouseover="this.focus()">生成到<input name="endx" class="input1" id="endx" onFocus="this.select()" onClick="fPopCalendar(endx,endx);return false" size="10" readonly="readOnly" mouseover="this.focus()" />  导入人 <input name="iner" type="text" class="input1" id="iner" size="8" /> 按栏目 <select name="list">   <option value="0" selected>请选择</option>   <%sql="SELECT column_id, column_name FROM tbnc_CMScolumn order by column_id"rs.open sql,conn,1,1do until rs.eof%>   <option value="<%=trim(rs("column_id"))%>"><%=trim(rs("column_id"))%>-<%=trim(rs("column_name"))%></option>   <% rs.movenextlooprs.close()%> </select> 生成 <input name="num" type="text" class="input1" id="num" size="8" />条<br /><br />注:如果不选栏目或者导入人的话,可能会因为某天导入的数据量过大而使服务器当掉,请小心!</td>  </tr>  <tr>    <td height="39" align="center"><input type="submit" name="Submit" value="生 成" /></td>  </tr></table></form><%end sub%><div align="center"><%timer2 = timerthetime=cstr(int(((timer2-timer1)*10000 )+0.5)/10)%>页面执行时间:<%=thetime%> 毫秒</div></body></html><%sub creatPage(filename,strUrl,path)  xmlhttp.open "GET",strUrl,false  xmlhttp.send()  strHtml=xmlhttp.responseBody  if path<>"" then   FilePath=Server.mappath("/newpage/" & path & "/" & filename & ".htm")  else   FilePath=Server.mappath("/html/" & filename & ".htm")  end if  ado.type=1  ado.open()  ado.write(strHtml)  ado.SaveToFile FilePath,2  ado.close()end subsub checkPath(path) '检查目录是否存在,否则创建它 if not fso.FolderExists(path) then  fso.createFolder(path) end ifend subfunction CutStr(str,strlen) dim I,l,t,c l=len(str) t=0 for I=1 to l  c=Abs(Asc(Mid(str,i,1)))  if c>255 then   t=t+2  else   t=t+1  end if  if t>=strlen Then   If I<>l Then cutStr=left(str,i)&"..."   exit for  else   cutStr=str  end if nextend functionfunction saferequest(paraname,paratype)dim paravalueparavalue=request(paraname)if paratype=1 then  if not isnumeric(paravalue) then    response.write "variable <font color=red>" & paraname & "</font> must be number!"    response.write "Do not hack this page!Thank you!"    response.end  end ifelse paravalue=replace(paravalue,"&","&amp;") paravalue=replace(paravalue,"*","") paravalue=replace(paravalue,"<","&lt;") paravalue=replace(paravalue,"chr(34)","&quot;") paravalue=replace(paravalue,">","&gt;") paravalue=replace(paravalue,"#","") paravalue=replace(paravalue, "''", "‘") paravalue=replace(paravalue, """", "“")end ifsaferequest=paravalueend function%>

阅读(5709) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册