<!--#INCLUDE FILE="conn.asp" -->
<!--#INCLUDE FILE="Class_Checkuser.asp" -->
<!--#INCLUDE FILE="Class_Top.asp" -->
<%
locat="快乐网签"
if membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=Class_Login.asp><font color=red>登录或注册校友录</font></a>。"
	Call top(1,1)
	Call Error("Information",ErrMsg)
	
else
	
	toact=request("toact")
	select case toact
	case "add"
	Call top(1,1)
	response.write "<table cellpadding=3 cellspacing=1 align=center class=tableborder1><tr><th valign=middle colspan=2 align=center height=20><b><a href=n_url.asp>"&membername& "的个人书签</a></b></td><tr><td valign=middle class=tablebody1>"
		call main()
	case "del"
		call del()
	case "edit"
	Call top(1,1)
	response.write "<table cellpadding=3 cellspacing=1 align=center class=tableborder1><tr><th valign=middle colspan=2 align=center height=20><b><a href=n_url.asp>"&membername& "的个人书签</a></b></td><tr><td valign=middle class=tablebody1>"
		call edit()
	case "added"
		call added()
	case "edited"
		call edited()
	case "move"
		call move()
	case else
		response.write "<script>alert('请选择您要进行的操作！');history.go(-1);</script>"
		response.end
	end select
end if

response.write "</table>"
call footer()

sub main()
%>
<script language=vbscript>
<!--
function chform(theform)
	if trim(theform.webname.value)="" then
		alert("请输入收藏网址的名称！")
	elseif trim(theform.weburl.value)="" then
		alert("请输入要收藏的网址")
	else
		theform.submit
	end if
end function
//-->
</script>
<%
	dim group,userid
	set rs=server.createobject("adodb.recordset")
	sql="select * from [scfav] where username='"&membername&"'"
	rs.open sql,conn,1,1
	if rs.eof and rs.bof then
		response.write "<div align=center>您还没有在本校友录建立个人快乐网签，马上<a href='n_urlnew.asp'><font color=red>申请</font></a>快乐网签。</div>"
	else
		group=rs("groups")
		userid=rs("id")
		response.write "<form name=thisform method=post action=?toact=added onSubmit='chform(this);return false;'><table cellpadding=3 cellspacing=1 align=center valign=top class=tableborder1>"
		response.write "<tr><td class=tablebody2 align=center colspan=3><b>添加网址</b>"
		response.write "<tr><td class=tablebody1 align=left colspan=3>"
		response.write "&nbsp;&nbsp;请填写下表以完成网址的添加,<font color=red>*</font>为必需内容。"
		response.write "<tr><td width=20% class=tablebody2><td class=tablebody1 align=left>收藏名字：<input type=text name=webname>&nbsp;<font color=red>*</font>"
		response.write "<br>收藏网址：<input type=text name=weburl size=30 value=http://>&nbsp;<font color=red>*</font>"
		response.write "<br>所属&nbsp;&nbsp;分组：<select name=group>"
		for i=0 to rs("groupnum")-1
			response.write "<option value="&trim(split(group,"|")(i))&">"&trim(split(group,"|")(i))
		next
		response.write "</select>&nbsp;<font color=red>*</font>请选择"
		response.write "<br>简单说明：<input type=text name=webtext>"
		response.write "<br><input type=reset value=重置>&nbsp;&nbsp;&nbsp;<input type=submit value=添加>"
		response.write "<td width=20% class=tablebody2></table></form>"
	end if
end sub

sub added()
	dim webname,weburl,group,webtext
	dim userid
	webname=trim(request("webname"))
	weburl=trim(request("weburl"))
	group=trim(request("group"))
	webtext=trim(request("webtext"))
		if webname="" or weburl="" or group="" then
			response.write "<script>alert('请从正常渠道进入！');history.go(-1);</script>"
			response.end
		end if
		set rs=server.createobject("adodb.recordset")
		sql="select * from [scfav] where username='"&membername&"'"
		rs.open sql,conn,1,1
		if rs.eof and rs.bof then
			response.write "<div align=center>您还没有在本校友录建立个人快乐网签，马上<a href='n_urlnew.asp'><font color=red>申请</font></a>快乐网签。</div>"
		else
			userid=rs("id")
			rs.close
			sql="select * from [scurl] where (id is null)"
			rs.open sql,conn,1,3
			rs.addnew
			rs("webname")=webname
			rs("weburl")=weburl
			rs("grouptype")=group
			rs("webtext")=webtext
			rs("username")=membername
			rs.update
			response.redirect "n_url.asp"
		end if
end sub

sub edit()
%>
<script language=vbscript>
<!--
function xxx(form1)
	if trim(form1.webname.value)="" then
		alert("请输入收藏网址的名称！")
	elseif trim(form1.weburl.value)="" then
		alert("请输入要收藏的网址")
	else
		form1.submit
	end if
end function
//-->
</script>
<%
	dim urlid
	urlid=request("urlid")
	if urlid="" then
		response.write "<script>alert('请从正当渠道进入！');history.go(-1);</script>"
		response.end
	end if
	set rs=server.createobject("adodb.recordset")
	sql="select * from scurl where id="&urlid
	rs.open sql,conn,1,1
	if rs.eof and rs.bof then
		response.write "<script>alert('请从正当渠道进入！！');history.go(-1);</script>"
		response.end
	else
		response.write "<form name=thisform1 method=post action=?toact=edited onSubmit='xxx(this);return false;'><table cellpadding=3 cellspacing=1 align=center valign=top class=tableborder1>"
		response.write "<tr><td class=tablebody2 align=center colspan=3><b>编辑网址</b>"
		response.write "<tr><td class=tablebody1 align=left colspan=3>"
		response.write "&nbsp;&nbsp;请填写下表以完成网址的编辑,<font color=red>*</font>为必需内容。"
		response.write "<tr><td width=20% class=tablebody2><td class=tablebody1 align=left>收藏名字：<input type=text name=webname value="&rs("webname")&">&nbsp;<font color=red>*</font>"
		response.write "<input type=hidden name=urlid value="&urlid&">"
		response.write "<br>收藏网址：<input type=text name=weburl value="&rs("weburl")&" size=30>&nbsp;<font color=red>*</font>"
		response.write "<br>简单说明：<input type=text name=webtext value="&rs("webtext")&">"
		response.write "<br><input type=reset value=重置>&nbsp;&nbsp;&nbsp;<input type=submit value=修改>"
		response.write "<td width=20% class=tablebody2></table></form>"
	end if
	
end sub

sub edited()
	dim urlid,webname,weburl,webtext
	urlid=trim(request("urlid"))
	webname=trim(request("webname"))
	weburl=trim(request("weburl"))
	webtext=trim(request("webtext"))
	if webname="" or urlid="" or weburl="" then
		response.write "<script>alert('请从正常渠道进入！');history.go(-1);</script>"
		response.end
	end if
	set rs=server.createobject("adodb.recordset")
	sql="select * from [scurl] where id="&urlid
	rs.open sql,conn,1,3
	if rs.eof and rs.bof then
		response.write "<script>alert('请从正当渠道进入！！');history.go(-1);</script>"
		response.end
	else
		rs("webname")=webname
		rs("weburl")=weburl
		rs("webtext")=webtext
		rs.update
		response.redirect "n_url.asp"
	end if
end sub

sub del()
	dim urlid
	urlid=request("toacter")
	if request("chkall")=1 then
		set rs=server.createobject("adodb.recordset")
		sql="delete from [scurl] where username='"&membername&"'"
		rs.open sql,conn,1,3
	else
		if urlid="" then
			response.write "<script>alert('请选择您要操作的收藏网址！');history.go(-1);</script>"
			response.end
		else
			set rs=server.createobject("adodb.recordset")
			sql="delete from [scurl] where username='"&membername&"' and id in ("&urlid&")"
			rs.open sql,conn,1,3
		end if
	end if
	response.redirect "n_url.asp"
end sub

sub move()
	dim urlid,group
	group=request("group")
	urlid=request("toacter")
	if request("chkall")=1 then
		set rs=server.createobject("adodb.recordset")
		sql="update scurl set grouptype='"&group&"' where username='"&membername&"'"
		conn.execute(sql)
	else
		if urlid="" then
			response.write "<script>alert('请选择您要操作的收藏网址！');history.go(-1);</script>"
			response.end
		else
			set rs=server.createobject("adodb.recordset")
			sql="update scurl set grouptype='"&group&"' where username='"&membername&"' and id in ("&urlid&")"
			conn.execute(sql)
		end if
	end if
	response.redirect "n_url.asp"
end sub


%>