Пример #1
0
             }
         }
         $cash_amount = array();
         while ($c_cur =& $cash->currency_next($cm_i)) {
             if (isset($cash_check[$c_cur->id()])) {
                 $cash_counts = array(CASH_POSTS => 0, CASH_BONUS => 0, CASH_REPLIES => 0);
                 $cash_amount[$c_cur->id()] = $c_cur->data('cash_default');
                 for ($j = 0; $j < count($forum_list); $j++) {
                     $forum_id = $forum_list[$j];
                     if ($c_cur->forum_active($forum_id)) {
                         $cash_counts[CASH_POSTS] += $forums[$forum_id][CASH_POSTS];
                         $cash_counts[CASH_BONUS] += $forums[$forum_id][CASH_BONUS];
                         $cash_counts[CASH_REPLIES] += $forums[$forum_id][CASH_REPLIES];
                     }
                 }
                 $cash_amount[$c_cur->id()] += $c_user->get_setting($c_cur->id(), 'cash_perpost') * $cash_counts[CASH_POSTS];
                 $cash_amount[$c_cur->id()] += $c_user->get_setting($c_cur->id(), 'cash_postbonus') * $cash_counts[CASH_BONUS];
                 $cash_amount[$c_cur->id()] += $c_user->get_setting($c_cur->id(), 'cash_perreply') * $cash_counts[CASH_REPLIES];
             }
         }
         $c_user->set_by_id_array($cash_amount);
         $config_update = $c_user->id() . "," . $max_user;
         $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '{$config_update}' WHERE config_name = 'cash_resetting'";
         if (!$db->sql_query($sql)) {
             message_die(GENERAL_ERROR, 'Error updating config data', '', __LINE__, __FILE__, $sql);
         }
         print sprintf($lang['User_updated'], $c_user->name()) . FLUSH;
         flush();
     }
 }
 $sql = "DELETE FROM " . CONFIG_TABLE . "  WHERE config_name = 'cash_resetting'";
Пример #2
0
 function cash_update($mode, $poster_id, $first_post, &$old_message, &$new_message, $forum_id, $topic_id, $post_id, $new_bbcode, $topic_starter, $old_bbcode)
 {
     global $board_config, $lang, $db, $phpbb_root_path, $phpEx, $userdata, $cash;
     if ($mode == 'reply' && $poster_id != $topic_starter && ($topic_userdata = get_userdata($topic_starter))) {
         $topic_creator = new cash_user($topic_starter, $topic_userdata);
         $topic_creator->give_bonus($topic_id);
     }
     if ($poster_id == ANONYMOUS) {
         return;
     }
     if ($userdata['user_id'] == $poster_id) {
         $posting_user = new cash_user($userdata['user_id'], $userdata);
     } else {
         $posting_user = new cash_user($poster_id);
     }
     $all_active = true;
     $forumcount = array();
     $forumlist = array();
     if (($mode == 'newtopic' || $mode == 'reply') && intval($board_config['cash_disable_spam_num']) > 0) {
         $all_active = false;
         $interval = time() - 3600 * intval($board_config['cash_disable_spam_time']);
         $sum = 0;
         $sql = "SELECT forum_id, count(post_id) as postcount\n\t\t\t\t\tFROM " . POSTS_TABLE . "\n\t\t\t\t\tWHERE poster_id = {$poster_id}\n\t\t\t\t\t\tAND post_time > {$interval}\n\t\t\t\t\tGROUP BY forum_id";
         if (!($result = $db->sql_query($sql))) {
             message_die(GENERAL_ERROR, 'Error retrieving post data', '', __LINE__, __FILE__, $sql);
         }
         while ($row = $db->sql_fetchrow($result)) {
             $forumlist[] = $row['forum_id'];
             $forumcount[$row['forum_id']] = $row['postcount'];
             $sum += $row['postcount'];
         }
         if ($sum < $board_config['cash_disable_spam_num']) {
             $all_active = true;
         }
     }
     $new_len = array(strlen($new_message), cash_quotematch($new_message, $new_bbcode));
     $old_len = array(strlen($old_message), cash_quotematch($old_message, $old_bbcode));
     $sql_clause = array();
     $message_clause = array();
     $reply_bonus = array();
     $all_spam = !$all_active;
     while ($c_cur =& $cash->currency_next($cm_i, CURRENCY_ENABLED, $forum_id)) {
         $this_enabled = $all_active;
         if (!$all_active) {
             $sum = 0;
             for ($i = 0; $i < count($forumlist); $i++) {
                 if ($c_cur->forum_active($forumlist[$i])) {
                     $sum += $forumcount[$forumlist[$i]];
                 }
             }
             if ($sum < $board_config['cash_disable_spam_num']) {
                 $this_enabled = true;
                 $all_spam = false;
             }
         }
         if ($this_enabled) {
             $base = $first_post ? $posting_user->get_setting($c_cur->id(), 'cash_perpost') : $posting_user->get_setting($c_cur->id(), 'cash_perreply');
             $perchar = $posting_user->get_setting($c_cur->id(), 'cash_perchar', PERCHAR_DEC_BONUS);
             $max = $posting_user->get_setting($c_cur->id(), 'cash_maxearn');
             $quotes = $c_cur->mask(CURRENCY_INCLUDEQUOTES) ? 0 : 1;
             $total_added = $mode != 'delete' ? min($max, $base + $perchar * $new_len[$quotes]) : 0;
             $total_removed = $mode != 'newtopic' && $mode != 'reply' ? min($max, $base + $perchar * $old_len[$quotes]) : 0;
             $total_change = $total_added - $total_removed;
             if ($total_change != 0) {
                 $change_sign = $total_change > 0;
                 $change_amount = $change_sign ? $total_change : -$total_change;
                 $change_sign = $change_sign ? " + " : " - ";
                 $sql_clause[] = $c_cur->db() . " = " . $c_cur->db() . $change_sign . $change_amount;
                 $message_clause[] = $c_cur->display($change_amount);
             }
         }
     }
     if ($all_spam) {
         return $board_config['cash_disable_spam_message'];
     }
     if (count($sql_clause) > 0) {
         $sql = "UPDATE " . USERS_TABLE . " \n\t\t\t\t\tSET " . implode(', ', $sql_clause) . "\n\t\t\t\t\tWHERE user_id = " . $poster_id;
         if (!$db->sql_query($sql)) {
             message_die(GENERAL_ERROR, 'Error in updating cash', '', __LINE__, __FILE__, $sql);
         }
     }
     return $userdata['user_id'] == $poster_id && $board_config['cash_display_after_posts'] == 1 ? sprintf($board_config['cash_post_message'], implode(', ', $message_clause)) : '';
 }
Пример #3
0
 function cash_update_thanks($poster_id)
 {
     global $config, $lang, $db, $user, $cash;
     $posting_user = new cash_user($poster_id);
     $sql_clause = array();
     $message_clause = array();
     while ($c_cur =& $cash->currency_next($cm_i, CURRENCY_ENABLED, $forum_id)) {
         $perthanks = $posting_user->get_setting($c_cur->id(), 'cash_perthanks');
         $sql_clause[] = $c_cur->db() . ' = ' . $c_cur->db() . ' + ' . $perthanks;
         $message_clause[] = $c_cur->display($perthanks);
     }
     if (sizeof($sql_clause) > 0) {
         $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\tSET " . implode(', ', $sql_clause) . "\n\t\t\t\t\tWHERE user_id = " . $poster_id;
         $db->sql_query($sql);
         // Mighty Gorgon: to be fixed because it returns ARRAY
         //return $message_clause;
         return '';
     }
 }