|
- <?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');
- @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);
- $t_k = $_GET['t_k'];
- $action = $_GET['action'];
- $start = $_GET['start'];
- if(!$action){
- $action = 1;
- }
- if(!$start){
- $start = 0;
- }
- if(!$t_k){
- $t_k = 0;
- }
- $percount = 2000;
- require_once R_P.'require/pingfunc.php';
- if ($action == '1')
- {
- if(!$start){
- //$db->query("UPDATE pw_threads SET ifmark=''");
- //$db->query("UPDATE pw_tmsgs SET ifmark=''");
- //$db->query("UPDATE pw_posts SET ifmark=''");
- }
- $query = $db->query("SELECT * FROM pw_pinglog WHERE id>$start LIMIT $percount");
- unset($lastid);
- while ($rt = $db->fetch_array($query)){
- $lastid = $rt['id'];
- $ids = '';
- $ifmark_threads = $db->get_value("SELECT ifmark FROM pw_threads WHERE tid=".$rt['tid']);
- $ifmark_threads = $ifmark_threads+$rt['point'];
- $db->update("UPDATE pw_threads SET ifmark = '$ifmark_threads' WHERE tid=".$rt['tid']);
- if($rt['pid']==0){
- $ifmark_tmsgs = $db->get_value("SELECT ifmark FROM pw_tmsgs WHERE tid=".$rt['tid']);
- if(strpos($ifmark_tmsgs,":")){
- list($num,$ids) = explode(":",$ifmark_tmsgs);
- }
- if(!$ids){
- $num = 1;
- $ids = $rt['id'];
- $ifmark_tmsgs = $num.":".$ids;
- }else{
- $idsarr = explode(",",$ids);
- if(!in_array($rt['id'],$idsarr)){
- $num++;
- $ids .= ','.$rt['id'];
- $ifmark_tmsgs = $num.":".$ids;
- }
- }
- $db->update("UPDATE pw_tmsgs SET ifmark = '$ifmark_tmsgs' WHERE tid=".$rt['tid']);
- }else{
- $ifmark_posts = $db->get_value("SELECT ifmark FROM pw_posts WHERE pid=".$rt['pid']);
- if(strpos($ifmark_posts,":")){
- list($num,$ids) = explode(":",$ifmark_posts);
- }
- if(!$ids){
- $num = 1;
- $ids = $rt['id'];
- $ifmark_posts = $num.":".$ids;
- }else{
- $idsarr = explode(",",$ids);
- if(!in_array($rt['id'],$idsarr)){
- $num++;
- $ids .= ','.$rt['id'];
- $ifmark_posts = $num.":".$ids;
- }
- }
- $db->update("UPDATE pw_posts SET ifmark = '$ifmark_posts' WHERE pid=".$rt['pid']);
- }
- }
- $db->free_result($query);
- $maxid = $db->get_value("SELECT max(id) FROM pw_pinglog");
- empty($lastid) && $lastid = $end;
- echo '最大id',$maxid,'<br>','最后id',$lastid;
- if($lastid < $maxid){
- echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=1&start=$lastid'>";
- }else{
- echo 111;exit;
- }
- }
- elseif ($action == '2')
- {
- //根据评分信息来更新tmsgs的ifmark字段
- $ifmark='';
- echo '根据评分信息来更新tmsgs的ifmark字段';
- echo '<br>';
- echo "SELECT fid,tid FROM pw_threads WHERE tid>$start ORDER BY tid LIMIT $percount";
- echo '<br>';
- $query = $db->query("SELECT fid,tid FROM pw_threads WHERE tid>$start ORDER BY tid LIMIT $percount");
- while ($t = $db->fetch_array($query))
- {
- $lastid = $t['tid'];
- $count = $db->get_value("SELECT SUM(point) FROM pw_pinglog WHERE tid=".$t['tid']);
- if($count){
- $db->update("UPDATE pw_threads SET ifmark=$count WHERE tid=".$t['tid']);
- update_markinfo($t['fid'],$t['tid'],0);
- }else{
- $db->update("UPDATE pw_threads SET ifmark=0 WHERE tid=".$t['tid']);
- $db->update("UPDATE pw_tmsgs SET ifmark='' WHERE tid=".$t['tid']);
- }
- $s_c++;
- }
- $maxid = $db->get_value("SELECT max(tid) FROM pw_threads");
- echo '当前pw_threads表最大tid '.$maxid;
- if($maxid > $lastid)
- {
- echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=1&start=$lastid'>";
- }
- else{
- echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=2'>";
- //echo '根据评分信息来更新tmsgs的ifmark字段[结束]';exit;
- }
- }
- elseif ($action == '3')
- {
- $ptable = $_GET['ptable'];
- if(!$ptable){
- $ptable = 0;
- }
- //根据评分信息来更新posts的ifmark字段
- if(!$ptable){
- $pw_posts = 'pw_posts';
- }else{
- $pw_posts = 'pw_posts'.$ptable;
- }
- echo '根据评分信息来更新posts的ifmark字段';
- echo '<br>';
- echo "SELECT fid,tid,pid FROM $pw_posts WHERE pid>$start ORDER BY pid LIMIT $percount";
- echo '<br>';
- $query = $db->query("SELECT fid,tid,pid FROM $pw_posts WHERE pid>$start ORDER BY pid LIMIT $percount");
- while ($p = $db->fetch_array($query))
- {
- $lastid = $p['pid'];
- update_markinfo($p['fid'],$p['tid'],$p['pid']);
- $s_c++;
- }
- $maxid = $db->get_value("SELECT max(pid) FROM $pw_posts");
- echo '当前'.$pw_posts.'表最大pid '.$maxid;
- if($maxid > $lastid)
- {
- echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=2&start=$lastid&ptable=$ptable&s_c=$s_c'>";
- }
- else{
- $ptable++;
- $ptable_check = $db->get_one("SHOW TABLE STATUS LIKE 'pw_posts{$ptable}'");
- if($ptable_check){
- echo "<meta http-equiv='refresh' content='0;url=update_mark.php?action=2&start=0&ptable=$ptable&s_c=$s_c'>";
- }else{
- echo '根据评分信息来更新回复的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 './';
- }
- ?>
|