<%@LANGUAGE="VBSCRIPT" CodePage="936"%>
<%if session("admin")="" then
response.Redirect "../admin/login.asp"
end if
%>
<%
function leftshow(str,leftc)
if len(str)>=leftc then
leftshow=left(str,leftc)&".."
else
leftshow=str
end if
end function

function htmlencode(reString)
dim Str
str=reString
str=replace(str, "&", "&amp;")
str=replace(str, ">", "&gt;")
str=replace(str, "<", "&lt;")
htmlencode=Str
end function
'================================================== 
'函 数 名：   YuZhe_UrlEncode 
'功    能：   将指定字符进行指定格式进行编码 
'参    数:    iStrCode 目标字符 
'             iPageCode 指定编码　65001-UTF-8或936-GB2312 
'================================================== 
Function YuZhe_UrlEncode(iStrCode, iPageCode) 
    Dim StrUrlEncode 
    StrUrlEncode = "" '初始化变量 
    If iPageCode <> SetPageCode Then '如果指定要编码的类型与当前页面编码不一至，则临时设置处理该函数时的页面编码类型 
        Session.CodePage = iPageCode 
        StrUrlEncode = Server.UrlEncode(iStrCode) 
        Session.CodePage = SetPageCode '还原页面编码为默认 
    Else 
        StrUrlEncode = Server.UrlEncode(iStrCode) 
    End If 
    YuZhe_UrlEncode = StrUrlEncode 
End Function 

'==================================================    
'函数名：    Gb2312UrlDecode    
'功能：      将Gb2312Url编码解码为中文    
'EncodeStr:  需要解码的GB2312编码，仅在GB2312页面编码中有效    
'==================================================    
Function Gb2312UrlDecode(DecodeStr)    
    'On Error Resume Next    
    If DecodeStr = "" Or IsNull(DecodeStr) Then Exit Function   
    Dim NewGb2312UrlDecodeStr,HaveGb2312UrlDecodeChar,LastGb2312UrlDecodeChar    
    Dim iGb2312UrlDecode,Gb2312UrlDecodeChar_C,Gb2312UrlDecodeChar_C_1,Gb2312UrlDecodeChar_Num_1    
    NewGb2312UrlDecodeStr = ""     
    HaveGb2312UrlDecodeChar = False     
    LastGb2312UrlDecodeChar = ""     
    For iGb2312UrlDecode = 1 To Len(DecodeStr)    
        Gb2312UrlDecodeChar_C = mid(DecodeStr,iGb2312UrlDecode,1)     
        If Gb2312UrlDecodeChar_C = "+" Then     
            NewGb2312UrlDecodeStr = NewGb2312UrlDecodeStr & " "     
        ElseIf Gb2312UrlDecodeChar_C = "%" Then     
            Gb2312UrlDecodeChar_C_1 = Mid(DecodeStr,iGb2312UrlDecode+1,2)     
            Gb2312UrlDecodeChar_Num_1 = Cint("&H" & Gb2312UrlDecodeChar_C_1)     
            If HaveGb2312UrlDecodeChar Then     
                HaveGb2312UrlDecodeChar = False     
                NewGb2312UrlDecodeStr = NewGb2312UrlDecodeStr & Chr(Cint("&H" & LastGb2312UrlDecodeChar & Gb2312UrlDecodeChar_C_1))     
            Else      
                If abs(Gb2312UrlDecodeChar_Num_1) <= 127 then     
                    NewGb2312UrlDecodeStr = NewGb231     
                    HaveGb2312UrlDecodeChar = True     
                    LastGb2312UrlDecodeChar = Gb2312UrlDecodeChar_C_1     
                End If     
            End if     
            iGb2312UrlDecode = iGb2312UrlDecode+2     
        Else     
            NewGb2312UrlDecodeStr = NewGb2312UrlDecodeStr & Gb2312UrlDecodeChar_C    
        End If   
    Next   
    Gb2312UrlDecode = NewGb2312UrlDecodeStr    
End Function   
'雨哲注：该函数代码由雨哲修改于网络 
%>
<%
sub editsiteinfo()
Dim infostrSourceFile,infoobjXML
infostrSourceFile=Server.MapPath("xml/info.xml")
Set infoobjXML=Server.CreateObject("Microsoft.XMLDOM")
infoobjXML.load(infostrSourceFile)
Dim infoobjNodes
Set infoobjNodes=infoobjXML.selectSingleNode("xml/qqinfo/qqset[siteid ='1']")
If Not IsNull(infoobjNodes) then
infoobjNodes.childNodes(0).text=htmlencode(request.form("sitename"))
infoobjNodes.childNodes(1).text=htmlencode(request.form("siteskin"))
infoobjNodes.childNodes(2).text=htmlencode(request.form("siteshowx"))
infoobjNodes.childNodes(3).text=htmlencode(request.form("siteshowy"))
infoobjNodes.childNodes(4).text=htmlencode(request.form("sitemyt"))
infoobjNodes.childNodes(5).text=htmlencode(request.form("sitemsn"))
infoobjNodes.childNodes(6).text=htmlencode(request.form("siteskype"))
siteww=htmlencode(request.form("siteww"))  
  dim   chinese   
  chinese=0     
  For   i   =1   to   Len(Trim(siteww))   
          if   asc(Mid(siteww,i,1))<0   then   
          chinese=1   
          exit   for   
          end   if   
  next   
  if   chinese=1   then   
infoobjNodes.childNodes(7).text=YuZhe_UrlEncode(htmlencode(request.form("siteww")),936)
  else   
infoobjNodes.childNodes(7).text=htmlencode(request.form("siteww"))
  end   if   
infoobjNodes.childNodes(8).text=htmlencode(request.form("sitetel1"))
infoobjNodes.childNodes(9).text=htmlencode(request.form("sitetel2"))
infoobjNodes.childNodes(10).text=htmlencode(request.form("sitefax"))
infoobjNodes.childNodes(11).text=htmlencode(request.form("siteemail"))
infoobjNodes.childNodes(12).text=htmlencode(request.form("sitepost"))
infoobjNodes.childNodes(13).text=htmlencode(request.form("siteaddress"))
infoobjXML.save(infostrSourceFile)
%>
<script language="javascript">
alert("参数修改成功！")
location.href="?type=manage"
</script>
<%
Else
%>
<script language="javascript">
alert("Xml 未成功打开！")
history.back()
</script>
<%
End If
Set infoobjNodes=nothing
Set infoobjXML=nothing
end sub


sub addinfo()
if trim(request.form("qq"))="" or trim(request.form("dis"))="" or trim(request.form("face"))="" then
%>
<script language="javascript">
alert("没有填入必要的数据！")
history.back()
</script>
<%
response.end
end if

dim jtb_color
if trim(request.form("color"))="" then
jtb_color="#000000"
else
jtb_color=htmlencode(request.form("color"))
end if

Dim strSourceFile,objXML,oListNode,oDetailsNode,AllNodesNum
strSourceFile=Server.MapPath("xml/qq.xml")
Set objXML=Server.CreateObject("Microsoft.XMLDOM")
objXML.load(strSourceFile)
Dim objRootlist
Set objRootlist=objXML.documentElement.selectSingleNode("qqlist")
dim id
If objRootlist.hasChildNodes then
id=objRootlist.lastChild.lastChild.text+1
Else
id=1
End If
Set objRootlist=nothing
Set oListNode=objXML.documentElement.selectSingleNode("qqlist").AppendChild(objXML.createElement("qq"))
Set oDetailsNode=oListNode.appendChild(objXML.createElement("qid"))
oDetailsNode.Text=htmlencode(request.form("qq"))
Set oDetailsNode=oListNode.appendChild(objXML.createElement("dis"))
oDetailsNode.Text=htmlencode(request.form("dis"))
Set oDetailsNode=oListNode.appendChild(objXML.createElement("face"))
oDetailsNode.Text=htmlencode(request.form("face"))
Set oDetailsNode=oListNode.appendChild(objXML.createElement("color"))
oDetailsNode.Text=jtb_color
Set oDetailsNode=oListNode.appendChild(objXML.createElement("id"))
oDetailsNode.Text=id
objXML.save(strSourceFile)
Set objRootlist=nothing
Set oListNode=nothing
Set oDetailsNode=nothing
Set objXML=nothing
%>
<script language="javascript">
alert("添加新的QQ号成功！")
location.href="?type=manage"
</script>
<%
response.end
end sub



sub editinfo()
dim editid:editid=request.querystring("id")
if not IsNumeric(editid) or editid="" then
%>
<script language="javascript">
alert("非法操作！")
history.back()
</script>
<%
response.end
else
editid=clng(editid)
end if
if trim(request.form("qq"))="" or trim(request.form("dis"))="" or trim(request.form("face"))="" then
%>
<script language="javascript">
alert("没有添入必要的数据！")
history.back()
</script>
<%
response.end
end if
Dim strSourceFile,objXML
strSourceFile=Server.MapPath("xml/qq.xml")
Set objXML=Server.CreateObject("Microsoft.XMLDOM")
objXML.load(strSourceFile) 
Dim objNodes
Set objNodes=objXML.selectSingleNode("xml/qqlist/qq[id ='"&editid&"']")
If Not IsNull(objNodes) then
objNodes.childNodes(0).text=htmlencode(request.form("qq"))
objNodes.childNodes(1).text=htmlencode(request.form("dis"))
objNodes.childNodes(2).text=htmlencode(request.form("face"))
objNodes.childNodes(3).text=htmlencode(request.form("color"))
objXML.save(strSourceFile)
Set objNodes=nothing
Set objXML=nothing
%>
<script language="javascript">
alert("修改成功！")
location.href="?type=manage"
</script>
<%
else
%>
<script language="javascript">
alert("修改失败！")
location.href="?type=manage"
</script>
<%
end if
response.end
end sub

sub delinfo()
dim delid
delid=request.querystring("id")
if not IsNumeric(delid) or delid="" then
%>
<script language="javascript">
alert("非法操作！")
location.href="<%=jurl%>?type=manage"
</script>
<%
response.end
else
delid=clng(delid)
end if
Dim strSourceFile,objXML
strSourceFile=Server.MapPath("xml/qq.xml")
Set objXML=Server.CreateObject("Microsoft.XMLDOM")
objXML.load(strSourceFile)
Dim objNodes
Set objNodes=objXML.selectSingleNode("xml/qqlist/qq[id ='"&delid&"']")
if Not IsNull(objNodes) then
if request.querystring("yn")="" then
%>
<script language="javascript">
if(confirm("确认要删除[<%=objNodes.childNodes(0).text%>]的信息吗？"))
window.location="?type=manage&act=delete&id=<%=delid%>&yn=1"
else
history.back()
</script>
<%
else
objNodes.parentNode.removeChild(objNodes)
objXML.save(strSourceFile)
%>
<script language="javascript">
alert("删除成功！")
location.href="?type=manage"
</script>
<%
end if
else
%>
<script language="javascript">
alert("没有找到指定的条目！")
location.href="?type=manage"
</script>
<%
End If
Set objNodes=nothing
Set objXML=nothing
response.end
end sub


select case request.querystring("act")
case "login" call login()
case "editsiteinfo" call editsiteinfo()
case "add"  call addinfo()
case "edit"  call editinfo()
case "delete" call delinfo()
end select
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网站在线客服管理系统</title>
<style type="text/css">
<!--
body{margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;BACKGROUND:#D7F1E8;}
a{font-style:normal;TEXT-DECORATION: none;color:#000000;}
a:hover{font-style:normal;TEXT-DECORATION: none;color:#F4F4F4;}
a:active{font-style:normal;TEXT-DECORATION: none;color:#000000;}
table{font-size: 9pt;font-family: tahoma;color:#000000;}
-->
</style>
</head>
<body>


<%
sub slist()
%>
<table border="0" width="90%" cellpadding="0" cellspacing="0" align="center" bgcolor="#f1f1f1">
  <tr bgcolor="#ffffff">
    <td >
    <fieldset align="center" bgcolor="#ffffff">
    <legend bgcolor="#ffffff">网站在线客服管理系统</legend>
<%
Dim infostrSourceFile,infoobjXML
infostrSourceFile=Server.MapPath("xml/info.xml")
Set infoobjXML=Server.CreateObject("Microsoft.XMLDOM")
infoobjXML.load(infostrSourceFile)
Dim infoobjNodes
Set infoobjNodes=infoobjXML.selectSingleNode("xml/qqinfo/qqset[siteid ='1']")
If Not IsNull(infoobjNodes) then
%>
    <form method="post" action="?type=manage&act=editsiteinfo">
    <table border="0" width="90%" align="center" bgcolor="#f1f1f1">    
    
      <tr bgcolor="#ffffff">
        <td width="100" height="25">&nbsp;网站名：</td><td width="400"><input type="text" name="sitename" size="30" value="<%=infoobjNodes.childNodes(0).text%>">
       </td>
     </tr>     
      <tr bgcolor="#ffffff">
        <td width="100" height="25">&nbsp;使用皮肤：</td><td width="400"><input type="text" name="siteskin" size="30" value="<%=infoobjNodes.childNodes(1).text%>">
        </td>
      </tr>
      <tr bgcolor="#ffffff">
        <td width="100" height="25">&nbsp;显示界面X坐标：</td><td width="400"><input type="text" name="siteshowx" size="30" value="<%=infoobjNodes.childNodes(2).text%>"></td>
      </tr>
      <tr bgcolor="#ffffff">
        <td width="100" height="25">&nbsp;Y坐标：</td><td width="400"><input type="text" name="siteshowy" size="30" value="<%=infoobjNodes.childNodes(3).text%>"></td>
      </tr>
        <tr bgcolor="#ffffff">
        <td width="100" height="25">阿里巴巴贸易通:</td><td width="400"><input type="text" name="sitemyt" size="30" value="<%=infoobjNodes.childNodes(4).text%>">(留空前台不显示)</td>
      </tr>
        <tr bgcolor="#ffffff">
        <td width="100" height="25">MSN:</td><td width="400"><input type="text" name="sitemsn" size="30" value="<%=infoobjNodes.childNodes(5).text%>">(留空前台不显示)</td>
      </tr>
       <tr bgcolor="#ffffff">
        <td width="100" height="25">skype:</td><td width="400"><input type="text" name="siteskype" size="30" value="<%=infoobjNodes.childNodes(6).text%>">(留空前台不显示)</td>
      </tr>
        <tr bgcolor="#ffffff">   
         <td width="100" height="25">&nbsp;旺旺：</td><td width="400"><input type="text" name="siteww" size="50" value="<%=infoobjNodes.childNodes(7).text%>"><br>(留空前台不显示)
     </td>
     </tr>
       <tr bgcolor="#ffffff">
        <td width="100" height="25">联系电话一:</td><td width="400"><input type="text" name="sitetel1" size="30" value="<%=infoobjNodes.childNodes(8).text%>">(留空前台不显示)</td>
      </tr>
      <tr bgcolor="#ffffff">
        <td width="100" height="25">联系电话二:</td><td width="400"><input type="text" name="sitetel2" size="30" value="<%=infoobjNodes.childNodes(9).text%>">(留空前台不显示)</td>
      </tr>
        <tr bgcolor="#ffffff">
        <td width="100" height="25">联系传真:</td><td width="400"><input type="text" name="sitefax" size="30" value="<%=infoobjNodes.childNodes(10).text%>">(留空前台不显示)</td>
      </tr>
        <tr bgcolor="#ffffff">
        <td width="100" height="25">联系email:</td><td width="400"><input type="text" name="siteemail" size="30" value="<%=infoobjNodes.childNodes(11).text%>">(留空前台不显示)</td>
      </tr>
       <tr bgcolor="#ffffff">
        <td width="100" height="25">邮政编码:</td><td width="400"><input type="text" name="sitepost" size="30" value="<%=infoobjNodes.childNodes(12).text%>">(留空前台不显示)</td>
      </tr>
        <tr bgcolor="#ffffff">
        <td width="100" height="25">联系地址:</td><td width="400"><input type="text" name="siteaddress" size="30" value="<%=infoobjNodes.childNodes(13).text%>">(留空前台不显示)</td>
      </tr>
      
   
   
      <tr bgcolor="#ffffff">
        <td width="500" height="10" colspan="2"><input type="submit" name="submit" value="修改"></td>
      </tr>
    </table>
    </form>
<%
Else
%>
<script language="javascript">
alert("Xml 未成功打开！")
history.back()
</script>
<%
response.end
End If
Set infoobjNodes=nothing
Set infoobjXML=nothing
%>
    <table border="0" width="100%">
      <tr>
        <td width="180" height="25">&nbsp;QQ号</td>
        <td width="180" height="25">&nbsp;描述</td>
        <td width="80" height="25">&nbsp;头像</td>
        <td width="30" align="center" height="25">编辑</td>
        <td width="30" align="center" height="25">删除</td>
      </tr>
<%
Dim strSourceFile,objXML,objRootsite,AllNodesNum
strSourceFile=Server.MapPath("xml/qq.xml")
Set objXML=Server.CreateObject("Microsoft.XMLDOM")
objXML.load(strSourceFile)
Set objRootsite=objXML.documentElement.selectSingleNode("qqlist")
AllNodesNum=objRootsite.childNodes.length-1
Dim iCount
For iCount=0 to AllNodesNum
%>
      <tr>
        <td width="180" height="25">&nbsp;<%=objRootsite.childNodes.item(iCount).childNodes.item(0).text%></td>
        <td width="180" height="25">&nbsp;<%=objRootsite.childNodes.item(iCount).childNodes.item(1).text%></td>
        <td width="80" height="25">&nbsp;<img src="images/qqface/<%=objRootsite.childNodes.item(iCount).childNodes.item(2).text%>_m.gif" border="0"></td>
        <td width="30" align="center" height="25"><a href="?type=manage&mtype=edit&id=<%=objRootsite.childNodes.item(iCount).childNodes.item(4).text%>">编辑</a></td>
        <td width="30" align="center" height="25"><a href="?type=manage&act=delete&id=<%=objRootsite.childNodes.item(iCount).childNodes.item(4).text%>">删除</a></td>
      </tr>
<%
Next
Set objRootsite=nothing
Set objXML=nothing
%>      
    </table>
    <form method="post" action="?type=manage&act=add">
    <table border="0" width="500">
      <tr>
        <td width="500" height="10"></td>
      </tr>     
      <tr>
        <td width="500" height="25">&nbsp;添加新的QQ号</td>
      </tr>     
      <tr>
        <td width="500" height="25">&nbsp;QQ号：<input type="text" name="qq" size="20"></td>
      </tr>     
      <tr>
        <td width="500" height="25">&nbsp;描述：<input type="text" name="dis" size="25"></td>
      </tr>
      <tr>
        <td width="500" height="25">&nbsp;颜色：<input type="text" name="color" size="25"> 输入颜色代码例如：#000000</td>  
      </tr>
      <tr>
        <td width="500" height="25">&nbsp;头像：<br>   
        <%dim fcount:for fcount=1 to 100%>
        <input type="radio" name="face" value="<%=fcount%>"><img src="images/qqface/<%=fcount%>_m.gif" border="0">                                                      
        <%next%>                                                      
        </td>                                                                           
      </tr>
      <tr>
        <td width="500" height="10"></td>
      </tr>
      <tr>
        <td width="500" height="25">&nbsp;<input type="submit" name="submit" value="确定添加">&nbsp;<input type="reset" name="reset" value="取消重置"></td>
      </tr>
      <tr>
        <td width="500" height="10"></td>
      </tr>
    </table>
    </form>
    </fieldset>
    </td>
  </tr>
</table>
<%
end sub



sub neditinfo()
%>

<table border="0" width="500" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td width="500">
    <fieldset align="center">
    <legend>编辑QQ信息</legend>    
<%
dim neditid:neditid=request.querystring("id")
if not IsNumeric(neditid) or neditid="" then
%>
<script language="javascript">
alert("非法操作！")
history.back()
</script>
<%
response.end
else
neditid=clng(neditid)
end if
Dim strSourceFile,objXML
strSourceFile=Server.MapPath("xml/qq.xml")
Set objXML=Server.CreateObject("Microsoft.XMLDOM")
objXML.load(strSourceFile)
Dim objNodes
Set objNodes=objXML.selectSingleNode("xml/qqlist/qq[id ='"&neditid&"']")
If Not IsNull(objNodes) then
%>
    <form method="post" action="?type=manage&act=edit&id=<%=neditid%>">
    <table border="0" width="500">
      <tr>
        <td width="500" height="10"></td>
      </tr>     
      <tr>
        <td width="500" height="25">&nbsp;修改指定的QQ信息</td>
      </tr>     
      <tr>
        <td width="500" height="25">&nbsp;QQ号：<input type="text" name="qq" size="20" value="<%=objNodes.childNodes(0).text%>"></td>
      </tr>     
      <tr>
        <td width="500" height="25">&nbsp;描述：<input type="text" name="dis" size="25" value="<%=objNodes.childNodes(1).text%>"> </td>                                                                         
      </tr>
      <tr>
        <td width="500" height="25">&nbsp;颜色：<input type="text" name="color" size="25" value="<%=objNodes.childNodes(3).text%>"> 输入颜色代码例如：#000000</td>  
      </tr>
      <tr>
        <td width="500" height="25">&nbsp;头像：<br>
        <%dim fcount:for fcount=1 to 100%>
        <input type="radio" name="face" value="<%=fcount%>"<%if objNodes.childNodes(2).text=cstr(fcount) then response.write" checked"%>><img src="images/qqface/<%=fcount%>_m.gif" border="0">                                      
        <%next%>                                      
        </td>                                                                           
      </tr>
      <tr>
        <td width="500" height="10"></td>
      </tr>
      <tr>
        <td width="500" height="25">&nbsp;<input type="submit" name="submit" value="确定修改">&nbsp;<input type="reset" name="reset" value="取消重置"></td>
      </tr>
      <tr>
        <td width="500" height="10"></td>
      </tr>
    </table>
    </form>
    </fieldset>
    </td>
  </tr>
</table>
<%
else
%>
<script language="javascript">
alert("发生错误！")
history.back()
</script>
<%
end if
Set objNodes=nothing
Set objXML=nothing
end sub

if request.querystring("type")="manage" then
%>
<table border="0" width="90%" cellpadding="0" cellspacing="0" align="center" bgcolor="#ffffff">
  <tr>
    <td width="500" height="20"></td>
  </tr>
</table>
<%

select case request.querystring("mtype")
case "edit" call neditinfo()
case else call slist()
end select
%>
<table border="0" width="500" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td width="500" height="10"></td>
  </tr>
  <tr>
    <td width="500" height="20" align="center">网站在线客服管理系统 <a href="http://www.sdxco.com" target="_blank">sdxco.Com</a> 执行时间:<%=FormatNumber((enddtime-starttime)*1000,3)%>毫秒</td>
  </tr>
</table>
<%
else
response.clear
response.redirect "/"
response.end
end if
%>
</body>
</html>