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)) : '';
 }