bots = "0"; $this->limit = 15*60; // 15 Minuten } function posts_gesamt($autoawardid, $awardid, $beschreibung, $datum = 0) { global $db, $n; if(($datum + $this->limit) < time()) { $userposts = $db->query_first("SELECT max(userposts) FROM bb".$n."_users WHERE userid NOT IN (".$this->bots.") GROUP by userid ORDER BY userposts DESC"); $user_res = $db->query("SELECT userid FROM bb".$n."_users WHERE userposts='".$userposts[0]."' AND userid NOT IN (".$this->bots.")"); $db->unbuffered_query("DELETE FROM bb".$n."_user2awards WHERE autoawardid='".$autoawardid."'"); while($user = $db->fetch_array($user_res)) $db->unbuffered_query("INSERT INTO bb".$n."_user2awards (userid, awardid, autoawardid, beschreibung) VALUES ('".$user[0]."', '".$awardid."', '".$autoawardid."', '".$beschreibung."')"); $db->unbuffered_query("UPDATE bb".$n."_autoawards SET datum='".time()."' WHERE autoawardid='".$autoawardid."'"); } } function posts_monat($autoawardid, $awardid, $beschreibung, $datum = 0) { global $db, $n; $monat = date("n", time()) - 1; $jahr = date("Y", time()); if(!$monat) { $monat = 12; $jahr--; } $zeit_anfang = mktime(0, 0, 0, $monat, 1, $jahr); $monat++; if($monat == 13) { $monat = 1; $jahr++; } $zeit_ende = mktime(0, 0, 0, $monat, 1, $jahr); if($zeit_ende > $datum) { $anzahl = 0; $userposts_res = $db->query("SELECT COUNT(p.postid) AS anzahl, p.userid FROM bb".$n."_posts p LEFT JOIN bb".$n."_threads t ON (t.threadid = p.threadid) LEFT JOIN bb".$n."_boards b ON (b.boardid = t.boardid) WHERE p.userid NOT IN (".$this->bots.") AND b.countuserposts = 1 AND posttime >= '".$zeit_anfang."' AND posttime < '".$zeit_ende."' GROUP BY userid ORDER BY anzahl DESC"); $db->unbuffered_query("DELETE FROM bb".$n."_user2awards WHERE autoawardid='".$autoawardid."'"); while($userposts = $db->fetch_array($userposts_res)) { if(!$anzahl) $anzahl = $userposts['anzahl']; if($anzahl > $userposts['anzahl']) break; $db->unbuffered_query("INSERT INTO bb".$n."_user2awards (userid, awardid, autoawardid, beschreibung) VALUES ('".$userposts['userid']."', '".$awardid."', '".$autoawardid."', '".$beschreibung."')"); } $db->unbuffered_query("UPDATE bb".$n."_autoawards SET datum='".$zeit_ende."' WHERE autoawardid='".$autoawardid."'"); } } function posts_woche($autoawardid, $awardid, $beschreibung, $datum = 0) { global $db, $default_startweek, $n; $verschiebung = date("w") - $default_startweek; if($verschiebung < 0) $verschiebung += 7; if(($datum + 604800) <= time()) { $db->unbuffered_query("DELETE FROM bb".$n."_user2awards WHERE autoawardid='".$autoawardid."'"); $zeit_anfang = mktime(0, 0, 0, date("n"), (date("j") - $verschiebung - 7), date("Y")); $zeit_ende = mktime(0, 0, 0, date("n"), (date("j") - $verschiebung), date("Y")); $userposts_res = $db->query("SELECT COUNT(p.postid) AS anzahl, p.userid FROM bb".$n."_posts p LEFT JOIN bb".$n."_threads t ON (t.threadid = p.threadid) LEFT JOIN bb".$n."_boards b ON (b.boardid = t.boardid) WHERE p.userid NOT IN (".$this->bots.") AND b.countuserposts = 1 AND posttime >= '".$zeit_anfang."' AND posttime < '".$zeit_ende."' GROUP BY userid ORDER BY anzahl DESC"); while($userposts = $db->fetch_array($userposts_res)) { if(!$anzahl) $anzahl = $userposts['anzahl']; if($anzahl > $userposts['anzahl']) break; $db->unbuffered_query("INSERT INTO bb".$n."_user2awards (userid, awardid, autoawardid, beschreibung) VALUES ('".$userposts['userid']."', '".$awardid."', '".$autoawardid."', '".$beschreibung."')"); } $db->unbuffered_query("UPDATE bb".$n."_autoawards SET datum='".$zeit_ende."' WHERE autoawardid='".$autoawardid."'"); } } function user_neu($autoawardid, $awardid, $beschreibung, $datum = 0) { global $db, $n; $user = $db->query_first("SELECT userid, regdate FROM bb".$n."_users ORDER BY regdate DESC"); if($datum < $user['regdate']) { $db->unbuffered_query("DELETE FROM bb".$n."_user2awards WHERE autoawardid='".$autoawardid."'"); $db->unbuffered_query("INSERT INTO bb".$n."_user2awards (userid, awardid, autoawardid, beschreibung) VALUES ('".$user['userid']."', '".$awardid."', '".$autoawardid."', '".$beschreibung."')"); $db->unbuffered_query("UPDATE bb".$n."_autoawards SET datum='".$user['regdate']."' WHERE autoawardid='".$autoawardid."'"); } } } ?>