<!-- #Include File="Con_User.asp" -->
<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

dim n_sort,gid,g_id,gname,select_add,id,name,url,rssum
n_sort="book"
rssum=0
g_id=trim(request.querystring("g_id"))
if not(isnumeric(g_id)) then g_id=0
tit="网络书签"
call DoWebHead(2,1)
'----------------------------左边 开始----------------------------
'----------------------------左边 结束----------------------------
'----------------------------中间 开始----------------------------
%>
<script language=javascript>
function group_edit(geid,gename)
{
  var gevar='请输入要修改的书签组（ID：'+geid+'）的新名称，长度不能超过20位';
  this.document.groupedit_frm.g_id.value=geid;
  var gename=prompt(gevar+'：',gename);
  if (gename == null || gename == '' || gename.length>20)
  { alert(gevar+"！");return; }
  else
  { this.document.groupedit_frm.g_name.value=gename; }
  this.document.groupedit_frm.submit();
}
function group_del(gdid)
{
  if (confirm("此操作将删除ID为 "+gdid+" 的书签组！\n真的要删除吗？\n删除后将无法恢复！"))
  { window.location="?action=groupdel&g_id="+gdid; }
}
function bookmark_edit(bid,bname,burl)
{
  var var1='请输入要修改的个人书签（ID：'+bid+'）的名称，长度不能超过50位';
  var var2='请输入要修改的个人书签（ID：'+bid+'）的地址，长度不能超过100位';
  this.document.bookmarkedit_frm.id.value=bid;
  var bename=prompt(var1+'：',bname);
  if (bename == null || bename == '' || bename.length>50)
  { alert(var1+"！");return; }
  else
  {
    this.document.bookmarkedit_frm.name.value=bename;
    var beurl=prompt(var2+'：',burl);
    if (beurl == null || beurl == '' || beurl.length>100)
    { alert(var2+"！");return; }
    else
    {this.document.bookmarkedit_frm.url.value=beurl;}
  }
  this.document.bookmarkedit_frm.submit();
}
function bookmark_del(bdid)
{
  if (confirm("此操作将删除ID为 "+bdid+" 的个人书签！\n真的要删除吗？\n删除后将无法恢复！"))
  { window.location="?action=bookmarkdel&id="+bdid; }
}
</script>
<%
select case action
case "groupedit"
  call group_edit()
case "bookmarkedit"
  call bookmark_edit()
case "groupdel"
  call group_del()
case "bookmarkdel"
  call bookmark_del()
case "groupadd"
  call group_add()
case "bookmarkadd"
  call bookmark_add()
end select
dim sTmp,sTmps
sql="select g_id,g_name from AsaiMHUserBookGroup where g_sort='"&n_sort&"' and username='"&login_username&"' order by g_id"
set rs=conn.execute(sql)
do while not rs.eof
  gid=rs("g_id")
  gname=rs("g_name")
  select_add=select_add&vbcrlf&"<option value='"&gid&"'"
  if int(gid)=int(g_id) then select_add=select_add&" selected"
  select_add=select_add&">"&gname&"</option>"
sTmp=sTmp&"<tr class=tr>" & _
vbcrlf&"<td>"&img_skin("m_")&"<a href='?g_id="&gid&"' class=red_3>"&gname&"</a></td>" & _
vbcrlf&"<td align=center><a href=""javascript:group_edit("&gid&",'"&gname&"');""><img src='"&Cls.web_skindir&"sys/edit.gif' border=0></a>&nbsp;<a href=""javascript:group_del("&gid&");""><img src='"&Cls.web_skindir&"sys/del.gif' border=0></a></td>" & _
vbcrlf&"</tr>"
  rs.movenext
loop
rs.close
sql="select id,name,url from AsaiMHUserBookMark where"
if action<>"all" then sql=sql&" g_id="&g_id&" and"
sql=sql&" username='"&login_username&"' order by id desc"
set rs=Cls.exec(sql,1)
do while not rs.eof
  id=rs("id")
  name=rs("name")
  url=rs("url")
  rssum=rssum+1
sTmps=sTmps&"<tr class=tr>" & _
vbcrlf&"<td align=center class=tims>"&rssum&"</td>" & _
vbcrlf&"<td><a href='"&url&"' target=_blank title='"&Cls.code_html(name,1,0)&"'>"&Cls.code_html(name,1,15)&"</a></td>" & _
vbcrlf&"<td><a href='"&url&"' target=_blank title='"&Cls.code_html(url,1,0)&"'>"&Cls.code_html(url,1,35)&"</a></td>" & _
vbcrlf&"<td align=center><a href=""javascript:bookmark_edit("&id&",'"&name&"','"&url&"');""><img src='"&Cls.web_skindir&"sys/edit.gif' border=0></a>&nbsp;<a href=""javascript:bookmark_del("&id&");""><img src='"&Cls.web_skindir&"sys/del.gif' border=0></a></td>" & _
vbcrlf&"</tr>"
  rs.movenext
loop
rs.close
dim gnames
gnames="<a href='?g_id="&gid&"'>"&gname&"</a>"
if int(g_id)=int(gid) then
gnames="<a href='?g_id="&gid&"' class=red_3>"&gname&"</a>"
  End If
    Cls.HtmlRcod "body",Cls.ReadTemplate ("user_BookMark")
	Cls.HtmlRcod "dir_skin",Cls.web_skindir
	Cls.HtmlRcod "g_id",g_id
	Cls.HtmlRcod "tit",tit
	Cls.HtmlRcod "body",sTmp
	Cls.HtmlRcod "bodys",sTmps
	Cls.HtmlRcod "img_skin",img_skin("h_")
	Cls.HtmlRcod "select_add",select_add
	Cls.OutPage
'----------------------------中间 结束----------------------------
call DoWebEnd()
sub group_del()
  gid=trim(request.querystring("g_id"))
  if not(isnumeric(gid)) then
    Call Cls.Out_Msg("系统发现您提交的数据有错误存在：\n\n您在删除书签组时输入的书签组ID出错！\n\n请返回重新输入。","javascript:history.back(1)")
    Exit Sub
  End If
  sql="delete from AsaiMHUserBookGroup where g_id="&gid&" and g_sort='"&n_sort&"' and username='"&login_username&"'"
  call Cls.exec(sql,1)
  sql="delete from AsaiMHUserBookMark where g_id="&gid&" and username='"&login_username&"'"
  call Cls.exec(sql,1)
  Call Cls.Out_Msg("您成功的删除了一书签组！","?")
End Sub
sub group_edit()
  gname=Cls.Code_Var(request.form("g_name"))
  gid=trim(request.form("g_id"))
  if len(gname)<1 or len(gname)>20 or not(isnumeric(gid)) then
    Call Cls.Out_Msg("系统发现您提交的数据有错误存在：\n\n您在修改书签组的 组名称 时输入的数据有误！\n\n请返回重新输入。","javascript:history.back(1)")
    Exit Sub
  End If
  sql="update AsaiMHUserBookGroup set g_name='"&gname&"' where g_id="&gid&" and g_sort='"&n_sort&"' and username='"&login_username&"'"
  call Cls.exec(sql,1)
  g_id=gid
  Call Cls.Out_Msg("您成功的修改了书签组（名称："&gname&"）！","?")
End Sub
sub bookmark_del()
  id=trim(request.querystring("id"))
  if not(isnumeric(id)) then
    Call Cls.Out_Msg("系统发现您提交的数据有错误存在：\n\n您在删除个人书签时输入的书签ID出错！\n\n请返回重新输入。","javascript:history.back(1)")
    Exit Sub
  End If
  sql="delete from AsaiMHUserBookMark where id="&id&" and username='"&login_username&"'"
  call Cls.exec(sql,1)
  Call Cls.Out_Msg("您成功的删除了一书签组！","?")
End Sub
sub bookmark_edit()
  name=Cls.Code_Var(request.form("name"))
  url=Cls.Code_Var(request.form("url"))
  id=trim(request.form("id"))
  if len(name)<1 or len(name)>50 or len(url)<1 or len(url)>100 or not(isnumeric(id)) then
    Call Cls.Out_Msg("系统发现您提交的数据有错误存在：\n\n您在修改个人书签时输入的数据有误！\n\n请返回重新输入。","javascript:history.back(1)")
    Exit Sub
  End If
  sql="update AsaiMHUserBookMark set name='"&name&"',url='"&url&"' where id="&id&" and username='"&login_username&"'"
  call Cls.exec(sql,1)
  Call Cls.Out_Msg("您成功的修改了个人书签（名称："&name&"）！","?")
End Sub
sub group_add()
  gname=Cls.Code_Var(request.form("g_name"))
  if len(gname)<1 or len(gname)>20 then
    Call Cls.Out_Msg("系统发现您提交的数据有错误存在：\n\n添加书签组的 组名称 是必须要的！\n\n请返回重新输入。","javascript:history.back(1)")
    Exit Sub
  End If
  sql="insert into AsaiMHUserBookGroup(g_sort,g_name,username) values('"&n_sort&"','"&gname&"','"&login_username&"')"
  call Cls.exec(sql,1)
  Call Cls.Out_Msg("您成功的添加了一书签组（名称："&gname&"）！","?")
End Sub
sub bookmark_add()
  dim gg
  gg=trim(request.form("g_id"))
  if not(isnumeric(gg)) then gg=0
  name=Cls.Code_Var(request.form("name"))
  url=Cls.Code_Var(request.form("url"))
  if len(name)<1 or len(name)>50 or len(url)<8 or len(url)>100 then
    Call Cls.Out_Msg("系统发现您提交的数据有错误存在：\n\n添加新书签的 书签名称 和 书签地址 是必须要的！\n\n请返回重新输入。","javascript:history.back(1)")
    Exit Sub
  End If
  sql="insert into AsaiMHUserBookMark(g_id,username,name,url) values("&gg&",'"&login_username&"','"&name&"','"&url&"')"
  call Cls.exec(sql,1)
  g_id=gg
  Call Cls.Out_Msg("您成功的添加了一个我的个人书签（名称："&name&"）！","?")
End Sub
%>
