Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
831 florian 1
<?php
2
/*
3
 
4
This is just a simple script for updating the post-count of each user, which
5
is shown in the user's profile. It can be run multiple times, but should at
6
least be run once after a conversion from Phorum 3 to Phorum 5.
7
 
8
How to use?
9
 
10
Just copy this script to your main Phorum 5 directory and run it either
11
from your webbrowser or from the console. It will show only some summary
12
in the end, nothing more.
13
 
14
Depending on the number of messages and users, it may take some time.
15
 
16
*/
17
 
18
 
19
// we try to disable the execution timeout
20
// that command doesn't work in safe_mode :(
21
set_time_limit(0);
22
 
23
require './common.php';
24
 
25
// no need to change anything below this line
26
$sql="select user_id, count(*) as postcnt from ".$PHORUM["message_table"]." group by user_id";
27
$conn = phorum_db_mysql_connect();
28
$res = mysql_query($sql, $conn);
29
if ($err = mysql_error()) phorum_db_mysql_error("$err: $sql");
30
if(mysql_num_rows($res)) {
31
    $usercnt=0;
32
    while($row = mysql_fetch_row($res)) {
33
        $user=array("user_id"=>$row[0],"posts"=>$row[1]);
34
        phorum_user_save_simple($user);
35
        $usercnt++;
36
    }
37
}
38
 
39
print "$usercnt Users updated with their current postcounts. Done!<br>\n";
40
 
41
?>