保存成repair_ipfrom放到pw论坛的根目录下浏览器执行即可。
- <?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 = 200;
- require_once R_P.'require/postfunc.php';
- if ($action == 'tmsgs'){
- $query = $db->query("SELECT tid,userip FROM pw_tmsgs WHERE tid>$start LIMIT $percount");
- while ($rt = $db->fetch_array($query))
- {
- $lastid = $rt['tid'];
- //echo $rt['useip'];
- $ipfrom = cvipfrom($rt['userip']);
- //echo $ipfrom;exit;
- $db->update("UPDATE pw_tmsgs SET ipfrom='$ipfrom' WHERE tid=".$rt['tid']);
- $s_c++;
- }
- $maxid = $db->get_value("SELECT max(tid) FROM pw_tmsgs");
- 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{
- echo "<meta http-equiv='refresh' content='0;url=$basename?action=posts'>";
- }
- }elseif ($action == 'posts'){
- $query = $db->query("SELECT pid,userip FROM pw_posts WHERE pid>$start LIMIT $percount");
- while ($rt = $db->fetch_array($query))
- {
- $lastid = $rt['pid'];
- $ipfrom = cvipfrom($rt['userip']);
- $db->update("UPDATE pw_posts SET ipfrom='$ipfrom' WHERE pid=".$rt['pid']);
- $s_c++;
- }
- $maxid = $db->get_value("SELECT max(pid) FROM pw_posts");
- 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{
- echo '<br />根据评分信息来更新回复的ifmark字段[结束]';
- }
- }
- 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 './';
- }
- ?>