diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-04-04 21:09:24 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-04-04 21:09:24 +0000 |
commit | 7fac91c2cc4ca3dedf4459f9cdf9955e33be0f42 (patch) | |
tree | d1667c823da84a417540c3afdbcf08fc5cf6773c /includes | |
parent | 8d249c5f289f382e214297fda1bf6eec6b3961bd (diff) | |
download | brdo-7fac91c2cc4ca3dedf4459f9cdf9955e33be0f42.tar.gz brdo-7fac91c2cc4ca3dedf4459f9cdf9955e33be0f42.tar.bz2 |
- various smaller improvements
Diffstat (limited to 'includes')
-rw-r--r-- | includes/user.inc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/includes/user.inc b/includes/user.inc index 09b434102..5c97cb02d 100644 --- a/includes/user.inc +++ b/includes/user.inc @@ -100,4 +100,33 @@ function user_ban($mask, $type) { return db_fetch_object($result); } +function user_gravity($id) { + global $status; + + $period = 5184000; // maximum 60 days + $number = 30; // maximum 30 comments + + $r1 = db_query("SELECT COUNT(nid) AS number FROM node WHERE author = '$id' AND (". time() ." - timestamp < $period) AND status = '$status[posted]'"); + if ($story = db_fetch_object($r1)) { + $bonus += $story->number; + } + + $r2 = db_query("SELECT COUNT(nid) AS number FROM node WHERE author = '$id' AND (". time() ." - timestamp < $period) AND status = '$status[dumped]'"); + if ($story = db_fetch_object($r2)) { + $bonus -= $story->number; + } + + $r3 = db_query("SELECT score, votes FROM comments WHERE author = '$id' AND (". time() ." - timestamp < $period) ORDER BY timestamp LIMIT $number"); + while ($comment = db_fetch_object($r3)) { + $weight++; + $score += $weight * $comment->score; + $votes += $weight * $comment->votes; + } + + $bonus += $weight / 5; + + if ($votes > 0) return ($score + $weight) / $votes + $bonus; + else return 0; +} + ?>
\ No newline at end of file |