<!-- #include file="include/admin_onlogin.asp" -->
<%
'****************************************************
' 阳光情缘 2006V3.0      Power by sdsun.com.cn
' Email: 27072320@qq.com  , sdsun163@163.com
' Web: http://www.sdsun.com.cn
' Copyright (C) 2006 sdsun.com.cn All Rights Reserved.
'****************************************************
admins=true
popedom_num=0
data_name="jk_skin_mod"
index_url="skin"
tit_fir="模板"
tit="新闻/文章模板配置"

call admin_header(0,0)
%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='admins_config_skin.asp'>标准模板配置</a></td>
  <td width=10></td>
  <td><a href='admins_config_skin_mod.asp' class=red>新闻/文章模板配置</a></td>
  <td width=10></td>
  <td><a href='admins_config_skin.asp?jk_mod=css' >CSS样式文件生成</a></td>
  <td width=10></td>
  <td><a href='admin_data.asp?action=cache'>网站缓存清理</a></td>
  <td width=10></td>
  <td><%call admin_read("","网站模板设置","模板功能可以对您的网站进行个性设计。<br>如果你不是很熟悉此功能，请不要随便修改，最好在我们的辅导下修改。<br><font class=red>如果系统允许用户使用“自选风格”，则请在修改模板后一定要清理网站缓存！</font>")%></td>
  </tr>
  </table>
</td></tr>
</table>
<%
call admin_table(1)

select case action
case "edit"
  call joekoe_chk_edit()
case "add"
  call joekoe_chk_add()
case "handle"
  call joekoe_chk_handle()
case "inport"
  call joekoe_chk_inport()
case else
  call joekoe_chk_main()
end select

call admin_ender(1)

sub joekoe_chk_edit()
  dim s_type,s_name,s_left,s_center,s_more,s_end,s_view
  call admin_td("编辑"&tit_fir)
  sql="select top 1 * from "&data_name&" where s_id="&id
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,3
  if rs.eof then
    call admin_msg("要进行编辑的"&tit_fir&"（ID："&s_id&"）不存在！","?",1)
    exit sub
  end if
  if chk() then
    s_type=request.querystring("s_type")
    if int(s_type)<>2 then s_type=1
    s_name=code_admin("s_name",1,20)
    s_left=code_admin("s_left",1,0)
    s_center=code_admin("s_center",1,0)
    s_more=code_admin("s_more",1,0)
    s_end=code_admin("s_end",1,0)
    s_view=code_admin("s_view",1,0)
    if s_name="" or s_left="" or s_center="" or s_more="" or s_end="" or s_view="" then
      rs.close
      call admin_error(tit_fir&"的 名称 及 内容 不能为空！")
      exit sub
    end if
    rs("s_type")=s_type
    rs("s_name")=s_name
    rs("s_left")=s_left
    rs("s_center")=s_center
    rs("s_more")=s_more
    rs("s_end")=s_end
    rs("s_view")=s_view
    rs.update
    rs.close
    call delete_cache_skins()
    call admin_msg("成功编辑一项"&tit_fir&"信息","?",1)
    exit sub
  end if
  call form_first()
  s_type=rs("s_type")
%>
<form action='?action=edit&id=<%response.write id%>' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td width='22%'><%response.write tit_fir%>类型：</td>
<td width='78%'><input type=radio name=s_type value='1'<%if int(s_type)<>2 then response.write " checked"%>>&nbsp;文章模板&nbsp;&nbsp;<input type=radio name=s_type value='2'<%if int(s_type)=2 then response.write " checked"%>>&nbsp;新闻模板</td>
</tr>
<tr>
<td><%response.write tit_fir%>名称：</td>
<td><input type=text name=s_name value='<%response.write rs("s_name")%>' size=30 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td>左表格<%response.write tit_fir%>：</td>
<td>
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><textarea name=s_left cols=60 rows=6><%response.write joekoe_cms.code_word(rs("s_left"))%></textarea></td>
  <td width=5></td>
  <td valign=bottom><img src=images/admin/viewpic.gif onclick="runscript(s_left)"><%call textarea_resize("s_left")%></td>
  </tr>
  </table>
</td>
</tr>
<tr>
<td>主表格<%response.write tit_fir%>：</td>
<td>
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><textarea name=s_center cols=60 rows=6><%response.write joekoe_cms.code_word(rs("s_center"))%></textarea></td>
  <td width=5></td>
  <td valign=bottom><img src=images/admin/viewpic.gif onclick="runscript(s_center)"><%call textarea_resize("s_shop_center")%></td>
  </tr>
  </table>
</td>
</tr>
<tr>
<td>表格附属更多：</td>
<td>
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><textarea name=s_more cols=60 rows=3><%response.write joekoe_cms.code_word(rs("s_more"))%></textarea></td>
  <td width=5></td>
  <td valign=bottom><img src=images/admin/viewpic.gif onclick="runscript(s_more)"><%call textarea_resize("s_more")%></td>
  </tr>
  </table>
</td>
</tr>
<tr>
<td>表格附属更多：</td>
<td>    <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><textarea name=s_end cols=60 rows=3><%response.write joekoe_cms.code_word(rs("s_end"))%></textarea></td>
  <td width=5></td>
  <td valign=bottom><img src=images/admin/viewpic.gif onclick="runscript(s_end)"><%call textarea_resize("s_end")%></td>
  </tr>
  </table>
</td>
</tr>
<tr>
<td>浏览表格模板：</td>
<td>
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><textarea name=s_view cols=60 rows=16><%response.write joekoe_cms.code_word(rs("s_view"))%></textarea></td>
  <td width=5></td>
  <td valign=bottom><img src=images/admin/viewpic.gif onclick="runscript(s_view)"><%call textarea_resize("s_view")%></td>
  </tr>
  </table>
</td>
</tr>
<%
  rs.close
  call submit_edit()
end sub

sub joekoe_chk_add()
  dim s_type,s_name,s_left,s_center,s_more,s_end,s_view
  call admin_td("添加"&tit_fir)
  if chk() then
    s_type=trim(request.form("s_type"))
    if int(s_type)<>2 then s_type=1
    s_name=code_admin("s_name",1,20)
    s_left=code_admin("s_left",1,0)
    s_center=code_admin("s_center",1,0)
    s_end=code_admin("s_end",1,0)
    s_view=code_admin("s_view",1,0)
    if s_name="" or s_left="" or s_center="" or s_more="" or s_end="" or s_view="" then
      call admin_error(tit_fir&"的 名称 及 内容 不能为空！")
      exit sub
    end if
    sql="select * from "&data_name
    call joekoe_cms.exe_conn(rs,sql,3)
    rs.addnew
    rs("s_type")=s_type
    rs("s_name")=s_name
    rs("s_left")=s_left
    rs("s_center")=s_center
    rs("s_more")=s_more
    rs("s_end")=s_end
    rs("s_view")=s_view
    rs.update
    rs.close
    call delete_cache_skins()
    call admin_msg("成功添加一项新的"&tit_fir&"信息","?",1)
    exit sub
  end if
  call form_first()
%>
<form action='?action=add' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td width='22%'><%response.write tit_fir%>类型：</td>
<td width='78%'><input type=radio name=s_type value='1' checked>&nbsp;文章模板&nbsp;&nbsp;<input type=radio name=s_type value='2'>&nbsp;新闻模板</td>
</tr>
<tr>
<td><%response.write tit_fir%>名称：</td>
<td><input type=text name=s_name value='' size=30 maxlength=20><%response.write redx%></td>
</tr>
<tr>
<td>左表格<%response.write tit_fir%>：</td>
<td>
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><textarea name=s_left cols=60 rows=6></textarea></td>
  <td width=5></td>
  <td valign=bottom><img src=images/admin/viewpic.gif onclick="runscript(s_left)"><%call textarea_resize("s_left")%></td>
  </tr>
  </table>
</td>
</tr>
<tr>
<td>主表格<%response.write tit_fir%>：</td>
<td>
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><textarea name=s_center cols=60 rows=6></textarea></td>
  <td width=5></td>
  <td valign=bottom><img src=images/admin/viewpic.gif onclick="runscript(s_center)"><%call textarea_resize("s_shop_center")%></td>
  </tr>
  </table>
</td>
</tr>
<tr>
<td>表格附属更多：</td>
<td>
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><textarea name=s_more cols=60 rows=3></textarea></td>
  <td width=5></td>
  <td valign=bottom><img src=images/admin/viewpic.gif onclick="runscript(s_more)"><%call textarea_resize("s_more")%></td>
  </tr>
  </table>
</td>
</tr>
<tr>
<td>表格附属底部：</td>
<td>    <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><textarea name=s_end cols=60 rows=3><</textarea></td>
  <td width=5></td>
  <td valign=bottom><img src=images/admin/viewpic.gif onclick="runscript(s_end)"><%call textarea_resize("s_end")%></td>
  </tr>
  </table>
</td>
</tr>
<tr>
<td>浏览表格模板：</td>
<td>
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><textarea name=s_view cols=60 rows=16></textarea></td>
  <td width=5></td>
  <td valign=bottom><img src=images/admin/viewpic.gif onclick="runscript(s_view)"><%call textarea_resize("s_view")%></td>
  </tr>
  </table>
</td>
</tr>
<%
  call submit_add()
end sub

sub joekoe_chk_handle()
  dim sel_type,sel_id
  sel_type=code_admin("sel_type",1,0)
  sel_id=code_admin("sel_id",1,0)
  sel_id=replace(sel_id," ","")
  if sel_id="" then
    call admin_msg("没有选择可操作的记录！","?",1)
    exit sub
  end if
  if sel_type="delete" then
    sql="delete from "&data_name&" where s_dir<>'"&joekoe_cms.web_skin&"' and s_id in("&sel_id&")"
    call joekoe_cms.exec(sql,0)
    call delete_cache_skins()
    call admin_msg("成功删除所选择的"&tit_fir,"?",1)
    exit sub
  end if
  dim skin_file,export_type,econn,fieldsnum,dim_skin,dim_fields,j
  skin_file=code_admin("skin_file",1,0)
  export_type=code_admin("export_type",1,0)
  if skin_file="" then
    call admin_msg("导出的数据库路径不能为空！","?",1)
    exit sub
  end if
  sql="select * from "&data_name&" where s_id in("&sel_id&") order by s_id"
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    call admin_msg("没有选择可操作的记录！","?",1)
    exit sub
  end if
  dim_skin=rs.getrows()
  fieldsnum=rs.fields.count-1
  redim dim_fields(fieldsnum)
  for i=0 to fieldsnum
    dim_fields(i)=rs(i).name
  next
  rs.close
  on error resume next
  set econn=server.createobject("adodb.connection")
  econn.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath(skin_file)
  if export_type="replace" then
    econn.execute("delete * from "&data_name)
  end if
  rs.open "select * from "&data_name&" where s_id",econn,1,3
  if err.number=-2147467259 then
    erase dim_skin
    erase dim_fields
    rs.close
    econn.close
    set econn=nothing
    err.clear
    call admin_msg("导出的数据库或数据表出现异常（可能不存在）！","?",1)
    exit sub
  end if
  for j=0 to ubound(dim_skin,2)
    rs.addnew
    for i=1 to fieldsnum
      rs(dim_fields(i))=dim_skin(i,j)
    next
    rs.update
  next
  rs.close
  econn.close
  set econn=nothing
  erase dim_skin
  erase dim_fields
  call admin_msg("成功导出所选择的"&tit_fir&"数据！","?",1)
end sub

sub joekoe_chk_inport()
  dim skin_file,export_type,econn,fieldsnum,dim_skin,dim_fields,j
  skin_file=code_admin("skin_file",1,0)
  export_type=code_admin("export_type",1,0)
  if skin_file="" then
    call admin_msg("导出的数据库路径不能为空！","?",1)
    exit sub
  end if
  on error resume next
  set econn=server.createobject("adodb.connection")
  econn.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath(skin_file)
  rs.open "select * from "&data_name&" order by s_id",econn,1,1
  dim_skin=rs.getrows()
  fieldsnum=rs.fields.count-1
  redim dim_fields(fieldsnum)
  for i=0 to fieldsnum
    dim_fields(i)=rs(i).name
  next
  rs.close
  econn.close
  set econn=nothing
  if err.number=-2147467259 then 
    erase dim_skin
    erase dim_fields
    err.clear
    call admin_msg("导出的数据库或数据表出现异常（可能不存在）！","?",1)
    exit sub
  end if
  if export_type="replace" then
    call joekoe_cms.exec("truncate table "&data_name,0)
  end if
  sql="select * from "&data_name
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,3
  for j=0 to ubound(dim_skin,2)
    rs.addnew
    for i=1 to fieldsnum
      rs(dim_fields(i))=dim_skin(i,j)
    next
    rs.update
  next
  rs.close
  erase dim_skin
  erase dim_fields
  call delete_cache_skins()
  call admin_msg("成功导入所外部"&tit_fir&"数据！","?",1)
end sub

sub joekoe_chk_main()
  dim s_id
  call admin_td(tit)
%>
<tr align=center valign=top>
<td width='22%'>
  <table border=0>
  <tr><td height=30><%response.write img_admin("s_imp","")%>&nbsp;<a href='?action=add'>添加模板</a></td></tr>
  <tr><td><%response.write img_admin("","")%>&nbsp;<a href='?jk_mod=article'<%if jk_mod="article" then response.write " class=red"%>>文章模板</a></td></tr>
  <tr><td><%response.write img_admin("","")%>&nbsp;<a href='?jk_mod=news'<%if jk_mod="news" then response.write " class=red"%>>新闻模板</a></td></tr>
  </table>
</td>
<td width='78%'>
  <table cellspacing=1 cellpadding=3 class=table0>
  <form action='?action=handle' method=post>
  <tr align=center>
  <td class=td width='6%'>ID</td>
  <td class=td width='20%'><%response.write tit_fir%>类型</td>
  <td class=td width='60%'><%response.write tit_fir%>名称</td>
  <td class=td width='14%'>操作&nbsp;<input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
  </tr>
<%
  sql="select s_id,s_type,s_name from "&data_name
  select case jk_mod
  case "article"
    sql=sql&" where s_type=1"
  case "news"
    sql=sql&" where s_type=2"
  end select
  sql=sql&" order by s_id"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    s_id=rs("s_id")
%>
  <tr align=center>
  <td class=tims><%response.write s_id%></td>
  <td><%
    if int(rs("s_type"))=2 then
      response.write "新闻"&tit_fir
    else
      response.write "文章"&tit_fir
    end if
%></td>
  <td align=left>&nbsp;<a href='?action=edit&id=<%response.write s_id%>'><%response.write joekoe_cms.code_html(rs("s_name"),1,0)%></a></td>
  <td><a href='?action=edit&id=<%response.write s_id%>'>编辑</a>&nbsp;&nbsp;<input type=checkbox name=sel_id value='<%response.write s_id%>'></td>
  </tr>
<%
    rs.movenext
  loop
  rs.close
%>
  <tr class=tr2><td colspan=5 height=40 align=center>
    <table border=0>
    <tr class=tr2>
    <td>导出的数据库：</td>
    <td><input type=text name=skin_file value='' size=25></td>
    <td><select name=export_type><option value='add'>追加</option><option value='replace'>替换</option></select></td>
    <td><input type=radio name=sel_type value='export' checked>导出</td>
    <td><input type=radio name=sel_type value='delete'>删除</td>
    <td><input type=submit value='执行所选操作' onclick="return sel_click(this.form);"></td>
    </tr>
    </table>
  </td></tr>
  </form>
<%call admin_td0("导入外部"&tit_fir&"数据",5)%>
  <tr><td colspan=5 align=center>
    <table border=0>
    <form action='?action=inport' method=post>
    <tr>
    <td>导入<%response.write tit_fir%>数据库名：</td>
    <td><input type=text name=skin_file value='' size=25></td>
    <td><select name=export_type><option value='add'>追加导入</option><option value='replace'>替换导入</option></select></td>
    <td><input type=submit value='执行导入操作' onclick="javascript:return click_return('导入外部<%response.write tit_fir%>数据库',0);"></td>
    </tr>
    </form>
    </table>
  </td></tr>
  </table>
</td>
</tr>
<%
end sub

sub delete_cache_skins()
  application.contents.remove(joekoe_cms.web_cookies&"_CMS_Skin")
end sub 
'****************************************************
' 阳光情缘 2006V3.0      Power by sdsun.com.cn
' Email: 27072320@qq.com  , sdsun163@163.com
' Web: http://www.sdsun.com.cn
' Copyright (C) 2006 sdsun.com.cn All Rights Reserved.
'****************************************************
%>
