论坛风格切换
  • 3143阅读
  • 0回复

[常用修复工具]修复群组主题数的工具 [复制链接]

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

发帖
766
金币
626
威望
556
只看楼主 倒序阅读 使用道具 楼主  发表于: 2011-06-20
按惯例,保存成repair_colony.php,其实这个还是有些缺陷的,不过总比官方后台那个功能好用多了。

  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 = 1000;
  31. if ($action == 'tmsgs'){
  32.     $query = $db->query("SELECT id FROM pw_colonys WHERE id>$start LIMIT $percount");
  33.     while ($rt = $db->fetch_array($query))
  34.     {
  35.     $lastid = $rt['id'];
  36.         $count = $db->get_value("SELECT count(*) FROM pw_argument WHERE cyid=".$rt['id']);
  37.         $db->update("UPDATE pw_colonys SET tnum='$count' WHERE id=".$rt['id']);
  38.         $s_c++;
  39.     }
  40.     $maxid = $db->get_value("SELECT max(id) FROM pw_colonys");
  41.     echo '当前'.$lastid.'表最大tid '.$maxid;
  42.     if($maxid > $lastid){
  43.     echo "<meta http-equiv='refresh' content='0;url=$basename?action=$action&start=$lastid&s_c=$s_c'>";
  44.     }else{
  45.         exit;
  46.     }
  47. }
  48. exit;
  49. function getdirname($path=null){
  50. if (!empty($path)) {
  51. if (strpos($path,'\\')!==false) {
  52. return substr($path,0,strrpos($path,'\\')).'/';
  53. } elseif (strpos($path,'/')!==false) {
  54. return substr($path,0,strrpos($path,'/')).'/';
  55. }
  56. }
  57. return './';
  58. }
  59. ?>

[url=http://www.phpwind.com]phpwind[/url]
快速回复
限100 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
提到某人:
选择好友
上一个 下一个