<!--#include file="inc/config.asp"-->
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="getips.asp"-->
<%
dim CatalogId,ParentId
if(request.QueryString("CatalogId")<>"") then
	cid=Clng(request.QueryString("CatalogId"))	
else
	cid=0
end if
if(request.QueryString("ParentId")<>"") then
	ParentId=Clng(request.QueryString("ParentId"))
else
	pid=2
end if
%>
<!DOCTYPE html PUBliC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>发布信息-<%=SiteName%></title>
<link href="style/index.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/prototype.js"></script>
<script type="text/javascript" src="/js/effects.js"></script>
<script type="text/javascript" src="/js/validation.js"></script>
<script type="text/javascript" src="/js/areas.js"></script>
<script type="text/javascript" src="/js/catalogs.js"></script>
<LINK media=screen href="/js/dhtmlgoodies_calendar.css" rel=stylesheet></LINK>
<SCRIPT src="/js/dhtmlgoodies_calendar.js" type=text/javascript></SCRIPT>
</head>

<body>
<!--#include file="head.asp"-->
<div class="br"></div>
<table width="960"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="24"><div class="position">当前位置：<a href="/">首页</a>&gt;发布信息</div></td>
  </tr>
</table>
				  <table width="960"  border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td style="border-bottom:1px solid #2fc300;"><h2>发布信息</h2></td>
            </tr>
</table>
					<table width="960" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#2fc300">
            <tr>
              <td height="4"></td>
            </tr>
          </table>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
            <td valign="top">
          <%
        dim act
        act=request.querystring("act")
        if(act="do") then
         ' call IpLock()
				 	if(lcase(request.Form("GetCode"))<>lcase(session("GetCode"))) then
						response.write("<div align=""center""><br><h3>验证码错误</h3></p>")
					else
						call InfoAddOk()
						session("GetCode")=""
						response.write("<div align=""center""><br><h3>成功发布信息</h3>信息需要经过审核才可以看到。)</p>")
						response.write("<p align=""center"">您可以：<a href=""publish.asp?pid="&ParentId&"&cid="&CatalogId&""">&lt;-继续发布</a>&nbsp;<a href=""/"">返回分类信息</a></p><br>")
					end if
        else
          call mod_personalinfo()
        end if
        %>    </td>
          </tr>
        </table>
<%
sub InfoAddOk
	dim rs,InfoTypeId,ParentId,CatalogId,DelPass,Title,ExpireDate,ItemsNum,Price,Province,City,ContactMan,Tel,Mobile,QQ,Content,Photo,SavePath,Demons,Address,Area,MIP
	SavePath="/html/"&chan_data(now())&chan_day(now())&"/"&chan_file(now())&"."&FileExt
	InfoTypeId=Cint(request.Form("InfoTypeId"))
	ParentId=Cint(request.form("ParentId"))
	if(isnumeric(request.Form("CatalogId"))) then
		CatalogId=Cint(request.Form("CatalogId"))
	else
		CatalogId=0
	end if
	Province=request.Form("Province")
	if(Province<>"") then
		Province=Cint(Province)
	else
		Province=0
	end if
	City=request.Form("City")
	if(City<>"") then
		City=Cint(City)
	else
		City=0
	end if
	DelPass=request.Form("DelPass")
	Title=tohtml2(request.Form("Title"))
	if(Title=session("TotCms_LastPost")) then
		response.write("<script>alert('不能重复发布相同的信息!');history.back();</script>")
	elseif(CatalogId=0) then
		response.write("<script>alert('请选择二级分类!');history.back();</script>")
	elseif(City=0) then
		response.write("<script>alert('请选择区县!');history.back();</script>")
	else
		ExpireDate=Cint(request.Form("ExpireDate"))
		ItemsNum=Cint(request.form("ItemsNum"))
		Price=Csng(request.form("Price"))
		
		
		if(Province>0) then
			set rs=server.CreateObject("adodb.recordset")
			rs.open "select title from t_area where id="&Province,conn,3,1
			if not rs.eof then
				Area=rs(0)
			end if
			rs.close
			set rs=nothing
		end if
		if(City>0) then
			set rs=server.CreateObject("adodb.recordset")
			rs.open "select title from t_area where id="&City,conn,3,1
			if not rs.eof then
				Area=Area&rs(0)
			end if
			rs.close
			set rs=nothing
		end if
		ContactMan=tohtml2(request.Form("ContactMan"))
		Tel=tohtml2(request.Form("Tel"))
		QQ=tohtml2(request.Form("QQ"))
		Content=trim(request.Form("Content"))
		Demons=gotTopic(Content,200)
		Content=tohtml(Content)
		Photo="/images/nopic.gif"
		Address=tohtml2(request.Form("Address"))
		MIP=request.ServerVariables("REMOTE_ADDR")&naddress(request.ServerVariables("REMOTE_ADDR"))
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select * from t_info where 1=0",conn,3,3
		rs.addnew
		rs("UserId")="anonymous"
		rs("InfoTypeId")=InfoTypeId
		rs("ParentId")=ParentId
		rs("CatalogId")=CatalogId	
		rs("Photo")=Photo
		rs("Title")=Title
		rs("Price")=Price
		rs("Province")=Province
		rs("City")=City
		rs("ContactMan")=ContactMan
		rs("QQ")=QQ
		rs("Tel")=Tel	
		rs("Content")=Content
		rs("Demons")=Demons
		rs("PubDate")=now()
		rs("ExpireDate")=dateadd("d",ExpireDate,now())
		rs("PubIp")=MIP
		rs("Hits")=1
		rs("IsCheck")=0
		rs("IsDel")=0
		rs("IsHot")=0
		rs("IsTop")=0
		rs("DelPass")=DelPass
		rs("SavePath")=SavePath
		rs("Address")=Address
		rs("Area")=Area
		rs("Score")=0
		rs("ScoreEndDate")=now()
		rs.update
		rs.close
		set rs=nothing
		session("TotCms_LastPost")=Title
	end if
	
end sub
sub mod_personalinfo
	dim rs,userinfo,sql,first
	set rs=server.CreateObject("adodb.recordset")
	sql="select id,title from catalogs where parentid="&PlugIn_InfoId&" order by id asc"
	rs.open sql,conn,3,1
	if not rs.eof and not rs.bof then
		first=rs.GetRows()
	else
		
	end if
	rs.close
	set rs=nothing
%>
<form id="PostForm" name="PostForm" method="post" action="?act=do">
<table width="960" border="0" align="center" cellpadding="0" cellspacing="1" class="border">  
  <tr>
    <td class="td_row">&nbsp;</td>
    <td class="td_row">&nbsp;</td>
  </tr>
  <tr>
    <td class="pad_5">服务类型：</td>
    <td class="td_row">
	<select name="InfoTypeId" id="InfoTypeId">
		<option value="1" selected="selected">供</option>
		<option value="2">求</option>
    </select>    </td>
  </tr>
  <tr>
    <td class="pad_5">信息分类：</td>
    <td class="td_row">
		<select name="ParentId" id="ParentId" size="10" onchange="GetCatalogChilds(this.options[this.selectedIndex].value,0,'CatalogId')">
		<%
		dim sel
			if isarray(first) then
			for i=0 to ubound(first,2)
					if(first(0,i)=pid) then
						sel=" selected=""selected"""
					else
						sel=""
					end if
					response.Write("<option value="""&first(0,i)&""""&sel&">"&first(1,i)&"</option>"&Chr(10))    	
			next
		end if
		%>
    </select>		
		<select name="CatalogId" id="CatalogId" size="10">
			<option>请选择二级分类</option>
		</select>
		<script type="text/javascript">
		GetCatalogChilds(<%=pid%>,<%=cid%>,'CatalogId');	
		</script></td>
  </tr>
  <tr>
    <td class="pad_5">标题：(<span class="style1">*</span>)</td>
    <td class="td_row"><input name="Title" type="text" class="validate-title" id="Title" title="请输入信息标题" size="80" maxlength="200" />
    <span id="advice-validate-title-Title" style="display:none; color:#FF0000;">标题5-200个字符</span></td>
  </tr>
  <tr>
    <td width="18%" class="pad_5">价格：(<span class="style1">*</span>)</td>
    <td width="82%" class="td_row"><input name="Price" type="text" id="Price" class="validate-number" value="0" size="8" />0=面议<span id="advice-validate-number-Price" style="display:none; color:#FF0000;">请输入数字</span></td>
  </tr>
  <tr>
    <td class="pad_5">区县：</td>
    <td class="td_row">	
  		<select name="Province" id="Province" onchange="GetChilds(this.options[this.selectedIndex].value,0,'City')">
        <option value="0">选择城市</option>
        <script type="text/javascript">
				document.write(GetFirst(3,''));
        </script>
      </select>
      <select name="City" id="City">
        <option value="0">选择地区</option>
      </select>	
      <script type="text/javascript">
				GetChilds(3,0,'City');
      </script>
  	</td>
  </tr>
  <tr>
    <td class="pad_5">联系人：(<span class="style1">*</span>)</td>
    <td class="td_row"><input name="ContactMan" type="text" id="ContactMan" class="required" />
    <span id="advice-required-ContactMan" style="display:none; color:#FF0000;">联系人不能为空!</span></td>
  </tr>
  <tr>
    <td class="pad_5">电话：(<span class="style1">*</span>)</td>
    <td class="td_row"><input name="Tel" type="text" class="required" />
      <span id="advice-required-Tel" style="display:none; color:#FF0000;">电话不能为空!</span></td>
  </tr>
  <tr>
    <td class="pad_5">地址：</td>
    <td class="td_row"><input name="Address" type="text" id="Address" size="32" /></td>
  </tr>
  <tr>
    <td class="pad_5">QQ：</td>
    <td class="td_row"><input name="QQ" type="text" /></td>
  </tr>
  <tr>
    <td class="pad_5">详细说明：</td>
    <td class="td_row"><textarea name="Content" cols="60" rows="5" id="Content" class="validate-content"></textarea><span id="advice-validate-content-Content" style="display:none; color:#FF0000;">详细说明10-2000字!</span></td>
  </tr>
  <tr>
    <td class="pad_5">信息有效期：</td>
    <td class="td_row"><select name="ExpireDate" id="ExpireDate">
      <option value="7">7天</option>
      <option value="15">15天</option>
      <option value="30">30天</option>
      <option value="90">90天</option>
      <option value="180">180天</option>
      <option value="360">360天</option>
    </select>    </td>
  </tr>
  <tr>
    <td class="pad_5">信息删除密码：</td>
    <td class="td_row"><input name="DelPass" type="text" id="DelPass" class="validate-password" title="信息删除密码" /><span id="advice-validate-password-DelPass" style="display:none; color:#FF0000;">信息删除密码3个字符以上(不含password,123456这样的密码)!</span></td>
  </tr>
  <tr>
    <td class="pad_5">验证码：</td>
    <td height="50" class="td_row">
    	
<input name="GetCode" type="text" id="GetCode" size="20" class="required" style="width:60px; height:20px; line-height:20px; font-size:20px; font-weight:bold; color:#090;" /><img src="/image.asp" onclick="this.src='/image.asp?time='+Math.random()" /><span id="advice-required-GetCode" style="display:none; color:#FF0000; border:1px solid #999;">请输入验证码!</span></td>
  </tr>
  <tr>
    <td class="td_row">&nbsp;</td>
    <td height="50" class="td_row"><input name="Photo" type="hidden" id="Photo" size="30" />
    <input type="submit" name="Submit" value="确 定" />
      <input type="reset" name="Submit2" value="取 消" /></td>
  </tr>
</table>
</form>
<script language="javascript">
function upImgs(){
	var ret=window.showModalDialog('upimg.htm','','dialogHeight:140px;dialogWidth:410px;help:no;status:no;scroll:no')+'';
	
	if(ret!='undefined'){
		document.PostForm.Photo.value=ret
		document.getElementById('p_view').src=ret;
	}
}
function formCallback(result, form) {
	window.status = "valiation callback for form '" + form.id + "': result = " + result;
}

var valid = new Validation('PostForm', {immediate : true, onFormValidate : formCallback,useTitles : true});
Validation.addAllThese([
	['validate-password', '信息删除密码3个字符以上(不含password,1234566这样的密码)', {
		minLength : 3,
		notOneOf : ['password','PASSWORD','123456','012345']
	}],
	['validate-content','',{
		minLength:6,
		maxLength : 2000
	}],
	['validate-title','',{
		minLength:5,
		maxLength:200
	}]
]);
</script>
<%
end sub
%>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#2fc300">
  <tr>
    <td height="4"></td>
  </tr>
</table>
<!--#include file="root.asp"-->
</body>
</html>
<%
call connclose()
%>
