<script language=javascript>
function g_edit(geid,gename)
{
  var gevar='请输入要修改的书签分类（ID：'+geid+'）的新名称，长度不能超过20位';
  this.document.gedit_frm.g_id.value=geid;
  var gename=prompt(gevar+'：',gename);
  if (gename == null || gename == '' || gename.length>20)
  { alert(gevar+"！");return; }
  else
  { this.document.gedit_frm.g_name.value=gename; }
  this.document.gedit_frm.submit();
}

function g_del(gdid)
{
  if (confirm("此操作将删除ID为 "+gdid+" 的书签分类！\n真的要删除吗？\n删除后将无法恢复！"))
  { window.location="?action=gdel&g_id="+gdid; }
}

function b_edit(bid,bname,burl)
{
  var var1='请输入要修改的个人书签（ID：'+bid+'）的名称，长度不能超过50位';
  var var2='请输入要修改的个人书签（ID：'+bid+'）的地址，长度不能超过100位';
  this.document.bedit_frm.id.value=bid;
  var bename=prompt(var1+'：',bname);
  if (bename == null || bename == '' || bename.length>50)
  { alert(var1+"！");return; }
  else
  {
    this.document.bedit_frm.name.value=bename;
    var beurl=prompt(var2+'：',burl);
    if (beurl == null || beurl == '' || beurl.length>100)
    { alert(var2+"！");return; }
    else
    {this.document.bedit_frm.url.value=beurl;}
  }
  this.document.bedit_frm.submit();
}

function b_del(bdid)
{
  if (confirm("此操作将删除ID为 "+bdid+" 的个人书签！\n真的要删除吗？\n删除后将无法恢复！"))
  { window.location="?action=bdel&id="+bdid; }
}
</script>
<%
'****************************************************
' Hxcms Ver7.6       Power by vip138.com
' Web: http://www.vip138.com,http://www.vip138.com
' Copyright (C) 2006 vip138.com All Rights Reserved.
'****************************************************
dim gid,g_id,gname,select_add,id,name,url,i,action
action=Request.QueryString("action")
g_id=trim(request.querystring("g_id"))
if not(isnumeric(g_id)) then g_id=0
start="网络书签"
'=================================================
'过程名：content_book
'作  用：显示发表内容、表单
'参  数：无
'Web:    http://www.vip138.com
'=================================================
sub content_book()
    select case action
       case "gedit"
          call g_edit()
       case "bedit"
          call b_edit()
       case "gdel"
          call g_del()
       case "bdel"
          call b_del()
       case "gadd"
          call g_add()
       case "badd"
          call b_add()
       case else
          call b_book()
    end select
end sub

'=================================================
'过程名：b_book
'作  用：显示书签列表
'参  数：无
'Web:    http://www.vip138.com
'=================================================
sub b_book()
Response.write "<BR><table bgcolor='#ffffff' borderColor='#f0f0f0' Border='1' Cellspacing='0' Cellpadding='5' width='96%' align='Center' style=""border-collapse: collapse"">"
Response.write "<tr>"
Response.write "<td colspan=2 align=Center><FONT color='#b70000'><B>·</B></FONT>&nbsp;<a href='?g_id=0'>根目录书签</a>&nbsp;&nbsp;<FONT color='#b70000'><B>·</B></FONT>&nbsp;<a href='?action=all'>浏览所有书签</a></td>"
Response.write "</tr>"
Response.write "<tr><form action='?action=gadd' method=post onsubmit=""javascript:frm_submitonce(this);"">"
Response.write "<td width='85%'>书签分类↓&nbsp;&nbsp;&nbsp;&nbsp;添加新的书签分类：<input type=text name=g_name size=20 maxlength=20 class='input'>&nbsp;<input type=submit value='添加分类' class='input'></td></form>"
Response.write "<td width='15%' align=center>分类操作</td>"
Response.write "</tr>"
Response.write "<form name=gedit_frm action='?action=gedit' method=post>"
Response.write "<input type=hidden name=g_id value='"&g_id&"'>"
Response.write "<input type=hidden name=g_name value=''>"
Response.write "</form>"
sql="select id,name from user_book where g_id=0 and s_id=0 and username='"&Hx66_name&"' order by id"
set rs=conn.execute(sql)
do while not rs.eof
  gid=rs("id")
  gname=rs("name")
  select_add=select_add&vbcrlf&"<option value='"&gid&"'"
  if int(gid)=int(id) then select_add=select_add&" selected"
  select_add=select_add&">"&gname&"</option>"
Response.write "<tr>"
Response.write "<td><FONT color='#b70000'><B>·</B></FONT>&nbsp;<a href='?g_id="&gid&"'>"&gname&"</a></td>"
Response.write "<td align=center><a href=""javascript:g_edit("&gid&",'"&gname&"');"">编辑</a>&nbsp;<a href=""javascript:g_del("&gid&");"">删除</a></td>"
Response.write "</tr>"
rs.movenext
loop
rs.close
Response.write "</table>"
Response.write "<BR><table bgcolor='#ffffff' borderColor='#f0f0f0' Border='1' Cellspacing='0' Cellpadding='5' width='96%' align='Center' style=""border-collapse: collapse"">"
Response.write "<tr align=center>"
Response.write "<td width='8%'>序号</td>"
Response.write "<td width='32%'>我的个人书签名称</td>"
Response.write "<td width='45%'>书签地址</td>"
Response.write "<td width='15%'>操 作</td>"
Response.write "</tr>"
Response.write "<form name=bedit_frm action='?g_id="&g_id&"&action=bedit' method=post>"
Response.write "<input type=hidden name=id value=''>"
Response.write "<input type=hidden name=name value=''>"
Response.write "<input type=hidden name=url value=''>"
Response.write "</form>"
i=0
sql="select id,name,url from user_book where s_id=1 and"
if action<>"all" then sql=sql&" g_id="&g_id&" and"
sql=sql&" username='"&Hx66_name&"' order by id desc"
set rs=conn.execute(sql)
if not Rs.eof then
do while not rs.eof
  i=i+1
  id=rs("id")
  name=rs("name")
  url=rs("url")
Response.write "<tr>"
Response.write "<td align=center>"&i&"</td>"
Response.write "<td><a href='"&url&"' target=_blank alt='"&name&"'>"&name&"</a></td>"
Response.write "<td><a href='"&url&"' target=_blank alt='"&url&"'>"&url&"</a></td>"
Response.write "<td align=center><a href=""javascript:b_edit("&id&",'"&name&"','"&url&"');"">编辑</a>&nbsp;<a href=""javascript:b_del("&id&");"">删除</a></td>"
Response.write "</tr>"
rs.movenext
loop
else
response.write "<tr><td align=center colspan=4>此分类目前尚无你的书签！</td></tr>"
end if
rs.close
Response.write "</table>"
Response.write "<BR><table bgcolor='#ffffff' borderColor='#f0f0f0' Border='1' Cellspacing='0' Cellpadding='5' width='96%' align='Center' style=""border-collapse: collapse"">"
Response.write "<tr align=center>"
Response.write "<td>&nbsp;<img src='img/user/book.gif' border='0' align=absmiddle>&nbsp;添加新的个人书签&nbsp;→&nbsp;最多可存 <FONT color=red><B>"&booksum&"</B></FONT> 个在您的个人书签中</td></tr>"
Response.write "<tr><td>"
Response.write "<table border=0>"
Response.write "<form action='?action=badd' method=post onsubmit=""javascript:frm_submitonce(this);"">"
Response.write "<tr>"
Response.write "<td>书签名称：</td>"
Response.write "<td>"
Response.write "<table border=0 cellpadding=0>"
Response.write "<tr>"
Response.write "<td><input type=text name=name size=30 maxlength=50 class='input'></td>"
Response.write "<td>&nbsp;所属书签分类：</td>"
Response.write "<td><select name=g_id class='input'>"
Response.write "<option value='0'>[根目录书签]</option>"
Response.write ""& select_add &""
Response.write "</select></td>"
Response.write "</tr>"
Response.write "</table>"
Response.write "</td></tr>"
Response.write "<tr>"
Response.write "<td>书签地址：</td>"
Response.write "<td>"
Response.write "<table border=0 cellpadding=0>"
Response.write "<tr>"
Response.write "<td><input type=text name=url size=50 value='http://' maxlength=100 class='input'></td>"
Response.write "<td><input type=submit value='添加书签' class='input'></td>"
Response.write "</tr>"
Response.write "</table>"
Response.write "</td></tr>"
Response.write "</form>"
Response.write "</table>"
Response.write "</td></tr>"
Response.write "</table>"
end sub

'=================================================
'过程名：g_del
'作  用：删除书签分类
'参  数：无
'Web:    http://www.vip138.com
'=================================================
sub g_del()
  gid=trim(request.querystring("g_id"))
  if not(isnumeric(gid)) then
    response.write"<SCRIPT language=JavaScript>alert('您在删除书签分类时ID出错！');"
    response.write"javascript:history.go(-1);</SCRIPT>"
    response.end
    exit sub
  end if
  sql="delete from user_book where id="&gid&" and username='"&Hx66_name&"'"
  call conn.execute(sql)
  response.write"<SCRIPT language=JavaScript>alert('成功的删除了一书签分类！');"
    response.write"this.top.location.href='User_book.asp';</SCRIPT>"
    response.end
end sub

'=================================================
'过程名：g_edit
'作  用：修改书签分类
'参  数：无
'Web:    http://www.vip138.com
'=================================================
sub g_edit()
  gname=CheckStr(request.form("g_name"))
  gid=trim(request.form("g_id"))
  if len(gname)<1 or len(gname)>20 or not(isnumeric(gid)) then
    response.write"<SCRIPT language=JavaScript>alert('您在修改书签分类时输入的数据有误！');"
    response.write"javascript:history.go(-1);</SCRIPT>"
    response.end
  exit sub
  end if
  sql="update user_book set name='"&gname&"' where id="&gid&" and username='"&Hx66_name&"'"
  call conn.execute(sql)
  response.write"<SCRIPT language=JavaScript>alert('成功的修改了书签分类："&gname&"');"
    response.write"this.top.location.href='User_book.asp';</SCRIPT>"
    response.end
end sub

'=================================================
'过程名：b_del
'作  用：删除个人书签
'参  数：无
'Web:    http://www.vip138.com
'=================================================
sub b_del()
  id=trim(request.querystring("id"))
  if not(isnumeric(id)) then
    response.write"<SCRIPT language=JavaScript>alert('您在删除个人书签时输入的书签ID出错！');"
    response.write"javascript:history.go(-1);</SCRIPT>"
    response.end
    exit sub
  end if
  sql="delete from user_book where id="&id&" and username='"&Hx66_name&"'"
  call conn.execute(sql)
    response.write"<SCRIPT language=JavaScript>alert('成功的删除了一个书签！');"
    response.write"this.top.location.href='User_book.asp';</SCRIPT>"
    response.end
end sub

'=================================================
'过程名：b_edit
'作  用：修改个人书签
'参  数：无
'Web:    http://www.vip138.com
'=================================================
sub b_edit()
  name=CheckStr(request.form("name"))
  url=CheckStr(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
    response.write"<SCRIPT language=JavaScript>alert('您在修改个人书签时输入的数据有误！');"
    response.write"javascript:history.go(-1);</SCRIPT>"
    response.end
    exit sub
  end if
  sql="update user_book set name='"&name&"',url='"&url&"' where id="&id&" and username='"&Hx66_name&"'"
  call conn.execute(sql)
    response.write"<SCRIPT language=JavaScript>alert('成功的修改了个人书签（名称："&name&"）！');"
    response.write"this.top.location.href='User_book.asp';</SCRIPT>"
    response.end
end sub

'=================================================
'过程名：g_add
'作  用：添加书签分类
'参  数：无
'Web:    http://www.vip138.com
'=================================================
sub g_add()
  gname=CheckStr(request.form("g_name"))
  if len(gname)<1 or len(gname)>20 then
    response.write"<SCRIPT language=JavaScript>alert('请输入书签分类的名称！');"
    response.write"javascript:history.go(-1);</SCRIPT>"
    response.end
    exit sub
  end if
  conn.execute("insert into user_book(name,username) values('"&gname&"','"&Hx66_name&"')")
    response.write"<SCRIPT language=JavaScript>alert('成功的添加了一书签分类："&gname&"');"
    response.write"this.top.location.href='User_book.asp';</SCRIPT>"
    response.end
end sub

'=================================================
'过程名：b_add
'作  用：添加个人书签
'参  数：无
'Web:    http://www.vip138.com
'=================================================
sub b_add()
  dim gg_id,ubsum
  gg_id=trim(request.form("g_id"))
  if not(isnumeric(gg_id)) then gg_id=0
  name=CheckStr(request.form("name"))
  url=CheckStr(request.form("url"))
  ubsum=conn.execute("select count(*) from user_book where username='"&Hx66_name&"'")(0)
  if ubsum>=booksum then
    response.Write"<script language=javascript>alert('您目前的书签(含分类)已达到系统"&booksum&"个限定数，请清理后添加！！');history.back();</script>"
    response.end
  exit sub
  end if
  if len(name)<1 or len(name)>50 or len(url)<8 or len(url)>100 then
    response.write"<SCRIPT language=JavaScript>alert('请输入书签名称 和 书签地址\n\n你的输入超过字数限定！');"
    response.write"javascript:history.go(-1);</SCRIPT>"
    response.end
    exit sub
  end if
  sql="insert into user_book(g_id,s_id,username,name,url) values("&gg_id&",1,'"&Hx66_name&"','"&name&"','"&url&"')"
  call conn.execute(sql)
    response.write"<SCRIPT language=JavaScript>alert('成功的添加了一个我的个人书签："&name&"');"
    response.write"this.top.location.href='User_book.asp';</SCRIPT>"
    response.end
end sub
'****************************************************
' Hxcms Ver7.6       Power by vip138.com
' Web: http://www.vip138.com,http://vip138.com
' Copyright (C) 2006 vip138.com All Rights Reserved.
'****************************************************
%>

