📄 ppst_sub.asp
字号:
<%
Function GetBigClassName(NewsBigClassID) '定义一个过程,将大类ID转换为名称
Set RsBigClass=Server.CreateObject("Adodb.RecordSet")
SqlBigClass="Select * From PPst_BigClass Where BigClassID="&NewsBigClassID
rsBigClass.open sqlBigClass,conn,1,1
GetBigClassName=RsBigClass("BigClassName")
RsBigClass.Close
End Function
Function GetSmallClassName(NewsSmallClassID) '定义一个过程,将小类ID转换为名称
Set RsSmallClass=Server.CreateObject("Adodb.RecordSet")
SqlSmallClass="Select * From PPst_SmallClass Where SmallClassID="&NewsSmallClassID
rsSmallClass.open sqlSmallClass,conn,1,1
GetSmallClassName=RsSmallClass("SmallClassName")
RsSmallClass.Close
End Function
Function RongCuo(RongCuoName,MaxValue,TrueValue) '容错判断是否是数字且在范围(0到..)之内
If Not Isnumeric(RongCuoName) then
If RongCuoName="" then
RongCuo=TrueValue
Else
RongCuo=RongCuoName
End If
ElseIf MaxValue=0 and RongCuoName<0 then '如该数无最大要求,则,若为负即赋予默认值
RongCuo=TrueValue
ElseIf MaxValue<>0 and (RongCuoName<0 or RongCuoName>MaxValue) then
''如该数有最大要求,则,若为负或超过最大值即赋予默认值
RongCuo=TrueValue
Else
RongCuo=RongCuoName
End If
End Function
Sub PPst_News(BigClassID,SmallClassID,NewsNum,NewsPic,FontColor,LeftNum,NewOpen,IsNew,NewGif,FileName,TrHeight,FontSize,StyleID,NewsIcon,IconGif,ShiJian,OrderBy,IsPage,MoreNum,Key)
'Call PPst_News(11,0,10,"#FF0000",30,1,0,"new.gif","ReadNews.asp",20,"td12",1,"icon.gif",2)
'详细参数说明
'BigClassID ------- 新闻大类ID号:0为全部大类
'SmallClassID ------- 新闻小类ID号:0为全部分类
'NewsNum ------- 新闻条数:0为全部新闻
'NewsPic ------- 是否提示图片新闻:0为不提示,1为提示
'FontColor ------- 文字颜色,无论有没有连接,都显示此颜色,必须加双引号,如:"#FF0000"
'LeftNum ------- 显示标题最左边的字符数,默认30,一个汉字算两个字符
'NewOpen ------- 是否新窗口打开,0在原窗口打开,1在新窗口打开,容错默认为1
'IsNew ------- 是否在当天的新闻标题的后面显示new, 默认0为不显示,1为显示,并自定义,容错默认为0
'NewGif ------- 当IsNew=1时,自定义图片的地址,必须加双引号,如:"new.gif"
'FileName ------- 用以打开该新闻的程序文件:必须加双引号,如:"ReadNews.asp"
'TrHeight ------- 每条新闻所在行的高度:单位像素(px),0为自动
'StyleID ------- 每条新闻的CSS样式名,默认为0,即无,1为点划线,2为虚线
'NewsIcon ------- 每条新闻前缀:0为不显示,1为显示默认(黑点),2为自定义,容错默认为1
'IconGif ------- 当NewsIcon=2时,自定义图片的地址,必须加双引号,如:"icon.gif"
'ShiJian ------- 是否显示新闻的发布时间:0为不显示,1,2,3,分别代表三种显示效果,容错默认为2
'OrderBy ------- 调出的新闻以什么排序,0为按发表时间,1为阅读次数,容错默认为0
'IsPage ------- 是否显示分页,0为不显示,1,2,3为三种样式显示,容错默认为0
'MoreNum ------- 分页显示的时候。每页显示多少条新闻,
'Key ------- 搜索的时候专用,
BigClassID=RongCuo(BigClassID,0,0)
SmallClassID=RongCuo(SmallClassID,0,0)
NewsNum=RongCuo(NewsNum,0,10)
NewsPic=RongCuo(NewsPic,1,0)
LeftNum=RongCuo(LeftNum,0,30)
NewOpen=RongCuo(NewOpen,1,1)
IsNew=RongCuo(IsNew,1,0)
TrHeight=RongCuo(TrHeight,0,20)
FontSize=RongCuo(FontSize,0,12)
StyleID=RongCuo(StyleID,2,0)
NewsIcon=RongCuo(NewsIcon,2,1)
ShiJian=RongCuo(ShiJian,3,2)
OrderBy=RongCuo(OrderBy,1,0)
IsPage=RongCuo(IsPage,3,0)
MoreNum=RongCuo(MoreNum,0,10)
If (Key="t" or Key="c" or Key="") then
Key0=""
ElseIf Len(Key)=1 then
Key0=""
ElseIf (Left(Key,1)="t" or Left(Key,1)="c") then
Key0=Right(Key,Len(Key)-1)
Else
Key0=""
End If
If NewsNum=0 or IsPage>0 then
sql = "Select * from [PPst_News] where Shenhe=1"
Else
sql = "Select top "&NewsNum&" * from [PPst_News] where Shenhe=1"
End If
If Key0<>"" and Left(Key,1)="t" then
Sql=Sql&" and Title like '%"&Key0&"%'"
ElseIf Key0<>"" and Left(Key,1)="c" then
Sql=Sql&" and Content like %'"&Key0&"'%"
End If
If BigClassID<>0 then
Sql=Sql&" and BigClassID="&BigClassID
End If
If SmallClassID<>0 then
Sql=Sql&" and SmallClassID="&SmallClassID
End If
If OrderBy=0 then
Sql=Sql&" Order By ID Desc"
Else
Sql=Sql&" Order By ReadCishu Desc"
End If
'Call T(sql)
If StyleID=0 then NewsCSS=""
If StyleID=1 then NewsCSS="style=border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:#000000;"
If StyleID=2 then NewsCSS="style=border-bottom-width:1px;border-bottom-style:dashed;border-bottom-color:#000000;"
Set Rs=Server.CreateObject("Adodb.RecordSet")
rs.open sql,conn,1,1
If Rs.RecordCount=0 Then
response.Write "<table width=100% border=0 cellspacing=0 cellpadding=0>"
response.Write "<tr><td height="&TRheight&" "&NewsCSS&" align=center valign=middle>暂时没有数据..</td></tr></table>"
Else
If IsPage=1 then
page=request.QueryString("page")
rs.pagesize=MoreNum
total=rs.recordcount
if Not IsEmpty(trim(Request("Page"))) then
page = CInt(Request("page"))
if page>rs.PageCount then
rs.AbsolutePage = rs.PageCount
elseif page <= 0 then
page = 1
else
rs.AbsolutePage = page
end if
End if
page = rs.AbsolutePage
End If
response.Write "<table width=100% border=0 cellspacing=0 cellpadding=0>"
If IsPage=1 then
PPst_End=rs.PageSize
Else
PPst_End=rs.recordcount
End If
For i=1 to PPst_End
response.Write "<tr><td height="&TRheight&" "&NewsCSS&" Align=left valign=middle>"
If NewsIcon=0 then
response.Write ""
Elseif NewsIcon=1 then
response.Write "<font color=#000000>·</font>"
Elseif NewsIcon=2 then
response.Write "<img src="&IconGif&" border=0>"
End if
If NewsPic=1 and rs("SmallPicURL")<>"" then
response.Write "<font color=#FF000>"
If FontSize<>"" then Response.Write "<span style=""Color:FF0000;font-size:"&FontSize&"px"">图</span>"
response.Write "</font>"
End If
Response.Write "<a href="&FileName&"?id="&rs("ID")
PPst_LeiBie1=GetBigClassName(rs("BigClassID"))
PPst_LeiBie2=GetSmallClassName(rs("SmallClassID"))
Response.Write " title=大类:"&PPst_LeiBie1&"
小类:"&PPst_LeiBie2&"
作者:"&rs("Author")&"
阅读:"&rs("ReadCishu")&"次
时间:"&rs("AddTime")
If NewOpen=1 then
response.write " target=""_blank"">"
Elseif NewOpen=0 then
response.write ">"
End if
If FontSize<>0 and FontColor<>"" then
response.Write "<span style=""font-size:"&FontSize&"px;color:"&FontColor&""">"
ElseIf FontSize=0 and FontColor<>"" then
response.Write "<span style=""color:"&FontColor&""">"
ElseIf FontSize=0 and FontColor<>"" then
response.Write "<span style=""font-size:"&FontSize&"px"">"
End If
If NewsPic=1 and rs("SmallPicURL")<>"" then
response.write TitleLeft(rs("Title"),LeftNum-2)
Else
response.write TitleLeft(rs("Title"),LeftNum)
End If
If FontSize<>0 or FontColor<>"" then response.Write "</span>"
response.Write "</span></a>"
If IsNew=1 and DateValue(rs("AddTime"))=Date() then
Response.Write "<img src="&NewGif&" border=0>"
End if
If shijian=1 then response.write "<font color=999999>["&formatdatetime(rs("AddTime"),1)&"])</font>"
If shijian=2 then response.write "<font color=999999>["&formatdatetime(rs("AddTime"),2)&"]</font>"
If shijian=3 then response.write "<font color=999999>["&month(rs("AddTime"))&"月"&day(rs("AddTime"))&"日]</font>"
If shijian=4 then response.write "<font color=999999>["&month(rs("AddTime"))&"-"&day(rs("AddTime"))&"]</font>"
If shijian=5 then response.write "<font color=999999>["&weekDayName(weekday(rs("AddTime")))&"]</font>"
response.write "</td></tr>"
rs.movenext
If rs.eof then exit for
Next
response.write "<tr><td height=5></td></tr>"
If IsPage=1 then
Response.write "<tr><td align=right valign=middle>"
if rs.pagecount<>1 and rs.pagecount<>0 then%>
<%if page<rs.pagecount then%>
<%if page=1 then %>
[首页] [上页]
<%else%>
[<a href="<%=ThisFileName%>?<%If Key0<>"" then response.Write "B="&BigClassID&"&S="&SmallClassID&"&K="&Key&"&"%>page=<%=1%>">首页</a>]
[<a href="<%=ThisFileName%>?<%If Key0<>"" then response.Write "B="&BigClassID&"&S="&SmallClassID&"&K="&Key&"&"%>page=<% =page-1 %>">上一页</a>]
<% end if %>
[<a href="<%=ThisFileName%>?<%If Key0<>"" then response.Write "B="&BigClassID&"&S="&SmallClassID&"&K="&Key&"&"%>page=<%=page+1%>">下页</a>]
[<a href="<%=ThisFileName%>?<%If Key0<>"" then response.Write "B="&BigClassID&"&S="&SmallClassID&"&K="&Key&"&"%>page=<%=rs.PageCount%>">尾页</a>]
<%else%>
[<a href="<%=ThisFileName%>?<%If Key0<>"" then response.Write "B="&BigClassID&"&S="&SmallClassID&"&K="&Key&"&"%>page=<% = 1%>">首页</a>]
[<a href="<%=ThisFileName%>?<%If Key0<>"" then response.Write "B="&BigClassID&"&S="&SmallClassID&"&K="&Key&"&"%>page=<% =page -1 %>">上页</a>]
[下页] [尾页]
<%end if %>
<%else%>
[首页] [上页] [下页] [尾页]
<%end if%>
[页次:<font color="red"><b><%=page%></b></font>/<%=rs.PageCount%>]
[共 <%=rs.RecordCount%> 条 <font color="red"><b><%=rs.PageSize%></b></font>条/页] <select style="width:50px;" onChange="window.location.href=this.options[this.selectedIndex].value">
<option value="<%=ThisFileName%>">页码</option>
<%For k=1 to rs.PageCount%>
<option value="<%=ThisFileName%>?<%If Key0<>"" then response.Write "B="&BigClassID&"&S="&SmallClassID&"&K="&Key&"&"%>page=<% = k%>"><% = k%></option>
<%Next%>
</select>
</td></tr>
<% Rs.Close
End If
response.Write "</table>"
End If
End Sub
Sub PPst_Pinglun(NewsID,PinglunNum,PinglunReply)
If IsPinglun=1 then
Set Rs=Server.CreateObject("Adodb.RecordSet")
If PinglunNum=0 then
Sql="Select * From PPst_Pinglun Where NewsID="&NewsID+1-1&" order by ID desc"
Else
Sql="Select top "&PinglunNum&" * From PPst_Pinglun Where NewsID="&NewsID+1-1&" order by ID desc"
End If%>
<script language="javascript">
<!--
// Example: obj = findObj("image1");点击展开输入框
function findObj(theObj, theDoc)
{
var p, i, foundObj;
if(!theDoc) theDoc = document;
if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
{
theDoc = parent.frames[theObj.substring(p+1)].document;
theObj = theObj.substring(0,p);
}
if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
for (i=0; !foundObj && i < theDoc.forms.length; i++)
foundObj = theDoc.forms[i][theObj];
for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
foundObj = findObj(theObj,theDoc.layers[i].document);
if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
return foundObj;
}
//-->
</script>
<%
rs.open sql,conn,1,1
If Rs.RecordCount=0 then
Response.Write "<table width=100% border=0 cellpadding=0 cellspacing=0>"%>
<tr OnMouseUp="with(findObj('viewpl'))if (style.display=='none') {style.display=''}else{style.display='none'}"><td align=left valign=middle bgcolor=#FFFFFF height="30" style="cursor:hand">
<font color="#FF0000">暂时还没有评论 <b>点击这里增加评论</b></font></td></tr></table>
<%Else
Response.Write "<table width=100% border=0 cellpadding=0 cellspacing=0>"%>
<tr OnMouseUp="with(findObj('viewpl'))if (style.display=='none') {style.display=''}else{style.display='none'}"><td align=left valign=middle bgcolor=#FFFFFF height="30" style="cursor:hand">
<font color="#FF0000">评论列表 <b>点击这里增加评论</b></font></td></tr></table>
<%Response.Write "<table width=100% border=0 cellpadding=0 cellspacing=1 bgcolor=#CCCCCC>"
do until rs.eof
Response.Write "<tr><td colspan=2 align=left width=100% valign=middle bgcolor=#EEEEEE height=20><b>作者</b>:"&Server.HTMLEncode(Rs("Author"))&" <b>回复</b>:"&Server.HTMLEncode(Rs("Title"))&" ("&Rs("AddTime")&")</td></tr>"
Response.Write "<tr><td width=1% bgcolor=#FFFFFF height=20></td><td align=left valign=top bgcolor=#FFFFFF>"&Server.HTMLEncode(Rs("Content"))&"</td></tr>"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -