function go_clipboard_add() { $ids = $_POST['ids']; $points = $_POST['points']; $currency = $_POST['currency']; $bonus_currency = $_POST['bonus_currency']; $penalty = $_POST['penalty']; $reason = $_POST['reason']; $badge_ID = $_POST['badge_ID']; foreach ($ids as $key => $value) { if ($reason != '') { if ($points != '') { go_add_currency($value, $reason, 6, $points, 0, false); } if ($currency != '') { go_add_currency($value, $reason, 6, 0, $currency, false); } if ($bonus_currency != '') { go_add_bonus_currency($value, $bonus_currency, $reason); } if ($penalty != '') { go_add_penalty($value, $penalty, $reason); } if ($badge_ID != '') { do_shortcode('[go_award_badge id="' . $badge_ID . '" repeat = "off" uid="' . $value . '"]'); } go_message_user($value, $reason); } } die; }
function go_buy_item() { global $wpdb; $go_table_name = $wpdb->prefix . "go"; $post_id = $_POST["the_id"]; $qty = $_POST['qty']; $current_purchase_count = $_POST['purchase_count']; if (isset($_POST['recipient']) && !empty($_POST['recipient']) && $_POST['recipient'] != '') { $recipient = $_POST['recipient']; $recipient_id = $wpdb->get_var('SELECT id FROM ' . $wpdb->users . ' WHERE display_name="' . $recipient . '"'); $recipient_purchase_count = $wpdb->get_var("SELECT count FROM {$table_name_go} WHERE post_id={$post_id} AND uid={$recipient_id} LIMIT 1"); } $user_id = get_current_user_id(); $custom_fields = get_post_custom($post_id); $sending_receipt = $custom_fields['go_mta_store_receipt'][0]; $store_cost = unserialize($custom_fields['go_mta_store_cost'][0]); if (!empty($store_cost)) { $req_currency = $store_cost[0]; $req_points = $store_cost[1]; $req_bonus_currency = $store_cost[2]; $req_penalty = $store_cost[3]; $req_minutes = $store_cost[4]; } $penalty = $custom_fields['go_mta_penalty_switch']; $store_limit = unserialize($custom_fields['go_mta_store_limit'][0]); $is_limited = (bool) $store_limit[0]; if ($is_limited) { $limit = (int) $store_limit[1]; } $store_filter = unserialize($custom_fields['go_mta_store_filter'][0]); $is_filtered = (bool) $store_filter[0]; if ($is_filtered) { $req_rank = $store_filter[1]; $bonus_filter = $store_filter[2]; } $store_exchange = unserialize($custom_fields['go_mta_store_exchange'][0]); $is_exchangeable = (bool) $store_exchange[0]; if ($is_exchangeable) { $exchange_currency = $store_exchange[1]; $exchange_points = $store_exchange[2]; $exchange_bonus_currency = $store_exchange[3]; } $item_url = $custom_fields['go_mta_store_item_url'][0]; $badge_id = $custom_fields['go_mta_badge_id'][0]; $store_focus = $custom_fields['go_mta_store_focus'][0]; $is_focused = (bool) $store_focus[0]; if ($is_focused) { $item_focus = $store_focus[1]; } $repeat = 'off'; $cur_currency = go_return_currency($user_id); $cur_points = go_return_points($user_id); $cur_bonus_currency = go_return_bonus_currency($user_id); $cur_penalty = go_return_penalty($user_id); $cur_minutes = go_return_minutes($user_id); $enough_currency = check_values($req_currency, $cur_currency); $enough_points = check_values($req_points, $cur_points); $enough_bonus_currency = check_values($req_bonus_currency, $cur_bonus_currency); $enough_penalty = check_values($req_penalty, $cur_penalty); $enough_minutes = check_values($req_minutes, $cur_minutes); $within_limit = true; if (!empty($limit)) { $qty_diff = $limit - $current_purchase_count - $qty; if ($qty_diff < 0) { $within_limit = false; } } if (($enough_currency && $enough_bonus_currency && $enough_points && $enough_minutes || $penalty) && $within_limit) { if ($is_focused && !empty($item_focus)) { $user_focuses = (array) get_user_meta($user_id, 'go_focus', true); $user_focuses[] = $item_focus; update_user_meta($user_id, 'go_focus', $user_focuses); } if ($recipient_id) { go_message_user($recipient_id, get_userdata($user_id)->display_name . " has purchased {$qty} <a href='javascript:;' onclick='go_lb_opener({$post_id})'>" . get_the_title($post_id) . "</a> for you."); if ($exchange_currency || $exchange_points || $exchange_bonus_currency) { go_add_post($recipient_id, $post_id, -1, $exchange_points, $exchange_currency, $exchange_bonus_currency, null, null, $repeat); go_add_bonus_currency($recipient_id, $exchange_bonus_currency, get_userdata($user_id)->display_name . " purchase of {$qty} " . get_the_title($post_id) . "."); } else { go_add_post($recipient_id, $post_id, -1, 0, 0, 0, null, $repeat); } go_add_post($user_id, $post_id, -1, -$req_points, -$req_currency, -$req_bonus_currency, -$req_minutes, null, $repeat); $wpdb->query($wpdb->prepare("UPDATE {$go_table_name} SET reason = 'Gifted' WHERE uid = %d AND status = %d AND gifted = %d AND post_id = %d ORDER BY timestamp DESC, reason DESC, id DESC LIMIT 1", $user_id, -1, 0, $post_id)); } else { go_add_post($user_id, $post_id, -1, -$req_points, -$req_currency, -$req_bonus_currency, -$req_minutes, null, $repeat); if (!empty($req_penalty)) { go_add_penalty($user_id, -$req_penalty, get_the_title($post_id)); } } if (!empty($badge_id)) { if ($recipient_id) { do_shortcode('[go_award_badge id="' . $badge_id . '" repeat = "off" uid="' . $recipient_id . '"]'); } else { do_shortcode('[go_award_badge id="' . $badge_id . '" repeat = "off" uid="' . $user_id . '"]'); } } if (!empty($item_url) && isset($item_url)) { $item_hyperlink = '<a target="_blank" href="' . $item_url . '">Grab your loot!</a>'; echo $item_hyperlink; } else { echo "Purchased"; } if ($sending_receipt === 'true') { $receipt = go_mail_item_reciept($user_id, $post_id, $req_currency, $req_points, $req_bonus_currency, $req_minutes, $qty, $recipient_id); if (!empty($receipt)) { echo $receipt; } } } else { $currency_name = go_return_options('go_currency_name'); $points_name = go_return_options('go_points_name'); $bonus_currency_name = go_return_options('go_bonus_currency_name'); $minutes_name = go_return_options('go_minutes_name'); $enough_array = array($currency_name => $enough_currency, $points_name => $enough_points, $bonus_currency_name => $enough_bonus_currency, $minutes_name => $enough_minutes); $errors = array(); foreach ($enough_array as $key => $enough) { if (!$enough) { $errors[] = $key; } } if (!empty($errors)) { $errors = implode(', ', $errors); echo 'Need more ' . substr($errors, 0, strlen($errors)); } if ($is_limited && !$within_limit) { $qty_diff *= -1; echo "You've attempted to purchase " . ($qty_diff == 1 ? '1 item' : "{$qty_diff} items") . " greater than the purchase limit."; } } die; }
function go_clipboard_add() { $ids = $_POST['ids']; $points = $_POST['points']; $currency = $_POST['currency']; $bonus_currency = $_POST['bonus_currency']; $penalty = $_POST['penalty']; $minutes = $_POST['minutes']; $reason = $_POST['reason']; $badge_ID = $_POST['badge_ID']; foreach ($ids as $key => $value) { if ($reason != '') { if ($points != '') { go_add_currency($value, $reason, 6, $points, 0, false); } if ($currency != '') { go_add_currency($value, $reason, 6, 0, $currency, false); } if ($bonus_currency != '') { go_add_bonus_currency($value, $bonus_currency, $reason); } if ($penalty != '') { go_add_penalty($value, $penalty, $reason); } if ($minutes != '') { go_add_minutes($value, $minutes, $reason); } if ($badge_ID != '') { do_shortcode("[go_award_badge id='{$badge_ID}' repeat = 'off' uid='{$value}']"); } go_message_user($value, $reason); } } die; }
function go_admin_bar_add() { $points_points = $_POST['go_admin_bar_points_points']; $points_reason = $_POST['go_admin_bar_points_reason']; $currency_points = $_POST['go_admin_bar_currency_points']; $currency_reason = $_POST['go_admin_bar_currency_reason']; $bonus_currency_points = $_POST['go_admin_bar_bonus_currency_points']; $bonus_currency_reason = $_POST['go_admin_bar_bonus_currency_reason']; $penalty_points = $_POST['go_admin_bar_penalty_points']; $penalty_reason = $_POST['go_admin_bar_penalty_reason']; $minutes_points = $_POST['go_admin_bar_minutes_points']; $minutes_reason = $_POST['go_admin_bar_minutes_reason']; $user_id = get_current_user_id(); if ($points_points != '' && $points_reason != '') { go_add_currency($user_id, $points_reason, 6, $points_points, 0, false); go_update_ranks($current_user_id, $current_points); } if ($currency_points != '' && $currency_reason != '') { go_add_currency($user_id, $currency_reason, 6, 0, $currency_points, false); } if ($bonus_currency_points != '' && $bonus_currency_reason != '') { go_add_bonus_currency($user_id, $bonus_currency_points, $bonus_currency_reason); } if ($penalty_points != '' && $penalty_reason != '') { go_add_penalty($user_id, $penalty_points, $penalty_reason); } if ($minutes_points != '' && $minutes_reason != '') { go_add_minutes($user_id, $minutes_points, $minutes_reason); } die; }