2001-03-10 11:07:52 +00:00
|
|
|
<?php
|
2001-03-03 11:44:51 +00:00
|
|
|
|
|
|
|
$module = array("cron" => "rating_cron",
|
|
|
|
"help" => "rating_help",
|
|
|
|
"page" => "rating_page",
|
|
|
|
"block" => "rating_block");
|
|
|
|
|
|
|
|
function rating_cron() {
|
2001-04-07 20:00:21 +00:00
|
|
|
$r1 = db_query("SELECT id FROM users ORDER BY rating DESC");
|
|
|
|
while ($account = db_fetch_object($r1)) {
|
2001-04-04 21:09:24 +00:00
|
|
|
db_query("UPDATE users SET rating = '". user_gravity($account->id) ."' WHERE id = '$account->id'");
|
2001-04-07 20:00:21 +00:00
|
|
|
$rating[$account->id] = ++$i;
|
|
|
|
}
|
|
|
|
|
|
|
|
db_query("DELETE FROM rating");
|
|
|
|
|
|
|
|
$r2 = db_query("SELECT id FROM users ORDER BY rating DESC");
|
|
|
|
while ($account = db_fetch_object($r2)) {
|
|
|
|
db_query("INSERT INTO rating (user, new, old) VALUES ('$account->id', '". ++$j ."', '". $rating[$account->id] ."')");
|
2001-03-03 11:44:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function rating_help() {
|
|
|
|
?>
|
2001-04-05 20:33:36 +00:00
|
|
|
<P>The rating cron will periodically calculate each user's gravity, the overall time-weighted rating of each user's contributions.</P>
|
|
|
|
<?
|
2001-03-03 11:44:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function rating_list($limit) {
|
2001-04-07 20:00:21 +00:00
|
|
|
$result = db_query("SELECT u.userid, u.rating, r.* FROM users u LEFT JOIN rating r ON u.id = r.user ORDER BY u.rating DESC LIMIT $limit");
|
2001-03-03 11:44:51 +00:00
|
|
|
|
2001-03-03 12:17:12 +00:00
|
|
|
$output .= "<TABLE CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
|
2001-03-03 11:44:51 +00:00
|
|
|
while ($account = db_fetch_object($result)) {
|
2001-04-07 20:00:21 +00:00
|
|
|
$ranking = $account->old - $account->new;
|
|
|
|
$output .= "<TR><TD ALIGN=\"right\">". ++$i ."</TD><TD>". format_username($account->userid) ."</TD><TD ALIGN=\"right\">". check_output($account->rating) ."</TD><TD>(". ($ranking < 0 ? "" : "+") ."$ranking)</TD></TR>";
|
2001-03-03 11:44:51 +00:00
|
|
|
}
|
|
|
|
$output .= "</TABLE>\n";
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
function rating_page() {
|
|
|
|
global $theme;
|
|
|
|
$theme->header();
|
|
|
|
$theme->box("Top 100 users", rating_list(100));
|
|
|
|
$theme->footer();
|
|
|
|
}
|
|
|
|
|
|
|
|
function rating_block() {
|
2001-03-28 07:03:47 +00:00
|
|
|
$block[0][subject] = "Top 10:<BR>users";
|
|
|
|
$block[0][content] = rating_list(10);
|
|
|
|
$block[0][info] = "Top 10: users";
|
2001-03-03 11:44:51 +00:00
|
|
|
return $block;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|