Beispiel #1
0
     flash_message($lang->newpoints_error, 'error');
     admin_redirect("index.php?module=newpoints-maintenance");
 }
 if (intval($mybb->input['start']) > 0) {
     $start = intval($mybb->input['start']);
 } else {
     $start = 0;
 }
 if (intval($mybb->input['per_page']) > 0) {
     $per_page = intval($mybb->input['per_page']);
 } else {
     $per_page = 50;
 }
 $query = $db->simple_select("users", "COUNT(*) as users");
 $total_users = $db->fetch_field($query, 'users');
 $allforumrules = newpoints_getallrules('forum');
 $query = $db->simple_select('users', 'uid,usergroup', '', array('order_by' => 'uid', 'order_dir' => 'ASC', 'limit' => "{$start}, {$per_page}"));
 while ($user = $db->fetch_array($query)) {
     // recount points
     $points = 0;
     // group rules
     $grouprules = newpoints_getrules('group', $user['usergroup']);
     if (!$grouprules) {
         $grouprules['rate'] = 1;
     }
     // no rule set so default income rate is 1
     // if the group rate is 0, nothing is going to be added so let's just skip this user
     if ($grouprules['rate'] == 0) {
         continue;
     }
     $firstposts = array(0);
Beispiel #2
0
 function newpoints_perview()
 {
     global $db, $mybb, $cache, $groupscache, $userupdates;
     if (!$mybb->user['uid']) {
         return;
     }
     if ($mybb->settings['newpoints_main_enabled'] != 1) {
         return;
     }
     // check group rules - primary group check
     $grouprules = newpoints_getallrules('group');
     if (empty($grouprules)) {
         return;
     }
     if ($mybb->settings['newpoints_income_pageview'] != 0) {
         newpoints_addpoints($mybb->user['uid'], $mybb->settings['newpoints_income_pageview'], 1, $grouprules[$mybb->user['usergroup']]['rate']);
     }
     if ($mybb->settings['newpoints_income_visit'] != 0) {
         if (TIME_NOW - $mybb->user['lastactive'] > 900) {
             newpoints_addpoints($mybb->user['uid'], $mybb->settings['newpoints_income_visit'], 1, $grouprules[$mybb->user['usergroup']]['rate']);
         }
     }
     foreach ($grouprules as $gid => $rule) {
         if ($rule['pointsearn'] == 0 || $rule['period'] == 0 || $rule['lastpay'] > TIME_NOW - $rule['period']) {
             return;
         }
         //die("testing".$rule['pointsearn']." | ".$rule['period']." | ".$rule['lastpay']." | ".TIME_NOW);
         $amount = floatval($rule['pointsearn']);
         $userupdates[$gid] = $amount;
         // update rule with last payment
         $db->update_query('newpoints_grouprules', array('lastpay' => TIME_NOW), 'gid=\'' . $gid . '\'');
         if ($mybb->user['usergroup'] == $gid) {
             $mybb->user['newpoints'] += $amount;
         }
         if (!empty($userupdates)) {
             // run updates to users on shut down
             add_shutdown('newpoints_update_users');
         }
     }
 }