• 1679阅读
  • 0回复

[程序设置问题]修复pw tmsgs表和pw posts表ipfrom的工具 [复制链接]

上一主题 下一主题
离线太史慈
 

发帖
777
金币
626
威望
556
只看楼主 正序阅读 使用道具 楼主  发表于: 2013-08-28
保存成repair_ipfrom放到pw论坛的根目录下浏览器执行即可。

  1. <?php
  2. error_reporting(0);
  3. define('P_W',1);
  4. define('PW_UPLOAD',1);
  5. define('R_P',getdirname(__FILE__));
  6. define('D_P',R_P);
  7. require_once(R_P.'require/common.php');
  8. include_once(D_P.'data/bbscache/config.php');
  9. //require_once(R_P.'admin/cache.php');
  10. $basename = 'http://'.$_SERVER['HTTP_HOST'].(isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);
  11. @header("Content-Type:text/html; charset=$db_charset");
  12. include_once(D_P.'data/sql_config.php');
  13. if ($database=='mysqli' && Pwloaddl('mysqli')===false) {
  14.     $database = 'mysql';
  15. }
  16. require_once Pcv(R_P."require/db_$database.php");
  17. $db = new DB($dbhost,$dbuser,$dbpw,$dbname,$PW,$charset,$pconnect);
  18. $action = $_GET['action'];
  19. $start = $_GET['start'];
  20. $s_c = $_GET['s_c'];
  21. if(!$action){
  22.     $action = 'tmsgs';
  23. }
  24. if(!$start){
  25.     $start = 0;
  26. }
  27. if(!$s_c){
  28.     $s_c = 0;
  29. }
  30. $percount = 200;
  31. require_once R_P.'require/postfunc.php';
  32. if ($action == 'tmsgs'){
  33.     $query = $db->query("SELECT tid,userip FROM pw_tmsgs WHERE tid>$start LIMIT $percount");
  34.     while ($rt = $db->fetch_array($query))
  35.     {
  36. $lastid = $rt['tid'];
  37.     //echo $rt['useip'];
  38.         $ipfrom = cvipfrom($rt['userip']);
  39.         //echo $ipfrom;exit;
  40.         $db->update("UPDATE pw_tmsgs SET ipfrom='$ipfrom' WHERE tid=".$rt['tid']);
  41.         $s_c++;
  42.     }
  43.     $maxid = $db->get_value("SELECT max(tid) FROM pw_tmsgs");
  44.     echo '当前'.$lastid.'表最大tid '.$maxid;
  45.     if($maxid > $lastid){
  46. echo "<meta http-equiv='refresh' content='0;url=$basename?action=$action&start=$lastid&s_c=$s_c'>";
  47.     }
  48.     else{
  49. echo "<meta http-equiv='refresh' content='0;url=$basename?action=posts'>";
  50.     }
  51. }elseif ($action == 'posts'){
  52.     $query = $db->query("SELECT pid,userip FROM pw_posts WHERE pid>$start LIMIT $percount");
  53.     while ($rt = $db->fetch_array($query))
  54.     {
  55. $lastid = $rt['pid'];
  56.         $ipfrom = cvipfrom($rt['userip']);
  57.         $db->update("UPDATE pw_posts SET ipfrom='$ipfrom' WHERE pid=".$rt['pid']);
  58.         $s_c++;
  59.     }
  60.     $maxid = $db->get_value("SELECT max(pid) FROM pw_posts");
  61.     echo '当前'.$lastid.'表最大tid '.$maxid;
  62.     if($maxid > $lastid){
  63. echo "<meta http-equiv='refresh' content='0;url=$basename?action=$action&start=$lastid&s_c=$s_c'>";
  64.     }
  65.     else{
  66.         echo '<br />根据评分信息来更新回复的ifmark字段[结束]';
  67.     }
  68. }
  69. exit;
  70. function getdirname($path=null){
  71. if (!empty($path)) {
  72. if (strpos($path,'\\')!==false) {
  73. return substr($path,0,strrpos($path,'\\')).'/';
  74. } elseif (strpos($path,'/')!==false) {
  75. return substr($path,0,strrpos($path,'/')).'/';
  76. }
  77. }
  78. return './';
  79. }
  80. ?>

[url=http://www.phpwind.com]phpwind[/url]
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
提到某人:
选择好友
上一个 下一个