index.asp

来自「实现一个用JSP、Servlet技术实现的小型物流网站系统。实现功能如下:管理员」· ASP 代码 · 共 697 行 · 第 1/2 页

ASP
697
字号
<% data_path="../../" 'ACC连接数据库路径,对SQL无效 %>
<!--#include file="../../conn/conn.asp"-->
<!--#include file="../../inc/safe.asp"-->

<%
if session("globalecmaster")="" or session("masterflag")="" then
response.write "<script language='javascript'>"
response.write"parent.location.href='../login.asp';</SCRIPT>" 
response.end
end if

'权限限制^^^^^^^^^^^^^^^^^^^^
 dim ishavegant
 ishavegant=false
 in_str=split(session("masterflag"),",")
 for each ins in in_str
 if trim(ins)="07" then 
 ishavegant=true
 end if
 next 
 if ishavegant=false then
 response.redirect "../err.asp"
 response.end
 end if
 '^^^
%>
<%
sub WriteErrMsg()
    response.write "<table align='center' width='300' border='0' cellpadding='2' cellspacing='0' class='border'>"
    response.write "<tr class='title'><td align='center' height='15'>错误提示</td></tr>"
    response.write "<tr class='tdbg'><td align='left' height='100'>" & errmsg & "<p align='center'>【<a href='javascript:onclick=history.back()'>返 回</a>】<br></p></td></tr>"
	response.write "</table>" 
end sub
function dvHTMLEncode(fString)
if not isnull(fString) then
    fString = replace(fString, ">", "&gt;")
    fString = replace(fString, "<", "&lt;")
    fString = Replace(fString, CHR(32), "&nbsp;")
    fString = Replace(fString, CHR(9), "&nbsp;")
     fString = Replace(fString, CHR(39), "&#39;")
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
    fString = Replace(fString, CHR(10), "<BR> ")

    dvHTMLEncode = fString
end if
end function

dim strFileName,MaxPerPage
MaxPerPage=20
dim totalPut,CurrentPage,TotalPages
dim sql,rs,ID,LinkType
dim Action,FoundErr,ErrMsg
Action=Replace_Text(request("Action"))
ID=Replace_Text(Request("ID"))
LinkType=Replace_Text(request("LinkType"))
strFileName="index.asp?LinkType=" & LinkType

if request("page")<>"" then
if not isnumeric(request("page")) then
    currentPage=1
else
	currentPage=cint(request("page"))
end if
end if
if ID<>"" then
	if Action="Check" then
		conn.execute "Update [yixiang_link] set IsOK=1 where linkID=" & CLng(ID)
	elseif Action="CancelCheck" then
		conn.execute "Update [yixiang_link] set IsOK=0 where linkID=" & CLng(ID)
	elseif Action="Good" then
		conn.execute "Update [yixiang_link] set IsGood=1 where linkID=" & CLng(ID)
	elseif Action="CancelGood" then
		conn.execute "Update [yixiang_link] set IsGood=0 where linkID=" & CLng(ID)
	elseif Action="Del" then
		conn.execute "Delete From [yixiang_link] where linkID=" & CLng(ID)
	end if
end if
%>
<script LANGUAGE="javascript">
function ConfirmDel()
{
   if(confirm("确定要删除此友情链接站点吗?"))
     return true;
   else
     return false;
}
</script><style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
a {
	font-size: 12px;
	color: #003399;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #003399;
}
a:hover {
	text-decoration: underline;
	color: #FF6600;
}
a:active {
	text-decoration: none;
}
-->
</style>

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="150" align="center" valign="top">&nbsp;</td>
    <td width="100%" align="center" valign="top">
	<table width="600" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">
  <tr class="topbg"> 
    <td height="22" align=center><strong>友情链接管理</strong> <br />&nbsp;&nbsp;<a href="index.asp?Action=Add">添加友情连接</a>&nbsp;&nbsp;</td>
  </tr>
</table>
<br>
<%
if Action="Add" then
	call Add()
elseif Action="SaveAdd" then
	call SaveAdd()
elseif Action="Modify" then
	call Modify()
elseif Action="SaveModify" then
	call SaveModify()
else
	call main()
end if
if FoundErr=1 then
	call WriteErrMsg()
end if

sub main()
	sql="select * from [yixiang_link] where LinkType>0 "
	if LinkType<>"" then
		LinkType=CInt(LinkType)
		if LinkType=1 then
			sql=sql & " and LinkType=1 "
		elseif LinkType=2 then
			sql=sql & " and LinkType=2 "
		end if
	end if
	if Request("tj")=1 then sql=sql&" and isgood=1 "
	if Request("ws")=1 then sql=sql&" and IsOK=0 "
	sql=sql & " order by addtime desc"
	'response.write sql
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
  	if rs.eof and rs.bof then
		response.write "目前共有 0 个友情链接"
	else
    	totalPut=rs.recordcount
		if currentpage<1 then
       		currentpage=1
    	end if
    	if (currentpage-1)*MaxPerPage>totalput then
	   		if (totalPut mod MaxPerPage)=0 then
	     		currentpage= totalPut \ MaxPerPage
		  	else
		      	currentpage= totalPut \ MaxPerPage + 1
	   		end if

    	end if
	    if currentPage=1 then
        	showContent
        	showpage strFileName,totalput,MaxPerPage,true,true,"个站点"
   	 	else
   	     	if (currentPage-1)*MaxPerPage<totalPut then
         	   	rs.move  (currentPage-1)*MaxPerPage
         		dim bookmark
           		bookmark=rs.bookmark
            	showContent
            	showpage strFileName,totalput,MaxPerPage,true,true,"个站点"
        	else
	        	currentPage=1
           		showContent
           		showpage strFileName,totalput,MaxPerPage,true,true,"个站点"
	    	end if
		end if
	end if
	rs.close
	set rs=nothing
end sub

sub showContent
   	dim i
    i=0
	if linktype="" then linktype=3
%>
  <table width="680" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#F0F0F0" Class="border">
    <tr class="title">
      <td width="61" height="22" align="center" bgcolor="#EEEEEE">链接类型</td>
      <td width="74" height="24" align="center" bgcolor="#EEEEEE">网站名称</td>
	  <% if linktype<>2 then %>
      <td width="99" height="22" align="center" bgcolor="#EEEEEE">网站LOGO</td>
	  <% end if %>
      <td width="155" height="22" align="center" bgcolor="#EEEEEE">网站简介</td>
      <td width="77" height="22" align="center" bgcolor="#EEEEEE">站长</td>
      <td width="66" height="22" align="center" bgcolor="#EEEEEE">状态</td>
      <td width="112" height="22" align="center" bgcolor="#EEEEEE">操作</td>
    </tr>
<%
do while not rs.eof
%>
    <tr bgcolor="#F7F7F7" class="tdbg" onMouseOver="this.style.backgroundColor='#BFDFFF'" onMouseOut="this.style.backgroundColor=''">
      <td width="61" align="center">
	  <%
	  if rs("LinkType")=1 then
	  	response.write "<a href='index.asp?LinkType=1'><font color=blue>LOGO链接</font></a>"
	  else
		response.write "<a href='index.asp?LinkType=2'>文字链接</a>"
	  end if
	  %></td>
      <td width="74" height="22"><a href="<%=rs("SiteUrl")%>" target='blank' title="<%=rs("SiteUrl")%>"><%=rs("SiteName")%></a></td>
      <% if linktype<>2 then %>
	  <td width="99" align="center">
<%
if rs("imageurl")<>"" and rs("imageurl")<>"http://" and rs("LinkType")=1 then
	if lcase(right(rs("imageurl"),3))="swf" then
		Response.Write "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='88' height='31'><param name='movie' value='" & rs("imageurl") & "'><param name='quality' value='high'><embed src='" & rs("imageurl") & "' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='88' height='31'></embed></object>"
	else
		response.write "<a href='" & rs("SiteUrl") & "' target='_blank' title='" & rs("imageurl") & "'><img src='" & rs("imageurl") & "' width='88' height='31' border='0'></a>"
	end if
else
	response.write "&nbsp;"
end if
%> </td>
<% end if %>
      <td width="155"><%=rs("SiteIntro")%></td>
      <td width="77" align="center"><a href="mailto:<%=rs("Email")%>"><%=rs("SiteAdmin")%></a></td>
      <td width="66" align="center"> <%
	  if rs("IsOK")=1 then
	  	response.write "<font color=blue>已审核</font>"
	  else
	    response.write "&nbsp;"
	  end if
	  if rs("IsGood")=1 then
	  	response.write "<br><font color=red>推荐</font>"
	  end if
	  %> </td>
      <td width="112" align="center"> <%
	  If rs("IsOK")=0 Then 
        response.write "<a href='index.asp?ID=" & rs("linkid") & "&Action=Check'><font color=blue>审核通过</font></a>&nbsp;&nbsp;"
      Else
        response.write "<a href='index.asp?ID=" & rs("linkid") & "&Action=CancelCheck'>取消审核</a>&nbsp;&nbsp;"
      End If
	  response.write "<a href='index.asp?Action=Modify&ID=" & rs("linkid") & "'>修改</a><br>"
	  if rs("IsGood")=0 then
        response.write "<a href='index.asp?ID=" & rs("linkid") & "&Action=Good'><font color=green>设为推荐</font></a>&nbsp;&nbsp;"
      Else
        response.write "<a href='index.asp?ID=" & rs("linkid") & "&Action=CancelGood'>取消推荐</a>&nbsp;&nbsp;"
      End If
      response.write "<a href='index.asp?Action=Del&ID=" & rs("linkid") & "' onclick='return ConfirmDel();'>删除</a>"
	  %> </td>
    </tr>
    <%
	i=i+1
	if i>=MaxPerPage then exit do
	rs.movenext
loop
%>
</table>
<%
end sub

sub Add()
%>
<form method="post" name="msform" onSubmit="return Check()" action="index.asp">
  <table width="600" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#F7F7F7" class="border">
    <tr class="title"> 
      <td height="22" colspan="2" align="center"><strong>添加友情链接</strong></td>
    </tr>
    <tr class="tdbg"> 
      <td width="181" height="25" align="center"><strong>链接类型:</strong></td>
      <td width="408" height="25"><input name="LinkType" type="radio" onClick="logoshow()" value="1" checked>
        Logo链接&nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" onClick="wenzi()" name="LinkType" value="2">
      文字链接</td>
    </tr>
	<script language=vbscript>
	sub wenzi()
	logoa.style.display="none"
	end sub
	sub logoshow()
	logoa.style.display=""
	end sub
	</script>
    <tr class="tdbg"> 
      <td width="181" height="25" align="center" valign="middle"><strong>网站名称:</strong></td>
      <td height="25"> <input name="SiteName" size="30"  maxlength="20" title="这里请输入您的网站名称,最多为20个汉字"> 
        <font color="#FF0000"> *</font></td>
    </tr>
    <tr class="tdbg"> 
      <td width="181" height="25" align="center"><strong>网站地址:</strong></td>
      <td height="25"> <input name="SiteUrl" size="30"  maxlength="100" type="text"  value="http://" title="这里请输入您的网站地址,最多为50个字符,前面必须带http://"> 
        <font color="#FF0000">*</font></td>
    </tr>
    <tr class="tdbg" id=logoa> 
      <td width="181" height="25" align="center"><strong>网站Logo:</strong></td>
      <td height="25"> <input name="fujian" size="30"  maxlength="100" type="text"  value="http://" title="这里请输入您的网站imageurl地址,最多为50个字符,如果您在第一选项选择的是文字链接,这项就不必填"></td>
    </tr>
	
    <tr class="tdbg"> 
      <td width="181" height="25" align="center"><strong>站长姓名:</strong></td>
      <td height="25"> <input name="SiteAdmin" size="30"  maxlength="20" type="text"  title="这里请输入您的大名了,不然我知道您是谁啊。最多为20个字符"></td>
    </tr>
    <tr class="tdbg"> 
      <td width="181" height="25" align="center"><strong>电子邮件:</strong></td>
      <td height="25"> <input name="Email" size="30"  maxlength="30" type="text" title="这里请输入您的联系电子邮件,最多为30个字符"></td>
    </tr>
    <tr class="tdbg"> 
      <td width="181" align="center"><strong>网站简介:</strong></td>
      <td valign="middle"> <textarea name="SiteIntro" cols="40" rows="5" id="SiteIntro" title="这里请输入您的网站的简单介绍"></textarea></td>
    </tr>
    <tr class="tdbg"> 
      <td width="181" height="25" align="center"><strong>推荐站点:</strong></td>
      <td height="25" valign="middle"> <input name="IsGood" type="radio" value="1" checked>
        是&nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" name="IsGood" value="0">
        否</td>
    </tr>
    <tr class="tdbg"> 
      <td width="181" height="25" align="center"><strong>审核通过:</strong></td>
      <td height="25" valign="middle"><input name="IsOK" type="radio" value="1" checked>
        是&nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" name="IsOK" value="0">
        否</td>
    </tr>
    <tr class="tdbg"> 
      <td height="40" colspan="2" align="center"><input name="Action" type="hidden" id="Action" value="SaveAdd"> 
        <input type="submit" value=" 确 定 " name="cmdOk"> &nbsp; <input type="reset" value=" 重 填 " name="cmdReset">      </td>
    </tr>
  </table>
</form>
<%
end sub

sub Modify()
	if ID="" then
		FoundErr=1
		ErrMsg=ErrMsg & " 请指定友情站点ID "
		exit sub
	else
		ID=Clng(ID)
	end if

⌨️ 快捷键说明

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