コード例 #1
0
ファイル: go_globals.php プロジェクト: zetheroth/game-on
function go_global_info()
{
    global $wpdb;
    global $current_user_id;
    global $current_points;
    global $current_currency;
    global $current_bonus_currency;
    global $current_penalty;
    $current_user = wp_get_current_user();
    $current_user_id = $current_user->ID;
    $current_points = go_return_points($current_user_id);
    $current_currency = go_return_currency($current_user_id);
    $current_bonus_currency = go_return_bonus_currency($current_user_id);
    $current_penalty = go_return_penalty($current_user_id);
    go_get_rank($current_user_id);
}
コード例 #2
0
ファイル: go_clipboard.php プロジェクト: zetheroth/game-on
function go_clipboard_collect_data()
{
    global $wpdb;
    $table_name_user_meta = $wpdb->prefix . 'usermeta';
    $table_name_go = $wpdb->prefix . 'go';
    $uid = $wpdb->get_results("SELECT user_id \n\t\tFROM {$table_name_user_meta} \n\t\tWHERE meta_key = '{$wpdb->prefix}capabilities' \n\t\tAND meta_value NOT LIKE '%administrator%'");
    $time = round(microtime(true));
    $array = get_option('go_graphing_data');
    foreach ($uid as $id) {
        foreach ($id as $value) {
            $bonus_currency = go_return_bonus_currency($value);
            $penalty = go_return_penalty($value);
            $currency = go_return_currency($value);
            $points = go_return_points($value);
            $third_stage = (int) $wpdb->get_var("select count(*) from " . $table_name_go . " where uid = {$value} and status = 3");
            $fourth_stage = (int) $wpdb->get_var("select count(*) from " . $table_name_go . " where uid = {$value} and status = 4");
            $array[$value][$time] = $bonus_currency . ',' . $penalty . ',' . $points . ',' . $third_stage . ',' . $fourth_stage . ',' . $currency;
        }
    }
    update_option('go_graphing_data', $array);
}
コード例 #3
0
ファイル: go_clipboard.php プロジェクト: Gaestelj/game-on-1
function go_clipboard_intable()
{
    global $wpdb;
    $class_a_choice = $_POST['go_clipboard_class_a_choice'];
    $table_name_user_meta = $wpdb->prefix . 'usermeta';
    $uid = $wpdb->get_results("SELECT user_id \n\t\tFROM {$table_name_user_meta} \n\t\tWHERE meta_key = '{$wpdb->prefix}capabilities' \n\t\tAND meta_value NOT LIKE '%administrator%'");
    foreach ($uid as $id) {
        $class_a = get_user_meta($id->user_id, 'go_classifications', true);
        if (!empty($class_a[$class_a_choice])) {
            $user_data_key = get_userdata($id->user_id);
            $user_login = $user_data_key->user_login;
            $user_display = $user_data_key->display_name;
            $user_first_name = $user_data_key->user_firstname;
            $user_last_name = $user_data_key->user_lastname;
            $user_url = $user_data_key->user_url;
            if (go_return_options('go_focus_switch') == 'On') {
                $user_focuses = go_display_user_focuses($id->user_id);
                $focus_name = get_option('go_focus_name');
                $focuses = get_option('go_focus');
                $focuses_list = "<option>{$user_focuses}</option><option " . (empty($user_focuses) || $user_focuses == "No {$focus_name}" ? "selected" : '') . ">No {$focus_name}</option>";
                foreach ($focuses as $focus) {
                    $focuses_list .= "<option value='" . esc_attr($focus) . "' >{$focus}</option>";
                }
            }
            $bonus_currency = go_return_bonus_currency($id->user_id);
            $penalty = go_return_penalty($id->user_id);
            $minutes = go_return_minutes($id->user_id);
            $currency = go_return_currency($id->user_id);
            $points = go_return_points($id->user_id);
            $badge_count = go_return_badge_count($id->user_id);
            go_get_rank($id->user_id);
            global $current_rank;
            echo "<tr id='user_{$id->user_id}'>\n\t\t\t\t\t<td><input class='go_checkbox' type='checkbox' name='go_selected' value='{$id->user_id}'/></td>\n\t\t\t\t\t<td><span><a href='#' onclick='go_admin_bar_stats_page_button(&quot;{$id->user_id}&quot;);'>{$user_login}</a></td>\n\t\t\t\t\t<td>{$class_a[$class_a_choice]}</td>\n\t\t\t\t\t<td><a href='{$user_url}' target='_blank'>{$user_last_name}, {$user_first_name}</a></td>\n\t\t\t\t\t<td>{$user_display}</td>\n\t\t\t\t\t<td>{$current_rank}</td>\n\t\t\t\t\t" . (go_return_options('go_focus_switch') == 'On' ? "<td><select class='go_focus' onchange='go_user_focus_change(&quot;{$id->user_id}&quot;, this);'>{$focuses_list}</select</td>" : '') . "\n\t\t\t\t\t<td class='user_points'>{$points}</td>\n\t\t\t\t\t<td class='user_currency'>{$currency}</td>\n\t\t\t\t\t<td class='user_bonus_currency'>{$bonus_currency}</td>\n\t\t\t\t\t<td class='user_penalty'>{$penalty}</td>\n\t\t\t\t\t<td class='user_minutes'>{$minutes}</td>\n\t\t\t\t\t<td class='user_badge_count'>{$badge_count}</td>\n\t\t\t\t  </tr>";
        }
    }
    die;
}
コード例 #4
0
ファイル: go_stats.php プロジェクト: SpencerNussbaum/game-on
function go_return_user_data($id, $counter, $sort)
{
    $points = go_return_points($id);
    $currency = go_return_currency($id);
    $bonus_currency = go_return_bonus_currency($id);
    $badge_count = go_return_badge_count($id);
    $user_data_key = get_userdata($id);
    $user_display = "<a href='#' onclick='go_admin_bar_stats_page_button(&quot;{$id}&quot;);'>{$user_data_key->display_name}</a>";
    switch ($sort) {
        case 'points':
            echo "<li>{$counter} {$user_display} <div class='go_stats_amount'>{$points}</div></li>";
            break;
        case 'currency':
            echo "<li>{$counter} {$user_display} <div class='go_stats_amount'>{$currency}</div></li>";
            break;
        case 'bonus_currency':
            echo "<li>{$counter} {$user_display} <div class='go_stats_amount'>{$bonus_currency}</div></li>";
            break;
        case 'badges':
            echo "<li>{$counter} {$user_display} <div class='go_stats_amount'>{$badge_count}</div></li>";
            break;
    }
}
コード例 #5
0
ファイル: buy-ajax.php プロジェクト: SpencerNussbaum/game-on
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;
}
コード例 #6
0
ファイル: go_pnc.php プロジェクト: SpencerNussbaum/game-on
function go_update_totals($user_id, $points, $currency, $bonus_currency, $penalty, $minutes, $status = null)
{
    global $wpdb;
    $table_name_go_totals = $wpdb->prefix . "go_totals";
    $bonuses = go_return_bonus_currency($user_id);
    $penalties = go_return_penalty($user_id);
    if ($status !== -1) {
        $modded_array = go_return_multiplier($user_id, $points, $currency, $bonuses, $penalties);
        $points = $modded_array[0];
        $currency = $modded_array[1];
    }
    if ($points != 0) {
        $totalpoints = go_return_points($user_id);
        $wpdb->update($table_name_go_totals, array('points' => $points + $totalpoints), array('uid' => $user_id));
        go_update_ranks($user_id, $points + $totalpoints);
        go_notify('points', $points, 0, 0, 0, 0, $user_id);
        $p = (string) ($points + $totalpoints);
        go_update_admin_bar('points', go_return_options('go_points_name'), $p, $status);
    }
    if ($currency != 0) {
        $totalcurrency = go_return_currency($user_id);
        $wpdb->update($table_name_go_totals, array('currency' => $currency + $totalcurrency), array('uid' => $user_id));
        go_notify('currency', 0, $currency, 0, 0, 0, $user_id);
        go_update_admin_bar('currency', go_return_options('go_currency_name'), $currency + $totalcurrency);
    }
    if ($bonus_currency != 0) {
        $total_bonus_currency = go_return_bonus_currency($user_id);
        $wpdb->update($table_name_go_totals, array('bonus_currency' => $total_bonus_currency + $bonus_currency), array('uid' => $user_id));
        go_notify('bonus_currency', 0, 0, $bonus_currency, 0, 0, $user_id);
        go_update_admin_bar('bonus_currency', go_return_options('go_bonus_currency_name'), $total_bonus_currency + $bonus_currency);
    }
    if ($penalty != 0) {
        $total_penalty = go_return_penalty($user_id);
        $wpdb->update($table_name_go_totals, array('penalty' => $total_penalty + $penalty), array('uid' => $user_id));
        go_notify('penalty', 0, 0, 0, $penalty, 0, $user_id);
        go_update_admin_bar('penalty', go_return_options('go_penalty_name'), $total_penalty + $penalty);
    }
    if ($minutes != 0) {
        $total_minutes = go_return_minutes($user_id);
        $wpdb->update($table_name_go_totals, array('minutes' => $total_minutes + $minutes), array('uid' => $user_id));
        go_notify('minutes', 0, 0, 0, 0, $minutes, $user_id);
        go_update_admin_bar('minutes', go_return_options('go_minutes_name'), $total_minutes + $minutes);
    }
}
コード例 #7
0
function go_the_lb_ajax()
{
    check_ajax_referer('go_lb_ajax_referall', 'nonce');
    global $wpdb;
    $table_name_go = "{$wpdb->prefix}go";
    $the_id = $_POST['the_item_id'];
    $the_post = get_post($the_id);
    $the_title = $the_post->post_title;
    $item_content = get_post_field('post_content', $the_id);
    $the_content = wpautop($item_content);
    $custom_fields = get_post_custom($the_id);
    if (isset($custom_fields['go_mta_penalty_switch'])) {
        $penalty = true;
    }
    $store_cost = !empty($custom_fields['go_mta_store_cost'][0]) ? unserialize($custom_fields['go_mta_store_cost'][0]) : null;
    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];
    }
    $store_filter = !empty($custom_fields['go_mta_store_filter'][0]) ? unserialize($custom_fields['go_mta_store_filter'][0]) : null;
    if (!empty($store_filter)) {
        $is_filtered = $store_filter[0];
        if ($is_filtered) {
            $req_rank = $store_filter[1];
            $bonus_filter = count($store_filter[2]) > 0 ? (int) $store_filter[2] : null;
            $penalty_filter = count($store_filter[3]) > 0 ? (int) $store_filter[3] : null;
        }
    }
    $store_limit = !empty($custom_fields['go_mta_store_limit'][0]) ? unserialize($custom_fields['go_mta_store_limit'][0]) : null;
    if (!empty($store_limit)) {
        $is_limited = $store_limit[0];
        if ($is_limited == 'true') {
            $purchase_limit = $store_limit[1];
        }
    }
    $user_id = get_current_user_id();
    $user_points = go_return_points($user_id);
    $user_bonus_currency = go_return_bonus_currency($user_id);
    $user_currency = go_return_currency($user_id);
    $user_penalties = go_return_penalty($user_id);
    $user_minutes = go_return_minutes($user_id);
    $purchase_count = $wpdb->get_var("SELECT SUM(count) FROM {$table_name_go} WHERE post_id={$the_id} AND uid={$user_id} LIMIT 1");
    $is_giftable = !empty($custom_fields['go_mta_store_giftable'][0]) ? $custom_fields['go_mta_store_giftable'][0] : '';
    $is_unpurchasable = !empty($custom_fields['go_mta_store_unpurchasable'][0]) ? $custom_fields['go_mta_store_unpurchasable'][0] : '';
    echo "<h2>{$the_title}</h2>";
    echo '<div id="go-lb-the-content">' . do_shortcode($the_content) . '</div>';
    if ($user_points >= $req_rank || $req_rank <= 0 || $penalty) {
        $lvl_color = "g";
        $output_level = $req_rank *= -1;
    } else {
        $lvl_color = "r";
    }
    if ($req_currency == 0) {
        $gold_color = "n";
    } elseif ($req_currency < 0) {
        $gold_color = "g";
        $output_currency = $req_currency *= -1;
    } else {
        $gold_color = "r";
    }
    if ($req_points == 0) {
        $points_color = "n";
    } elseif ($req_points < 0) {
        $points_color = "g";
        $output_points = $req_points *= -1;
    } else {
        $points_color = "r";
    }
    if ($req_bonus_currency == 0) {
        $bonus_currency_color = "n";
    } elseif ($req_bonus_currency < 0) {
        $bonus_currency_color = "g";
        $output_bonus_currency = $req_bonus_currency *= -1;
    } else {
        $bonus_currency_color = "r";
    }
    if ($req_penalty == 0) {
        $penalty_color = "n";
    } elseif ($req_penalty < 0) {
        $penalty_color = "r";
        $output_penalty = $req_penalty *= -1;
    } else {
        $penalty_color = "g";
    }
    if ($req_minutes == 0) {
        $minutes_color = "n";
    } elseif ($req_minutes < 0) {
        $minutes_color = "g";
        $output_minutes = $req_minutes *= -1;
    } else {
        $minutes_color = "r";
    }
    if ($lvl_color == "g" && $gold_color == "g" && $points_color == "g") {
        $buy_color = "gold";
    } else {
        $buy_color = "gold";
    }
    $user_focuses = array();
    if ($is_filtered === 'true' && !is_null($penalty_filter) && $user_penalties >= $penalty_filter) {
        $penalty_diff = $user_penalties - $penalty_filter;
        if ($penalty_diff > 0) {
            die("You have {$penalty_diff} too many " . go_return_options('go_penalty_name') . ".");
        } elseif ($penalty_diff == 0) {
            die("You need less than {$penalty_filter} " . go_return_options('go_penalty_name') . " to buy this item.");
        }
    }
    // Get focus options associated with item
    $item_focus_array = !empty($custom_fields['go_mta_store_focus'][0]) ? unserialize($custom_fields['go_mta_store_focus'][0]) : null;
    // Check if item actually has focus
    $is_focused = (bool) filter_var($item_focus_array[0], FILTER_VALIDATE_BOOLEAN);
    if ($is_focused) {
        $item_focus = $item_focus_array[1];
    }
    // Check if user has a focus
    if (get_user_meta($user_id, 'go_focus', true) != null) {
        $user_focuses = (array) get_user_meta($user_id, 'go_focus', true);
    }
    // Check if item is locked by focus
    $locked_by_focus = !empty($custom_fields['go_mta_store_focus_lock'][0]) ? $custom_fields['go_mta_store_focus_lock'][0] : null;
    if (!empty($locked_by_focus)) {
        $focus_category_lock = true;
    }
    // Grab which focuses are chosen as the locks
    if (get_the_terms($the_id, 'store_focus_categories') && $focus_category_lock) {
        $categories = get_the_terms($the_id, 'store_focus_categories');
        $category_names = array();
        foreach ($categories as $category) {
            array_push($category_names, $category->name);
        }
    }
    // Check to see if the user has any of the focuses
    if (!empty($category_names) && $user_focuses) {
        $go_ahead = array_intersect($user_focuses, $category_names);
    }
    if ($is_focused && !empty($item_focus) && !empty($user_focuses) && in_array($item_focus, $user_focuses)) {
        die('You already have this ' . go_return_options('go_focus_name') . '!');
    }
    if (empty($go_ahead) && !empty($focus_category_lock)) {
        die('Item only available to those in ' . implode(', ', $category_names) . ' ' . strtolower(go_return_options('go_focus_name')));
    }
    if ($is_filtered === 'true' && !is_null($bonus_filter) && $user_bonus_currency < $bonus_filter) {
        die('You require more ' . go_return_options('go_bonus_currency_name') . ' to view this item.');
    }
    if (!empty($purchase_limit) && $purchase_count >= $purchase_limit) {
        die("You've reached the maximum purchase limit.");
    }
    if ($user_points < $req_rank) {
        die("You need to reach {$req_rank_key} to purchase this item.");
    }
    ?>
	<div id="golb-fr-price" class="golb-fr-boxes-<?php 
    echo $gold_color;
    ?>
" req="<?php 
    echo $req_currency;
    ?>
" cur="<?php 
    echo $user_currency;
    ?>
"><?php 
    echo go_return_options('go_currency_name') . ': ' . (empty($req_currency) ? 0 : ($req_currency < 0 ? $output_currency : $req_currency));
    ?>
</div>
	<div id="golb-fr-points" class="golb-fr-boxes-<?php 
    echo $points_color;
    ?>
" req="<?php 
    echo $req_points;
    ?>
" cur="<?php 
    echo $user_points;
    ?>
"><?php 
    echo go_return_options('go_points_name') . ': ' . (empty($req_points) ? 0 : ($req_points < 0 ? $output_points : $req_points));
    ?>
</div>
	<div id="golb-fr-bonus_currency" class="golb-fr-boxes-<?php 
    echo $bonus_currency_color;
    ?>
" req="<?php 
    echo $req_bonus_currency;
    ?>
" cur="<?php 
    echo $user_bonus_currency;
    ?>
"><?php 
    echo go_return_options('go_bonus_currency_name') . ': ' . (empty($req_bonus_currency) ? 0 : ($req_bonus_currency < 0 ? $output_bonus_currency : $req_bonus_currency));
    ?>
</div>
    <div id='golb-fr-penalty' class='golb-fr-boxes-<?php 
    echo $penalty_color;
    ?>
' req='<?php 
    echo $req_penalty;
    ?>
' cur='<?php 
    echo $user_penalties;
    ?>
'><?php 
    echo go_return_options('go_penalty_name') . ': ' . (empty($req_penalty) ? 0 : ($req_penalty < 0 ? $output_penalty : $req_penalty));
    ?>
</div>
    <div id="golb-fr-minutes" class="golb-fr-boxes-<?php 
    echo $minutes_color;
    ?>
" req="<?php 
    echo $req_minutes;
    ?>
" cur="<?php 
    echo $user_minutes;
    ?>
"><?php 
    echo go_return_options('go_minutes_name') . ': ' . (empty($req_minutes) ? 0 : ($req_minutes < 0 ? $output_minutes : $req_minutes));
    ?>
</div>
	<?php 
    if ($is_unpurchasable != 'on') {
        ?>
		<div id="golb-fr-qty" class="golb-fr-boxes-n">Qty: <input id="go_qty" style="width: 40px;font-size: 11px; margin-right:0px; margin-top: 0px; bottom: 3px; position: relative;" value="1" disabled="disabled" /></div>
		<div id="golb-fr-buy" class="golb-fr-boxes-<?php 
        echo $buy_color;
        ?>
" onclick="goBuytheItem( '<?php 
        echo $the_id;
        ?>
', '<?php 
        echo $buy_color;
        ?>
', '<?php 
        echo $purchase_count;
        ?>
' ); this.removeAttribute( 'onclick' );">Buy</div>
		<div id="golb-fr-purchase-limit" val="<?php 
        echo !empty($purchase_limit) ? $purchase_limit : 0;
        ?>
"><?php 
        echo !empty($purchase_limit) ? "Limit {$purchase_limit}" : 'No limit';
        ?>
</div>
		<div id="golb-purchased">
		<?
		if ( is_null( $purchase_count ) ) { 
			echo 'Quantity purchased: 0';
		} else {
			echo "Quantity purchased: {$purchase_count}";
		} 
	}
	 if ( ! empty( $item_focus ) && ! empty( $penalty ) && $is_giftable == 'on' ) {
	 ?>
 		<br />
		Gift this item <input type='checkbox' id='go_toggle_gift_fields'/>
        <div id="go_recipient_wrap" class="golb-fr-boxes-giftable">Gift To: <input id="go_recipient" type="text"/></div>
        <div id="go_search_results"></div> 
     <script>   
		var go_gift_check_box = jQuery( "#go_toggle_gift_fields" );
		var go_gift_text_box = jQuery( "#go_recipient_wrap" );
		go_gift_text_box.prop( "hidden", true );
		go_gift_check_box.click( function() {
			if ( jQuery( this ).is( ":checked" ) ) {
				go_gift_text_box.prop( "hidden", false );
			} else {
				go_gift_text_box.prop( "hidden", true );
				jQuery( '#go_search_results' ).hide();
				jQuery( "#go_recipient" ).val( '' );
			}
		});
	</script>
    
	<?php 
    }
    ?>
	</div>
	<?php 
    die;
}
コード例 #8
0
function go_the_lb_ajax()
{
    check_ajax_referer('go_lb_ajax_referall', 'nonce');
    global $wpdb;
    $table_name_go = $wpdb->prefix . "go";
    $the_id = $_POST["the_item_id"];
    $the_post = get_post($the_id);
    $the_title = $the_post->post_title;
    $item_content = get_post_field('post_content', $the_id);
    $the_content = wpautop($item_content);
    $custom_fields = get_post_custom($the_id);
    if (isset($custom_fields['go_mta_penalty_switch'])) {
        $penalty = true;
    }
    $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];
    }
    $store_filter = unserialize($custom_fields['go_mta_store_filter'][0]);
    $is_filtered = $store_filter[0];
    if ($is_filtered) {
        $req_rank = $store_filter[1];
        $bonus_filter = $store_filter[2] . length > 0 ? (int) $store_filter[2] : null;
        $penalty_filter = $store_filter[3] . length > 0 ? (int) $store_filter[3] : null;
    }
    $store_limit = unserialize($custom_fields['go_mta_store_limit'][0]);
    $is_limited = $store_limit[0];
    if ($is_limited == 'true') {
        $purchase_limit = $store_limit[1];
    }
    $user_id = get_current_user_id();
    $user_points = go_return_points($user_id);
    $user_bonus_currency = go_return_bonus_currency($user_id);
    $user_currency = go_return_currency($user_id);
    $user_penalties = go_return_penalty($user_id);
    $purchase_count = $wpdb->get_var("SELECT SUM(count) FROM {$table_name_go} WHERE post_id={$the_id} AND uid={$user_id} LIMIT 1");
    echo '<h2>' . $the_title . '</h2>';
    echo '<div id="go-lb-the-content">' . do_shortcode($the_content) . '</div>';
    if ($user_points >= $req_rank || $req_rank <= 0 || $penalty) {
        $lvl_color = "g";
    } else {
        $lvl_color = "r";
    }
    if ($user_currency >= $req_currency || $req_currency <= 0 || $penalty) {
        $gold_color = "g";
    } else {
        $gold_color = "r";
    }
    if ($user_points >= $req_points || $req_points <= 0 || $penalty) {
        $points_color = "g";
    } else {
        $points_color = "r";
    }
    if ($user_bonus_currency >= $req_bonus_currency || $req_bonus_currency <= 0 || $penalty) {
        $bonus_currency_color = "g";
    } else {
        $bonus_currency_color = "r";
    }
    if ($lvl_color == "g" && $gold_color == "g" && $points_color == "g") {
        $buy_color = "g";
    } else {
        $buy_color = "r";
    }
    $user_focuses = array();
    if ($is_filtered === 'true' && !is_null($penalty_filter) && $user_penalties >= $penalty_filter) {
        $penalty_diff = $user_penalties - $penalty_filter;
        if ($penalty_diff > 0) {
            die("You have {$penalty_diff} too many " . go_return_options('go_penalty_name') . ".");
        } else {
            if ($penalty_diff == 0) {
                die("You need less than {$penalty_filter} " . go_return_options('go_penalty_name') . " to buy this item.");
            }
        }
    }
    // Check if user has a focus
    if (get_user_meta($user_id, 'go_focus', true) != null) {
        $user_focuses = (array) get_user_meta($user_id, 'go_focus', true);
    }
    // Check if the item has a focus and the focus gateway is turned on
    if ($custom_fields['go_mta_focuses'][0] && $custom_fields['go_mta_focus_item_switch'][0] == 'on') {
        $item_focus = $custom_fields['go_mta_focuses'][0];
    }
    // If user has the focus and the item is a focus gateway echo this
    if ($item_focus && !empty($user_focuses) && in_array($item_focus, $user_focuses)) {
        die('You already have this ' . go_return_options('go_focus_name') . '!');
    }
    if ($is_filtered === 'true' && !is_null($bonus_filter) && $user_bonus_currency < $bonus_filter) {
        die('You require more ' . go_return_options('go_bonus_currency_name') . ' to view this item.');
    }
    if (!empty($purchase_limit) && $purchase_count >= $purchase_limit) {
        die("You've reached the maximum purchase limit.");
    }
    if ($user_points < $req_rank) {
        die("You need to reach {$req_rank_key} to purchase this item.");
    }
    ?>
	<div id="golb-fr-price" class="golb-fr-boxes-<?php 
    echo $gold_color;
    ?>
" req="<?php 
    echo $req_currency;
    ?>
" cur="<?php 
    echo $user_currency;
    ?>
"><?php 
    echo go_return_options('go_currency_name') . ': ' . $req_currency;
    ?>
</div>
	<div id="golb-fr-points" class="golb-fr-boxes-<?php 
    echo $points_color;
    ?>
" req="<?php 
    echo $req_points;
    ?>
" cur="<?php 
    echo $user_points;
    ?>
"><?php 
    echo go_return_options('go_points_name') . ': ' . $req_points;
    ?>
</div>
	<div id="golb-fr-bonus_currency" class="golb-fr-boxes-<?php 
    echo $bonus_currency_color;
    ?>
" req="<?php 
    echo $req_bonus_currency;
    ?>
" cur="<?php 
    echo $user_bonus_currency;
    ?>
"><?php 
    echo go_return_options('go_bonus_currency_name') . ': ' . $req_bonus_currency;
    ?>
</div>
	<div id="golb-fr-qty" class="golb-fr-boxes-g">Qty: <input id="go_qty" style="width: 40px;font-size: 11px; margin-right:0px; margin-top: 0px; bottom: 3px; position: relative;" value="1" disabled="disabled" /></div>
	<?php 
    if (!$item_focus && !$penalty) {
        ?>
        <div id="go_recipient_wrap" class="golb-fr-boxes-g">Recipient: <input id="go_recipient" type="text"/></div>
        <div id="go_search_results"></div>
	<?php 
    }
    ?>
	<div id="golb-fr-buy" class="golb-fr-boxes-<?php 
    echo $buy_color;
    ?>
" onclick="goBuytheItem('<?php 
    echo $the_id;
    ?>
', '<?php 
    echo $buy_color;
    ?>
', '<?php 
    echo $purchase_count;
    ?>
'); this.removeAttribute('onclick');">Buy</div>
	<div id="golb-fr-purchase-limit" val="<?php 
    echo $purchase_limit;
    ?>
"><?php 
    if ($purchase_limit == 0) {
        echo 'No limit';
    } else {
        echo 'Limit ' . $purchase_limit;
    }
    ?>
 </div>
	<div id="golb-purchased">
	<?php 
    if (is_null($purchase_count)) {
        echo 'Quantity purchased: 0';
    } else {
        echo "Quantity purchased: {$purchase_count}";
    }
    ?>
	</div>
	<?php 
    die;
}
コード例 #9
0
ファイル: go_stats.php プロジェクト: zetheroth/game-on
function go_return_user_data($id, $counter, $sort)
{
    $points = go_return_points($id);
    $currency = go_return_currency($id);
    $bonus_currency = go_return_bonus_currency($id);
    $badge_count = go_return_badge_count($id);
    $user_data_key = get_userdata($id);
    $user_display = "<a href='{$user_data_key->user_url}' target='_blank'>{$user_data_key->display_name}</a>";
    switch ($sort) {
        case 'points':
            echo "<li>{$counter} {$user_display} <div class='go_stats_amount'>{$points}</div></li>";
            break;
        case 'currency':
            echo "<li>{$counter} {$user_display} <div class='go_stats_amount'>{$currency}</div></li>";
            break;
        case 'bonus_currency':
            echo "<li>{$counter} {$user_display} <div class='go_stats_amount'>{$bonus_currency}</div></li>";
            break;
        case 'badges':
            echo "<li>{$counter} {$user_display} <div class='go_stats_amount'>{$badge_count}</div></li>";
            break;
    }
}