<!--#include file="../../conn/conn.asp" -->
<!--#include file="../../Inc/Commoncode.asp" -->
<!--#include file="../../inc/CommonFunction.asp"-->
<!--#include file="../checkvalid.asp" -->
<!--#include file="../../inc/md5.asp"-->
<!--#include file="../../API/API_Config.asp"-->
<!--#include file="../../API/API_Function.asp"-->
<%If Not FRAdminLevel(303) Then Call ErrorMsg()
set rs=server.createobject("ADODB.Recordset")
member_login=trim(request("login"))
Function isletternumber(strng)
 isletternumber = false
 Dim regEx, Match ' Create variables.
 Set regEx = New RegExp   ' Create a regular expression object (stupid, huh?)
 regEx.Pattern = "^[A-Za-z0-9]{4,20}$" ' Sets pattern.
 regEx.IgnoreCase = True   ' Set case insensitivity.
 Set Match = regEx.Execute(strng)   ' Execute search.
 if match.count then isletternumber= true
End Function
if not isletternumber(member_login) then
  Response.Write ("<script language=JavaScript>{alert('错误：用户名要求为4-20个字母或数字！请重新选择用户名。');location.href = 'javascript:history.go(-1)';}</script>")
  Response.End 
end if
sql="select member_login from JOB_member where member_login='"&member_login&"'"
rs.open sql,conn,1,1
if not rs.eof then
 rs.close
 set rs=nothing
 Response.Write ("<script language=JavaScript>{alert('错误：用户名"&member_login&"已经存在！请选择新的用户名。');location.href = 'javascript:history.go(-1)';}</script>")
 Response.End
end if
rs.close
member_pwd=MD5(trim(Request("pwd")),32)
Member_apipwd=trim(Request("pwd"))
company_type=trim(Request("user_type"))
company_startdate=trim(Request("startdate"))
company_enddate=trim(Request("enddate"))
member_name=CheckStr(trim(request("comname")))
sql="select member_name from job_member where member_name='"&member_name&"'"
rs.open sql,conn,1,1
if not rs.eof then
 rs.close
 set rs=nothing
 conn.close
 set conn=nothing
 Response.Write ("<script language=JavaScript>{alert('错误：此公司已经存在！');location.href = 'javascript:history.go(-1)';}</script>")
 Response.End
end if
rs.close
set rs=nothing
company_introduce=CheckStrbox(request("introduce"))
If lenmix(company_introduce)>=8000 Then 
response.write "<script language=javascript>alert('错误：公司简介太长了，要求不多于8000个字符!！');location.href='javascript:history.back()';</script>"
response.end 
end if
if trim(request("url"))<>"" then
	company_url=CheckStr(trim(request("url")))
	dd=strcomp("http://",left(company_url,7),1)
	if dd<>0 then
		response.write "<script language=javascript>alert('错误：网址必须以 http:// 开头!！');location.href='javascript:history.back()';</script>"
	 response.end 
	end if
end if
company_licence=CheckStr(trim(request("licence")))
company_trade=cint(trim(request("trade")))
company_provinceid=cint(trim(request("province")))
company_capitalid=cint(trim(request("capital")))
company_cityid=cint(trim(request("city")))
company_ecoclass=CheckStr(trim(request("ecoclass")))
if request("funddate")<>"" then company_founddate=request("funddate")
if trim(request("fund"))<>"" then company_fund=trim(request("fund"))
company_workers=CheckStr(trim(request("workers")))
company_address=CheckStr(trim(request("address")))
company_post=CheckStr(trim(request("post")))
company_contact=CheckStr(trim(Request("contact")))
company_tel=trim(Request("tel"))
company_mobile=trim(Request("mobile"))
company_fax=trim(Request("fax"))
company_email=CheckStr(trim(request("email")))
'添加对整合接口的支持
If API_Enable Then
	'重置错误状态和信息
	FoundErr = False
	ErrMsg = ""
	set sMyXmlHTTP=server.createobject("MSXML2.ServerXMLHTTP")
	sMyXmlHTTP.setTimeouts API_Timeout, API_Timeout, API_Timeout * 6, API_Timeout * 6
	Dim intIndex
		For intIndex = 0 To UBound(ArrUrls)
		sMyXmlHTTP.open "POST",ArrUrls(intIndex),false
		sMyXmlHTTP.setRequestHeader "Content-Type", "text/xml; charset=gb2312"
		sMyXmlHTTP.Send "<root><appid>finereason</appid><action>reguser</action><syskey>"&MD5(member_login & API_SysKey, 16)&"</syskey><username>"&member_login&"</username><password>"&Member_apipwd&"</password><email>"&company_email&"</email><question>默认问题</question><answer>默认答案</answer><userip>"&trueIP&"</userip><jointime>"&Now()&"</jointime><userstatus>0</userstatus></root>"
		If sMyXmlHTTP.readyState = 4 And sMyXmlHTTP.Status = 200 Then
			Dim objRecXml
			Set objRecXml = Server.CreateObject("Microsoft.XMLDOM")
			objRecXml.Async = False
			objRecXml.Load (sMyXmlHTTP.ResponseXML)
			If objRecXml.documentElement.selectSingleNode("//status").Text <> "0" Then
				FoundErr = True
				ErrMsg = objRecXml.documentElement.selectSingleNode("//message").Text & " [APIError-API-" & intIndex & "]"
			End If
		End If
		If FoundErr Then
			call Show_Err()
			Exit For
		End If
		Next
End If

set rs=server.createobject("ADODB.Recordset")
sql="select * from JOB_member where member_login='"&member_login&"'"
rs.open sql,conn,1,3
if rs.eof then
rs.addnew
rs("member_login")=member_login
rs("member_pwd")=member_pwd
rs("Member_Auditing")=1
rs("Member_groupid")=company_type
rs("member_startdate")=company_startdate
rs("member_enddate")=company_enddate
rs("member_name")=member_name
rs("member_provinceid")=company_provinceid
rs("member_capitalid")=company_capitalid
rs("member_cityid")=company_cityid
rs("member_licence")=company_licence
rs("member_trade")=company_trade
rs("member_ecoclass")=company_ecoclass
rs("member_founddate")=company_founddate
rs("member_fund")=company_fund
rs("member_workers")=company_workers
rs("member_introduce")=company_introduce
rs("member_address")=company_address
rs("member_post")=company_post
rs("member_contact")=company_contact
rs("member_tel")=company_tel
rs("member_telshowflag")=1
rs("member_mobile")=company_mobile
rs("member_mobileshowflag")=1
rs("member_fax")=company_fax
rs("member_email")=company_email
rs("member_emailshowflag")=1
rs("member_url")=company_url
rs("member_regdate")=now()
rs("member_logindate")=now()
rs("member_loginnum")=0
rs("member_typeid")=2
rs("member_flag")=1'不需要审核
rs("member_consumenums")=clng(request("consume"))
rs("member_command")=0
rs("member_commandstartdate")=null
rs("member_commandenddate")=null
rs.update
rs.close
end if
'更新静态页面
set rsuc=conn.execute("select * from JOB_Channel where ChannelID=2")
	UseCreateHTML=rsuc("UseCreateHTML")
set rsuc=nothing
if  CreateHTML=1 and UseCreateHTML<>0 then
	set rsh=conn.execute("select * from JOB_member where member_login='"&member_login&"' and member_typeid=2")
	if not rsh.eof then
	member_id=rsh("member_id")
	Call CompanyContentHtml(Member_id) '生成企业介绍页面
	Call HireListContentHtml(Member_id) '生成企业职位列表页面
	end if
	Set rsh=Nothing
end if
conn.close
set conn=nothing
response.write ("<script language=JavaScript>if (confirm('企业添加成功！继续添加企业资料？')){location.href='company_add.asp'}else{location.href='cmember_searchlist.asp'}</script>")
response.end
%>