<!--#include file=conn.asp-->
<!--#include file=config.asp-->
<!--#include file=const.asp-->
<!--#include file=char.asp-->
<!--#include file=inc/ubbcode.asp-->
<%
 '=========================================================
' File: userdiary.asp
' Version:3.0
' Date: 2005-11-6
' 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
'=========================================================
response.buffer=true
stats="我的日记"
call nav()
if not founduser then
  	errmsg=errmsg+"<br>"+"<li>您没有<a href=login.asp target=_blank>登录</a>。"
	founderr=true
end if
if Cint(GroupSetting(84))<>0 and dateadd("n",Cint(GroupSetting(84)),myjoinDate)>=Now() then
  	errmsg=errmsg+"<br>"+"<li>新注册用户"&GroupSetting(84)&"分钟后才能撰写日记，请稍后<a href=login.asp target=_blank>登录</a>。"
	founderr=true
end if
if founderr then
	call head_var("","")
	call Mslove_error()
else
	call head_var(membername & "的帐号","mycount.asp")
%>
<table cellpadding=3 cellspacing=1 align=center class=tableborder1>
<tr>
<th width=12% height=25 id=tabletitlelink><a href=mycount.asp>我的帐号</a></th>
<th width=11%  id=tabletitlelink><a href=mymodify.asp>基本资料</a></th>
<th width=11%  id=tabletitlelink><a href=modifypsw.asp>密码修改</a></th>
<th width=11%  id=tabletitlelink><a href=modifyfd.asp>交友资料</a></th>
<th width=11%  id=tabletitlelink><a href=modifyadd.asp>联系资料</a></th>
<th width=11%  id=tabletitlelink><a href=usersms.asp>短信服务</a></th>
<th width=11%  id=tabletitlelink><a href=friendlist.asp>我的好友</a></th>
<th width=11%  id=tabletitlelink><a href=favlist.asp>我的收藏</a></th>
<th width=11%  id=tabletitlelink><a href=userphoto.asp>我的相册</a></th>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class=tableborder2>
  <tr> 
    <td width="48" height="31" align="right"><img src="Skins/Default/diary/x_line2.gif" width="1" height="30"></td>
    <td width="97" align="center"><a href="diaryindex.asp"><img src="Skins/Default/diary/dh_sy.gif" width="78" height="21" border="0"></a></td>
    <td width="11"><img src="Skins/Default/diary/x_line2.gif" width="1" height="30"></td>
    <td width="83"><a href="userdiary.asp"><img src="Skins/Default/diary/dh_mydaily.gif" width="76" height="21" border="0"></a></td>
    <td width="10"><img src="Skins/Default/diary/x_line2.gif" width="1" height="30"></td>
    <td width="89"><a href="userdiary.asp?action=newdiary"><img src="Skins/Default/diary/dh_fb.gif" width="81" height="21" border="0"></a></td>
    <td width="11"><img src="Skins/Default/diary/x_line2.gif" width="1" height="30"></td>
    <td width="84"><a href="diarylist.asp?action=hot"><img src="Skins/Default/diary/dh_hot.gif" width="74" height="21" border="0"></a></td>
    <td width="10"><img src="Skins/Default/diary/x_line2.gif" width="1" height="30"></td>
    <td width="87"><a href="diarylist.asp?action=new"><img src="Skins/Default/diary/dh_new.gif" width="76" height="21" border="0"></a></td>
    <td width="10"><img src="Skins/Default/diary/x_line2.gif" width="1" height="30"></td>
    <td width="88"><a href="diarylist.asp?action=best"><img src="Skins/Default/diary/dh_best.gif" width="75" height="21" border="0"></a></td>
    <td width="103">&nbsp;</td>
  </tr>
</table>
<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.datetime.value==''){
     alert('日记时间不能为空！');
     document.theForm.datetime.focus();
     return false;
  }
  if (document.theForm.Typied.value==''){
    alert('日记所属不能指定为外部栏目！');
    document.theForm.Typied.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>
<%
call tumppages()'翻页处理
strFileName="userdiary.asp?"
dim Did,Dcount,todaynum'检查数据库中会员日记多少篇
did=Checkstr(Trim(Request("did")))
if did="" then
did=0
else
did=cint(Did)
end if
sql="select count(Did) from [Ms_diary] where Username='"&trim(membername)&"'"
set rs=conn.execute(sql)
if not (rs.eof and rs.bof) then
todaynum=rs(0)
else
todaynum=0
end if
rs.close
sql="select count(id) from [Ms_diary] 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
Select Case Trim(Request("action"))
	Case "newdiary"
		Stats="发表日记"
		Call newdiary()
	case "newsave"
		Stats="保存日记"
		Call newsave()
	Case "edit"
		Stats="修改日记"
		Call edit()
	Case "editsave"
		Stats="保存修改日记"
		Call editsave()
	Case "清空"
		Stats="清空日记"
		Call Alldelet()
	Case "删除"
		Stats="删除日记"
		Call delet()
	Case "移动"
		Stats="移动日记"
		Call moveall()
	Case "showview"
		Stats="查看日记"
		Call showview()
	case else
	call main()
End Select
if founderr then call Mslove_error()
end if
call activeonline()
call footer()


sub main()%>
<table width="100%" align=center cellpadding=3 cellspacing=1 class=tableborder1>
  <form action="userdiary.asp" method=post name=theform>
    <tr align="left"> 
      <th height="28" colspan="7" align="center"  class=tablebody1>我的日记</th>
    </tr>
    <tr align="center"> 
      <td width="5%" height="27"  class=tablebody2>心情 </td>
      <td width="52%"  class=tablebody2>日记主题</td>
      <td width="8%"  class=tablebody2>修改</td>
      <td width="8%"  class=tablebody2>人气</td>
      <td width="11%"  class=tablebody2>日期</td>
      <td width="8%"  class=tablebody2>审核</td>
      <td width="8%"  class=tablebody2>操作</td>
    </tr>
    <%dim Ispublic,ps,typen
  set rs=server.createobject("adodb.recordset")
    sql="select * from Ms_diary where Username='"&Trim(membername)&"' order by Did desc"
	rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
call rspages()
do while not rs.eof and page_count<Cint(MaxPerPage)
Did=rs("Did")
Ispublic=rs("Ispublic")
if Ispublic=1 then
ps="公开且允许评论"
elseif Ispublic=2 then
ps="公开但不可评论"
else
ps="写给自己看，不公开"
end if
Select Case rs("Typeid")
	Case 1
	typen="以文会友"
	Case 2
	typen="生活点滴"
	Case 3
	typen="情感话题"
	Case 4
	typen="人生感悟"
	Case 5
	typen="胡思乱想"
	Case 6
	typen="此刻心情"
End Select
%>
    <tr align="center"> 
      <td width="5%" align="center"  class=tablebody1><img src=<%=rs("Topic")%> border=0 width=20></td>
      <td width="52%" align="left"  class=tablebody1><%response.write("<a href=userdiary.asp?action=showview&Did="&Did&" title=""主题："&rs("Title")&Brstrt&"属性："&ps&Brstrt&"分类："&typen&""">"&left(rs("Title"),24)&"</a>")
	  if datediff("d",rs("Addtime"),date())<1 then
response.write("&nbsp;<img src=images/new.gif>")
end if%></td>
      <td align="center"  class=tablebody1><a href="userdiary.asp?action=edit&Did=<%=did%>">修改</a></td>
      <td width="8%" align="center"  class=tablebody1><%if rs("hits")>=Clicknums then
	response.write("<font color=red>"&rs("hits")&"</font>")
	else
	response.write(""&rs("hits")&"")
	end if%></td>
      <td width="11%" align="center"  class=tablebody1><%=rs("Datetime")%></td>
      <td width="8%" align="center"  class=tablebody1><%if rs("Checked")=1 then
	response.write("已审")
	else
	response.Write("<font color=red>未审</font>")
	end if%></td>
      <td width="8%" align="center"  class=tablebody1><input type=checkbox name=id value=<%=Did%>></td>
    </tr>
    <%page_count=page_count+1
	rs.movenext
  loop
  else
  response.write("<tr align=""center""><td height=""30"" colspan=""7"" align=""center""  class=tablebody1>您还没有日记，请添加日记！</td></tr>")
  end if
  rs.close
  %>
    <tr align="center"> 
      <td height="30" colspan="7" align="left"  class=tablebody2> <%if totalrec>0 then
		  	call showpage(strFileName)
		  end if%></td>
    </tr>
    <tr align="right"> 
      <td height="29" colspan="7"  class=tablebody1> 
        <input type=checkbox name=chkall value=on onclick="CheckAll(this.form)">
        选中所有显示记录&nbsp;<input type=submit name=action onclick="{if(confirm('确定移动选定的日记吗?')){this.document.favform.submit();return true;}return false;}" value="移动">
        -> <select name="Typeid" id="Typeid">
		<option selected>请选择分类...</option>
          <option value="1">以文会友</option>
          <option value="2">生活点滴</option>
          <option value="3">情感话题</option>
          <option value="4">人生感悟</option>
		  <option value="5">胡思乱想</option>
		  <option value="6">此刻心情</option> </select> &nbsp; <input type=submit name=action onclick="{if(confirm('确定清空所有日记吗?')){this.document.favform.submit();return true;}return false;}" value="清空"> 
        &nbsp; <input type=submit name=action onclick="{if(confirm('确定删除选定的日记吗?')){this.document.favform.submit();return true;}return false;}" value="删除"></td>
    </tr>
    <tr align="center"> 
      <td colspan="7" align="left"  class=tablebody1>提示：<br> <li>添加一篇公开日记赠送金钱<font color="#FF0000">30</font>、经验值<font color="#FF0000">1</font>点，删除随之减少。</li>
        <li>日记获得会员评论再赠送金钱（<strong>5</strong>/会员）。</li>
        <li>日记被评为佳作获得金钱<strong>50</strong>、经验值<strong>5</strong>点、魅力值<strong>1</strong>点，被检举属实扣除相应数值。</li>
        <li>人气值显示为红色表示为热门。</li>
        <li>您可以发表日记总数为 <b><font color=red><%=GroupSetting(48)%></font></b> 篇。</li></td>
    </tr>
  </form>
</table>
<%
end sub

sub newdiary()'添加日记
if Cint(GroupSetting(84))=0 then
  	errmsg=errmsg+"<br>"+"<li>您没有撰写日记的权限。"
	founderr=true
end if
if Cint(GroupSetting(92))<>0 and Dcount>=Cint(GroupSetting(92)) then
  	errmsg=errmsg+"<br>"+"<li>您的日记已经达到限额，请升级再撰写。"
	founderr=true
end if
if founderr=true then exit sub
%>
<script language="JavaScript" src="inc/Mymodify.js"></script>
<table width="100%" align=center cellpadding=3 cellspacing=1 class=tableborder1>
  <form method='POST' name='theForm' onSubmit='return CheckForm();' action='userdiary.asp' target='_self'>
    <input name=action type="hidden"  value=newsave>
    <tr> 
      <td background="Skins/Default/diary/detail_top4.jpg" height="135" colspan="2" align="center">每天都在忙忙碌碌的工作，属于自己的静思的时候是不是越来越少？<br> 
        <%=webname%>特别为您提供“心情日记”！让您精心炮制自己的心得、随想、日志等梦幻文章！<br>
        请选择公开日记，不但可以展示您的文采，还能让“<%=webname%>”的会员对您的了解大大增加哦！</td>
    </tr>
    <tr> 
      <td width="24%" height="15" align="left"  class=tablebody1><strong>日　　期：</strong> 
      </td>
      <td width="76%"  class=tablebody1><input name="datetime" type="text" id="datetime" onfocus="show_cele_date(datetime,'','',datetime)" size="20">
        选择模板： 
        <select name="diaryTemp" id="diaryTemp">
          <option value="1" selected>以文会友</option>
          <option value="2">生活点滴</option>
          <option value="3">情感话题</option>
          <option value="4">人生感悟</option>
		  <option value="5">胡思乱想</option>
		  <option value="6">此刻心情</option>
        </select></td>
    </tr>
	
    <%if Cint(Codeshow(3))=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="31" align="left"  class=tablebody1><strong>天　　气：</strong></td>
      <td  class=tablebody1><input name="Weather" type="radio" value="1" checked> 
        <img src="Skins/Default/weather/1.gif" alt="晴" width="13" height="13"> 
        <input type="radio" name="Weather" value="2"> <img src="Skins/Default/weather/2.gif" alt="晴转多云" width="15" height="14"> 
        <input type="radio" name="Weather" value="3"> <img src="Skins/Default/weather/3.gif" alt="阴" width="19" height="11"> 
        <input type="radio" name="Weather" value="4"> <img src="Skins/Default/weather/4.gif" alt="阴有小雨" width="13" height="14"> 
        <input type="radio" name="Weather" value="5"> <img src="Skins/Default/weather/5.gif" alt="雷雨" width="13" height="16"> 
        <input type="radio" name="Weather" value="6"> <img src="Skins/Default/weather/6.gif" alt="小雨" width="11" height="13"> 
        <input type="radio" name="Weather" value="7"> <img src="Skins/Default/weather/7.gif" alt="湿" width="13" height="12"> 
        <input type="radio" name="Weather" value="8"> <img src="Skins/Default/weather/8.gif" alt="彩虹" width="20" height="12"> 
        <input type="radio" name="Weather" value="9"> <img src="Skins/Default/weather/9.gif" alt="大雪" width="11" height="11"> 
        <input type="radio" name="Weather" value="10"> <img src="Skins/Default/weather/10.gif" alt="雪" width="18" height="17"></td>
    </tr>
    <tr> 
      <td align="left"  class=tablebody1><strong>我的心情：</strong></td>
      <td  class=tablebody1> <a href=alltopic.asp target=_blank>查看所有心情</a><br> 
        <input name=Topics type=text value="images/topicface/1.gif" size=30 readonly> 
        <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 height="34" align="left"  class=tablebody1><strong>日记主题：</strong></td>
      <td  class=tablebody1><input name="Title" type="text" id="Title" size="40"></td>
    </tr>
    <tr> 
      <td height="31" align="left"  class=tablebody1><strong>这篇日记：</strong></td>
      <td  class=tablebody1> <input name="Ispublic" type="radio" value="1" checked>
        公开且允许评论 
        <input type="radio" name="Ispublic" value="2">
        公开但不可评论 
        <input type="radio" name="Ispublic" value="0">
        写给自己看，不公开</td>
    </tr>
    <tr> 
      <td height="30" align="left"  class=tablebody1><strong>所 属 类：</strong></td>
      <td  class=tablebody1><select name="Typeid" id="Typeid">
          <option value="1" selected>以文会友</option>
          <option value="2">生活点滴</option>
          <option value="3">情感话题</option>
          <option value="4">人生感悟</option>
		  <option value="5">胡思乱想</option>
		  <option value="6">此刻心情</option>
        </select> </td>
    </tr>
    <tr> 
      <td height="38" align="left"  class=tablebody1 valign="top" ><strong>日记内容：</strong><br> 
        <br> <li>您最多可以发布 <b><font color=red><%if GroupSetting(92)=0 then
		response.Write("不限")
		else
		response.write(GroupSetting(92))
		end if%></font></b> 篇</li>
        <li>篇幅长度不超过 <b><font color=red><%if GroupSetting(93)=0 then
		response.Write("不限")
		else
		response.Write(GroupSetting(93))
		end if%></font></b> 字符</li>
        <li>您一天最多发布 <b><font color=red><%if GroupSetting(94)=0 then
		response.Write("不限")
		else
		response.Write(GroupSetting(94))
		end if%></font></b> 篇</li>
        <li>您还可以发布 <b><font color=red><%if GroupSetting(92)=0 then
		response.Write("不限")
		else
		response.write(Cint(GroupSetting(92))-Dcount)
		end if%></font></b> 篇</li>
		<li>撰写日记金钱/篇 <b><%=GroupSetting(86)%> <%=GroupSetting(87)%></b> 元</li>
		<li>撰写日记魅力/篇 <b><%=GroupSetting(88)%> <%=GroupSetting(89)%></b> 点</li>
		<li>撰写日记经验/篇 <b><%=GroupSetting(90)%> <%=GroupSetting(91)%></b> 点</li></td>
      <td  class=tablebody1> <textarea name='Content' style='display:none'></textarea> 
        <iframe id='editor' src='editor.asp' frameborder=0 scrolling=no width='510' height='405'></iframe></td>
    </tr>
    <tr> 
      <td height="27" align="left"  class=tablebody1><strong>日记选项：</strong></td>
      <td  class=tablebody1> <input name=emailflag type="radio" value="0" checked>
        不通知 &nbsp; <input type="radio" name=emailflag value="1">
        邮件通知 
        <input type="radio" name=emailflag value="2">
        短信通知 
        <input type="radio" name=emailflag value="3">
        邮件和短信通知</td>
    </tr>
    <tr> 
      <td height="34" colspan="2" align="center"  class=tablebody1><input class=2 type=Submit value="保存" name=Submit> 
        &nbsp; <input class=2 type="reset" name="Clear" value="清除"></td>
    </tr>
    <tr align="center"> 
      <td height="27" colspan="2"  class=tablebody2><%=webname%>提醒您在发布作品之前必须仔细阅读并同意下列条款</td>
    </tr>
    <tr> 
      <td height="105" colspan="2" valign="top"  class=tablebody1>1.自觉遵守：爱国、守法、自律、真实、文明的原则；<br>
        2.尊重网上道德，遵守《互联网电子公告服务管理规定》和《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他各项有关法律法规；<br>
        3.严禁发表危害国家安全、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的作品。一经发现，<%=webname%>有权立即删除您的帐号，且已收费用不予退还；<br>
        4.承担一切因您的行为而直接或间接导致的民事或刑事法律责任；<br>
        5.<%=webname%>仅提供作品发布平台，不对上传作品的会员是否拥有其所发布的文章及图片的版权及其他合法权益提供任何担保，也不意味着赞同作者在作品中所阐述的观点，<%=webname%>不为任何由于作品发布而引起的纠纷承担责任；<br>
        6.<%=webname%>有权保留或删除其管辖作品中的任意内容；<br>
        7.您在<%=webname%>公开或曾经公开发表的作品，<%=webname%>有权在网站内转载或引用；<br>
        8.发表作品即表明您已经阅读并接受上述条款。</td>
    </tr>
  </form>
</table>
<script>
first("selectp","selectc","theForm",0,0);
</script>
<%end sub

sub newsave()''保存日记
if Not ChkPost then'查检提交数据
	ErrMsg=ErrMsg+"<Br>"+"<li>您提交的数据不合法，请不要从外部提交发言。"
   	FoundErr=True
end if

if Cint(Codeshow(3))=1 then
	if Not CodeIsTrue() then
		errmsg=errmsg+"<br>"+"<li>验证码校验失败，请返回刷新页面后再输入验证码。"
		founderr=true
	end if
end if
if Cint(GroupSetting(84))=0 then
  	errmsg=errmsg+"<br>"+"<li>您没有撰写日记的权限。"
	founderr=true
end if
dim Title,Content
if Cint(GroupSetting(92))<>0 and Dcount>=Cint(GroupSetting(92)) then
  	errmsg=errmsg+"<br>"+"<li>您的日记已经达到限额，请升级再撰写。"
	founderr=true
end if
if Cint(GroupSetting(94))<>0 and todaynum>=Cint(GroupSetting(94)) then
  	errmsg=errmsg+"<br>"+"<li>您今天只能撰写"&Cint(GroupSetting(94))&"篇。"
	founderr=true
end if
	Title=checkStr(trim(Request("Title")))
	Content=checkStr(trim(Request("Content")))
if Request("datetime")="" or not isdate(Request("datetime")) then
		errmsg=errmsg+"<br>"+"<li>请选择一个正确的日期。"
		founderr=true
end if
if Title="" or strLength(Title)>250 then
		errmsg=errmsg+"<br>"+"<li>请输入日记标题(长度不能大于250)。"
		founderr=true
end if
if Cint(GroupSetting(93))<>0 and strLength(Content)>Cint(GroupSetting(93)) then
		errmsg=errmsg+"<br>"+"<li>请输入日记内容(长度不能大于"&GroupSetting(93)&"字符)。"
		founderr=true
end if
if Chkvalue(1,GroupSetting(86),Cint(GroupSetting(87)))=false then
	errmsg=errmsg+"<br>"+"<li>对不起，您的金币不够请确认。"
	founderr=true
end if
if Chkvalue(2,GroupSetting(88),Cint(GroupSetting(89)))=false then
	errmsg=errmsg+"<br>"+"<li>对不起，您的魅力值不够请确认。"
	founderr=true
end if
if Chkvalue(3,GroupSetting(90),Cint(GroupSetting(91)))=false then
	errmsg=errmsg+"<br>"+"<li>对不起，您的经验值不够请确认。"
	founderr=true
end if
if founderr=true then exit sub
set rs=server.createobject("adodb.recordset")
sql="select * from Ms_diary where Username='"&trim(membername)&"' and Title='"&Title&"' and Typeid="&Cint(request("Typeid"))&""
rs.Open sql,conn,1,3
if rs.eof and rs.bof then
rs.addnew()
rs("Username")=trim(membername)
rs("Typeid")=trim(request("Typeid"))
rs("Title")=Title
rs("Content")=UBBCode(Content)
rs("Topic")=trim(request("Topics"))
rs("Weather")=trim(request("Weather"))
rs("Ispublic")=Cint(trim(request("Ispublic")))
rs("DiaryTemp")=Cint(trim(request("DiaryTemp")))
rs("Datetime")=trim(request("Datetime"))
rs("LastPost")=trim(membername)
if Cint(GroupSetting(95))=1 then
rs("Checked")=1
end if
rs("Lasttime")=now()
rs("addtime")=now()
rs("emailflag")=trim(request("emailflag"))
rs.update()
rs.close
conn.execute("update Ms_setup set Userdiary=Userdiary+1 where Cid=1")
conn.execute("update Ms_user set Userdiary=Userdiary+1,UserWealth=UserWealth "&GroupSetting(86)&Cint(GroupSetting(87))&",UserEP=UserEP "&GroupSetting(88)&Cint(GroupSetting(89))&",UserCP=UserCP "&GroupSetting(90)&Cint(GroupSetting(91))&" where Userid="&Userid&"")
Call indata()''调用增加写手属性
	sucmsg=sucmsg+"<br>"+"<li>您已成功撰写日记。"
	call Mslove_suc()
else
Errmsg=Errmsg+"<li>"+"对不起，您发表日记已经存在。"
Founderr=true
exit sub
end if
end sub

Sub indata()''ClassID=1是日记写手
Set rs= Server.CreateObject("ADODB.Recordset")
sql="Select Username,Article,ClassID,Addtime From [Ms_Writer] Where Username='"&trim(membername)&"'"
rs.Open sql,conn,1,3
	If Not (Rs.eof or Rs.bof) then
	rs("Article")=rs("Article")+1
	rs.update()
	else
	rs.addnew
	rs("Username")=trim(membername)
	rs("Article")=1
	rs("ClassID")=1
	rs("Addtime")=Now()
	rs.update()
	end if
	rs.close	
end sub

sub edit()
if Did="" or not isnumeric(Did) then
  	errmsg=errmsg+"<br>"+"<li>参数错误。"
	founderr=true
end if
if Cint(GroupSetting(97))=0 then
  	errmsg=errmsg+"<br>"+"<li>您没有编辑日记的权限。"
	founderr=true
end if
if founderr=true then exit sub
''检查今天的日记是否超过限度。
dim emailflag
sql="select * from [Ms_diary] where Username='"&trim(membername)&"' and Did="&Did&""
set rs=conn.execute(sql)
if not (rs.eof and rs.bof) then
emailflag=rs("emailflag")
%>
<script language="JavaScript" src="inc/Mymodify.js"></script>
<table width="100%" align=center cellpadding=3 cellspacing=1 class=tableborder1>
  <form method='POST' name='theForm' onSubmit='return CheckForm();' action='userdiary.asp' target='_self'>
    <input name=action type="hidden" value=editsave>
    <input name=Did type="hidden" value=<%=Did%>>
    <tr> 
      <td height="135" colspan="2" align="center" background="Skins/Default/diary/detail_top4.jpg">每天都在忙忙碌碌的工作，属于自己的静思的时候是不是越来越少？<br> 
        <%=webname%>特别为您提供“心情日记”！让您精心炮制自己的心得、随想、日志等梦幻文章！<br>
        请选择公开日记，不但可以展示您的文采，还能让“<%=webname%>”的会员对您的了解大大增加哦！</td>
    </tr>
    <tr> 
      <td width="24%" height="15" align="left"  class=tablebody1><strong>日　　期： 
        </strong></td>
      <td width="76%"  class=tablebody1><input name="datetime" type="text" id="datetime" onfocus="show_cele_date(datetime,'','',datetime)" size="20" value="<%=rs("datetime")%>">
        选择模板： 
        <select name="diaryTemp" id="diaryTemp">
		  <option value="1" <%if rs("diaryTemp")=1 then%>selected<%end if%>>以文会友</option>
          <option value="2" <%if rs("diaryTemp")=2 then%>selected<%end if%>>生活点滴</option>
          <option value="3" <%if rs("diaryTemp")=3 then%>selected<%end if%>>情感话题</option>
          <option value="4" <%if rs("diaryTemp")=4 then%>selected<%end if%>>人生感悟</option>
		  <option value="5" <%if rs("diaryTemp")=5 then%>selected<%end if%>>胡思乱想</option>
		  <option value="6" <%if rs("diaryTemp")=6 then%>selected<%end if%>>此刻心情</option>
        </select></td>
    </tr>
	<%if Cint(Codeshow(3))=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="31" align="left"  class=tablebody1><strong>天　　气：</strong></td>
      <td  class=tablebody1><input name="Weather" type="radio" value="1" <%if rs("Weather")=1 then%>checked<%end if%>> 
        <img src="Skins/Default/weather/1.gif" alt="晴" width="13" height="13"> 
        <input type="radio" name="Weather" value="2" <%if rs("Weather")=2 then%>checked<%end if%>> 
        <img src="Skins/Default/weather/2.gif" alt="晴转多云" width="15" height="14"> 
        <input type="radio" name="Weather" value="3" <%if rs("Weather")=3 then%>checked<%end if%>> 
        <img src="Skins/Default/weather/3.gif" alt="阴" width="19" height="11"> 
        <input type="radio" name="Weather" value="4" <%if rs("Weather")=4 then%>checked<%end if%>> 
        <img src="Skins/Default/weather/4.gif" alt="阴有小雨" width="13" height="14"> 
        <input type="radio" name="Weather" value="5" <%if rs("Weather")=5 then%>checked<%end if%>> 
        <img src="Skins/Default/weather/5.gif" alt="雷雨" width="13" height="16"> 
        <input type="radio" name="Weather" value="6" <%if rs("Weather")=6 then%>checked<%end if%>> 
        <img src="Skins/Default/weather/6.gif" alt="小雨" width="11" height="13"> 
        <input type="radio" name="Weather" value="7" <%if rs("Weather")=7 then%>checked<%end if%>> 
        <img src="Skins/Default/weather/7.gif" alt="湿" width="13" height="12"> 
        <input type="radio" name="Weather" value="8" <%if rs("Weather")=8 then%>checked<%end if%>> 
        <img src="Skins/Default/weather/8.gif" alt="彩虹" width="20" height="12"> 
        <input type="radio" name="Weather" value="9" <%if rs("Weather")=9 then%>checked<%end if%>> 
        <img src="Skins/Default/weather/9.gif" alt="大雪" width="11" height="11"> 
        <input type="radio" name="Weather" value="10" <%if rs("Weather")=10 then%>checked<%end if%>> 
        <img src="Skins/Default/weather/10.gif" alt="雪" width="18" height="17"></td>
    </tr>
    <tr> 
      <td align="left"  class=tablebody1><strong>我的心情：</strong></td>
      <td  class=tablebody1> &nbsp;<a href=alltopic.asp target=_blank>查看所有心情</a><br> 
        <input name=Topics type=text value="<%=rs("Topic")%>" size=30 readonly> 
        <select name=Topic size=1 id="select2" 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 height="34" align="left"  class=tablebody1><strong>日记主题：</strong></td>
      <td  class=tablebody1><input name="Title" type="text" id="Title" size="40" value="<%=rs("Title")%>"></td>
    </tr>
    <tr> 
      <td height="36" align="left"  class=tablebody1><strong>这篇日记：</strong></td>
      <td  class=tablebody1> <input name="Ispublic" type="radio" value="1" <%if rs("Ispublic")=1 then%>checked<%end if%>>
        公开且允许评论 
        <input type="radio" name="Ispublic" value="2" <%if rs("Ispublic")=2 then%>checked<%end if%>>
        公开但不可评论 
        <input type="radio" name="Ispublic" value="0" <%if rs("Ispublic")=0 then%>checked<%end if%>>
        写给自己看，不公开 </td>
    </tr>
    <tr> 
      <td height="31" align="left"  class=tablebody1><strong>所 属 类：</strong></td>
      <td  class=tablebody1><select name="Typeid" id="Typeid">
          <option value="1" <%if rs("Typeid")=1 then%>selected<%end if%>>以文会友</option>
          <option value="2" <%if rs("Typeid")=2 then%>selected<%end if%>>生活点滴</option>
          <option value="3" <%if rs("Typeid")=3 then%>selected<%end if%>>情感话题</option>
          <option value="4" <%if rs("Typeid")=4 then%>selected<%end if%>>人生感悟</option>
		  <option value="5" <%if rs("Typeid")=5 then%>selected<%end if%>>胡思乱想</option>
		  <option value="6" <%if rs("Typeid")=6 then%>selected<%end if%>>此刻心情</option>
        </select> </td>
    </tr>
    <tr> 
      <td height="38" align="left"  class=tablebody1><strong>日记内容：</strong><br> 
        <br> <li>您最多可以发布 <b><font color=red><%if GroupSetting(92)=0 then
		response.Write("不限")
		else
		response.write(GroupSetting(92))
		end if%></font></b> 篇</li>
        <li>篇幅长度不超过 <b><font color=red><%if GroupSetting(93)=0 then
		response.Write("不限")
		else
		response.Write(GroupSetting(93))
		end if%></font></b> 字符</li>
        <li>您一天最多发布 <b><font color=red><%if GroupSetting(94)=0 then
		response.Write("不限")
		else
		response.Write(GroupSetting(94))
		end if%></font></b> 篇</li>
        <li>您还可以发布 <b><font color=red><%if GroupSetting(92)=0 then
		response.Write("不限")
		else
		response.write(Cint(GroupSetting(92))-Dcount)
		end if%></font></b> 篇</li>
		<li>撰写日记金钱/篇 <b><%=GroupSetting(86)%> <%=GroupSetting(87)%></b> 元</li>
		<li>撰写日记魅力/篇 <b><%=GroupSetting(88)%> <%=GroupSetting(89)%></b> 点</li>
		<li>撰写日记经验/篇 <b><%=GroupSetting(90)%> <%=GroupSetting(91)%></b> 点</li></td>
      <td  class=tablebody1> <textarea name='Content' style='display:none'><%=rs("Content")%></textarea> 
        <iframe id='editor' src='editor.asp' frameborder=0 scrolling=no width='510' height='405'></iframe></td>
    </tr>
    <tr> 
      <td height="24" align="left"  class=tablebody1><strong>日记选项：</strong></td>
      <td  class=tablebody1><input type="radio" name=emailflag value="0" <%if emailflag=0 then%>checked<%end if%>>
        不通知 &nbsp; <input type="radio" name=emailflag value="1" <%if emailflag=1 then%>checked<%end if%>>
        邮件通知 
        <input type="radio" name=emailflag value="2" <%if emailflag=2 then%>checked<%end if%>>
        短信通知 
        <input type="radio" name=emailflag value="3" <%if emailflag=3 then%>checked<%end if%>>
        邮件和短信通知</td>
    </tr>
    <tr> 
      <td height="34" colspan="2" align="center"  class=tablebody1><input class=2 type=Submit value="修改" name=Submit> 
        &nbsp; <input class=2 type="reset" name="Clear" value="清除"></td>
    </tr>
    <tr align="center"> 
      <td height="27" colspan="2"  class=tablebody2><%=webname%>提醒您在发布作品之前必须仔细阅读并同意下列条款</td>
    </tr>
    <tr> 
      <td height="105" colspan="2" valign="top"  class=tablebody1>1.自觉遵守：爱国、守法、自律、真实、文明的原则；<br>
        2.尊重网上道德，遵守《互联网电子公告服务管理规定》和《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他各项有关法律法规；<br>
        3.严禁发表危害国家安全、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的作品。一经发现，<%=webname%>有权立即删除您的帐号，且已收费用不予退还；<br>
        4.承担一切因您的行为而直接或间接导致的民事或刑事法律责任；<br>
        5.<%=webname%>仅提供作品发布平台，不对上传作品的会员是否拥有其所发布的文章及图片的版权及其他合法权益提供任何担保，也不意味着赞同作者在作品中所阐述的观点，<%=webname%>不为任何由于作品发布而引起的纠纷承担责任；<br>
        6.<%=webname%>有权保留或删除其管辖作品中的任意内容；<br>
        7.您在<%=webname%>公开或曾经公开发表的作品，<%=webname%>有权在网站内转载或引用；<br>
        8.发表作品即表明您已经阅读并接受上述条款。</td>
    </tr>
  </form>
</table>
<script>
first("selectp","selectc","theForm",0,0);
</script>
<%end if
rs.close
end sub

sub editsave()''保存修改日记
if Not ChkPost then'查检提交数据
	ErrMsg=ErrMsg+"<Br>"+"<li>您提交的数据不合法，请不要从外部提交发言。"
   	FoundErr=True
end if

if Cint(Codeshow(3))=1 then
	if Not CodeIsTrue() then
		errmsg=errmsg+"<br>"+"<li>验证码校验失败，请返回刷新页面后再输入验证码。"
		founderr=true
	end if
end if
if Did="" or not isnumeric(Did) then
  	errmsg=errmsg+"<br>"+"<li>参数错误。"
	founderr=true
end if
if Cint(GroupSetting(97))=0 then
  	errmsg=errmsg+"<br>"+"<li>您没有编辑日记的权限。"
	founderr=true
end if
dim Title,Content
	Title=checkStr(trim(Request("Title")))
	Content=checkStr(trim(Request("Content")))
if Request("datetime")="" or not isdate(Request("datetime")) then
		errmsg=errmsg+"<br>"+"<li>请选择一个正确的日期。"
		founderr=true
end if
if Title="" or strLength(Title)>250 then
		errmsg=errmsg+"<br>"+"<li>请输入日记标题(长度不能大于250)。"
		founderr=true
end if
if Cint(GroupSetting(93))<>0 and strLength(Content)>Cint(GroupSetting(93)) then
		errmsg=errmsg+"<br>"+"<li>日记内容长度不能大于"&GroupSetting(93)&"字符。"
		founderr=true
end if
if founderr=true then exit sub
set rs=server.createobject("adodb.recordset")
sql="select * from Ms_diary where Username='"&trim(membername)&"' and Did="&Did&""
rs.Open sql,conn,1,3
if not (rs.eof and rs.bof) then
rs("Typeid")=trim(request("Typeid"))
rs("Title")=Title
rs("Content")=ubbcode(Content)
rs("Topic")=trim(request("Topics"))
rs("Weather")=trim(request("Weather"))
rs("Ispublic")=Cint(trim(request("Ispublic")))
rs("DiaryTemp")=Cint(trim(request("DiaryTemp")))
rs("Datetime")=Cdate(trim(request("Datetime")))
if Cint(GroupSetting(95))=1 then
rs("Checked")=1
end if
rs("emailflag")=trim(request("emailflag"))
rs.update()
rs.close
	sucmsg=sucmsg+"<br>"+"<li>您已成功修改日记。"
	call Mslove_suc()
else
Errmsg=Errmsg+"<li>"+"对不起，数据库中不存在该日记。"
Founderr=true
exit sub
end if
end sub

sub Alldelet()''清空日记操作
dim delid
delid=0
if Cint(GroupSetting(98))=0 then
Errmsg=Errmsg+"<li>"+"对不起，您没有删除日记的权限。"
Founderr=true
exit sub
end if
set rs=server.createobject("adodb.recordset")
sql="select Did from Ms_diary where Username='"&trim(membername)&"'"
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
do while not rs.eof
if delid=0 then
delid=rs("Did")
else
delid=delid&","&rs("Did")
end if
rs.movenext
loop
rs.close
end if
conn.execute("update Ms_setup set Userdiary=Userdiary-"&Dcount&" where Cid=1")
conn.execute("update Ms_user set Userdiary=Userdiary-"&Dcount&",UserWealth=UserWealth-("&GroupSetting(18)&(Cint(GroupSetting(19))*Dcount)&"),UserEP=UserEP-("&GroupSetting(20)&(Cint(GroupSetting(21))*Dcount)&"),UserCP=UserCP-("&GroupSetting(22)&(Cint(GroupSetting(23))*Dcount)&") where Userid="&Userid&"")
conn.execute("delete from Ms_diary where Username='"&trim(membername)&"'")
conn.execute("update Ms_Writer set Article=0 where Username='"&trim(membername)&"' ")
conn.execute("delete from Ms_diaryb where Tid in("&delid&")")
sucmsg=sucmsg+"<br>"+"<li>您已成功清空所有日记。"
	call Mslove_suc()
end sub

sub delet()''删除选定日记
dim delid,FixID,splitid
delid=replace(request("id"),"'","")
delid=replace(delid,";","")
delid=replace(delid,"--","")
delid=replace(delid,")","")
fixid=replace(delid,",","")
fixid=Trim(replace(fixid," ",""))
splitid=split(delid,",")
splitid=ubound(splitid)
If Not IsNumeric(fixid) Then
	Errmsg=Errmsg+"<br><li>错误的参数。"
	founderr=true
End If
if delid="" or isnull(delid) then
Errmsg=Errmsg+"<li>"+"错误的参数。"
Founderr=true
end if

if founderr=true then exit sub
conn.execute("update Ms_setup set Userdiary=Userdiary-"&(splitid+1)&" where Cid=1")
conn.execute("update Ms_user set Userdiary=Userdiary-"&(splitid+1)&",UserWealth=UserWealth-("&GroupSetting(18)&(Cint(GroupSetting(19))*(splitid+1))&"),UserEP=UserEP-("&GroupSetting(20)&(Cint(GroupSetting(21))*(splitid+1))&"),UserCP=UserCP-("&GroupSetting(22)&(Cint(GroupSetting(23))*(splitid+1))&") where Username='"&trim(membername)&"'")
conn.execute("delete from Ms_diary where Username='"&trim(membername)&"' and Did in("&delid&")")
conn.execute("update Ms_Writer set Article=Article-"&(splitid+1)&" where Username='"&trim(membername)&"' ")
conn.execute("delete from Ms_diaryb where Tid in("&delid&")")
sucmsg=sucmsg+"<br>"+"<li>您已成功删除所选日记。"
	call Mslove_suc()
end sub

sub moveall()
dim delid,FixID,Typeid
delid=replace(request("id"),"'","")
delid=replace(delid,";","")
delid=replace(delid,"--","")
delid=replace(delid,")","")
fixid=replace(delid,",","")
fixid=Trim(replace(fixid," ",""))
Typeid=checkStr(trim(Request("Typeid")))
If Not IsNumeric(fixid) Then
	Errmsg=Errmsg+"<br><li>错误的参数。"
	founderr=true
End If
if delid="" or isnull(delid) then
Errmsg=Errmsg+"<li>"+"错误的参数。"
Founderr=true
end if
if Typeid="" or not isnumeric(Typeid) then
Errmsg=Errmsg+"<li>"+"没有选择移动类别。"
Founderr=true
end if
if founderr=true then exit sub
conn.execute("update Ms_diary set Typeid="&Typeid&" where Username='"&trim(membername)&"' and Did in("&delid&")")
sucmsg=sucmsg+"<br>"+"<li>您已成功移动所选日记到指定类别中。"
	call Mslove_suc()
end sub

sub showview()
dim Did
Did=Checkstr(Trim(Request("Did")))
if Did="" or not isnumeric(Did) then
  	errmsg=errmsg+"<br>"+"<li>参数错误。"
	founderr=true
end if

dim Title,DiaryTemp,Postname,Ispublic
set rs=server.createobject("adodb.recordset")
sql="select * from Ms_diary where Checked=1 and Ispublic<>0 and Did="&Did&""
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
Title=rs("Title")
Postname=rs("Username")
DiaryTemp=rs("DiaryTemp")
Ispublic=rs("Ispublic")%>
<style type="text/css">
<!--
.dotline {
	BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; PADDING-BOTTOM: 1px; BORDER-LEFT: #cccccc 1px solid; BORDER-BOTTOM: #cccccc 1px solid
}
.xuxian {
	BORDER-BOTTOM: #cccccc 1px dotted
}
-->
</style>
<table width="100%" align=center cellpadding=0 cellspacing=0 background="Skins/Default/diary/list_bg1.gif" class=tableborder1>
  <tr align="left"> 
    <td width="100%" height="14" align="right" valign="bottom" background="Skins/Default/diary/list_bg1.gif"  class=tablebody1><img src=Skins/Default/diary/detail_top<%=DiaryTemp%>.jpg></td>
  </tr>
  <tr align="center" valign="top" background="Skins/Default/diary/list_bg1.gif"> 
    <td height="397"> <table width="93%" height="397" border="0" cellpadding="0" cellspacing="0" class=dotline>
        <tr> 
          <td height="395" align="center" valign="top" bgcolor="#f5f5fa" style="word-wrap:break-word;line-height : 17pt"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td height="47" align="center"><b><%=Title%></b></td>
              </tr>
              <tr> 
                <td height="27" align="center">作者：<a href=dispuser.asp?username=<%=Postname%>><%=Postname%></a>　　最近更新：<%=replace(rs("Lasttime"),right(rs("Lasttime"),3),"")%>　　人气：<%=rs("hits")%></td>
              </tr>
              <tr> 
                <td height="28" align="center" class=xuxian>日期：<%=rs("Datetime")%>　 <%=weekdayname(WeekDay(rs("Datetime")))%> 　天气：<img src=Skins/Default/weather/<%=rs("Weather")%>.gif border=0 width=13>　 
                  　　心情：<img src=<%=rs("Topic")%> width=20 border=0 align="absmiddle"> 
                  　　<a href="postcomp.asp?Typeid=2&page=diaryview.asp?did=<%=did%>">检举日记</a> 
                </td>
              </tr>
              <TR> 
              <tr> 
                <td height="29" align="center">&nbsp;</td>
              </tr>
            </table>
            <table width="93%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td><%=rs("Content")%></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
  <tr align="center"> 
    <td height="27" align="center" background="Skins/Default/diary/list_bg1.gif"  class=tablebody1><a href="userdiary.asp?action=edit&Did=<%=Did%>"><img src="Skins/Default/EDIT.GIF" width="47" height="18" border="0"></a>&nbsp;&nbsp; 
      <a href="userdiary.asp?action=删除&id=<%=Did%>"><img src="Skins/Default/delete.gif" width="52" height="16" border="0"></a></td>
  </tr>
</table>
<%end if
rs.close
end sub%>
</body>
</html>  