⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 复件 news_class.asp

📁 这是我根据动网新闻核心自行设计的校园新闻系统
💻 ASP
📖 第 1 页 / 共 3 页
字号:
		If InStr(LCase(Attribute),atb)<>0 Then
			Response.Write "<a href='?action=set&op="&atb&"&id="&Id&"'><font color='#000000'>"&_
							""&showtext&""&_
							"</font></a>"
		Else
			Response.Write "<a href='?action=set&op="&atb&"&id="&Id&"'><font color='#C0C0C0'>"&_
							""&showtext&""&_
							"</font></a>"
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:setattribute
'# 描述:设置文章属性
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004
'#-----------------------------------------------------------------------------
	Private Function SetAttribute(sid,atb)
		Dim rs
		Dim satb
		Set rs=ActionConn.execute("select attribute from news where id="&sid)
		If Not rs.eof Then
			satb=rs(0)
			If InStr(satb,atb)<>0 Then
				satb=Replace(satb,atb,"")
			Else
				satb=satb&","&atb
			End If
		End If
		rs.Close
		Set rs = Nothing
		ActionConn.execute("update news set attribute='"&satb&"' where id="&sid)
		Response.Write "<Script>location.href='?action=list';</script>"
	End Function
'# ----------------------------------------------------------------------------
'# 函数:RequestForm
'# 描述:取得传递信息
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004-04-09
'#-----------------------------------------------------------------------------
	Private Function RequestForm()
		action=Request.QueryString("action")
		idd=Request.Form("idd")
		Id=Request.QueryString("id")
		Title=Request.Form("title")
		Categoryid=Request.Form("categoryid")
		Titlestyle=Request.Form("titlestyle")
		Titleurl=Request.Form("titleurl")
		Dim i
		Content=""
		For i = 1 To Request.Form("content1").Count 
			Content = Content & Request.Form("content1")(i) 
		Next 
		Writer=Request.Form("writer")
		Source=Request.Form("source")
		Keyword=Request.Form("keyword")
		Attribute=Request.Form("attribute")
		Text=Request.Form("text")
		Username=Request.Cookies("adminname")
		Dateandtime=Now()
		Template=0
		Pass=1
		Orderid=Id
		pic=Request.Form("pic")
		Hits=0
		
	End Function
'# ----------------------------------------------------------------------------
'# 函数:NewsView()
'# 描述:
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004
'#-----------------------------------------------------------------------------
Public Function NewsView()
	RequestForm()
	Set rs=ActionConn.execute("select code from template where id="&ctemplate)
	Dim showcode
	showcode=rs(0)
	Response.Write TemplateCode(showcode)
End Function
'# ----------------------------------------------------------------------------
'# 函数:Addpage
'# 描述:添加新闻页面
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004-04-09
'#-----------------------------------------------------------------------------
	Public Function AddPage()
		If LCase(Request.ServerVariables("request_method"))="post" Then
			RequestForm()
			pagination()
		Else
			Source=csource
			Writer=cwriter
			PageHtmlForm()
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:Pagination
'# 描述:内容分页的实现
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004
'#-----------------------------------------------------------------------------
	Private Function Pagination()
		Dim c
		c=Split(LCase(Content),"[page]")
		Dim t
		t=Title
		Dim cnum
		cnum=UBound(c)

		If cnum<1 Then
			Add()
		Else
			Content=""
			Title=""
			For i= 0 To cnum
				Content=c(i)
				Title=t&"("&i+1&")"
				Add()
				Content=""
				Title=""
			Next
		End If
		If Err Then
			Call ShowError("新闻添加失败")
		Else
			Call ShowSuccess("新闻添加成功","?action=add&categoryid="&Categoryid&"")
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:Modifypage
'# 描述:添加新闻页面
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004-04-09
'#-----------------------------------------------------------------------------
	Public Function ModifyPage()
		requestform()
		If Id="" Or IsNumeric(Id)=false Then
			Response.Write "错误的参数"
			exit function
		End If
		If LCase(Request.ServerVariables("request_method"))="post" Then
			RequestForm()
			Modify()
		Else
			GetNews(Id)
			PageHtmlForm()
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:listpage
'# 描述:新闻列表页面
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004-04-09
'#-----------------------------------------------------------------------------
	Public Function ListPage() 
		PageHtmlList()
	End Function
'# ----------------------------------------------------------------------------
'# 函数:setpage
'# 描述:新闻列表页面
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004-4-12
'#-----------------------------------------------------------------------------
	Public Function SetPage() 
		Dim op
		requestform()
		op=Request.QueryString("op")
		If op="" Or Id="" Or action="" Then
			Response.Write "错误的参数"
			exit function
		End If
		SetAttribute Id,op
	End Function
'# ----------------------------------------------------------------------------
'# 函数:Deletepage
'# 描述:删除新闻页面
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004-04-09
'#-----------------------------------------------------------------------------
	Public Function DeletePage()
		If LCase(Request.ServerVariables("request_method"))="post" Then
			RequestForm()
			Delete()
		Else
			PageHtmlList()
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:add
'# 描述:添加新闻
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004-04-09
'#-----------------------------------------------------------------------------
	Private Function Add()
		Dim Rs,Sql
		Set Rs=Actionconn.Execute("Select Max(Id) From News")
		If Isnull(Rs(0)) Or Rs(0)="" Then
			Id=1
		Else
			Id=Rs(0)+1
		End If
		Set Rs=Server.Createobject("Adodb.Recordset")
		Sql="Select * From [News]"
		Rs.Open Sql,Actionconn,3,2
		Rs.Addnew
		Rs("Id")=Id
		Rs("Title")=Title
		Rs("Categoryid")=Categoryid
		Rs("Titlestyle")=Titlestyle
		Rs("Titleurl")=Titleurl
		Rs("Content")=Content
		Rs("Writer")=Writer
		Rs("Source")=Source
		Rs("Keyword")=Keyword
		Rs("Attribute")=Attribute
		Rs("Text")=Text
		Rs("Username")=Username
		Rs("Dateandtime")=Dateandtime
		Rs("Template")=Template
		Rs("Pass")=Pass
		Rs("Hits")=Hits
		Rs("Orderid")=Id
		Rs("Categorytype")=Categorytype
		Rs("pic")=Pic
		Rs("ordertime")=DateAndTime
		Rs.Update
		Rs.Close
		Set Rs=Nothing
	End Function

'# ----------------------------------------------------------------------------
'# 函数:Modify
'# 描述:修改新闻内容
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004-04-09
'#-----------------------------------------------------------------------------
	Private Function Modify()
		Dim Rs,Sql
		Set Rs=Server.Createobject("Adodb.Recordset")
		Sql="Select * From [News] Where Id="&Id
		Rs.Open Sql,Actionconn,3,2
		Rs("Title")=Title
		Rs("Categoryid")=Categoryid
		Rs("Titlestyle")=Titlestyle
		Rs("Titleurl")=Titleurl
		Rs("Content")=Content
		Rs("Writer")=Writer
		Rs("Source")=Source
		Rs("Keyword")=Keyword
		Rs("Attribute")=Attribute
		Rs("Text")=Text
		Rs("Template")=Template
		Rs("Pass")=Pass
		Rs("pic")=Pic
		Rs.Update
		Rs.Close
		Set Rs=Nothing
		If Err Then
			Call ShowError("新闻修改失败")
		Else
			Call ShowSuccess("新闻修改成功","?action=list")
		End If
	End Function

'# ----------------------------------------------------------------------------
'# 函数:Delete
'# 描述:删除新闻
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004-4-12
'#-----------------------------------------------------------------------------
	Private Function Delete()
		Dim Sql
		If Id="-1" Then
			Sql="Delete * From News Where Categorytype='"&CategoryType&"'"
		ElseIf Id<>"" Then
			Sql="Delete * From News Where Id="&Id
		Else 
			Sql="Delete * From News where Id in ("&idd&")"
		End If
		Actionconn.Execute(Sql)
		If Err Then
			Call ShowError("新闻删除失败")
		Else
			Call ShowSuccess("新闻删除成功","?action=list")
		End If
	End Function

'# ----------------------------------------------------------------------------
'# 函数:取得单个新闻的属性
'# 描述:
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004-4-12
'#-----------------------------------------------------------------------------
	Public Function Getnews(Gid)
		Dim Rs
		Set Rs=Actionconn.Execute("Select * From news Where Id="&Gid)
		Id=Rs("Id")
		Title=Rs("Title")
		Categoryid=Rs("Categoryid")
		Titlestyle=Rs("Titlestyle")
		Titleurl=Rs("Titleurl")
		Content=Rs("Content")
		Writer=Rs("Writer")
		Source=Rs("Source")
		Keyword=Rs("Keyword")
		Attribute=Rs("Attribute")
		Text=Rs("Text")
		Username=Rs("Username")
		Dateandtime=Rs("Dateandtime")
		Template=Rs("Template")
		Pass=Rs("Pass")
		Orderid=Rs("Orderid")
		Hits=Rs("Hits")
		Categorytype=Rs("Categorytype")
		Pic=Rs("pic")
		Rs.Close
		Set Rs=Nothing
	End Function
 '# ----------------------------------------------------------------------------
 '# 函数:News_Show(nid)
 '# 描述:
 '# 参数: nid-新闻id,ncode-新闻显示用模板
 '# 返回:
 '# 作者:雷の龙
 '# 日期:2004
 '#-----------------------------------------------------------------------------
	Public Function News_Show(nid,ncode) 
		GetNews(nid)
		ActionConn.execute("update news set hits=hits+1 where id="&nid)
		Response.Write TemplateCode(ncode)
	End Function
'# ----------------------------------------------------------------------------
'# 函数:MoreList(Categoryid-类别,ntype-类别,Num-数量,tode-模板)
'# 描述:
'# 参数: -
'# 返回:
'# 作者:雷の龙
'# 日期:2004
'#-----------------------------------------------------------------------------
	Public Function MoreList(Categoryid,ntype,rows,cols,tcode) 
		Dim rs
		Dim Style
		Dim sql
		Dim Num
		Num=CInt(rows)*CInt(cols)
		sql="select *,(select categoryname from category where categoryid=news.categoryid and categoryType=news.categorytype) as categoryname from [news] where categorytype='"&CategoryType&"'"
		If Categoryid<>"-1" And categoryid<>"" Then
			sql=sql&" and left(categoryid,"&len(categoryid)&")='"&categoryid&"'"
		End If

		'判断是否是推荐新闻列表
		If InStr(ntype,"commend")<>0 Then
			sql=sql&" and instr(attribute,'commend')<>0"
		End If

		'判断是否图片新闻
		If InStr(ntype,"picnews")<>0 Then
			sql=sql&" and instr(attribute,'picnews')<>0"
		End If

		'判断排序方式
		If InStr(ntype,"hot")<>0 Then
			sql=sql&" order by hits desc"
		else
			sql=sql&" order by orderid desc"
		End If
		Dim i
		i=0
		Set rs=Server.CreateObject("adodb.recordset")
		rs.open sql,ActionConn,3,1
		Response.Write "<table width=100% border=0 cellpadding=0 cellspacing=0>"
		Dim totalcount,count,pagecount,nowpage,a
		totalcount=rs.recordcount
		'***********************************分页
		count=Num
		if count<=0 then
			count=Num
		end if
		if not rs.eof then
			rs.pagesize=count
			pagecount=rs.pagecount
			if request.querystring("page")="" then
				nowpage=1
			else
				nowpage=int(request.querystring("page"))
			end if
			if nowpage>=rs.pagecount then
				nowpage=rs.pagecount
			elseif nowpage<=1 then
				nowpage=1
			end if
			rs.absolutepage=nowpage
		else
			pagecount=1
			nowpage=1
		end if
		a=1
		Do While not rs.eof And i<cint(num)
			Response.Write "<tr>"
			For a= 1 To cols 
				Response.Write "<td class=td>"
				If Not rs.eof And i<CInt(num) Then
					Id=rs("id")
					Title=rs("title")
					content=rs("content")
					keyword=rs("keyword")
					attribute=rs("attribute")
					text=rs("text")
					username=rs("username")
					dateandtime=rs("dateandtime")
					template=rs("template")
					pass=rs("pass")

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -