按惯例,保存成repair_colony.php,其实这个还是有些缺陷的,不过总比官方后台那个功能好用多了。
- <?php
- error_reporting(0);
- define('P_W',1);
- define('PW_UPLOAD',1);
- define('R_P',getdirname(__FILE__));
- define('D_P',R_P);
- require_once(R_P.'require/common.php');
- include_once(D_P.'data/bbscache/config.php');
- //require_once(R_P.'admin/cache.php');
- $basename = 'http://'.$_SERVER['HTTP_HOST'].(isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);
- @header("Content-Type:text/html; charset=$db_charset");
- include_once(D_P.'data/sql_config.php');
- if ($database=='mysqli' && Pwloaddl('mysqli')===false) {
- $database = 'mysql';
- }
- require_once Pcv(R_P."require/db_$database.php");
- $db = new DB($dbhost,$dbuser,$dbpw,$dbname,$PW,$charset,$pconnect);
- $action = $_GET['action'];
- $start = $_GET['start'];
- $s_c = $_GET['s_c'];
- if(!$action){
- $action = 'tmsgs';
- }
- if(!$start){
- $start = 0;
- }
- if(!$s_c){
- $s_c = 0;
- }
- $percount = 1000;
- if ($action == 'tmsgs'){
- $query = $db->query("SELECT id FROM pw_colonys WHERE id>$start LIMIT $percount");
- while ($rt = $db->fetch_array($query))
- {
- $lastid = $rt['id'];
- $count = $db->get_value("SELECT count(*) FROM pw_argument WHERE cyid=".$rt['id']);
- $db->update("UPDATE pw_colonys SET tnum='$count' WHERE id=".$rt['id']);
- $s_c++;
- }
- $maxid = $db->get_value("SELECT max(id) FROM pw_colonys");
- echo '当前'.$lastid.'表最大tid '.$maxid;
- if($maxid > $lastid){
- echo "<meta http-equiv='refresh' content='0;url=$basename?action=$action&start=$lastid&s_c=$s_c'>";
- }else{
- exit;
- }
- }
- exit;
- function getdirname($path=null){
- if (!empty($path)) {
- if (strpos($path,'\\')!==false) {
- return substr($path,0,strrpos($path,'\\')).'/';
- } elseif (strpos($path,'/')!==false) {
- return substr($path,0,strrpos($path,'/')).'/';
- }
- }
- return './';
- }
- ?>