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

dim session_for,hvar
session_for=Cls.web_cookies&"_put_"
hvar=0
Index_Url="links"
select case action
case "add"
  tit_fir="友情链接"
  tit="自助链接"
  hvar=1
case else
  tit="友情链接"
  hvar=0
end select
call DoWebHead(0,hvar)
'----------------------------中间 开始----------------------------
select case action
case "add"
  call time_lock()
  call links_add()
case else
  call links_main()
end select
'----------------------------中间 结束----------------------------
call dowebend()

sub links_main()
  dim types,ltit,tmp1
  dim sql_add
  types=Cls.Code_ID("types")
  select case types
  case 1
    sql_add=" and sort='fir'"
    ltit="首页链接"
  case 2
    sql_add=" and sort='sec'"
    ltit="内页链接"
  case 3
    sql_add=" and sort='Bbs'"
    ltit="论坛链接"
  case 4
    sql_add=" and sort='txt'"
    ltit="文字链接"
  case else
    sql_add=""
    ltit="友情链接"
  end select
  Dim TrHtml
  Cls.ReadPage "links_view"
  TrHtml = Cls.CutFixContent(NewContent, "[Repeat]" , "[/Repeat]", 0)
  dim obj_page
  set obj_page=new Cls_PageCute
  obj_page.pageurl="?types="&types&"&"
  obj_page.nummer=Format_Mid_Num(12)
  obj_page.page_t=1
  obj_page.page_p=5
  obj_page.page_unit="个"
  obj_page.page_tit=ltit&"站点"
  obj_page.v_id="id"
  call obj_page.p_init("id,nname,url,pic,remark,webmaster,email","AsaiMHLinks","hidden=1"&sql_add,"orders")
  sql=obj_page.sql_count
  set rs=Cls.exec(sql,1)
  obj_page.rssum=rs(0)
  rs.close
  call obj_page.p_main("id,nname,url,pic,remark,webmaster,email","AsaiMHLinks","hidden=1"&sql_add,"orders")
  for i=1 to obj_page.page_num
  tmp1=tmp1&link_type(i+obj_page.page_now,rs("id"),rs("nname"),rs("url"),rs("pic"),rs("remark"),rs("webmaster"),rs("email"),TrHtml)
    rs.movenext
  next
  rs.close
  NewContent = Replace(NewContent,"[Repeat]"&TrHtml&"[/Repeat]",tmp1)
  Cls.HtmlRcod "ends","<tr><td colspan=5 class=tr0><div id=asaipage>"&obj_page.page_var&" "&obj_page.page_cute&" "&obj_page.page_shortcut&"</div></td></tr>"
	Cls.HtmlRcod "tit",tit
	Cls.HtmlRcod "m_help2",img_skin("m_help2")
    Cls.OutPage
  set obj_page=nothing
End Sub

Function link_type(u_i,u_id,u_nname,u_url,u_pic,u_remark,u_webmaster,u_email,u_TrHtml)
  if u_pic<>"" then
    if u_pic="Http://" or u_pic="http://" or u_pic="/Images/Links/" or u_pic="/images/links/" then
      u_pic="<font style='color: #606060;'><b>文字链接</b></font>"
    Else
      u_pic="<img src='"&u_pic&"' border=0 width=88 height=31>"
  End If
  End If
  Dim HtmlStr:HtmlStr=u_TrHtml
  HtmlStr = Replace(HtmlStr,"{$u_i}",u_i)
  HtmlStr = Replace(HtmlStr,"{$u_id}",u_id)
  HtmlStr = Replace(HtmlStr,"{$u_nname}",Cls.code_html(u_nname,1,0))
  HtmlStr = Replace(HtmlStr,"{$u_renname}",Cls.code_html(u_nname,1,20))
  HtmlStr = Replace(HtmlStr,"{$u_url}",u_url)
  HtmlStr = Replace(HtmlStr,"{$u_pic}",u_pic)
  HtmlStr = Replace(HtmlStr,"{$u_remark}",Cls.code_html(u_remark,1,20))
  HtmlStr = Replace(HtmlStr,"{$u_webmaster}",u_webmaster)
  HtmlStr = Replace(HtmlStr,"{$u_email}",u_email)
  link_type = HtmlStr
End Function

sub links_add()
  dim nname,nurl,npic,orders,nsort,hidden,found_err,sort
  dim remark,webmaster,email
  if chk() then
    nname=Cls.code_admin("nname",1,20)
    nurl=Cls.code_admin("url",1,100)
    npic=Cls.code_admin("pic",1,100)
    sort=Cls.code_admin("sort",1,5)
    remark=Cls.Code_admin("remark",1,100)
    webmaster=Cls.code_admin("webmaster",1,20)
    email=Cls.code_admin("email",1,20)
    found_err=""
    if nname="" then
      found_err=found_err & "+请输入您的 <font class=red>网站名称</font>（长度不能大于20）<br />"
    End If
    if nurl="" or lcase(nurl)="http://" or len(nurl)>100 then
      found_err=found_err & "+<font class=red>网站地址</font> 不能为空！（长度不能大于100）<br />"
    End If
    if ChkName(nname)=false then
      found_err=found_err & "+<font class=red>网站名称</font>  含有非法字符！<br />"
    End If
    if Cls.Is_Email(email,50)=false then
      found_err=found_err & "+<font class=red>邮件地址</font>  格式有错误！<br />"
    End If
    if sort<>"txt" then
      if npic="" or len(npic)>100 then
        found_err=found_err & "+<font class=red>图片地址</font> 不能为空！（长度不能大于100）<br />"
      End If
    End If
    if found_err<>"" then
         Cls.ReadPage "common"
	     Cls.HtmlRcod "msg",Found_Error(Found_Err,460)
	     Cls.HtmlRcod "tit",tit
	     Cls.OutPage
      exit sub
    End If
    orders=Cls.Max_ID("AsaiMHLinks","orders","")+1
    sql="select * from AsaiMHLinks"
    call Cls.exe_conn(rs,sql,3)
    rs.addnew
    rs("orders")=orders
    rs("sort")=sort
    rs("nname")=nname
    rs("webmaster")=webmaster
    rs("email")=email
    rs("remark")=remark
    rs("url")=nurl
    if npic="" then
    	rs("pic")="http://"
    Else
    	rs("pic")=npic
    End If
    rs("hidden")=false
    rs.update
    rs.close
    Dim lamsg:lamsg=Vbcrlf&"<TABLE cellspacing=1 cellpadding=4 align=center>"&_	
               Vbcrlf&"<tr><td align=center height=250> "&_				   
               Vbcrlf&"<b><font class=blue>操作成功!</font></b><br /><br /><font class=red>谢谢你与本站交换友情链接！请先做好本站链接，审核后即可开通！</font><br /><br /> "&_	
               Vbcrlf&"<a href='links.asp'>返回友情链接</a><br /><br /> "&_	
               Vbcrlf&"（系统将在 <font class=red>"& Format_Mid_Num(25)&"</font> 秒钟后自动返回） "&_	
               Vbcrlf&"<meta http-equiv='refresh' content='"& Format_Mid_Num(25)&"; url=Links.asp'> "&_	
               Vbcrlf&"</td></tr></table>"
    Cls.ReadPage "common"
	Cls.HtmlRcod "msg",lamsg
	Cls.HtmlRcod "tit",tit
	Cls.OutPage
    exit sub
  End If
  call form_first()
    Cls.ReadPage "links_add"
	Cls.HtmlRcod "tit",tit
	Cls.HtmlRcod "m_help2",img_skin("m_help2")
	Cls.OutPage
End Sub

function chk()
  chk=Cls.chk()
  if session(session_for&"addfrm")=false then chk=false
End Function

sub form_first()
  session(session_for&"addfrm")=true
End Sub
%>
