<!--#include file="conn.asp"-->
<!--#include file="../md5.asp"-->
<%
function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
	HTMLEncode2 = fString
end function
dim action,shjianame
action=request.QueryString("action")
shjianame=request.Cookies("godbook")("shjianame")
select case action
'//商家资料
case "myziliao"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [shjia] where name='"&request.Cookies("godbook")("shjianame")&"'",conn,1,3
rs("useremail")=trim(request.form("useremail"))
rs("name2")=trim(request("name2"))
rs("dz")=trim(request("dz"))
rs("tel")=trim(request("tel"))
rs("pc")=trim(request("pc"))
rs("oicq")=trim(request("qq"))
rs.update
rs.close
set rs=nothing
response.Write "<script language=javascript>alert('资料修改成功！');window.location.href='admin_right.asp?action=myziliao';</script>"
response.end

'//二级域名
case "url"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [shjia] where name='"&request.Cookies("godbook")("shjianame")&"'",conn,1,3
rs("url")=trim(request("url"))
rs.update
rs.close
set rs=nothing
response.Write "<script language=javascript>alert('域名添加成功！');window.location.href='admin_right.asp?action=url';</script>"
response.end

'//商家LOGO
case "logo"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [shjia] where name='"&request.Cookies("godbook")("shjianame")&"'",conn,1,3

    if rs("logo")="image/logo.gif" or rs("logo")=trim(request("logo")) then
    rs("logo")=trim(request("logo"))  'logo地址
    else
    dim image
    image="../"+rs("logo")' 路径由此文件所在的位置决定    
	If image <> "" Then
    image =server.mappath(image)
    End If
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	If fso.FileExists(image) Then
	fso.DeleteFile (image),true
	else
	Response.Write "<br>logo不存在无法删除！<br>"
	end if
    rs("logo")=trim(request("logo"))  'logo地址
	end if

rs.update
rs.close
set rs=nothing
response.Write "<script language=javascript>alert('修改成功！');window.location.href='admin_right.asp?action=logo';</script>"
response.end

'//密码修改
case "pass"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [shjia] where name='"&request.Cookies("godbook")("shjianame")&"'",conn,1,3
if trim(request("password"))<>"" then
rs("userpassword")=md5(trim(request("password")))
end if
rs.update
rs.close
set rs=nothing
response.Write "<script language=javascript>alert('密码修改成功！');window.location.href='admin_right.asp?action=pass';</script>"
response.end

'//商家公告
case "gong"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [shjia] where name='"&request.Cookies("godbook")("shjianame")&"'",conn,1,3
rs("content")=htmlencode2(trim(request("content")))
rs.update
rs.close
set rs=nothing
response.Write "<script language=javascript>alert('公告修改成功！');window.location.href='admin_right.asp?action=gong';</script>"
response.end

'//保存新闻
case "savenews"
set rs_news=server.CreateObject("adodb.recordset")
rs_news.open "select * from [shjia] where name='"&request.Cookies("godbook")("shjianame")&"'",conn,1,1
title=trim(request.form("title"))
content=trim(request.form("content"))
action=trim(request.form("action"))
set rs=server.CreateObject("adodb.recordset")
if action="add" then
rs.open "select * from [news]",conn,1,3
rs.addnew
rs("shjiaid")=rs_news("shjiaid")
rs("title")=title
rs("content")=content
rs("addTime")=now()
rs("shjianame")=shjianame
rs.update
rs.close
set rs=nothing
rs_news.close
set rs_news=nothing
response.Write "<script language=javascript>alert('新闻添加成功！');window.location.href='admin_right.asp?action=addnews';</script>"
response.End
elseif action="modify" then
rs.open "select * from news where newsid=" & cstr(request("id")),conn,1,3
rs("title")=title
rs("content")=content
rs("addTime")=now()
'rs("shjianame")=shjianame
rs.update
rs.Close
set rs=nothing
response.Write "<script language=javascript>alert('新闻修改成功！');window.location.href='admin_right.asp?action=glnews';</script>"
response.End
end if

'//保存企业简介
case "jj"
function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
	HTMLEncode2 = fString
end function
set rs_news=server.CreateObject("adodb.recordset")
rs_news.open "select * from [shjia] where name='"&request.Cookies("godbook")("shjianame")&"'",conn,1,1
content=trim(request.form("content"))
set rs=server.CreateObject("adodb.recordset")
jjong=trim(request.form("jjong"))
if jjong="" then
rs.open "select * from jj",conn,1,3
rs.addnew
rs("shjiaid")=rs_news("shjiaid")
rs("content")=htmlencode2(content)
rs.update
rs.close
set rs=nothing
rs_news.close
set rs_news=nothing
response.Write "<script language=javascript>alert('企业简介添加成功！');window.location.href='admin_right.asp?action=jj';</script>"
response.End
else
rs.open "select * from jj where shjiaid=" & cstr(request("id")),conn,1,3
rs("content")=htmlencode2(content)
rs.update
rs.Close
set rs=nothing
response.Write "<script language=javascript>alert('企业简介修改成功！');window.location.href='admin_right.asp?action=jj';</script>"
response.End
end if

'//保存付款方式
case "fkfs"
function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
	HTMLEncode2 = fString
end function
set rs_news=server.CreateObject("adodb.recordset")
rs_news.open "select * from [shjia] where name='"&request.Cookies("godbook")("shjianame")&"'",conn,1,1
content=trim(request.form("content"))
set rs=server.CreateObject("adodb.recordset")
fkong=trim(request.form("fkong"))
if fkong="" then
rs.open "select * from fkfs",conn,1,3
rs.addnew
rs("shjiaid")=rs_news("shjiaid")
rs("content")=htmlencode2(content)
rs.update
rs.close
set rs=nothing
rs_news.close
set rs_news=nothing
response.Write "<script language=javascript>alert('付款方式添加成功！');window.location.href='admin_right.asp?action=fkfs';</script>"
response.End
else
rs.open "select * from fkfs where shjiaid=" & cstr(request("id")),conn,1,3
rs("content")=htmlencode2(content)
rs.update
rs.Close
set rs=nothing
response.Write "<script language=javascript>alert('付款方式修改成功！');window.location.href='admin_right.asp?action=fkfs';</script>"
response.End
end if

'//保存配送说明
case "ps"
function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
	HTMLEncode2 = fString
end function
set rs_news=server.CreateObject("adodb.recordset")
rs_news.open "select * from [shjia] where name='"&request.Cookies("godbook")("shjianame")&"'",conn,1,1
content=trim(request.form("content"))
set rs=server.CreateObject("adodb.recordset")
psong=trim(request.form("psong"))
if psong="" then
rs.open "select * from ps",conn,1,3
rs.addnew
rs("shjiaid")=rs_news("shjiaid")
rs("content")=htmlencode2(content)
rs.update
rs.close
set rs=nothing
rs_news.close
set rs_news=nothing
response.Write "<script language=javascript>alert('配送说明添加成功！');window.location.href='admin_right.asp?action=ps';</script>"
response.End
else
rs.open "select * from ps where shjiaid=" & cstr(request("id")),conn,1,3
rs("content")=htmlencode2(content)
rs.update
rs.Close
set rs=nothing
response.Write "<script language=javascript>alert('配送说明修改成功！');window.location.href='admin_right.asp?action=ps';</script>"
response.End
end if

'//删除留言
case "delfk"
dim id
id=request.QueryString("fkid")
strdel="delete from [shop_shjiafk] where fkid="&id
conn.execute(strdel)
conn.close
response.Write "<script language=javascript>alert('你选择的留言已删除');window.location.href='admin_right.asp?action=fk';</script>"
response.end

'//删除新闻
case "delnews"
dim newsid
newsid=request.QueryString("newsid")
strdel="delete from [news] where newsid="&newsid
conn.execute(strdel)
conn.close
response.Write "<script language=javascript>alert('你选择的新闻已删除');window.location.href='admin_right.asp?action=glnews';</script>"
response.end
end select
%>