<!-- #include file="include/admin_onlogin.asp" -->
<%
del_upload_true=true
index_url="update"
call admin_master(0,0)
call admin_header(0,0)
%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='?'><%response.write tit%></a></td>
  <td width=10></td>
  <td><a href='?action=add'>添加新<%response.write tit_fir%></a></td>
  </tr>
  </table>
</td></tr>
</table>
<%
call admin_table(1,1)

if action="handle" then call joekoe_go_handle()

select case action
case "edit"
  call joekoe_chk_edit()
case "add"
  call joekoe_chk_add()
case else
  call joekoe_chk_main()
end select

call admin_ender(1)

sub joekoe_chk_edit()
  sql="select top 1 * from "&data_name&" where id="&id
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,3
  if rs.eof then
    rs.close
    call admin_msg(tit_fir&"（ID："&id&"）不在存！","?jk_mod="&nsort,1)
    exit sub
  end if
  dim topic,word
  call admin_td("编辑"&tit_fir)
  if chk() then
    topic=code_admin("topic",1,50)
    nsort=trim(request.form("nsort"))
    if nsort<>"forum" then nsort="news"
    word=request.form("word")
    if topic="" or word="" then
      rs.close
      call admin_error(tit_fir&"标题 和 "&tit_fir&"标题 不能为空！")
      exit sub
    end if
    rs("sort")=nsort
    rs("username")=login_username
    rs("topic")=topic
    rs("word")=word
    'rs("tim")=joekoe_cms.now_time
    rs.update
    rs.close
    call upload_note(index_url,id)
    call admin_msg("成功编辑一条"&tit_fir,"?jk_mod="&nsort,1)
    exit sub
  end if
  call form_first()
  nsort=rs("sort")
%>
<form name=add_frm action='?jk_mod=<%response.write jk_mod%>&action=edit&id=<%response.write id%>' method=post>
<input type=hidden name=chk value='yes'>
<input type=hidden name=upid value=''>
<tr>
<td><%response.write tit_fir%>标题：</td>
<td><input type=text name=topic value='<%response.write rs("topic")%>' size=65 maxlength=50></td>
</tr>
<tr>
<td><%response.write tit_fir%>名称：</td>
<td><input type=radio name=nsort value='news'<%if nsort<>"forum" then response.write " checked"%>>&nbsp;网站更新&nbsp;&nbsp;<input type=radio name=nsort value='forum'<%if nsort="forum" then response.write " checked"%>>&nbsp;论坛公告</td>
</tr>
<tr>
<td><%call frm_ubb_type("")%></td>
<td><%call frm_ubb("add_frm","word","&nbsp;&nbsp;")%></td>
</tr>
<tr>
<td valign=top><%response.write tit_fir%>内容：</td>
<td><textarea name=word rows=10 cols=65><%response.write joekoe_cms.code_word(rs("word"))%></textarea></td>
</tr>
<tr>
<td>上传图片：</td>
<td><iframe frameborder=0 name=upload_frame width='100%' height=30 scrolling=no src='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write left(index_url,1)%>&uptext=word'></iframe></td>
</tr>
<%
  rs.close
  call submit_edit()
end sub

sub joekoe_chk_add()
  dim topic,word
  call admin_td("添加"&tit_fir)
  if chk() then
    topic=code_admin("topic",1,50)
    nsort=trim(request.form("nsort"))
    if nsort<>"forum" then nsort="news"
    word=request.form("word")
    if topic="" or word="" then
      call admin_error(tit_fir&"标题 和 "&tit_fir&"标题 不能为空！")
      exit sub
    end if
    sql="select * from "&data_name&" where id is null"
    call joekoe_cms.exec("",-1)
    rs.open sql,conn,1,3
    rs.addnew
    rs("sort")=nsort
    rs("username")=login_username
    rs("topic")=topic
    rs("word")=word
    rs("tim")=joekoe_cms.now_time
    rs.update 
    rs.close
    call upload_note(index_url,first_id(data_name,"id"))
    call admin_msg("成功添加一条新的"&tit_fir,"?jk_mod="&nsort,1)
    exit sub
  end if
  call form_first()
%>
<form name=add_frm action='?jk_mod=<%response.write jk_mod%>&action=add' method=post>
<input type=hidden name=chk value='yes'>
<input type=hidden name=upid value=''>
<tr>
<td><%response.write tit_fir%>标题：</td>
<td><input type=text name=topic size=65 maxlength=50></td>
</tr>
<tr>
<td><%response.write tit_fir%>名称：</td>
<td><input type=radio name=nsort value='news' checked>&nbsp;网站更新&nbsp;&nbsp;<input type=radio name=nsort value='forum'>&nbsp;论坛公告</td>
</tr>
<tr>
<td><%call frm_ubb_type("")%></td>
<td><%call frm_ubb("add_frm","word","&nbsp;&nbsp;")%></td>
</tr>
<tr>
<td valign=top><%response.write tit_fir%>内容：</td>
<td><textarea name=word rows=10 cols=65></textarea></td>
</tr>
<tr>
<td>上传图片：</td>
<td><iframe frameborder=0 name=upload_frame width='100%' height=30 scrolling=no src='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write left(index_url,1)%>&uptext=word'></iframe></td>
</tr>
<%
  call submit_add()
end sub

sub joekoe_chk_main()
  dim sort,topic,tim
  call admin_td(tit)
%>
<tr align=center valign=top>
<td>
  <table border=0>
  <tr><td height=30><%response.write img_admin("","")%>&nbsp;<a href='?'>所有<%response.write tit%></a></td></tr>
  <tr><td><%response.write img_admin("","")%>&nbsp;<a href='?jk_mod=news'<%
  if jk_mod="news" then
    sql_add=" where sort='"&jk_mod&"'"
    response.write " class=red"
  end if
%>>网站更新</a></td></tr>
  <tr><td><%response.write img_admin("","")%>&nbsp;<a href='?jk_mod=forum'<%
  if jk_mod="forum" then
    sql_add=" where sort='"&jk_mod&"'"
    response.write " class=red"
  end if
%>>论坛公告</a></td></tr>
  <tr><td height=30><%response.write img_admin("","")%>&nbsp;<a href='?jk_mod=<%response.write jk_mod%>&action=add'>添加新<%response.write tit_fir%></a></td></tr>
  </table>
</td>
<td>
  <table cellspacing=1 cellpadding=3 class=table0>
  <form name=sel_form action='?jk_mod=<%response.write jk_mod%>&action=handle' method=post>
  <tr align=center>
  <td class=td width='7%'>序号</td>
  <td class=td width='50%'><%response.write tit%>标题</td>
  <td class=td width='17%'>发布人</td>
  <td class=td width='20%'>相关操作</td>
  <td class=td width='6%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
  </tr>
<%
  sql="select count(id) from "&data_name&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from "&data_name&sql_add&" order by id desc"
  call joekoe_cms.exec(sql,-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)
  for i=1 to nums
    id=rs("id")
    topic=rs("topic")
    tim=rs("tim")
%>
  <tr align=center>
  <td class=tims><a href='update.asp?action=<%response.write rs("sort")%>#<%response.write id%>' target=_blank><%response.write (viewpage-1)*nummer+i%></a></td>
  <td align=left><a href='?action=edit&id=<%response.write id%>' alt='<%response.write joekoe_cms.code_html(topic,1,0)%>'><%response.write joekoe_cms.code_html(topic,1,(20+tnum))%></a></td>
  <td><%response.write format_user_view(rs("username"),1,0)%></td>
  <td><%response.write pro_edit("?action=edit&id="&id,"编辑该"&tit_fir)%>&nbsp;&nbsp;<font alt='<%response.write joekoe_cms.time_type(tim,2)%>' class=tims><%response.write joekoe_cms.time_type(tim,4)%></font></td>
  <td><input type=checkbox name=sel_id value='<%response.write id%>'></td>
  </tr>
<%
    rs.movenext
  next
  rs.close
%>
  <tr class=tr1>
  <td colspan=3>
现有<font class=red><%response.write rssum%></font>条<%response.write tit_fir%>，
每页<font class=red><%response.write nummer%></font>条，
页次：<font class=red><%response.write viewpage%></font>/<font class=red><%response.write thepages%></font>
分页：<%response.write jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")%>
  </td>
  <td colspan=2 align=center>
执行
<select name=sel_type size=1>
<option value='删除'>删除</option>
</select>
<input type=submit value='操作' onclick="return sel_click(this.form);">
  </td>
  </tr>
  </form>
  </table>
</td>
</tr>
<%
end sub
%>