poll.asp

来自「是一个关于小学信息化教育的平台,提供了学校论坛,和聊天室功能!」· ASP 代码 · 共 388 行 · 第 1/2 页

ASP
388
字号
<!--#include file="../../include/db.asp"-->
<!--#include file="../../include/admin_check.asp"-->
<!--#include file="power.asp"-->
<%
'函数 checkAdmin ,判断 checkStr 是否包含在 adminStr 中
function checkAdmin(checkStr,adminStr)
	if adminStr="" or isnull(adminStr) then
		checkAdmin=false
	else
	 if instr(adminStr,"/"&checkStr&"/")<>0 then
	 	checkAdmin=true
	 else
	 	checkAdmin=false	 	
	 end if
	end if
end function

'如果用户没有管理问卷的权限,则回退
if not (session("adm_power")="1" or checkAdmin("poll",session("adm_power"))) then
	Response.Write "<script language=javascript>"
	response.write "alert('抱歉,你没有管理问卷的权限!');"
   	Response.Write "history.go(-1);;"
        Response.Write "</script>"	
        response.end	
end if

'清零和使用以及删除操作
if trim(request("act"))="toZero" or trim(request("act"))="toUse" or trim(request("act"))="toStop" or trim(request("act"))="del" then
		Myid=trim(request("id"))
		if Myid="" or not(isnumeric(Myid)) then
	 	 Response.Write "<script language=javascript>"
   	 	 Response.Write "alert('错误的参数!!');"
     	  	 Response.Write "history.go(-1);"  	  
    	  	 Response.Write "</script>"
	 	 Response.End
		end if
		
	'载入poll.xml	
	path=server.mappath("poll.xml")
	
	set myDoc=Server.CreateObject("microsoft.xmldom")
	myDoc.async=False
	myDoc.load(path)
		
	set xmlTop=myDoc.documentElement
	
	'判断问卷调查是否存在
	itemExist=falue
 	for i=0 to xmlTop.childNodes.length-1
 		itemId=xmlTop.childNodes.item(i).attributes.getNamedItem("id").nodeValue
 		if itemId=Myid then
 			set itemNode=xmlTop.childNodes.item(i)
 			ItemExist=true
 			exit for
 		end if
 	next 
 	
 	if not itemExist then
 	  Response.Write "<script language=javascript>"
   	  Response.Write "alert('该问卷调查不存在!!');"
     	  Response.Write "history.go(-1);"  	  
    	  Response.Write "</script>"
	  Response.End	
 	end if
 	
 	'清零操作
 	if trim(request("act"))="toZero" then
 		'总投票数清零
 		itemNode.attributes.getNamedItem("polled").nodeValue=0
 		'各选项投票数清零
 		for i=0 to itemNode.childNodes.length-1
 			itemNode.childNodes.item(i).attributes.getNamedItem("polled").nodeValue=0
 		next
 	  Response.Write "<script language=javascript>"
   	  Response.Write "alert('操作成功!!');"
    	  Response.Write "</script>"
 	end if
 	
 	'投入使用操作
 	if trim(request("act"))="toUse" then
 		'把所有<item>的<status>属性清零,把要使用的<item>的<status>属性值设置为 1
 		
 		for i=0 to xmlTop.childNodes.length-1
 			if xmlTop.childNodes.item(i).attributes.getNamedItem("id").nodeValue=myId then
 				xmlTop.childNodes.item(i).attributes.getNamedItem("status").nodeValue=1
 			else
 				xmlTop.childNodes.item(i).attributes.getNamedItem("status").nodeValue=0
 			end if
 		next
  	  Response.Write "<script language=javascript>"
   	  Response.Write "alert('操作成功!!');"
    	  Response.Write "</script>"
	end if
 	
 	'停止使用的操作
  	if trim(request("act"))="toStop" then
 		'把<item>的<status>属性清零
  		for i=0 to xmlTop.childNodes.length-1
 			if xmlTop.childNodes.item(i).attributes.getNamedItem("id").nodeValue=myId then
 				xmlTop.childNodes.item(i).attributes.getNamedItem("status").nodeValue=0
 				exit for
 			end if

 		next
 	  Response.Write "<script language=javascript>"
   	  Response.Write "alert('操作成功!!');"
    	  Response.Write "</script>"
	end if
	
	'删除操作
	if trim(request("act"))="del" then
 		'警告
 		
 		
 		'删除选定的<item> 		
  		for i=0 to xmlTop.childNodes.length-1
 			if xmlTop.childNodes.item(i).attributes.getNamedItem("id").nodeValue=myId then
 				set removeNode=xmlTop.removeChild(xmlTop.childNodes.item(i))
 				exit for
 			end if

 		next
 	 
	end if
	
	'把造作实现
	myDoc.save(path)	
end if

'载入或是重新载入poll.xml文件
path=server.mappath("poll.xml")
	
set myDoc=Server.CreateObject("microsoft.xmldom")
myDoc.async=False
myDoc.load(path)

'根节点
set xmlTop=myDoc.documentElement

'分页操作
myLen=xmlTop.childNodes.length
page=trim(request("page"))
'每页显示的<item>个数
itemCount=10

if page="" then
	page=1
else

	if Cint(page)>(myLen/itemCount+1) then
		page=myLen/itemCount+1
	end if
end if


if trim(request("act"))="search" then
session("yc_content")=""
	selectsql="select id,title,user_name,date,type_id from content where 1=1"
	if trim(request("title"))<>"" then
		selectsql=selectsql&" and title like '%"&transValue(trim(request("title")))&"%'"
	end if
	if trim(request("user_name"))<>"" then
		selectsql=selectsql&" and user_name like '%"&transValue(trim(request("user_name")))&"%'"
	end if
	if trim(request("type"))<>"" and trim(request("type"))<>"0" then
		selectsql=selectsql&" and type_id='"&trim(request("type"))&"'"
	end if	
	if trim(request("mydate"))<>"" then

		if trim(request("select_date"))="myBefore" then
		mydate=cdate(trim(request("mydate")))
			selectsql=selectsql&" and  date<='"&dateserial(year(mydate),month(mydate),day(mydate)+1)&"' order by date desc"
		else
			selectsql=selectsql&" and date>='"&cdate(trim(request("mydate")))&"' order by date asc"
		end if
	end if
end if


if trim(request("myjoke"))="1" then session("yc_content")=""

%>
<html>
<head>
<title>深圳育才一小欢迎您!</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="/include/page.css" type="text/css">

</head>

<body >
<table width="1" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td> 

⌨️ 快捷键说明

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