<!-- #include file="include/admin_onlogin.asp" -->
<!-- #include file="include/jk_ubb.asp" -->
<%
index_url="diary"
data_name="admin_diary"
tit_fir="日记"
tit="管理日记"
call admin_master(0,0)
call admin_header(0,0)
call admin_table(1,0)
select case action
case "handle"
  call sushi_chk_handle()
case else
  call diary_main()
end select
call admin_ender(1)

sub diary_main()
  dim id,nname,topic,hidden,tim,weather
  sql="select count(id) from diary"
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  if int(rssum)<1 then
    call diary_write()
    exit sub
  end if
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from diary order by id desc"
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
%>
<form name=sel_form action='?action=handle' method=post>
<tr align=center><td class=td>No.</td><td class=td>主题</td><td class=td>作者</td><td class=td>时间</td><td class=td>天气</td><td class=td>公开</td><td class=td>操作</td></tr>
<%
  for i=1 to nums
    id=rs("id")
    topic=rs("topic")
    tim=rs("tim")
    weather=rs("weather")
dim d_name
if rs("diaryname")<>"" then
d_name=rs("diaryname")
else
d_name=rs("nname")
end if	
%>
<tr class=bg_td align=center><td><%response.write rssum-(i+(viewpage-1)*nummer)+1%></td>
<td align=left><font alt='<%response.write joekoe_cms.code_html(topic,1,0)%>'><%response.write joekoe_cms.code_html(topic,1,20)%></font></td>
<td><%response.write d_name%></td>
<td><%response.write tim%></td>
<td><img src=images/diary/image/<%response.write weather%>.gif border=0></td>
<td><%if rs("hidden")=true then%><font color=blue><b alt=公开>√</b></font><%else%><font color=red><b alt=不公开>×</b></font><%end if%></td>
<td><input type=checkbox name=sel_id value=<%response.write id%>></td>
</tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=bg_tds height=30><td colspan=4>&nbsp;共有<font class=red><%response.write rssum%></font>条日记&nbsp;页次：<font class=red><%response.write viewpage&"</font>/<font class=red>"&thepages%></font>&nbsp;分页：<% response.write jk_pagecute(nummer,thepages,viewpage,"?action=mydiary&",5,"#ff0000") %></td>
<td colspan=2 align=center>

执行
<select name=sel_type size=1>
<option value='公开日记'>公开日记</option>
<option value='取消公开'>取消公开</option>
<option value='删除日记'>删除日记</option>
</select>
<input type=submit value='操作' onclick="return sel_click(this.form);">
</td><td align=center><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
</tr></form>
<%
end sub

function weeks(w)
select case w
	case 1 weeks="日"
	case 2 weeks="一"
	case 3 weeks="二"
	case 4 weeks="三"
	case 5 weeks="四"
	case 6 weeks="五"
	case 7 weeks="六"
end select

end function

function doweather(w)
select case w
	case "1" doweather="<img src=images/diary/image/1.gif border=0>&nbsp;多云"
	case "2" doweather="<img src=images/diary/image/2.gif border=0>&nbsp;阴天"
	case "3" doweather="<img src=images/diary/image/3.gif border=0>&nbsp;晴天"
	case "4" doweather="<img src=images/diary/image/4.gif border=0>&nbsp;雾"
	case "5" doweather="<img src=images/diary/image/5.gif border=0>&nbsp;雪"
end select
end function

sub sushi_chk_handle()
  dim sel_type,seltype
  sel_type=trim(request.form("sel_type"))
  select case sel_type
  case "公开日记"
    seltype="gkdiary"
  case "取消公开"
    seltype="qxdiary"
  case "删除日记"
    seltype="delete"
  case else
    sel_type=""
    seltype=""
  end select
  if sel_type="" or seltype="" then
    	Response.Write "<script>"
	Response.Write "alert('您在提交用户操作时出现非法的数据');"
	Response.Write "</script>"
    exit sub
  end if
  dim sel_id,hdim,hnum,id
  sel_id=trim(request.form("sel_id"))
  sel_id=replace(sel_id," ","")
  hdim=split(sel_id,",")
  hnum=ubound(hdim)
  for i=0 to hnum
    id=hdim(i)
    if isnumeric(id) then
      select case seltype
      case "delete"
  	 call joekoe_cms.exec("delete from diary where id="&id&"",0)
      case "gkdiary"
        sql="update diary set hidden=true where id="&id
        conn.execute(sql)
      case "qxdiary"
        sql="update diary set hidden=false where id="&id
        conn.execute(sql)
      case else

      end select
    end if
  next
  erase hdim
Response.Write ("<tr><td align=left class=td>&nbsp;&nbsp;成功信息</td></tr>")
Response.Write ("<tr><td align=center class=bg_td height=180>")
Response.Write ("已成功（"&sel_type&"）操作了"&(hnum+1)&"条"&tit_fir&"记录！<br><br>")
Response.Write ("<a href='"&trim(request.servervariables("http_referer"))&"'>返回上页</a>")
Response.Write ("&nbsp;&nbsp;&nbsp;&nbsp;<a href=?>日记首页</a></td></tr>")
end sub
%>