163k是.net开发 本人对.net不了解 索性写了一个asp的吧
php版本因为unicode的数据会乱码。
没写那么好 凑合写点简单的2次开发吧 功能也没写太详细写 这都是没办法逼的 163k封装的太严实了。
只可以做点简单的调用,完全的2次开发是不可能的。
案例: demo.asp
<!-- #include file="inc.asp" -->
dim news //取出数据 参考(163k数据结构)
set rss=conn.execute("SELECT top 8 newsid,chrtitle FROM "&t()&"News where iskill=1 and istop=0 AND (categoryid = 88) order by newsid desc ")
do while not rss.eof
news=news&"<li><A href='/article/article_"&rss("newsid")&".html' target='_blank'>"&rss("chrtitle")&"</A></li>"
rss.movenext
loop
set rss=nothing
Dim tp
Set tp = new tp_
'tp.cache "./asp_cache/live.html",86400 '调用缓存 300秒
tp.load "show.html" '加载模版
tp.ass "{$ckeywords}","生活信息" ' 替换标签
tp.ass "{$ctitle}","本地信息门户网站"
tp.ass "{$news$}",news
'tp.display '只输出
tp.html("./asp_cache/live.html") '输出 并生成html
show.html 模板
___________________________________________________________________________________________
<!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=utf-8" />
<title>{$ctitle}-{$SiteName}</title>
<meta name="keywords" content="{$ckeywords}" />
<link href="{$tplPath}skin/_newsList.css" type="text/css" rel="stylesheet" />
<link id="themecss" rel="stylesheet" rev="stylesheet" href="{$tplPath}skin/theme/theme1.css" type="text/css">
<script src="{$tplPath}js/common.js"></script>
<script type="text/javascript" src="{$tplPath}js/jquery.js"></script>
<script type="text/javascript" src="{$tplPath}js/rbtCss.js"></script>
</head>
<script>loadss();</script>
<body class="home-page" bgcolor="{$SiteColor}">
<div class="wrapper">
{$top$}
<!-- 主体 -->
<div id="content" class="clearfix">
<div class="col_main_danye">
<div class="newsShow">
<h2>{$chrtitle}</h2>
<div class="news_content">
<ul> {$news$}</ul>
</div> </div>
</div>
</div>
</div>
<!-- 主体 结束 -->
{$bottom$}
</div>
<script type="text/javascript" src="{$tplPath}js/n_scrll_top.js"></script>
<script type="text/javascript" src="{$tplPath}js/jquery.js"></script>
<script type="text/javascript" src="{$tplPath}js/font_change.js"></script>
</body>
</html>
____________________________________________________________________________________________
inc.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Session.CodePage=65001%>
<%Response.charset = "utf-8"%>
<% Response.Buffer = True %>
<%
dim host,user,pass,dbname,db_t,dir,dir_tp,FSObject
host="localhost"
user="sa"
pass="123123"
dbname=数据库名称"
db_t="mh163k_"
dir_tp="/template/default/tp/" '模板目录
%>
<!-- #include virtual="/asp/conn.asp" -->
<!-- #include virtual="/asp/fun.asp" -->
<!-- #include virtual="/asp/tp.asp" -->
asp/conn.asp '连接数据库
____________________________________________________________________________________
<%
connstr = "PROVIDER=SQLOLEDB.1;Data Source="&host&";Initial Catalog="&dbname&";Persist Security Info=True;User ID="&user&";Password="&pass&";Connect Timeout=60"
set Conn = Server.CreateObject("ADODB.Connection")
Conn.open connstr
If Err Then
echo("对不起,数据连接错误!<br/>")
End If
%>
asp/fun.asp '相关函数
____________________________________________________________________________________
<%
function echo(str) '输出
response.Write(str)
end function
function t() '表头
t=db_t
end function
function die() '停止
response.End()
end function
Function getHTML(File) '获取html
Dim objStream
On Error Resume Next
Set objStream = Server.CreateObject("ADODB.Stream")
If Err.Number=-2147221005 Then
Response.Write "<div align=center>非常遗憾,您的主机不支持ADODB.Stream,不能使用本程序</div>"
Err.Clear
Response.End
End If
With objStream
.Type = 2
.Mode = 3
.Open
.LoadFromFile Server.MapPath(File)
If Err.Number<>0 Then
Response.Write "<div align=center>文件<font color=#ff0000>"&File&"</font>无法被打开,请检查是否存在!</font></div>"
Err.Clear
Response.End
End If
.Charset = "UTF-8"
.Position = 2
getHTML= .ReadText
.Close
End With
Set objStream = Nothing
End Function
Function CheckFile(File) '检查某一文件是否存在
Dim fso
Filepath=Server.MapPath(File)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.FileExists(FilePath) then
CheckFile = True
Else
CheckFile = False
End if
Set fso = nothing
End Function
%>
asp/tp.asp '模板类 没仔细写 能解析循环的标签就好了。 如果你需要2次开发 写出来给我一份
____________________________________________________________________________________
<%
Class tp_
Public content
Public head
Public foot
Public rs_config
Public fso
Public nav
Private Sub Class_initialize
set fso=Server.CreateObject("Scripting.FileSystemObject")
set rs_config=conn.execute("SELECT * FROM "&t()&"config")
End Sub
Public Function load(filrname)
call head_()
call foot_()
content=getHTML(dir_tp&filrname)
content=replace(content,"{$top$}",head)
content=replace(content,"{$bottom$}",foot)
End Function
Public Function ass(s,v)
content=replace(content,s,v)
End Function
Public Function display()
content=replace(content,"{$SiteColor}",rs_config("SiteColor"))
content=replace(content,"{$SiteName}",rs_config("sitetitle"))
content=replace(content,"{$tplPath}","/template/default/")
response.Write(content)
End Function
Private Sub Class_Terminate
End Sub
Public Function head_()
dim top2,top1
top2="":top1=""
' if cstr(rs_config("headmoban"))="2" then //这里应该是根据程序设置 动态读取相应模板
' head=getHTML("\template\default\head\head2.html")
' else
' head=getHTML("\template\default\page_head.html")
' end if
head=getHTML(dir_tp&"\head.html")
head=replace(head,"{$HeadSiteUrl}","http://www.163.com/")
head=replace(head,"{$shouyecss}",1)
head=replace(head,"{$topurl}",rs_config("topurl"))
head=replace(head,"{$sitetel}",rs_config("sitetel"))
head=replace(head,"{$siteInfo}",rs_config("siteInfo"))
head=replace(head,"{$sitebiao}",rs_config("sitebiao"))
dim ii
ii=1
set rs_dh2=conn.execute("SELECT top 22 id,title,chrurl,styleid,isfont FROM "&t()&"daohang WHERE (isopen = 0) ORDER BY intorder,id")
do while not rs_dh2.eof
if ii=1 or ii=12 then clas=" class=""first"" " else clas=""
top2=top2&"<li "&clas&"><a href='"&rs_dh2("chrurl")&"' title='"&rs_dh2("title")&"'"
if rs_dh2("styleid")=0 then top2=top2&" target='_blank' "
top2=top2&">"
if rs_dh2("isfont")=1 then top2=top2&"<b>"
top2=top2&rs_dh2("title")
if rs_dh2("isfont")=1 then top2=top2&"</b>"
top2=top2&"</a></li>"
ii=ii+1
rs_dh2.movenext
loop
head=replace(head,"{$sitetopdaohang}",top2)
set rs_dh1=conn.execute("SELECT chrkind,chrurl FROM "&t()&"wangzhikind WHERE (styleid = 1) ORDER BY intorder")
do while not rs_dh1.eof
nstr=""
if nav=rs_dh1("chrurl") then nstr=" class=""current"" "
top1=top1&"<li ><a href='"&rs_dh1("chrurl")&"'><span "&nstr&">"&rs_dh1("chrkind")&"</span></a></li>" 'class='index'
rs_dh1.movenext
loop
head=replace(head,"{$menulist}",top1)
set rs_adt=conn.execute("SELECT top 1 indextouyou FROM "&t()&"adv_dingyi ")
head=replace(head,"{$topadvshow}",rs_adt("indextouyou"))
End Function
Public Function foot_()
dim foot_s
foot_s=""
' if cstr(rs_config("footmoban"))="2" then //这里应该是根据程序设置 动态读取相应模板
' foot=getHTML("\template\default\foot\foot2.html")
' else
' foot=getHTML("\template\default\Page_bottom.html")
' end if
foot=getHTML(dir_tp&"foot.html")
foot=replace(foot,"{$bottomurl}",rs_config("bottomurl"))
foot=replace(foot,"{$SiteUrl}",http://www.163.com)
foot=replace(foot,"{$siteip}",rs_config("siteip"))
foot=replace(foot,"{$sitetongji}",rs_config("sitetongji"))
a=split(rs_config("siteInfo"),"#")
foot=replace(foot,"{$SiteName}",a(0))
foot=replace(foot,"{$ThisSiteUrl}","")
foot=replace(foot,"{$sitebanquan}",rs_config("sitebanquan"))
foot=replace(foot,"{$ThisSiteUrl$}","\")
set rs_s=conn.execute("SELECT id,title FROM "&t()&"Article WHERE (styleid = 1) ORDER BY intorder")
do while not rs_s.eof
foot_s=foot_s&"| <a href='/help/article_"&rs_s("id")&".html' target='_blank'>"&rs_s("title")&"</a>"
rs_s.movenext
loop
foot=replace(foot,"{$details$}",foot_s)
End Function
Public Function html(FileUrl)
display()
set stm=server.CreateObject("adodb.stream")
stm.Type=2
stm.mode=3
stm.charset="utf-8"
stm.open
stm.WriteText content
stm.SaveToFile server.MapPath(FileUrl),2
stm.flush
stm.Close
set stm=nothing
End Function
Public Function cache(filename,ftime)
'先判断文件是否存在 and 时间小于300秒
dim f
set f=fso.GetFile(Server.MapPath(filename))
if CheckFile(filename) and DateDiff("s", Now, f.DateCreated)>ftime then
echo(getHTML(filename))
die()
end if
End Function
Function DeleteFile(filename)
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile server.MapPath(filename)
set fso = nothing
End Function
End Class
%>