Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[原创]字符替换程序 For 2.5 by lu5266

[复制链接]
lu5266 发表于 2005-12-3 19:21:47 | 显示全部楼层 |阅读模式
名称:  字符替换程序 For 2.5 by lu5266
演示:  一楼           
版本: 2.5&sp1
作者: lu5266
难易: 简单
支持: http://www.5466.ik8.com/

功能:  

          此程序适合于在dz2.5上 (默认的是2.5 要适合3.0的话,把代码里的的2.5改为3.0 ;)

           处理掉帖子,标题里一些你不想要的字符,或者替换一些字符

           特别是从2.5升级到3.0的时候会有一些不想要的字符
            例如 : 话题类型,3.0现在已经不需要了,因为有了主题分类

           或者是从pw转到dz的也会有一些不想要的字符




说明: 转贴请保留以上版权信息。



安装方法:

把下面代码保存为postadmin.php

传到论坛跟目录 运行就可以了




  1. <?

  2. $paversion=2.5; //你的论坛版本, 如果是3.0写 3.0 就可以了

  3. /*

  4. Name:      字符替换程序

  5. Author:    lu5266

  6. copyright: lu5266

  7. site:      http://www.5466.ik8.com  http://lulu.e-168.cn

  8. Function:  此程序适合于在dz3.0上 ( 要适合2.5的话,把上面的3.0改为 2.5 ;)

  9.            处理掉帖子,标题里一些你不想要的字符,或者替换一些字符

  10.            特别是从2.5升级到3.0的时候会有一些不想要的字符

  11.            或者是从pw转到dz的也会有一些不想要的字符


  12. declaration:  程序可任意修改,但请保留以上信息,谢谢

  13. */
  14. ?>

  15. <html>
  16. <head>
  17. <meta name="save" content="history">
  18. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  19. <title>字符替换程序 by lu5266</title>
  20. <style type="text/css"><!--
  21. a                        { text-decoration: none; color: #000000 }
  22. a:hover                        { text-decoration: underline; color:#CC3333 }
  23. body                        { scrollbar-base-color: #F8F8F8; scrollbar-arrow-color: #72C7CE; font-size: 9pt; background-color: #FFFFFF }
  24. table                        { font: 9pt Tahoma, Verdana; color: #000000 }
  25. input,select,textarea        { font: 9pt Tahoma, Verdana; color: #000000; font-weight: normal; background-color: #F8F8F8 }
  26. select                        { font: 9pt Tahoma, Verdana; color: #000000; font-weight: normal; background-color: #F8F8F8 }
  27.   .saveHistory {behavior:url(#default#savehistory);}
  28. --></style>
  29. <script language=javascript>
  30. function chkpa(this_pa){
  31. if(!this_pa.pasource.value){
  32.   alert("要被替换掉的字符不能为空,要不处理什么啊!?!?");
  33.   return false;
  34.   }  
  35. if(this_pa.pamethod[0].checked)
  36. var paflag="你现在选择的是查看模式,只是查看有多少将要被你替换掉的字符,不会影响数据库内容!";
  37. else
  38. var paflag="你现在选择的是处理模式,\n请你确认要替换的字符是否正确. 因为这个是操作数据库的.\n你确定你要执行此程序?";
  39. if(confirm(paflag)) { return true; this_pa.pasubmit.disabled=true;}
  40. else return false;
  41. }
  42. </script>
  43. </head>
  44. <body bgcolor="#E4E4E4">


  45. <?
  46. if($paversion==2.5) require_once "./include/common.php";
  47. else  require_once "./include/common.inc.php";
  48. if(!$discuz_user || $adminid !=1) showmessage("只有管理员才可以使用此管理程序! 你[ $discuz_user ]不是管理员!  请先登陆管理员的帐号再使用!");

  49. if(!submitcheck('pasubmit')){
  50. echo '<div align="center"><font color="blue"> <b>字符替换程序</b></font></div>';
  51. echo '<form name="pa" method="post" action="postadmin.php"  onSubmit="return chkpa(this)">';
  52. echo '<input type="hidden" name="formhash" value="'.FORMHASH.'">';
  53. echo 'Ⅰ① : 处理每个帖子(包括楼主的和回复的,表cdb_posts记录的)标题: <input type="radio" name="pacontent" class="saveHistory" value="1"  checked ><br>';
  54. echo 'Ⅰ② : 处理主题(这个是进入版块的时候的列表主题  表cdb_threads记录的): <input type="radio" name="pacontent"  class="saveHistory"value="3"><br>';
  55. echo 'Ⅱ:    处理贴内的内容(表cdb_posts记录的): <input type="radio" name="pacontent"  class="saveHistory"value="2"><br>';
  56. echo 'Ⅲ:    请输入要执行的版块的fid, 用 , 隔开多个版块,例如: 1,2,3,10 ( 留空的话为整个论坛): <input type="text" name="pafid" class="saveHistory" onkeyup="value=value.replace(/[^0-9,]/g, \'\')"><br>';
  57. echo 'Ⅳ:    请输入要执行的帖子的pid, 用 , 隔开多个帖子,例如: 1,2,3,10 ( 留空的话为上面所填版块的所有帖子): <input type="text" name="papid" class="saveHistory" onkeyup="value=value.replace(/[^0-9,]/g,\'\')"><br>';
  58. echo 'Ⅴ:    请输入将要被替换掉的字符: <input type="text" name="pasource" class="saveHistory"><br>';
  59. echo 'Ⅵ:    请输入用来替换的字符(留空的话,就是用空来代替): <input type="text" name="patarget" class="saveHistory"><br>';
  60. echo 'Ⅶ:  ①查看模式: <input type="radio" name="pamethod" class="saveHistory" value="1" checked>            ';
  61. echo '   ②处理模式: <input type="radio" name="pamethod"  class="saveHistory" value="2"><br>';
  62. echo '<p align="center"><input type="submit" name="pasubmit" value="提交"></p></form>';
  63. }

  64. else{

  65. $pafid=trim($pafid);
  66. $papid=trim($papid);

  67. if($pacontent==1) $pacontent="subject";
  68. elseif($pacontent==3) $pacontent="thread";
  69. else $pacontent="message";

  70. if($pamethod==1) $altmethod="的".$pacontent."进行 '".$patarget."' 替换 '".$pasource."' 的替换前查看,处理结果也是替换预览,此操作不会对论坛有任何影响.";
  71. else  $altmethod="的".$pacontent."进行 '".$patarget."' 替换 '".$pasource."' 的替换处理,此操作是根据你的请求而修改.";

  72. if($pacontent=="thread"){
  73. if($pafid){
  74. $query=" select fid,tid,subject from cdb_threads  where fid IN ($pafid) and subject like '%$pasource%' order by tid asc";
  75. $alttext="你现在是对版块为".$pafid.$altmethod;
  76. }
  77. else{
  78. $query="select fid,tid,subject  from cdb_threads  where  subject like '%$pasource%' order by tid asc";
  79. $alttext="你现在是对整个论坛".$altmethod;
  80. }
  81. }

  82. else{
  83. if($pafid && $papid){
  84. $query="select fid,tid,pid,message,subject from cdb_posts  where fid IN ($pafid) and pid IN ($papid) and $pacontent like '%$pasource%' order by pid asc";
  85. $alttext="你现在是对版块为".$pafid.",pid为".$papid.$altmethod;
  86. }
  87. elseif(!$pafid && !$papid){
  88. $query="select fid,tid,pid,message,subject  from cdb_posts  where  $pacontent like '%$pasource%' order by pid asc";
  89.   $alttext="你现在是对整个论坛".$altmethod;
  90. }
  91. else{
  92. if($pafid) {
  93. $query="select fid,tid,pid,message,subject  from cdb_posts  where fid IN ($pafid) and $pacontent like '%$pasource%' order by pid asc";
  94.    $alttext="你现在是对fid为".$pafid.$altmethod;
  95. }
  96. else {
  97. $query="select fid,tid,pid,message,subject  from cdb_posts  where  pid IN ($papid) and $pacontent like '%$pasource%' order by pid asc";
  98. $alttext="你现在是对pid为".$pafid.$altmethod;
  99.   }
  100. }
  101. }

  102. $result = $db->query($query);
  103. echo " 总共有<font color=red >".$db->num_rows($result)."</font>条记录<br><br> <font color=red >由于你的记录可能很多,请耐心等待,处理完成前请不要关闭此窗口</font><br><br>";
  104. echo " <font color=blue ><b>". $alttext."</b> </font> <br>";
  105. echo " <font color=green >读取的结果是: </font> <br>";

  106. if($pacontent=="thread"){
  107. while($thread = $db->fetch_array($result)){
  108. echo "fid=".$thread[fid]."    tid=".$thread[tid]."<br>";
  109. $thread[subject]=str_replace($pasource,$patarget,$thread[subject]);
  110. $thread[subject]=addslashes($thread[subject]);
  111. echo "处理后: tid=".$thread[tid].", 主题:".$thread[subject] ."<br>";
  112. if($pamethod==2)  $db->query("update cdb_threads set subject='$thread[subject]' where tid='$thread[tid]'");
  113. }
  114. }
  115. else{
  116. while($thread = $db->fetch_array($result)){
  117. echo "fid=".$thread[fid]."    tid=".$thread[tid].":      pid=".$thread[pid] ."<br>";
  118. $thread[$pacontent]=str_replace($pasource,$patarget,$thread[$pacontent]);
  119. $thread[$pacontent]=addslashes($thread[$pacontent]);
  120. if($pacontent=="subject")  echo "处理后: tid=".$thread[tid].", 标题:".$thread[subject] ."<br>";
  121. if($pamethod==2) $db->query("update cdb_posts set $pacontent='$thread[$pacontent]' where pid='$thread[pid]'");
  122. }
  123. }

  124. if($pamethod==2) echo "<br><br><font color=red >严重恭喜你,所有的替换已经完成,你可以刷新此页,看看还有没有记录.</font><br><br><br></center>";
  125. else echo "<br><br><font color=red >以上就是你的查看结果.要替换的话,请后退后选择处理模式,再执行.</font><br><br><br></center>";

  126. }
  127. ?>

  128. </body>
  129. </html>
复制代码
 楼主| lu5266 发表于 2005-12-3 19:23:58 | 显示全部楼层



回复

使用道具 举报

 楼主| lu5266 发表于 2005-12-3 19:25:02 | 显示全部楼层
此贴为方便整理贴

F兄

自习去了

88
回复

使用道具 举报

yulebbs 发表于 2005-12-3 19:48:51 | 显示全部楼层
沙发支持
回复

使用道具 举报

M55 发表于 2005-12-3 20:03:37 | 显示全部楼层
靠!这个不顶是人吗~~~~~
回复

使用道具 举报

爱好者 发表于 2005-12-3 20:33:29 | 显示全部楼层
我又来了!
回复

使用道具 举报

freddy 发表于 2005-12-3 20:41:03 | 显示全部楼层
支持!
回复

使用道具 举报

yjflq2002 发表于 2005-12-3 21:06:52 | 显示全部楼层
顶了。
回复

使用道具 举报

 楼主| lu5266 发表于 2005-12-3 23:12:43 | 显示全部楼层
强烈感谢大家支持啊
回复

使用道具 举报

Shadowsong 发表于 2005-12-4 00:17:58 | 显示全部楼层
强烈感谢楼主发贴啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-5-2 20:36 , Processed in 0.205303 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表