论坛风格切换
  • 4095阅读
  • 1回复

[常用修复工具]更新评分的工具 [复制链接]

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

发帖
766
金币
626
威望
556
只看楼主 倒序阅读 使用道具 楼主  发表于: 2011-11-21
— 本帖被 云天河 从 项目开发 移动到本区(2011-11-21) —
从pw_pinglog表统计更新pw_threads的ifmark
保存成update_mark.php
楼主的版本是老版,1楼的版本是后来的更新版,效率高一点。

  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. @header("Content-Type:text/html; charset=$db_charset");
  11. include_once(D_P.'data/sql_config.php');
  12. //if ($database=='mysqli' && Pwloaddl('mysqli')===false) {
  13.     $database = 'mysql';
  14. //}
  15. require_once Pcv(R_P."require/db_$database.php");
  16. $db = new DB($dbhost,$dbuser,$dbpw,$dbname,$PW,$charset,$pconnect);
  17. $t_k = $_GET['t_k'];
  18. $action = $_GET['action'];
  19. $start = $_GET['start'];
  20. if(!$action){
  21.     $action = 1;
  22. }
  23. if(!$start){
  24.     $start = 0;
  25. }
  26. if(!$t_k){
  27.     $t_k = 0;
  28. }
  29. $percount = 1000;
  30. require_once R_P.'require/pingfunc.php';
  31. if ($action == '1')
  32. {
  33.     //根据评分信息来更新tmsgs的ifmark字段
  34.     $ifmark='';
  35.     echo '根据评分信息来更新tmsgs的ifmark字段';
  36.     echo '<br>';
  37.     echo "SELECT fid,tid FROM pw_threads WHERE tid>$start ORDER BY tid LIMIT $percount";
  38.     echo '<br>';
  39.     $query = $db->query("SELECT fid,tid FROM pw_threads WHERE tid>$start ORDER BY tid LIMIT $percount");
  40.     while ($t = $db->fetch_array($query))
  41.     {
  42.         $lastid = $t['tid'];
  43.         $count = $db->get_value("SELECT SUM(point) FROM pw_pinglog WHERE tid=".$t['tid']);
  44.         if($count){
  45.             $db->update("UPDATE pw_threads SET ifmark=$count WHERE tid=".$t['tid']);
  46.             update_markinfo($t['fid'],$t['tid'],0);
  47.         }else{
  48.             $db->update("UPDATE pw_threads SET ifmark=0 WHERE tid=".$t['tid']);
  49.             $db->update("UPDATE pw_tmsgs SET ifmark='' WHERE tid=".$t['tid']);
  50.         }
  51.         $s_c++;
  52.     }
  53.     $maxid = $db->get_value("SELECT max(tid) FROM pw_threads");
  54.     echo '当前pw_threads表最大tid '.$maxid;
  55.     if($maxid > $lastid)
  56.     {
  57.         echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=1&start=$lastid'>";
  58.     }
  59.     else{
  60.         echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=2'>";
  61.         //echo '根据评分信息来更新tmsgs的ifmark字段[结束]';exit;
  62.     }
  63. }
  64. elseif ($action == '2')
  65. {
  66.     $ptable = $_GET['ptable'];
  67.     if(!$ptable){
  68.         $ptable = 0;
  69.     }
  70.     //根据评分信息来更新posts的ifmark字段
  71.     if(!$ptable){
  72.         $pw_posts = 'pw_posts';
  73.     }else{
  74.         $pw_posts = 'pw_posts'.$ptable;
  75.     }
  76.     echo '根据评分信息来更新posts的ifmark字段';
  77.     echo '<br>';
  78.     echo "SELECT fid,tid,pid FROM $pw_posts WHERE pid>$start ORDER BY pid LIMIT $percount";
  79.     echo '<br>';
  80.     $query = $db->query("SELECT fid,tid,pid FROM $pw_posts WHERE pid>$start ORDER BY pid LIMIT $percount");
  81.     while ($p = $db->fetch_array($query))
  82.     {
  83.         $lastid = $p['pid'];
  84.         update_markinfo($p['fid'],$p['tid'],$p['pid']);
  85.         $s_c++;
  86.     }
  87.     $maxid = $db->get_value("SELECT max(pid) FROM $pw_posts");
  88.     echo '当前'.$pw_posts.'表最大pid '.$maxid;
  89.     if($maxid > $lastid)
  90.     {
  91.         echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=2&start=$lastid&ptable=$ptable&s_c=$s_c'>";
  92.     }
  93.     else{
  94.         $ptable++;
  95.         $ptable_check = $db->get_one("SHOW TABLE STATUS LIKE 'pw_posts{$ptable}'");
  96.         if($ptable_check){
  97.             echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=2&start=0&ptable=$ptable&s_c=$s_c'>";
  98.         }else{
  99.             echo '根据评分信息来更新回复的ifmark字段[结束]';exit;
  100.         }
  101.     }
  102. }
  103. function getdirname($path=null){
  104.     if (!empty($path)) {
  105.         if (strpos($path,'\\')!==false) {
  106.             return substr($path,0,strrpos($path,'\\')).'/';
  107.         } elseif (strpos($path,'/')!==false) {
  108.             return substr($path,0,strrpos($path,'/')).'/';
  109.         }
  110.     }
  111.     return './';
  112. }
  113. ?>

[url=http://www.phpwind.com]phpwind[/url]
离线太史慈

发帖
766
金币
626
威望
556
只看该作者 沙发  发表于: 2011-11-21
  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. @header("Content-Type:text/html; charset=$db_charset");
  11. include_once(D_P.'data/sql_config.php');
  12. //if ($database=='mysqli' && Pwloaddl('mysqli')===false) {
  13.     $database = 'mysql';
  14. //}
  15. require_once Pcv(R_P."require/db_$database.php");
  16. $db = new DB($dbhost,$dbuser,$dbpw,$dbname,$PW,$charset,$pconnect);
  17. $t_k = $_GET['t_k'];
  18. $action = $_GET['action'];
  19. $start = $_GET['start'];
  20. if(!$action){
  21.     $action = 1;
  22. }
  23. if(!$start){
  24.     $start = 0;
  25. }
  26. if(!$t_k){
  27.     $t_k = 0;
  28. }
  29. $percount = 2000;
  30. require_once R_P.'require/pingfunc.php';
  31. if ($action == '1')
  32. {
  33.     if(!$start){
  34.         //$db->query("UPDATE pw_threads SET ifmark=''");
  35.         //$db->query("UPDATE pw_tmsgs SET ifmark=''");
  36.         //$db->query("UPDATE pw_posts SET ifmark=''");
  37.     }
  38.     $query = $db->query("SELECT * FROM pw_pinglog WHERE id>$start LIMIT $percount");
  39.     unset($lastid);
  40.     while ($rt = $db->fetch_array($query)){
  41.         $lastid = $rt['id'];
  42.         $ids = '';
  43.         $ifmark_threads = $db->get_value("SELECT ifmark FROM pw_threads WHERE tid=".$rt['tid']);
  44.         $ifmark_threads = $ifmark_threads+$rt['point'];
  45.         $db->update("UPDATE pw_threads SET ifmark = '$ifmark_threads' WHERE tid=".$rt['tid']);
  46.         if($rt['pid']==0){
  47.             $ifmark_tmsgs = $db->get_value("SELECT ifmark FROM pw_tmsgs WHERE tid=".$rt['tid']);
  48.             if(strpos($ifmark_tmsgs,":")){
  49.                 list($num,$ids) = explode(":",$ifmark_tmsgs);
  50.             }
  51.             if(!$ids){
  52.                 $num = 1;
  53.                 $ids = $rt['id'];
  54.                 $ifmark_tmsgs = $num.":".$ids;
  55.             }else{
  56.                 $idsarr = explode(",",$ids);
  57.                 if(!in_array($rt['id'],$idsarr)){
  58.                     $num++;
  59.                     $ids .= ','.$rt['id'];
  60.                     $ifmark_tmsgs = $num.":".$ids;
  61.                 }
  62.             }
  63.             $db->update("UPDATE pw_tmsgs SET ifmark = '$ifmark_tmsgs' WHERE tid=".$rt['tid']);
  64.         }else{
  65.             $ifmark_posts = $db->get_value("SELECT ifmark FROM pw_posts WHERE pid=".$rt['pid']);
  66.             if(strpos($ifmark_posts,":")){
  67.                 list($num,$ids) = explode(":",$ifmark_posts);
  68.             }
  69.             if(!$ids){
  70.                 $num = 1;
  71.                 $ids = $rt['id'];
  72.                 $ifmark_posts = $num.":".$ids;
  73.             }else{
  74.                 $idsarr = explode(",",$ids);
  75.                 if(!in_array($rt['id'],$idsarr)){
  76.                     $num++;
  77.                     $ids .= ','.$rt['id'];
  78.                     $ifmark_posts = $num.":".$ids;
  79.                 }
  80.             }
  81.             $db->update("UPDATE pw_posts SET ifmark = '$ifmark_posts' WHERE pid=".$rt['pid']);
  82.         }
  83.     }
  84.     $db->free_result($query);
  85.     $maxid = $db->get_value("SELECT max(id) FROM pw_pinglog");
  86.     empty($lastid) && $lastid = $end;
  87.     echo '最大id',$maxid,'<br>','最后id',$lastid;
  88.     if($lastid < $maxid){
  89.         echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=1&start=$lastid'>";
  90.     }else{
  91.         echo 111;exit;
  92.     }
  93. }
  94. elseif ($action == '2')
  95. {
  96.     //根据评分信息来更新tmsgs的ifmark字段
  97.     $ifmark='';
  98.     echo '根据评分信息来更新tmsgs的ifmark字段';
  99.     echo '<br>';
  100.     echo "SELECT fid,tid FROM pw_threads WHERE tid>$start ORDER BY tid LIMIT $percount";
  101.     echo '<br>';
  102.     $query = $db->query("SELECT fid,tid FROM pw_threads WHERE tid>$start ORDER BY tid LIMIT $percount");
  103.     while ($t = $db->fetch_array($query))
  104.     {
  105.         $lastid = $t['tid'];
  106.         $count = $db->get_value("SELECT SUM(point) FROM pw_pinglog WHERE tid=".$t['tid']);
  107.         if($count){
  108.             $db->update("UPDATE pw_threads SET ifmark=$count WHERE tid=".$t['tid']);
  109.             update_markinfo($t['fid'],$t['tid'],0);
  110.         }else{
  111.             $db->update("UPDATE pw_threads SET ifmark=0 WHERE tid=".$t['tid']);
  112.             $db->update("UPDATE pw_tmsgs SET ifmark='' WHERE tid=".$t['tid']);
  113.         }
  114.         $s_c++;
  115.     }
  116.     $maxid = $db->get_value("SELECT max(tid) FROM pw_threads");
  117.     echo '当前pw_threads表最大tid '.$maxid;
  118.     if($maxid > $lastid)
  119.     {
  120.         echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=1&start=$lastid'>";
  121.     }
  122.     else{
  123.         echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=2'>";
  124.         //echo '根据评分信息来更新tmsgs的ifmark字段[结束]';exit;
  125.     }
  126. }
  127. elseif ($action == '3')
  128. {
  129.     $ptable = $_GET['ptable'];
  130.     if(!$ptable){
  131.         $ptable = 0;
  132.     }
  133.     //根据评分信息来更新posts的ifmark字段
  134.     if(!$ptable){
  135.         $pw_posts = 'pw_posts';
  136.     }else{
  137.         $pw_posts = 'pw_posts'.$ptable;
  138.     }
  139.     echo '根据评分信息来更新posts的ifmark字段';
  140.     echo '<br>';
  141.     echo "SELECT fid,tid,pid FROM $pw_posts WHERE pid>$start ORDER BY pid LIMIT $percount";
  142.     echo '<br>';
  143.     $query = $db->query("SELECT fid,tid,pid FROM $pw_posts WHERE pid>$start ORDER BY pid LIMIT $percount");
  144.     while ($p = $db->fetch_array($query))
  145.     {
  146.         $lastid = $p['pid'];
  147.         update_markinfo($p['fid'],$p['tid'],$p['pid']);
  148.         $s_c++;
  149.     }
  150.     $maxid = $db->get_value("SELECT max(pid) FROM $pw_posts");
  151.     echo '当前'.$pw_posts.'表最大pid '.$maxid;
  152.     if($maxid > $lastid)
  153.     {
  154.         echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=2&start=$lastid&ptable=$ptable&s_c=$s_c'>";
  155.     }
  156.     else{
  157.         $ptable++;
  158.         $ptable_check = $db->get_one("SHOW TABLE STATUS LIKE 'pw_posts{$ptable}'");
  159.         if($ptable_check){
  160.             echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=2&start=0&ptable=$ptable&s_c=$s_c'>";
  161.         }else{
  162.             echo '根据评分信息来更新回复的ifmark字段[结束]';exit;
  163.         }
  164.     }
  165. }
  166. function getdirname($path=null){
  167.     if (!empty($path)) {
  168.         if (strpos($path,'\\')!==false) {
  169.             return substr($path,0,strrpos($path,'\\')).'/';
  170.         } elseif (strpos($path,'/')!==false) {
  171.             return substr($path,0,strrpos($path,'/')).'/';
  172.         }
  173.     }
  174.     return './';
  175. }
  176. ?>

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