<!--#include file="Conn.asp"-->
<!--#include file="inc/Cl_ClsSysTem.asp"-->
<!--#include file="inc/Cl_Function_Public.asp"-->
<!--#include file="Inc/Cl_ClsCount.asp"-->
<!--#include file="inc/Cl_Md5.asp"-->
<!--#include file="Inc/UPIConfig.asp"-->
<title>恒浪创力整合接口b</title>
<%
Dim HLMd5Info,UpiMd5Info,Action
Dim UserName,password,PwdConfirm,Question,Answer,Sex,Email,CookieDate
Dim UserReName,IDCard,BirthDay,CityInfo,ZipCode,UserTelePhone,UserAddRess,TruePassWord
Dim SchoolAge,UserWorking,UserHomePhone,UserMobile
Dim UserIM,CheckNum,CheckUrl,sqlReg,rsReg
Dim strMsg,strTitle,strbody
Dim RsGroup,sChargeType,sValidDays,sGroupPoint,sUserInfo,rsUGroup,sAddPoint


'---------通行证字段赋值
UpiMd5Info = UCase(Trim(Request("Md5Info")))
Action = Trim(Request("action"))
username = replace(Trim(Request("name")),"'","")
password = replace(Trim(Request("pass")),"'","")
If Len(password) = 32 Then password = Mid(password,9,16)
'--------------------------------------
CookieDate = Trim(Request("CookieDate"))
If CookieDate=0 or CookieDate="" Then CookieDate=1
'--------------------------CL REG Begin-----------------------
If Action="LogoutUser" then Call LogoutUser()
If Not (Action = "" or UserName = "" or UpiMd5Info = "") Then

	HLMd5Info = MD5(username&AdminSecurityKey,32)
	
	If UpiMd5Info = UCase(HLMd5Info) Then
	Select Case Action
	   Case "AddUser"
			Call AddAdmin()
		Case "LoginUser"			
			Call LoginAdmin()
		End Select
    End If
End If


Sub LoginAdmin()
if Cl.ChkUserLogin()=False then
	response.Redirect "" & Cl.WebDir & "User/Login.Asp"
end if
if Clng(Cl.User_Info(21))<>1 then
	Response.Redirect Cl.WebDir & "Showerr.asp?action=OtherErr&ErrCodes=<li>您不是系统管理员！"
end if
dim Sql,Rs
FoundErr=False
if FoundErr<>True then
	Sql="select ID,UserName,PassWord,Purview,Purview_Other,arrClassMaster,arrClassCheck,arrClassInput From Cl_Admin where username='" & UserName & "' and adduser='"&Cl.User_Info(5) &"'"
	Set Rs=Cl.Execute(Sql)
	
	if Rs.bof and Rs.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>用户名或密码错误或者您不是后台管理员！</li>"
		Rs.close:set Rs=Nothing
	else
		if password<>Rs(2) then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>用户名或密码错误，请返回重新输入！</li>"
			Rs.close:set Rs=Nothing
		else
			Cl.Execute("update Cl_Admin set LastLoginIP='"&Cl.UserTrueIP&"',LastLoginTime="&SqlNowString&",LoginTimes=LoginTimes+1 Where UserName='"&UserName&"'")
			Session.Timeout=30'设置session的有效时间
			Session("AdminName")=rs(1)
			Session("AdminPass")=rs(2)
			Rs.close:set Rs=Nothing
			
			Cl.Execute_L("insert into [Cl_AdminLog] (UserID,UserName,UserLevel,UserIP,ScriptName,LogContent,LogTime) values ('"&Cl.User_Info(4)&"','"&Cl.User_Info(5)&"','"&Cl.User_Info(21)&"','"&Cl.UserTrueIP&"','"&Cl.ScriptName&"','登录后台成功！','"&Now&"')")
			
		end if
	end if
end if
End Sub

Sub AddAdmin()
	dim Purview,adduser
	dim cMaxID,sPurview
	dim arrClassInput,arrClassCheck,arrClassMaster
	cMaxID=Cl.Execute("select Max(ChannelID) from Cl_Channel")(0)
	if Not IsNumeric(cMaxID) then cMaxID=5
	
	adduser=username
	Purview=""
	if Purview="" or Not IsNumeric(Purview) then Purview=2
	for i=1 to cMaxID
		sPurview=Trim(Request("Purview_"&i&""))
		if sPurview="" or Not IsNumeric(sPurview) then sPurview=4
		Purview=Purview & "," & Clng(sPurview)
	next
	
		'提升前台用户权限
	Cl.Execute_U("Update "&Db.UserTable&" Set "&Db.UserLevel&"=1 Where "&Db.UserName&"='"&adduser&"'")

	sql="Select * from Cl_Admin where username='"&username&"'"
	Set rs=Server.CreateObject("Adodb.RecordSet")
	OpenConn : rs.Open sql,Conn,1,3
	if not (rs.bof and rs.EOF) then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>数据库中已经存在此管理员！</li>"
		rs.close:set rs=Nothing
		exit sub
	end if
	rs.addnew
 	rs("username")=username
   	rs("password")=password
    rs("Purview")="1,1,1,1,1,4,4,4"
    rs("Purview_Other")="modifypwd"
 	rs("AddUser")=adduser
	rs.update
	rs.Close:set rs=Nothing
	'Cl.SaveAdminLog
	

End Sub


Sub ShowErr(ErrMsg)
	dim strErr
	strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
	strErr=strErr & "<link href='../Skins/Admin_Style.Css' rel='stylesheet' type='text/css'></head><body>" & vbcrlf
	strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf
	strErr=strErr & "  <tr align='center'><td height='22' class='title'><strong>错误信息</strong></td></tr>" & vbcrlf
	strErr=strErr & "  <tr><td height='100' class='tdbg' valign='top'><b>产生错误的可能原因：</b><br>" & ErrMsg &"</td></tr>" & vbcrlf
	strErr=strErr & "  <tr align='center'><td class='tdbg'><a href='Admin_Index.asp?Action=admin_login'>&lt;&lt; 返回登录页面</a></td></tr>" & vbcrlf
	strErr=strErr & "</table>" & vbcrlf
	strErr=strErr & "</body></html>" & vbcrlf
	response.write strErr
end sub

Function sRIM(s)
	Dim w
	w=Trim(s)
	If w<>"" and Not IsNull(w) Then 
		w=Replace(w,"|","")
	End If
	sRIM=w
End Function
%>
<%
'==================================================
'恒浪网站整合管理系统V4.05 请保留此版权信息~
'Powered by HoWave.net
'
'邮箱: websky888@126.com		
'ＱＱ: 615939753				
'网站: www.howave.net			www.jsp163.com
'论坛: bbs.howave.net			bbs.jsp163.com
'
'Copyright (C) 2006 HoWave.Net All Rights Reserved.
'==================================================
%>