1<?php 2// This file is part of BOINC. 3// http://boinc.berkeley.edu 4// Copyright (C) 2008 University of California 5// 6// BOINC is free software; you can redistribute it and/or modify it 7// under the terms of the GNU Lesser General Public License 8// as published by the Free Software Foundation, 9// either version 3 of the License, or (at your option) any later version. 10// 11// BOINC is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14// See the GNU Lesser General Public License for more details. 15// 16// You should have received a copy of the GNU Lesser General Public License 17// along with BOINC. If not, see <http://www.gnu.org/licenses/>. 18 19$cli_only = true; 20require_once("../inc/db.inc"); 21require_once("../inc/util_ops.inc"); 22require_once('../inc/sanitize_html.inc'); 23require_once('../inc/bbcode_convert.inc'); 24 25db_init(); 26 27set_time_limit(0); 28 29function fix_post($post) { 30 $text = html_to_bbcode($post->content); 31 if ($text != $post->content) { 32 $query = "update post set content = '"._mysql_escape_string($text)."' where id=".$post->id; 33 //echo "$post->content\n\n"; 34 //echo "$post->thread $query\n\n"; 35 $retval = _mysql_query($query); 36 if (!$retval) { 37 echo _mysql_error(); 38 exit(); 39 } 40 } 41} 42 43function fix_posts() { 44 $start_id = 0; //Set this to something else if you like 45 $posts = _mysql_query("select * from post where id>$start_id order by id"); 46 echo _mysql_error(); 47 $i=0; 48 while ($post = _mysql_fetch_object($posts)){ 49 $i++; 50 if ($i%100 == 0) { //For every 100 posts 51 echo $post->id.". "; flush(); // print out where we are 52 //usleep(200000); 53 } 54 55 if ($post->id > $start_id){ 56 fix_post($post); 57 } 58 } 59} 60 61// use this to patch problem cases; hand-edit 62function fix_fix() { 63 $posts = _mysql_query("select * from post where id=99"); 64 $post = _mysql_fetch_object($posts); 65 fix_post($post); 66} 67 68fix_posts(); 69//fix_fix(); 70 71?> 72