<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../inc/Cls_InType.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadHead()
'=============================================================================
Dim Action
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "savemain"
        Call SaveMain()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
%>
<script src="<%=CmsAdminMapPath%>js/check/link.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain">
  <div class="navigation"><a href="Admin.Index.Asp" class="back">友情链接管理</a> 插件管理 &gt; 友情链接管理 &gt; 添加友情链接 </div>
  <div id="contentTab">
    <div class="content-tab">
      <ul class="tab_nav">
        <li><a onclick="tabs(this);" class="selected" href="javascript:void(0);">添加友情链接</a></li>
      </ul>
    </div>
    <div class="tab_con" style="display: block;">
      <table class="form_table">
        <col width="200px">
          </col>
        
        <tbody>
          <tr>
            <th> 所属分类： </th>
            <td class="td2"><%=GetLinkType(0, "")%><span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 链接名称： </th>
            <td class="td2"><input type="text" class="txtInput w350" name="Title" id="Title" autocomplete="off" datatype="*4-150" nullmsg="链接名称必须填写" errormsg="至少4个字符,最多150个字符!" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 链接URL： </th>
            <td class="td2"><input type="text" class="txtInput w350" name="Url" id="Url" autocomplete="off" datatype="url" nullmsg="链接URL必须填写" errormsg="URL必须以:http//开头.域名后缀结尾,最多150个字符!" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 链接Logo： </th>
            <td class="td2"><input type="text" class="txtInput w350 left" name="Logo" id="Logo" autocomplete="off" datatype="*0-150" errormsg="最多150个字符!" />
              <a href="javascript:;" class="files">
              <input type="file" id="FileUpload" name="FileUpload" onchange="Upload('../', 'UpFile', 11000, 1, 'Logo', 'FileUpload');" />
              </a> <span class="uploading">正在上传，请稍候...</span>　
              <input type="button" class="btnSearch" value="从已上传中选择" onclick="ShowWin('Logo', '从已上传中选择', '../Admin_File.Asp?action=sf&ChannelId=11000&ReturnId=Logo', SetDialog.PublicWidth, SetDialog.PublicHeight, false);" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 链接排序： </th>
            <td class="td2"><input type="text" class="txtInput w100" name="Px" id="Px" autocomplete="off" value="100" datatype="px" nullmsg="排序必须填写" errormsg="只能是数字越小越排前,不可为：0,最多5位数" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th></th>
            <td><input type="submit" class="btnSubmit" value="提交保存" />
              &nbsp;
              <input name="重置" type="reset" class="btnSubmit" value="重 置" /></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    ChkSysAdminLevel "sys_link", "add"
    '=====================================================================
    Dim ClassId, Title, Url, Logo, Px
    ClassId = Easp.Post("ClassId:n:0")
    Title = Trim(Easp.Post("Title:s"))
    Url = Trim(Easp.Post("Url:s"))
    Logo = Trim(Easp.Post("Logo:s"))
    Px = Easp.Post("Px:n:0")
    '=====================================================================
    If ClassId = 0 Then
        CmsAdmin.JscriptMsg "所属分类必须选择！", "back", "Error", "null"
    End If
    If Easp.IsN(Title) Then
        CmsAdmin.JscriptMsg "链接名称必须填写！", "back", "Error", "null"
    End If
    If Easp.IsN(Url) Then
        CmsAdmin.JscriptMsg "链接URL必须填写！", "back", "Error", "null"
    End If
    If Px = 0 Then
        CmsAdmin.JscriptMsg "排序必须填写！", "back", "Error", "null"
    End If
    '=====================================================================
    Dim List, ResultVal
    Easp.Use "list"
    Set List = Easp.List.New
    List("ClassId") = ClassId
    List("Title") = Title
    List("Url") = Url
    List("Logo") = Logo
    List("Px") = Px
    List("Counts") = 1
    List("AddTime") = Now()
    '=====================================================================
    ResultVal = Easp.db.AR(TablePrefix & "Link:id", List.Hash)
    '=====================================================================
    Easp.C List
    If ResultVal <> 0 Then
        CmsAdmin.LoadCreateIndex()
        CmsAdmin.JscriptMsg "添加友情链接成功！", "Admin.Index.Asp", "Success", "null"
    End If
    '=====================================================================
End Sub
%>
