|
勋章修复工具,保存成repair_medal.php放到根目录下执行。 - <?php
- /**
- *
- * phpwind75 补丁修复程序 2009/12/08
- *
- */
- 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');
- //require_once(R_P.'lang/up_function.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'];
- if (empty($action)) {
- echo '<a href="repair_medals.php?action=articletopped2">开始运行medal工具 PHPWind v7.5SP3 (20091216)</a>';exit;
- } elseif ($action == 'articletopped2') {
- $per = 300;
- $step = $_GET['step'];
- !$step && $step = 1;
- $start = ($step - 1) * $per;
- $end = $start + $per - 1;
- $limit = "LIMIT $start,$end";
- $flag = false;
- $query = $db->query("SELECT * FROM pw_medaluser");
- while ($rt = $db->fetch_array($query)) {
- $now = $db->get_value("SELECT medals FROM pw_members WHERE uid='".$rt['uid']."'");
- if($now){
- $medal_arr = explode(",",$now);
- if(!in_array($rt['mid'],$medal_arr)){
- $newmedal = $now.','.$rt['mid'];
- $db->update("UPDATE pw_members SET medals ='".$newmedal."' WHERE uid='".$rt['uid']."'");
- }
- }else{
- $db->update("UPDATE pw_members SET medals ='".$rt['mid']."' WHERE uid='".$rt['uid']."'");
- }
- }
- echo '结束';
- exit;
- if ($flag == true) {
- $step += 1;
- echo "<meta http-equiv='refresh' content='0;url=$basename?action=articletopped2&step=$step'>";
- }else{
- updatetop();
- echo '修复置顶结束,看看置顶有没出来';exit;
- }
- }
- echo '升级中,请稍候...';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 './';
- }
- function createtable($array){
- global $db,$charset;
- foreach ($array as $key => $value) {
- !$value[1] && $value[1] = 'MyISAM';
- $value[0] = "CREATE TABLE IF NOT EXISTS $key ($value[0]) ";
- if ($db->server_info() > '4.1') {
- $value[0] .= "ENGINE=$value[1]".($charset ? " DEFAULT CHARSET=$charset" : '');
- } else {
- $value[0] .= "TYPE=$value[1]";
- }
- $db->query($value[0]);
- }
- }
- ?>
|