自己写的{$动易系统-批量修改模版的小程序}
前几天用动易的文章系统做了个站,开始的时候没有去精心管理模版,一味的做整体的网站策划,然后又忙于采集信息。要发布网站了,想把网站弄得漂亮点,才发现由于自己建的频道太多,再去把每个频道的每个模版去修改简直太麻烦,我的性格就是懒,否则不会用动易的系统,于是便写了个小程序。
程序小,功能小,但是却很实用---大家别笑话菜鸟。
PS:没有权限上传附件,只能把代码贴出来了,反正程序小,只有一个叶子。
代码如下:(贴进来可能有些变形,将就看吧)
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改模版</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.input {
border: 1px solid #006600;
}
.style1 {color: #FF0000}
.style2 {color: #009900}
-->
</style>
</head>
<!--
************************************************************************************************
功能介绍:实现修改相应“改动相同”的模版。
程序制作:长春大学生信息港(
http://www.0431stu.com)
免责声明:本程序是恋飞的鸵鸟为自己维护网站所用,如果本程序存在BUG对您的网站造成损害,概不负责!
************************************************************************************************
-->
<body>
<%
dim objrs,str1,str2,temp
if request("action")="yes" then
dim checkall,tps
checkall=request("checkall")
tps=request("tpId")
response.write "<br><a href=z_Tp.asp>点击这里返回</a><br>替换进行中……<br>"
OpenConn()
set objrs= server.createobject("adodb.recordset")
if checkall="yes" then
sql="select * from PE_Template"
else
if tps="" then
response.write "你还没有选择模版,请选择模版"
response.end
end if
sql="select * from PE_Template where TemplateID in("&tps&")"
end if
objrs.open sql,conn,1,3
str1=request("str1")
str2=request("str2")
while not objrs.eof
temp=objrs("TemplateContent")
objrs("TemplateContent")=replace(temp,str1,str2)
objrs.update
response.write objrs("TemplateName")&"----<font color=red>更新成功</font><br>"
objrs.movenext
wend
objrs.close
set objrs=nothing
CloseConn()
else
%>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#006600">
<form action="z_Tp.asp" method="post">
<tr bgcolor="#FFFFFF">
<td height="50" colspan="2"><div align="center">批量修改模版--代码替换(<span class="style1">注意:在进行此操作前一定要备份数据库</span>)</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="25" colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%"><input onClick="window.tps.style.display='none';" type="radio" name="checkall" value="yes">
所有模版</td>
<td><input name="checkall" onClick="window.tps.style.display='';" type="radio" value="no" checked>
自定义选择</td>
</tr>
</table></td>
</tr>
<tr id="tps" bgcolor="#FFFFFF">
<td height="69" colspan="2">
<%
showChannel()
%>
<table width="100%">
<%
OpenConn()
set objrs= server.createobject("adodb.recordset")
sql="select * from PE_Template order by ChannelID"
objrs.open sql,conn,1,3
dim i
i=1
while not objrs.eof
if i mod 2 = 1 then
response.write "<tr>"
end if
response.write "<td width=50% > <input type=checkbox name=tpId value="&objrs("TemplateID")&">"&objrs("TemplateName")&"(<font color=red>"&objrs("ChannelID")&"</font>)</td>"
if i mod 2 = 0 then
response.write "</tr>"
end if
objrs.movenext
i=i+1
wend
if i mod 2 = 0 then
response.write "</tr>"
end if
objrs.close
set objrs=nothing
CloseConn()
%>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="152" height="112"><div align="right">被替换代码:</div></td>
<td width="445" height="112"> <textarea name="str1" cols="50" rows="5" class="input"></textarea></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="107"><div align="right">替换成:</div></td>
<td height="107"> <textarea name="str2" cols="50" rows="5" class="input"></textarea></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="30" colspan="2"><div align="center"><input name="action" type="hidden" value="yes"><input type="submit" value=" 提 交 ">
</div></td>
</tr>
<tr valign="middle" bgcolor="#FFFFFF">
<td height="107" colspan="2"><p> 功能介绍:实现修改<span class="style2">相应</span>“<span class="style1">改动相同</span>”的模版。</p>
<p> 程序制作:<a href="http://www.0431stu.com">长春大学生信息港</a></p></td>
</tr>
</form>
</table>
</body>
</html>
<%
end if
function showChannel()
response.write "<table width=100% >"
dim csql,crs
csql="select * from PE_Channel"
OpenConn()
set crs=server.createobject("adodb.recordset")
crs.open csql,conn,1,1
dim j
j=1
while not crs.eof
if j mod 2 = 1 then
response.write "<tr>"
end if
response.write "<td width=50% ><font color=red >"&crs("ChannelID")&"--"&crs("ChannelName")&"</font></td>"
if j mod 2 = 0 then
response.write "</tr>"
end if
j=j+1
crs.movenext
wend
if j mod 2 = 0 then
response.write "</tr>"
end if
crs.close
set crs=nothing
CloseConn()
response.write "</table>"
end function
%>