Issues (1963)

html/ops/bbcode_convert.php (1 issue)

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;
20
require_once("../inc/db.inc");
21
require_once("../inc/util_ops.inc");
22
require_once('../inc/sanitize_html.inc');
23
require_once('../inc/bbcode_convert.inc');
24
25
db_init();
26
27
set_time_limit(0);
28
29
function 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();
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
39
        }
40
    }
41
}
42
43
function 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
62
function fix_fix() {
63
    $posts = _mysql_query("select * from post where id=99");
64
    $post = _mysql_fetch_object($posts);
65
    fix_post($post);
66
}
67
68
fix_posts();
69
//fix_fix();
70
71
?>
72