<!--#include file="Access.asp"  -->
<!-- #include file="inc/functions.asp" -->
<!-- #include file="inc/pingyin.asp" -->
<!-- #include file="x_to_html/index_to_html.asp" -->

<% '读取数据
page=request.querystring("page")
act=request.querystring("act")
keywords=request.querystring("keywords")
article_id=cint(request.querystring("id"))

id1=cint(request.querystring("id"))
pid_name=request.querystring("pid_name")
pid_name2=request.querystring("pid_name2")
ppid=cint(request.querystring("ppid"))

act1=Request("act1")
If act1="save" Then 
id2=trim(request.form("id2"))
c_name=trim(request.form("c_name"))
c_folder=trim(request.form("c_folder"))
c_folder_py=trim(request.form("c_folder_py"))
c_folder_yes=trim(request.form("c_folder_yes"))
c_image=trim(request.form("web_image"))
c_keywords=trim(request.form("c_keywords"))
c_description=trim(request.form("c_description"))
c_content=trim(request.form("c_content"))
c_index_push=trim(request.form("c_index_push"))
c_time=now()
%>
<% '汉字转化成拼音
if c_folder_py="1" then
c_folder=trans_letters(c_name)
else
c_folder=trans_letters(c_folder)
end if
%>

<% '创建分类文件夹
if c_folder_yes="1" and (c_folder<>"" or c_folder_py<>"") then

set rs=server.createobject("adodb.recordset")
sql="select [folder] from [category] where [name]='"&pid_name&"'"
rs.open(sql),cn,1,1
if not rs.eof and not rs.bof then
folder_0=rs("folder")
Set Fso=Server.CreateObject("Scripting.FileSystemObject") 
If Fso.FolderExists(Server.MapPath("/"&rs("folder")))=false Then
NewFolderDir="/"&rs("folder")
call CreateFolderB(NewFolderDir)
end if


set rs2=server.createobject("adodb.recordset")
sql="select [folder] from [category] where [name]='"&pid_name2&"'"
rs2.open(sql),cn,1,1
if not rs2.eof and not rs2.bof then
folder_2=rs2("folder")
Set Fso=Server.CreateObject("Scripting.FileSystemObject") 
If Fso.FolderExists(Server.MapPath("/"&rs("folder")&"/"&rs2("folder")))=false Then
NewFolderDir="/"&rs("folder")&"/"&rs2("folder")
call CreateFolderB(NewFolderDir)
end if

rs2.close
set rs2=nothing
end if

rs.close
set rs=nothing
end if

if ppid=1 then
NewFolderDir="/"&c_folder
end if

if ppid=2 then
NewFolderDir="/"&folder_0&"/"&c_folder
end if

if ppid=3 then
NewFolderDir="/"&folder_0&"/"&folder_2&"/"&c_folder
end if


call CreateFolderB(NewFolderDir)

end if
%>


<% '添加到数据库
set rs=server.createobject("adodb.recordset")
sql="select * from category where id="&id2&""
rs.open(sql),cn,1,3
rs("name")=c_name
rs("folder")=c_folder
rs("image")=c_image
rs("keywords")=c_keywords
rs("description")=c_description
rs("content")=c_content
rs("index_push")=c_index_push
rs("time")=c_time
rs.update
rs.close
set rs=nothing
%>

<%
call index_to_html()
%>

<% '在/html中创建分类文件夹
Set Fso=Server.CreateObject("Scripting.FileSystemObject") 
If Fso.FolderExists(Server.MapPath("/html/"&id2))=false Then
NewFolderDir="/html/"&id2
call CreateFolderB(NewFolderDir)
end if
%>

<%
response.Write "<script language='javascript'>alert('修改成功！');location.href='category_list.asp?page="&page&"&act="&act&"&keywords="&keywords&"';</script>"
end if 
 %>
	<%
Call header()

%>
<%
set rs2=server.createobject("adodb.recordset")
sql="select * from category where id="&id1&""
rs2.open(sql),cn,1,3
if not rs2.eof and not rs2.bof then
%>
  <form id="form1" name="form1" method="post" action="?act1=save&page=<%=page%>&act=<%=act%>&keywords=<%=keywords%>&pid_name=<%=pid_name%>&pid_name2=<%=pid_name2%>&ppid=<%=ppid%>">
         <script language='javascript'>
function checksignup1() {
if ( document.form1.c_name.value == '' ) {
window.alert('请输入分类名称^_^');
document.form1.c_name.focus();
return false;}

return true;}
</script>
	<table cellpadding='3' cellspacing='1' border='0' class='tableBorder' align=center>
	<tr>
	  <th class='tableHeaderText' colspan=2 height=25>新闻分类设置</th>
	<tr>
	<td width="15%" height=23 class='forumRow'>分类名称 (必填)</td>
	<td class='forumRow'><input name='c_name' type='text' id='c_nampe' value="<%=rs2("name")%>" size='40'>
	<input name='id2' type='hidden' id='id2' size='40' value="<%=id1%>">
	
	  &nbsp;<span style="color: #FF0000"><%
	  if ppid=2 then
response.write "当前为二级分类:&nbsp;"&pid_name&"&nbsp;>"
elseif ppid=3 then
response.write "当前为三级分类:&nbsp;"&pid_name&"&nbsp;>&nbsp;"&pid_name2&"&nbsp;>"
else
response.write "当前为一级分类"
end if%></span></td>
	</tr>
	<tr>
	<td class='forumRowHighLight' height=23>分类文件夹名称 (选填)</td>
    <td class='forumRowHighLight'><input type='text' id='c_folder' name='c_folder' value="<%=rs2("folder")%>" size='40' 
	<% if rs2("folder")<>"" then%>
	style="color:gray;" readonly
	<%
	else
	if logr()=false then
	response.write " readonly"
	end if
	end if%> >
     <%'只有超级管理员有权限创建文件夹
	  if logr() then
	  %>
     <% '判断文件夹是否存在，不存在则创建（1），存在则修改（2）
	  'rs0 一级分类，rs1 二级分类,rs2 当前分类
	  if ppid=1 then
	  Set Fso=Server.CreateObject("Scripting.FileSystemObject") 
If Fso.FolderExists(Server.MapPath("/"&rs2("folder")))=false Then
response.write "<br><input type='checkbox' name='c_folder_yes' value='1'><span style='color: #FF0000'>创建新文件夹</span> 该分类文件夹尚未创建,将创建新的文件夹"
else

if rs2("folder")="" then
response.write "尚未命名分类文件夹名称，<span style='color: #FF0000'>一旦命名将不可更改</span>"
response.write "<br/>"
response.write "<input type='checkbox' name='c_folder_py' value='1'>"
response.write "使用分类名称拼音命名,填入的字符将无效"
response.write "<br><input type='checkbox' name='c_folder_yes' value='1'><span style='color: #FF0000'>创建新文件夹</span> 如果未命名分类名称将无法创建"
else
response.write "<span style='color: #FF0000'>该分类文件夹已创建成功</span>"
end if

end if
end if


set rs0=server.createobject("adodb.recordset")
sql="select [folder] from [category] where [name]='"&pid_name&"'"
rs0.open(sql),cn,1,1
if not rs0.eof and not rs0.bof then

	  if ppid=2 then
	  
	  Set Fso=Server.CreateObject("Scripting.FileSystemObject") 
If Fso.FolderExists(Server.MapPath("/"&rs0("folder")&"/"&rs2("folder")))=false Then
response.write "<br><input type='checkbox' name='c_folder_yes' value='1'><span style='color: #FF0000'>创建新文件夹</span> 该分类文件夹尚未创建,将创建新的文件夹"
else
if rs2("folder")="" then
response.write "尚未命名分类文件夹名称，<span style='color: #FF0000'>一旦命名将不可更改</span>"
response.write "<br/>"
response.write "<input type='checkbox' name='c_folder_py' value='1'>"
response.write "使用分类名称拼音命名,填入的字符将无效"
response.write "<br><input type='checkbox' name='c_folder_yes' value='1'><span style='color: #FF0000'>创建新文件夹</span> 如果未命名分类名称将无法创建"
else
response.write "<span style='color: #FF0000'>该分类文件夹已创建成功</span>"
end if

end if
end if

set rs1=server.createobject("adodb.recordset")
sql="select [folder] from [category] where [name]='"&pid_name2&"'"
rs1.open(sql),cn,1,1
if not rs1.eof and not rs1.bof then

	  if ppid=3 then
	  
	  Set Fso=Server.CreateObject("Scripting.FileSystemObject") 
If Fso.FolderExists(Server.MapPath("/"&rs0("folder")&"/"&rs1("folder")&"/"&rs2("folder")))=false Then
response.write "<br><input type='checkbox' name='c_folder_yes' value='1'><span style='color: #FF0000'>创建新文件夹</span> 该分类文件夹尚未创建,将创建新的文件夹"
else
if rs2("folder")="" then
response.write "尚未命名分类文件夹名称，<span style='color: #FF0000'>一旦命名将不可更改</span>"
response.write "<br/>"
response.write "<input type='checkbox' name='c_folder_py' value='1'>"
response.write "使用分类名称拼音命名,填入的字符将无效"
response.write "<br><input type='checkbox' name='c_folder_yes' value='1'><span style='color: #FF0000'>创建新文件夹</span> 如果未命名分类名称将无法创建"
else
response.write "<span style='color: #FF0000'>该分类文件夹已创建成功</span>"
end if

end if
end if

rs1.close
set rs1=nothing
end if

rs0.close
set rs0=nothing
end if%>
<%
else
response.write "<span style='color: #FF0000'>&nbsp;无法修改</span>"
end if%></td>
	</tr>
	  <tr>
	    <td class='forumRow' height=23>分类图片</td>
	    <td width="85%" class='forumRow'><table width="100%" border="0" cellspacing="0" cellpadding="0">
         <tr>
           <td width="22%"  class='forumRow'><input name="web_image" type="text" id="web_image" value="<%=rs2("image")%>" size="30"></td>
           <td width="78%"  class='forumRow'><iframe width="500" name="ad" frameborder=0 height=30 scrolling=no src=upload.asp></iframe></td>
         </tr>
       </table></td>
      </tr>

      <td class='forumRowHighLight' height=11>分类关键字</td>
	      <td class='forumRowHighLight'><input type='text' id='v3' name='c_keywords' value="<%=rs2("keywords")%>" size='80'>
	  &nbsp;请以，隔开</td>
	</tr><tr>
	  <td class='forumRow' height=11>分类描述</td>
	  <td class='forumRow'><textarea name='c_description'  cols="100" rows="4" id="c_description" ><%=rs2("description")%></textarea></td>
	</tr>
	<tr>
	  <td class='forumRow' height=23>分类简介</td>
	  <td class='forumRow'> <textarea name='c_content' style='display:none' dataType='Require'  ><%=rs2("content")%></textarea>
 <iframe ID='eWebEditor1' src='editor/ewebeditor.htm?id=c_content&style=coolblue&originalfilename=d_originalfilename&savefilename=d_savefilename&savepathfilename=d_savepathfilename' frameborder='0' scrolling='no' width='100%' HEIGHT='260'></iframe></td>
	</tr>
	<tr>
	  <td class='forumRowHighLight' height=23>分类推荐</td>
	  <td class='forumRowHighLight'><label>
	    <input type="radio" name="c_index_push" value="1" <%
		if rs2("index_push")=1 then
		response.write "checked"
		end if%>>
      是
      &nbsp;
      <input name="c_index_push" type="radio" value="0" <%if rs2("index_push")=0 then
		response.write "checked"
		end if%>>
      否</label></td>
	</tr>
	<tr><td height="50" colspan=2  class='forumRow'><div align="center">
	  <INPUT type=submit value='提交' onClick='javascript:return checksignup1()' name=Submit>
	  </div></td></tr>
	</table>
</form>
<%
end if
rs2.close
set rs2=nothing
%>
<%
Call DbconnEnd()
 %>