<!-- #include file="include/con_user.asp" -->
<%
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 web_head(2,1,0,0,0)
'----------------------------左边 开始----------------------------
call user_left("")
'----------------------------左边 结束----------------------------
call web_center(0)
'----------------------------中间 开始----------------------------
%>
<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

%>
<table cellspacing=1 cellpadding=4 class=table>
<tr>
<td class=td0 width='90%'>&nbsp;<%response.write img_skin("m_user")%>我的书签组</td>
<td class=td0 width='10%' align=center>组操作</td>
</tr>
<form name=groupedit_frm action='?action=groupedit' method=post>
<input type=hidden name=g_id value='<%response.write g_id%>'>
<input type=hidden name=g_name value=''>
</form>
<tr class=bg_tds>
<td><%response.write img_skin("m_")%><a href='?g_id=0' class=gray>[ 根书签组 ]</a>&nbsp;&nbsp;
<%response.write img_skin("m_")%><a href='?action=all' class=gray>[ 浏览所有书签 ]</a></td>
<td align=center class=gray>暂无</td>
</tr>
<%
sql="select g_id,g_name from jk_group 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>"
%>
<tr class=bg_td>
<td><%response.write img_skin("m_")%><a href='?g_id=<%response.write gid%>'<%if int(g_id)=int(gid) then response.write " class=red_3"%>><%response.write gname%></a></td>
<td align=center><a href="javascript:group_edit(<%response.write gid%>,'<%response.write gname%>');"><img src='<%response.write joekoe_cms.web_dir_skin%>small/edit.gif' border=0></a>&nbsp;<a href="javascript:group_del(<%response.write gid%>);"><img src='<%response.write joekoe_cms.web_dir_skin%>small/del.gif' border=0></a></td>
</tr>
<%
  rs.movenext
loop
rs.close
%>
</table>

<table cellspacing=1 cellpadding=4 class=table>
<tr align=center>
<td class=td0 width='6%'>序号</td>
<td class=td0 width='34%'>我的个人书签名称</td>
<td class=td0 width='50%'>书签地址</td>
<td class=td0 width='10%'>操 作</td>
</tr>
<form name=bookmarkedit_frm action='?g_id=<%response.write g_id%>&action=bookmarkedit' method=post>
<input type=hidden name=id value=''>
<input type=hidden name=name value=''>
<input type=hidden name=url value=''>
</form>
<%
sql="select id,name,url from user_bookmark where"
if action<>"all" then sql=sql&" g_id="&g_id&" and"
sql=sql&" username='"&login_username&"' order by id desc"
set rs=joekoe_cms.exec(sql,1)
do while not rs.eof
  id=rs("id")
  name=rs("name")
  url=rs("url")
  rssum=rssum+1
%>
<tr class=bg_td>
<td align=center class=tims><%response.write rssum%></td>
<td><a href='<%response.write url%>' target=_blank alt='<%response.write joekoe_cms.code_html(name,1,0)%>'><%response.write joekoe_cms.code_html(name,1,15)%></a></td>
<td><a href='<%response.write url%>' target=_blank alt='<%response.write joekoe_cms.code_html(url,1,0)%>'><%response.write joekoe_cms.code_html(url,1,35)%></a></td>
<td align=center><a href="javascript:bookmark_edit(<%response.write id%>,'<%response.write name%>','<%response.write url%>');"><img src='<%response.write joekoe_cms.web_dir_skin%>small/edit.gif' border=0></a>&nbsp;<a href="javascript:bookmark_del(<%response.write id%>);"><img src='<%response.write joekoe_cms.web_dir_skin%>small/del.gif' border=0></a></td>
</tr>
<%
  rs.movenext
loop
rs.close
%>
</table>

<table cellspacing=1 cellpadding=4 class=table>
<tr><td class=td0>&nbsp;<%response.write img_skin("m_user")%>添加新的书签组</td></tr>
<tr class=bg_tds><td>
  <table border=0 cellpadding=2>
  <form action='?action=groupadd' method=post onsubmit="javascript:frm_submitonce(this);">
  <tr>
  <td>组名称：</td>
  <td><input type=text name=g_name size=20 maxlength=20></td>
  <td><input type=submit value='添加书签组'></td>
  </tr>
  </form>
  </table>
</td></tr>
</table>

<table cellspacing=1 cellpadding=4 class=table>
<tr><td class=td0>&nbsp;<%response.write img_skin("m_user")%>添加新的个人书签</td></tr>
<tr class=bg_tds><td>
  <table border=0>
  <form name=form1 action='?action=bookmarkadd' method=post onsubmit="javascript:frm_submitonce(this);">
  <%
  call bookmark_request()
  %>

<script language="JavaScript">
<!--
var Href,Title,Url,Cento;
Href=document.location.href;
var re;
re=new RegExp("#t=(.[^&]*)","ig");
if(re.test(Href)){
	re.exec(Href);
	Title=unescape(RegExp.$1);
}else{
	Title="<%response.write joekoe_cms.code_html(name,1,0)%>";
}

re=new RegExp("&u=(.[^&]*)","ig");
if(re.test(Href)){
	re.exec(Href);
	Url=unescape(RegExp.$1);
	re=new RegExp("^(.[^#]*)","ig");
	if(re.test(Url)){
		re.exec(Url);
		Url=RegExp.$1;
	}
}else{
	Url="<%response.write joekoe_cms.code_html(url,1,0)%>";
}

re=new RegExp("&c=(.[^&]*)","ig");
if(re.test(Href)){
	re.exec(Href);
	Cento=unescape(RegExp.$1);
}else{
	Cento="";
}
//-->
</script>

  <tr>
  <td>书签名称：</td>
  <td>
    <table border=0 cellpadding=0>
    <tr>
    <td><input type=text name=name id=name size=30 maxlength=50></td>
    <td>　书签组：</td>
    <td><select name=g_id>
    <option value='0'>[ 根书签组 ]</option>
<%response.write select_add%>
</select></td>
    </tr>
    </table>
  </td></tr>
  <tr>
  <td>书签地址：</td>
  <td>
    <table border=0 cellpadding=0>
    <tr>
    <td><input type=text name=url id=url size=50 maxlength=100></td>
    <td>　<input type=submit value='添加书签'></td>
    </tr>
    </table>
  </td></tr>
	<script language="JavaScript">
		<!--
		document.form1.name.value=Title;
		document.form1.url.value=Url;
		//document.form1.Intro.value=Cento;
		//-->
	</script>
  </form>
  </table>
</td></tr>
</table>

<table width="100%"  border="0" cellspacing="6">
      <tr>
        <td class=td0>&nbsp;<%response.write img_skin("m_user")%>如何收藏页面到<%=web_dim(1)%>？</td>
      </tr>
      <tr>
        <td class=blue>1) 右键添加方式（推荐）</td>
      </tr>
      <tr>
        <td>　IE浏览器：</td>
      </tr>
      <tr>
        <td>　　<strong>安 装</strong> 下载<a href="bookmarkdown/bookmark.reg" class=red>bookmark.reg</a>到本地，
双击运行安装。安装完后，重启浏览器，今后到任意网页右键菜单中将出现“收藏此页到<%=web_dim(1)%>”菜单，点击即可开始提交；</td>
      </tr>
      <tr>
        <td>　　<strong>卸 载</strong> 下载<a href="bookmarkdown/Remove_bookmark.reg" class=red>Remove_bookmark.reg</a>到本地，双击运行即可完成卸载； </td>
      </tr>
      <tr>
        <td> 　　如果不能直接下载.reg文件，请下载<A href="bookmarkdown/bookmarkdown.rar" class=red><B>bookmarkdown.rar</B></A>并解压使用。</td>
      </tr>
      <tr>
        <td class=blue>2) 链接栏或收藏夹添加方式</td>
      </tr>
      <tr>
        <td>　　<span style="font-weight: bold">操作</span>：</td>
      </tr>
      <tr>
        <td>2.1)将下面的链接拖放到浏览器链接栏（书签栏）：</td>
      </tr>
      <tr>
        <td>　　<a onClick="alert('拖动这个连接到浏览器链接栏或者右键点这个连接加到收藏夹中.'); return false;" href='javascript:u=location.href;t=document.title;c = "" + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text); location="<%=web_dim(2)%>/user_bookmark.asp#t="+escape(t)+"&amp;u="+escape(u)+"&amp;c="+escape(c).replace(/ /g, "+");void 0' class=red>提交<%=web_dim(1)%></a>(不弹出窗口方式)</td>
      </tr>
      <tr>
        <td>　　或 <a onClick="alert('拖动这个连接到浏览器链接栏或者右键点这个连接加到收藏夹中.'); return false;" href='javascript:u=location.href;t=document.title;c = "" + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text); void(zhai=window.open("<%=web_dim(2)%>/user_bookmark.asp#t="+escape(t)+"&amp;u="+escape(u)+"&amp;c="+escape(c).replace(/ /g, "+"),"zhai","scrollbars=no,width=480,height=420,left=75,top=50,status=no,resizable=yes"));zhai.focus();' class=red>提交<%=web_dim(1)%>(P)</a>(弹出窗口方式)</td>
      </tr>
      <tr>
        <td>2.2) 或者右键点上述连接连接“添加到收藏夹”中</td>
      </tr>
      <tr>
        <td>2.3) 在浏览器浏览到好的网页的时候，点击链接栏或收藏夹中的“提交<%=web_dim(1)%>”即可开始提交。</td>
      </tr>
      <tr>
        <td class=blue>3) 直接填写添加方式</td>
      </tr>
      <tr>
        <td>　操作：点击本页链接，并填入标题、网址等即可提交！</td>
      </tr>
    </table>
<%
response.write ukong
'----------------------------中间 结束----------------------------
call web_end(0,0)

sub group_del()
  gid=trim(request.querystring("g_id"))
  if not(isnumeric(gid)) then
    response.write vbcrlf & joekoe_cms.js_put("alert(""您在删除书签组时输入的书签组ID出错！\n\n请返回重新输入。"");history.back(1);",1)
    exit sub
  end if
  sql="delete from jk_group where g_id="&gid&" and g_sort='"&n_sort&"' and username='"&login_username&"'"
  call joekoe_cms.exec(sql,1)
  sql="delete from user_bookmark where g_id="&gid&" and username='"&login_username&"'"
  call joekoe_cms.exec(sql,1)
  response.write vbcrlf & joekoe_cms.js_put("alert(""成功的删除了一书签组！"");",1)
end sub

sub group_edit()
  gname=joekoe_cms.code_form(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 vbcrlf & joekoe_cms.js_put("alert(""您在修改书签组的 组名称 时输入的数据有误！\n\n请返回重新输入。"");history.back(1);",1)
    exit sub
  end if
  sql="update jk_group set g_name='"&gname&"' where g_id="&gid&" and g_sort='"&n_sort&"' and username='"&login_username&"'"
  call joekoe_cms.exec(sql,1)
  g_id=gid
  response.write vbcrlf & joekoe_cms.js_put("alert(""成功的修改了书签组的名称："&gname&""");",1)
end sub

sub bookmark_del()
  id=trim(request.querystring("id"))
  if not(isnumeric(id)) then
    response.write vbcrlf & joekoe_cms.js_put("alert(""您在删除个人书签时输入的书签ID出错！\n\n请返回重新输入。"");history.back(1);",1)
    exit sub
  end if
  sql="delete from user_bookmark where id="&id&" and username='"&login_username&"'"
  call joekoe_cms.exec(sql,1)
  response.write vbcrlf & joekoe_cms.js_put("alert(""成功的删除了一书签组！"");",1)
end sub

sub bookmark_edit()
  name=joekoe_cms.code_form(request.form("name"))
  url=joekoe_cms.code_form(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 vbcrlf & joekoe_cms.js_put("alert(""您在修改个人书签时输入的数据有误！\n\n请返回重新输入。"");history.back(1);",1)
    exit sub
  end if
  sql="update user_bookmark set name='"&name&"',url='"&url&"' where id="&id&" and username='"&login_username&"'"
  call joekoe_cms.exec(sql,1)
  response.write vbcrlf & joekoe_cms.js_put("alert(""成功的修改了个人书签（名称："&name&"）！"");",1)
end sub

sub group_add()
  gname=joekoe_cms.code_form(request.form("g_name"))
  if len(gname)<1 or len(gname)>20 then
    response.write vbcrlf & joekoe_cms.js_put("alert(""添加书签组的 组名称 是必须要的！\n\n请返回新输入。"");history.back(1);",1)
    exit sub
  end if
  sql="insert into jk_group(g_sort,g_name,username) values('"&n_sort&"','"&gname&"','"&login_username&"')"
  call joekoe_cms.exec(sql,1)
  response.write vbcrlf & joekoe_cms.js_put("alert(""成功的添加了一书签组："&gname&""");",1)
end sub

sub bookmark_add()
  dim gg
  gg=trim(request.form("g_id"))
  if not(isnumeric(gg)) then gg=0
  name=joekoe_cms.code_form(request.form("name"))
  url=joekoe_cms.code_form(request.form("url"))
  if len(name)<1 or len(name)>50 or len(url)<8 or len(url)>100 then
    response.write vbcrlf & joekoe_cms.js_put("alert(""添加新书签的 书签名称 和 书签地址 是必须要的！\n\n请返回新输入。"");history.back(1);",1)
    exit sub
  end if
  sql="insert into user_bookmark(g_id,username,name,url) values("&gg&",'"&login_username&"','"&name&"','"&url&"')"
  call joekoe_cms.exec(sql,1)
  g_id=gg
  response.write vbcrlf &joekoe_cms.js_put("alert(""成功的添加了一个我的个人书签："&name&""");",1)
end sub

sub bookmark_request()
  dim tmp_ty
  tmp_ty="|article|news|jober|learn|person|trade|zazhi|zazhi_book|team|ypage|shop|gallery|blog|website|forum|down"&_
  		 "|team_photo|team_news|"
  dim gg,ty,o_gg
  name=""
  url=""
  ty=trim(request.querystring("ty"))
  if instr(tmp_ty,"|"&ty&"|")<1 then
  	url=trim(request.querystring("addurl"))
  	if len(url)<8 or len(url)>100 or instr("http://",url)<1 then
  		url="http://"
  		exit sub
  	end if
  else
    gg=trim(request.querystring("addid"))
    if not(isnumeric(gg)) then
      exit sub
    end if
    select case ty
      case "team_photo","team_news"
        o_gg=trim(request.querystring("o_id"))
    	if not(isnumeric(gg)) then
   		   exit sub
   		end if
      	url=ty&"_view.asp?id="&gg&"&pid="&o_gg
      case "zazhi_book"
      	url=ty&".asp?id="&gg
      case "forum"
    	url=ty&"_view.asp?view_id="&gg
      case else
    	url=ty&"_view.asp?id="&gg
    end select
  end if
  name=trim(request.querystring("addname"))
  if len(name)<1 then
  	url="http://"
  	name=""
  	exit sub
  end if
  name=joekoe_cms.code_html(name,1,48)
end sub

%>