<!--#include file=conn.asp-->
<!--#include file=config.asp-->
<!--#include file=const.asp-->
<!--#include file=char.asp-->
<%
 '=========================================================
' File: artpost.asp
' Version:3.0
' Date: 2005-10-23
' Script Written by xmrxw
'=========================================================
' Copyright (C) 2004,2005 Xmrxw.Com All rights reserved.
' Web: http://www.xmrxw.com,http://www.xmzxw.com
' Email: info@mssky.com,super@mssky.com
' QQ：10689579　Msn：zdlmicr@hotmail.com
'=========================================================
dim ID,action
response.buffer=true
ID=checkStr(Request("ID"))
BoardID=checkStr(Request("BoardID"))
action=checkStr(Request("action"))
if Cint(GroupSetting(16))<>0 and dateadd("n",Cint(GroupSetting(16)),myjoinDate)>=Now() then
	Response.write "新注册用户"&Cint(GroupSetting(16))&"分钟后才能发布文章，请稍后"
	Response.End
end if
if Cint(GroupSetting(13))=0 then
	Response.write "您没有发布文章的权限。"
	Response.End
end if
if BoardID="" or not isInteger(BoardID) then
founderr=true
Errmsg=Errmsg+"<br>"+"<li>非法参数。"
end if
if action<>"new" then
if ID="" or not isInteger(ID) then
founderr=true
Errmsg=Errmsg+"<br>"+"<li>非法参数。"
end if
end if
''取出版块名称
dim Boardname
sql="select Boardname from [Ms_ArtType] where ID="&BoardID&""
set rs=conn.execute(sql)
if not (rs.eof and rs.bof) then
Boardname=rs(0)
else
founderr=true
Errmsg=Errmsg+"<br>"+"<li>版块参数错误。"
end if
rs.close
stats=""&Boardname&""
if not founduser then
	Errmsg=Errmsg+"<br>"+"<li>您还没有登陆，无权限发表文章。"
	founderr=true
end if
call nav()
if founderr then
	call head_var("","")
	call Mslove_error()
else
	call head_var("玫瑰美文","artindex.asp")
dim Dcount,Countart
''统计今日所发的文章数开始
sql="select count(id) from [Ms_Article] where Username='"&trim(membername)&"' and datediff('d',Addtime,now())=0"
set rs=conn.execute(sql)
if not (rs.eof and rs.bof) then
Dcount=rs(0)
else
Dcount=0
end if
rs.close
''统计用户所有的文章数开始
sql="select count(id) from [Ms_Article] where Username='"&trim(membername)&"'"
set rs=conn.execute(sql)
if not (rs.eof and rs.bof) then
Countart=rs(0)
else
Countart=0
end if
rs.close

Select Case Trim(Request("action"))
	Case "new"
		stats="发表文章"
	Case "edit"
		Stats="修改文章"
End Select
call webeditor()	
end if
call activeonline()
call footer()

sub webeditor()%>
<script language = 'JavaScript'>
function selectPaginationType(){
  document.theForm.PaginationType.value=2;
}
function CheckForm(){
  var CurrentMode=editor.CurrentMode;
  if (CurrentMode==0){
    document.theForm.Content.value=editor.HtmlEdit.document.body.innerHTML; 
  }
  else if(CurrentMode==1){
   document.theForm.Content.value=editor.HtmlEdit.document.body.innerText;
  }
  else{
    alert('预览状态不能保存！请先回到编辑状态后再保存');
    editor.HtmlEdit.focus();
     return false;
  }
if (document.theForm.Title.value==''){
     alert('文章标题不能为空！');
     document.theForm.Title.focus();
     return false;
  }
    if (document.theForm.Content.value==''){
      alert('文章内容不能为空！');
      editor.HtmlEdit.focus();
      return false;
    }
}
</script>
<%if action="edit" then
dim ETitle,EContent,ETopic,Esignflag,Eemailflag,EIncludePic
dim Eistop,EUsername,EAddtime,EComefrom,EEditor
sql="select Title,Editor,Comefrom,Content,Topic,signflag,emailflag,IncludePic,istop,Username,Addtime from [Ms_Article] where ID="&ID&""
set rs=conn.execute(sql)
if not (rs.eof and rs.bof) then
ETitle=rs(0)
EEditor=rs(1)
EComefrom=rs(2)
EContent=rs(3)
ETopic=rs(4)
Esignflag=rs(5)
Eemailflag=rs(6)
EIncludePic=rs(7)
Eistop=rs(8)
EUsername=rs(9)
EAddtime=rs(10)
end if
rs.close
else
Esignflag=0
Eemailflag=0
EIncludePic=0
Eistop=0
end if
dim CanEditPost,artGroupID
caneditpost=false
if action="edit" then''判断是否有编辑权限开始
sql="select u.usergroupID from Ms_Article b,[Ms_user] u where b.username=u.username and b.ID="&ID
set rs=conn.execute(sql)
if rs.eof and rs.bof then
	Errmsg=Errmsg+"<br>"+"<li>没有找到相应的文章。"
	Founderr=true
	exit sub
else
artGroupID=rs("UserGroupID")
end if
rs.close
if EUsername=membername then
		if Cint(GroupSetting(25))=0 then
			Errmsg=Errmsg+"<br>"+"<li>您没有编辑自己文章的权限，请<a href=login.asp>登陆</a>或者同管理员联系。"
			founderr=true
			CanEditPost=False
		else
			CanEditPost=True
		end if
	else
		if (master or supermaster or Standmaster or Vipuser) and Cint(GroupSetting(25))=1 then
			CanEditPost=True
		else
			CanEditPost=False
		end if
		if UserGroupID>3 and Cint(GroupSetting(25))=1 then
			CanEditPost=true
		end if
		if Cint(GroupSetting(25))=1  then
			CanEditPost=True
		elseif Cint(GroupSetting(25))=0 then
			CanEditPost=False
		end if
		if UserGroupID<4 and UserGroupID=artGroupID then
			Errmsg=Errmsg+"<br>"+"<li>同等级用户不能修改。"
			Founderr=true
			exit sub
		elseif UserGroupID<4 and UserGroupID>artGroupID then
			Errmsg=Errmsg+"<br>"+"<li>不能修改等级比您高的用户的文章。"
			Founderr=true
			exit sub
		end if
		if not CanEditPost then
			Errmsg=Errmsg+"<br>"+"<li>您没有足够的权限编辑本文章，请和管理员联系。"
			Founderr=true
			exit sub
		end if
	end if
end if''判断是否有编辑权限结束
%>
<table width="100%" align=center cellpadding=3 cellspacing=1 class=tableborder1>
  <form action="artSavePost.asp" method=POST onSubmit='return CheckForm();' name="theForm">
  <input name="action" type="hidden" value="<%=action%>"> 
  <input name="BoardID" type="hidden" value="<%=BoardID%>">
  <%if action="edit" then%>
  <input name="ID" type="hidden" value="<%=ID%>">
  <%end if%>
    <tr> 
      <th height="28" colspan="2" align="left"  class=tablebody1>* <%=stats%></th>
    </tr>
	<tr> 
      <td width="27%" height="25" align="left"  class=tablebody2><strong>用户名：</strong></td>
      <td width="73%"  class=tablebody2><input name="Username" type="text" id="Username" value="<%=trim(membername)%>"> 
        <font color="#FF0000"> *</font> <a href=reg.asp>没有注册？</a></td>
    </tr>
    <tr> 
      <td width="27%" height="26" align="left"  class=tablebody1><strong>密　码：</strong></td>
      <td width="73%" align="left"  class=tablebody1><input name="Password" type="password" id="Password" value="<%=MemberWord%>"> 
        <font color="#FF0000"> * </font> <a href=lostpass.asp>忘记密码？</a></td>
    </tr>
    <tr> 
      <td height="28" align="left"  class=tablebody2><strong>文章主题：</strong></td>
      <td align="left"  class=tablebody2>
	  <%if action="edit" then%>
	  <input name="Title" type="text" id="Title" size="40" value=<%=ETitle%>>
	  <%else%>
	  <input name="Title" type="text" id="Title" size="40">
	  <%end if%>
        <font color="#FF0000"> *</font></td>
    </tr>
	    <%if Cint(Codeshow(6))=1 then%>
    <tr> 
      <td height="27" align="left"  class=tablebody1><strong>检验码：</strong></td>
      <td align="left"  class=tablebody1> <input type="text" name="codestr" maxlength="4" size="4"> 
        &nbsp;<%=GetCode()%>&nbsp;</td>
    </tr>
    <%end if%>
	  <tr> 
      <td height="28" align="left"  class=tablebody2><strong>文章作者：</strong></td>
      <td align="left"  class=tablebody2>
	  <%if action="edit" then%>
	  <input name="Editor" type="text" id="Editor" size="20" value=<%=EEditor%>>
	  <%else%>
	  <input name="Editor" type="text" id="Editor" size="20">
	  <%end if%>
	  文章出处：
	  <%if action="edit" then%>
	  <input name="Comefrom" type="text" id="Comefrom" size="20" value=<%=EComefrom%>>
	  <%else%>
	  <input name="Comefromm" type="text" id="Comefromm" size="20" value="<%=webname%>">
	  <%end if%>
        </td>
    </tr>
    <tr> 
      <td align="left"  class=tablebody1><strong>当前心情：</strong></td>
      <td align="left"  class=tablebody1><a href=alltopic.asp target=_blank>查看所有心情</a><br> <%if action="edit" then%>
        <input name=Topics type=text value="<%=ETopic%>" size=30 readonly> 
		<%else%>
		 <input name=Topics type=text value="images/topicface/1.gif" size=30 readonly> 
		 <%end if%>
        <select name=select size=1 id="select" style="font-family:arial" onChange="document.images['topicimg'].src=options[selectedIndex].value; parent.document.theForm.Topics.value=options[selectedIndex].value">
          <%dim e
	  e=1
			for e=1 to 80%>
          <option value="images/topicface/<%=e%>.gif">image<%=e%>.gif</option>
          <%next%>
        </select> <img src=images/topicface/1.gif align="absmiddle" id=topicimg> 
      </td>
    </tr>
    <tr> 
      <td align="left" valign="top"  class=tablebody1><strong>文章内容：</strong><br> 
		<br> <li>您最多可以发布 <b><font color=red>
		<%if GroupSetting(24)=0 then
		response.Write("不限")
		else
		response.Write(GroupSetting(24))
		end if%></font></b> 篇</li> 
		<li>篇幅长度 <b><font color=red>
		<%if GroupSetting(17)=0 then
		response.Write("不限")
		else
		response.Write(GroupSetting(17))
		end if%></font></b> 字符</li>
		<li>您一天最多发布 <b><font color=red><%if GroupSetting(15)=0 then
		response.Write("不限")
		else
		response.Write(GroupSetting(15))
		end if%></font></b> 篇</li>
		<li>今天还可以发布 <b><font color=red><%if GroupSetting(15)=0 then
		response.Write("不限")
		else
		response.write(Cint(GroupSetting(15))-Dcount)
		end if%></font></b> 篇</li>
		<li>发布文章金钱/篇 <b><%=GroupSetting(18)%> <%=GroupSetting(19)%></b> 元</li>
		<li>发布文章魅力/篇 <b><%=GroupSetting(20)%> <%=GroupSetting(21)%></b> 点</li>
		<li>发布文章经验/篇 <b><%=GroupSetting(22)%> <%=GroupSetting(23)%></b> 点</li>
		<li>发布文章及回复可上传 <b>
		<%if GroupSetting(36)=1 then
		response.Write("<font color=red>是</font>")
		else
		response.Write("否")
		end if%></b> </li>
		</td>
      <td align="left"  class=tablebody1><textarea name='Content' style='display:none'><%
if action="edit" then%><%=EContent%><%end if%></textarea> 
        <iframe id='editor' src='editor.asp' frameborder=0 scrolling=no width='520' height='405'></iframe></td>
    </tr>
    <tr> 
      <td height="24" align="left"  class=tablebody2><strong>文章选项：</strong></td>
      <td align="left"  class=tablebody2><input type=checkbox name=signflag value=1 <%if Esignflag=1 then%>checked<%end if%>>
        显示签名&nbsp;&nbsp; <input type="radio" name=emailflag value="0" <%if Eemailflag=0 then%>checked<%end if%>>
        不通知 &nbsp; 
        <input type="radio" name=emailflag value="1" <%if Eemailflag=1 then%>checked<%end if%>>
        邮件通知 
        <input type="radio" name=emailflag value="2" <%if Eemailflag=2 then%>checked<%end if%>>
        短信通知 
        <input type="radio" name=emailflag value="3" <%if Eemailflag=3 then%>checked<%end if%>>
        邮件和短信通知<br> <input type=checkbox name=istop value=2 <%if Eistop=2 then%>checked<%end if%>>
        文章推荐&nbsp;&nbsp; <input name=istop type=checkbox id="istop" value=1 <%if Eistop=1 then%>checked<%end if%>>
        文章精华
<input type="radio" name="IncludePic" value="1" <%if EIncludePic=1 then%>checked<%end if%>>
        包含图片 
        <input name="IncludePic" type="radio" value="0" <%if EIncludePic=0 then%>checked<%end if%>>
        不含图片 </td>
    </tr>
    <tr align="center"> 
      <td height="25" colspan="2"  class=tablebody1><input class=2 type=Submit value="保存" name=Submit> 
        &nbsp; <input class=2 type="reset" name="Clear" value="清除"></td>
    </tr>
  </form>
</table>
<%
end sub
%>   
</body>
</html> 