Example #1
0
 function cp_modules_mypoints_admin()
 {
     echo '<div class="wrap">';
     echo '<h2>CubePoints - ' . __('My Points', 'cp') . '</h2>';
     echo __('Manage and view information about your points.', 'cp');
     echo '<br /><br />';
     echo '<div style="background:#EFEFEF;display:inline-block;margin-right:25px;"><div style="float:left;font-size:17px;font-weight:bold;background:#E0E0E0;padding:18px;color:#565656;">' . __('My Points', 'cp') . ':</div><div style="float:left;padding:18px;font-size:20px;">' . cp_getPoints(cp_currentUser()) . '</div></div>';
     if (cp_module_activated('ranks')) {
         echo '<div style="background:#EFEFEF;display:inline-block;"><div style="float:left;font-size:17px;font-weight:bold;background:#E0E0E0;padding:18px;color:#565656;">' . __('My Rank', 'cp') . ':</div><div style="float:left;padding:18px;font-size:20px;">' . cp_module_ranks_getRank(cp_currentUser()) . '</div></div>';
     }
     echo '<div style="clear:both;"></div><br />';
     echo '<p style="font-weight:bold;">' . __('Your recent point transactions:', 'cp') . '</p>';
     cp_show_logs(cp_currentUser(), 15, false);
     echo '</div>';
 }
 function bl_frontend_form_submit_check($post)
 {
     if (isset($post['post_id']) && is_numeric($post['post_id']) && $post['post_id'] != 0) {
         $data = get_option("bepro_listings");
         //check if in-sufficient funds
         $uid = get_current_user_id();
         $current_points = cp_getPoints($uid);
         //if insufficient funds then abort listing save altogether
         if ($current_points == 0) {
             header("Location: " . get_bloginfo("url") . "/?p=" . $data["redirect_need_funds"]);
         }
         //update cubepoint records
         $new_points = $current_points - $data["charge_amount"];
         cp_updatePoints($uid, $new_points);
         cp_log("listing", $uid, -$data["charge_amount"], "Listing payment");
     }
 }
Example #3
0
 function cp_module_pcontent_buy()
 {
     if (!isset($_POST['cp_module_pcontent_pay'])) {
         return;
     }
     $pcontent_enabled = (bool) get_post_meta($_POST['cp_module_pcontent_pay'], 'cp_pcontent_points_enable', 1);
     if (!$pcontent_enabled) {
         return;
     }
     $uid = cp_currentUser();
     global $wpdb;
     $pid = $_POST['cp_module_pcontent_pay'];
     if ((int) $wpdb->get_var("SELECT COUNT(*) FROM " . CP_DB . " WHERE `uid`={$uid} AND `data`={$pid} AND `type`='pcontent'") != 0) {
         return;
     }
     if (!is_user_logged_in()) {
         add_filter('cp_module_pcontent_post_content_' . $_POST['cp_module_pcontent_pay'], create_function('$data', 'return "<p style=\\"color:red;\\">' . get_option('cp_module_pcontent_text_logout') . '</p>";'));
         return;
     }
     if (cp_getPoints(cp_currentUser()) < get_post_meta($_POST['cp_module_pcontent_pay'], 'cp_pcontent_points', 1)) {
         add_filter('cp_module_pcontent_post_content_' . $_POST['cp_module_pcontent_pay'], create_function('$data', 'return "<p style=\\"color:red;\\">' . get_option('cp_module_pcontent_text_insufficient') . '</p>";'));
         return;
     }
     cp_points('pcontent', cp_currentUser(), -get_post_meta($_POST['cp_module_pcontent_pay'], 'cp_pcontent_points', 1), $_POST['cp_module_pcontent_pay']);
     if (get_option('cp_module_pcontent_payauthor')) {
         $post = get_post($_POST['cp_module_pcontent_pay']);
         cp_points('pcontent_author', $post->post_author, get_post_meta($_POST['cp_module_pcontent_pay'], 'cp_pcontent_points', 1), serialize(array($_POST['cp_module_pcontent_pay'], cp_currentUser())));
     }
 }
Example #4
0
				<div class="item-list-tabs no-ajax" id="subnav">
					<ul>
						<?php 
bp_get_options_nav();
?>
					</ul>
				</div>
				
				<?php 
global $bp;
cp_show_logs($bp->displayed_user->id, get_option('bp_points_logs_per_page_cp_bp'), false);
if (get_option('bp_tallyuserpoints_cp_bp')) {
    define('CBALLPTS', $wpdb->prefix . 'usermeta');
    $allpoints = $wpdb->get_var($wpdb->prepare('select sum(`meta_value`) from ' . CBALLPTS . ' where `meta_key`=\'cpoints\''));
    $yourpoints = cp_getPoints($bp->displayed_user->id);
    $yourworth1 = $yourpoints / $allpoints;
    $yourworth2 = $yourworth1 * 100;
    echo '
					<p class="cbbpimgawards" style="padding:20px;">' . __('Points earned by all members is', 'cp_buddypress') . ' ' . number_format($allpoints) . '</p>
					<p class="cbbpimgawards" style="padding:20px;">' . __('Your percentage of all points earned by members is', 'cp_buddypress') . ' ' . number_format($yourworth2, 2, '.', '') . ' %</p>
					';
}
?>
				
				
			</div><!-- #item-body -->
		</div><!-- .padder -->
	</div><!-- #content -->

<?php 
Example #5
0
    /**
     * Section template.
     */
    function section_template()
    {
        ?>
		<?php 
        get_header();
        ?>

			<?php 
        get_sidebar();
        ?>
	<div class="content">
		<div class="padder">

  <script src="http://code.jquery.com/jquery-latest.js"></script>
  <script>
  $(document).ready(function(){
   setTimeout(function(){
  $("div.noticetime").fadeOut("slow", function () {
  $("div.noticetime").remove();
      });
    
}, 2000);
 });
  </script>

		<?php 
        do_action('bp_before_blog_page');
        ?>
		

			<?php 
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                ?>

				<h2 class="pagetitle"><?php 
                the_title();
                ?>
</h2>

				<div id="post-<?php 
                the_ID();
                ?>
" <?php 
                post_class();
                ?>
> <?php 
                $sql = "alter table wp_cp add column status INT";
                $rt = mysql_query($sql);
                global $wpdb;
                if (!is_user_logged_in()) {
                    $page_id = get_the_ID();
                    $current_user = wp_get_current_user();
                    $page_title = get_the_title($page_id);
                    $page_id_manual = $wpdb->get_var("SELECT post_parent FROM wp_posts WHERE post_title = '{$page_title}' order by id desc limit 1 ");
                    $table_name = $wpdb->prefix . "cp";
                    $table_name_meta = $wpdb->prefix . "postmeta";
                    global $current_user;
                    $user_id = $current_user->ID;
                    $sum = $wpdb->get_var("SELECT meta_value FROM wp_postmeta WHERE meta_key='sum' and post_id= '{$page_id_manual}' ");
                    echo $sum;
                    echo '<div class="entry">';
                    the_content(__('<p class="serif">Read the rest of this page &rarr;</p>', 'buddypress'));
                    ?>

						<?php 
                    wp_link_pages(array('before' => '<div class="page-link"><p>' . __('Pages: ', 'buddypress'), 'after' => '</p></div>', 'next_or_number' => 'number'));
                    ?>
						<?php 
                    edit_post_link(__('Edit this page.', 'buddypress'), '<p class="edit-link">', '</p>');
                } else {
                    $page_id = get_the_ID();
                    $current_user = wp_get_current_user();
                    $page_title = get_the_title($page_id);
                    $page_id_manual = $wpdb->get_var("SELECT post_parent FROM wp_posts WHERE post_title = '{$page_title}' order by id desc limit 1 ");
                    $table_name = $wpdb->prefix . "cp";
                    $table_name_meta = $wpdb->prefix . "postmeta";
                    global $current_user;
                    $user_id = $current_user->ID;
                    $sum = $wpdb->get_var("SELECT meta_value FROM wp_postmeta WHERE meta_key='sum' and post_id= '{$page_id_manual}' ");
                    echo $sum;
                    $test = (int) $wpdb->get_var("SELECT count(*) FROM {$table_name} WHERE uid = '{$user_id}' AND  data = '{$page_title}' ");
                    $points = cp_getPoints($user_id);
                    if ($test == 0) {
                        $test_b = (int) $wpdb->get_var("SELECT count(*) FROM {$table_name} WHERE uid = '{$user_id}' AND  data = '{$page_title}' ");
                        if ($test == 0) {
                            global $wpdb;
                            $page_id = get_the_ID();
                            $page_title = get_the_title($page_id);
                            $table_name_meta = $wpdb->prefix . "postmeta";
                            global $current_user;
                            $current_user = wp_get_current_user();
                            $user_id = $current_user->ID;
                            $xp_value_e = $wpdb->get_var("SELECT meta_value FROM wp_postmeta WHERE post_id = '{$page_id}' AND meta_key =  'xp_e'");
                            echo '<div class="noticetime"><div class="notice-wrap"><div class="notice-item-wrapper"><div style="" class="notice-item notice"><div class="notice-item-close">×</div><p>+' . $xp_value_e . '</p></div></div></div></div>';
                            $time = date('m/d@H:i', current_time('timestamp', 0));
                            $wpdb->insert('wp_cp', array('timestamp' => time(), 'uid' => $user_id, 'points' => $xp_value_e, 'data' => $page_title, 'type' => "Quest", 'status' => 1), array('%s', '%s', '%s'));
                            $wpdb->insert('wp_class_cur_log', array('uid' => $user_id, 'quest' => $page_title, 'enc' => $time), array('%s', '%s', '%s'));
                            update_user_meta($user_id, 'cpoints', $points + $xp_value_e);
                        }
                    }
                    $stat = (int) $wpdb->get_var("SELECT status FROM wp_cp WHERE uid = '{$user_id}' AND  data = '{$page_title}' ");
                    if (isset($gold_clicked)) {
                        $stat = 2;
                    }
                    $gold_clicked = $_POST['pc_gold_b'];
                    if (isset($gold_clicked)) {
                        $stat_a = (int) $wpdb->get_var("SELECT status FROM wp_cp WHERE uid = '{$user_id}' AND  data = '{$page_title}' ");
                        if ($stat_a == 1) {
                            global $wpdb;
                            $page_id = get_the_ID();
                            $page_title = get_the_title($page_id);
                            $current_user = wp_get_current_user();
                            $user_id = $current_user->ID;
                            $time = date('m/d@H:i', current_time('timestamp', 0));
                            $xp_value_a = $wpdb->get_var("SELECT meta_value FROM wp_postmeta WHERE post_id = '{$page_id}' AND meta_key =  'xp_a'");
                            $xp_value_e = $wpdb->get_var("SELECT meta_value FROM wp_postmeta WHERE post_id = '{$page_id}' AND meta_key =  'xp_e'");
                            $xp_value_ae = $xp_value_a - $xp_value_e;
                            echo '<div class="noticetime"><div class="notice-wrap"><div class="notice-item-wrapper"><div style="" class="notice-item notice"><div class="notice-item-close">×</div><p>+' . $xp_value_ae . '</p></div></div></div></div>';
                            $wpdb->update('wp_cp', array('timestamp' => time(), 'points' => $xp_value_a, 'type' => "Quest", 'data' => $page_title, 'status' => 2), array(uid => $user_id, data => $page_title), array('%s', '%s'));
                            $wpdb->update('wp_class_cur_log', array('acc' => $time), array(uid => $user_id, quest => $page_title), array('%s', '%s'));
                            $stat = 2;
                            update_user_meta($user_id, 'cpoints', $points + $xp_value_ae);
                        }
                    }
                    $button_clik = $_POST['add_button'];
                    if (isset($button_clik)) {
                        $stat_c = (int) $wpdb->get_var("SELECT status FROM wp_cp WHERE uid = '{$user_id}' AND  data = '{$page_title}' ");
                        if ($stat_c == 2) {
                            global $wpdb;
                            $page_id = get_the_ID();
                            $page_title = get_the_title($page_id);
                            $current_user = wp_get_current_user();
                            $user_id = $current_user->ID;
                            $time = date('m/d@H:i', current_time('timestamp', 0));
                            $test_c = (int) $wpdb->get_var("select count(*) from wp_cp where uid= {$user_id} and data = '{$page_title}' and status = 3");
                            $xp_value_c = $wpdb->get_var("SELECT meta_value FROM wp_postmeta WHERE post_id = '{$page_id}' AND meta_key =  'xp_c'");
                            $wpdb->update('wp_cp', array('timestamp' => time(), 'points' => $xp_value_c, 'type' => "Quest", 'status' => 3), array(uid => $user_id, data => $page_title), array('%s', '%s'));
                            $wpdb->update('wp_class_cur_log', array('com' => $time), array(uid => $user_id, quest => $page_title), array('%s', '%s'));
                            $xp_value_a = $wpdb->get_var("SELECT meta_value FROM wp_postmeta WHERE post_id = '{$page_id}' AND meta_key =  'xp_a'");
                            $xp_value_ce = $xp_value_c - $xp_value_a;
                            echo '<div class="noticetime"><div class="notice-wrap"><div class="notice-item-wrapper"><div style="" class="notice-item notice"><div class="notice-item-close">×</div><p>+' . $xp_value_ce . '</p></div></div></div></div>';
                            $stat = 3;
                            update_user_meta($user_id, 'cpoints', $points + $xp_value_ce);
                        }
                    }
                    $button_master = $_POST['master'];
                    if (isset($button_master)) {
                        $stat_m = (int) $wpdb->get_var("SELECT status FROM wp_cp WHERE uid = '{$user_id}' AND  data = '{$page_title}' ");
                        if ($stat_m == 3) {
                            global $wpdb;
                            $userlogin = $current_user->user_login;
                            $page_id = get_the_ID();
                            $page_title = get_the_title($page_id);
                            $current_user = wp_get_current_user();
                            $user_id = $current_user->ID;
                            $test_m = (int) $wpdb->get_var("select count(*) from wp_cp where uid= {$user_id} and data = '{$page_title}' and status = 4");
                            $time = date('m/d@H:i', current_time('timestamp', 0));
                            $gold_value_m = (int) $wpdb->get_var("SELECT meta_value FROM wp_postmeta WHERE post_id = '{$page_id}' AND meta_key =  'gold_m'");
                            $xp_value_c = $wpdb->get_var("SELECT meta_value FROM wp_postmeta WHERE post_id = '{$page_id}' AND meta_key =  'xp_c'");
                            $xp_value_m = $wpdb->get_var("SELECT meta_value FROM wp_postmeta WHERE post_id = '{$page_id}' AND meta_key =  'xp_m'");
                            $xp_value_me = $xp_value_m - $xp_value_c;
                            echo '<div class="noticetime"><div class="notice-wrap"><div class="notice-item-wrapper"><div style="" class="notice-item notice"><div class="notice-item-close">×</div><p>+' . $xp_value_me . '</p></div></div></div></div>';
                            $wpdb->update('wp_cp', array('timestamp' => time(), 'type' => "Quest", 'status' => 4, 'points' => $xp_value_m), array(uid => $user_id, data => $page_title), array('%s', '%s'));
                            $wpdb->update('wp_class_cur_log', array('mas' => $time), array(uid => $user_id, quest => $page_title), array('%s', '%s'));
                            $wpdb->insert('wp_class_cur', array('gold' => $gold_value_m, 'gold_reason' => $page_title, 'status' => 4, 'login' => $userlogin, 'timestamp' => $time), array('%s', '%s'));
                            update_user_meta($user_id, 'cpoints', $points + $xp_value_me);
                            $stat = 4;
                            echo '<embed src ="/wp-content/plugins/cube-gold/CashRegister.mp3" hidden="true" autostart="true"></embed>';
                        }
                    }
                    if ($stat == 1) {
                        $value = 'I Accept This Quest';
                        $accept = '<form method="post" action=""> <input name="pc_gold_b" type="submit" value="' . $value . '"/> </form>';
                        echo $accept;
                    } else {
                        echo '<div class="entry">';
                        the_content(__('<p class="serif">Read the rest of this page &rarr;</p>', 'buddypress'));
                        ?>

						<?php 
                        wp_link_pages(array('before' => '<div class="page-link"><p>' . __('Pages: ', 'buddypress'), 'after' => '</p></div>', 'next_or_number' => 'number'));
                        ?>
						<?php 
                        edit_post_link(__('Edit this page.', 'buddypress'), '<p class="edit-link">', '</p>');
                        ?>

   <?php 
                        if ($stat == 2) {
                            ?>

<form method="post" action="">
<input type="submit" value="Complete Quest" name="add_button">
</form>

			<?php 
                        }
                        if ($stat == 3) {
                            ?>

<form method="post" action="">
<input type="submit" value="Master Quest" name="master">
</form>


			<?php 
                        }
                        ?>
 
      <?php 
                    }
                }
                echo '<br />';
                comments_template();
                ?>

<?php 
            }
        }
        ?>

		
	<?php 
        do_action('bp_after_blog_page');
        ?>

        </div><!-- .padder -->

	</div><!-- #content -->
</div>

    <br />
    </div>
    <?php 
        get_footer();
        ?>
	<?php 
    }
Example #6
0
function gold_admin_bar_init()
{
    global $wpdb;
    global $wp_admin_bar;
    $current_user = wp_get_current_user();
    $user_id = $current_user->ID;
    $userlogin = $current_user->user_login;
    $testing = $wpdb->get_var('select option_value from wp_options where option_name = "cp_module_ranks_data"');
    $new = unserialize($testing);
    ksort($new);
    $new_array = array(current($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new));
    reset($new);
    $rank = cp_module_ranks_getRank(cp_currentUser());
    $rank_points = array_search($rank, $new_array);
    $current_rank_points = array_search($rank, $new);
    // Get the sum of the gold, silver, and copper.
    $prev_lvl = $new_array[$rank_points];
    $xp = cp_getPoints($user_id);
    $current_lvl = array_search($next_lvl, $new);
    $next_ranks_points = $new_array[$rank_points + 1];
    $xp_level = array_search($next_ranks_points, $new);
    $xp_left = $xp;
    $percentage_num = $xp - array_search($prev_lvl, $new);
    $percentage_dom = $xp_level - $current_rank_points;
    $percentage = $percentage_num / $percentage_dom * 100;
    reset($new);
    $new = unserialize($testing);
    ksort($new);
    $first_value = next($new);
    $second_value = next($new);
    $third_value = next($new);
    $forth_value = next($new);
    $fifth_value = next($new);
    $sixth_value = next($new);
    $seventh_value = next($new);
    $eaighth_value = next($new);
    $nineth_value = next($new);
    $tenth_value = next($new);
    $eleventh_value = next($new);
    $twelveth_value = next($new);
    $thirteenth_value = next($new);
    $forteenth_value = next($new);
    reset($new);
    if ($percentage == 0) {
        $percentage = 1;
    }
    if ($percentage > 100) {
        $percentage = 100;
    }
    // Is the user sufficiently leveled, or has the bar been disabled?
    if (!is_admin_bar_showing() || !is_user_logged_in()) {
        return;
    }
    $wp_admin_bar->add_menu(array('title' => 'Add', 'href' => false, 'id' => 'gold_links'));
    if (!is_admin_bar_showing() || !is_user_logged_in()) {
        return;
    }
    $wp_admin_bar->add_menu(array('title' => "<div id='prog_bar_admin_box' style='width:120px; padding-top: 7px !important;'><div id=\"progress-bar-2\" class=\"all-rounded\" style=\"\tborder: 2px solid #777777 !important;\n\n\n\n\n\n\n\n\tborder-radius: 8px 8px 8px 8px;\n\n\n\n\n\n\n\n\tclear: none !important;\n\n\n\n\n\n\n\n\tmargin-bottom: 0 !important;\n\n\n\n\n\n\n\n\tpadding: 0 !important;\">\n\n\n\n\n\n\n\n\n\t<div id\n\n\n\n\n\n\n\n\t=\"progress-bar-percentage\" class=\"all-rounded\" style=\"\n\n\n\n\n\n\n\n\t-webkit-border-radius: 5px;\n\n\n\n\n\n\n\n    -moz-border-radius: 5px;\n\n\n\n\n\n\n\n    border-radius: 5px;\n\n\n\n\n\n\n\n\tborder-bottom-width:100%; \n\n\n\n\n\n\n\n\tpadding: 5px 0px;\n\n\n\n\n\n\n\n \tcolor: #FFF;\n\n\n\n\n\n\n\n \tfont-weight: bold;\n\n\n\n\n\n\n\n\tbackground-color:#ff6600;\n\n\n\n\n\n\n\n \ttext-align: center; width: " . $percentage . "%\">\n\n\n\n\n\n\n\n\t</div></div></div>", 'href' => false, 'id' => 'prog_bar_links'));
    /**
     * Add the submenu links.
     */
    $wp_admin_bar->add_menu(array('title' => '







<form action = "" method="post">







<div style="background: url(/wp-content/plugins/cube-gold/images/clock.png); width: 34px; height: 34px; float:left; margin-right:2px;"></div><input type="text" name = "minutes_admin" style="margin-top:8px; margin-left: 6px; width: 25px;" />  







for:<input type="text" name = "minutes_reason_admin" style="width: 145px; margin-left: 6px;"  />















<br />















<div style="background: url(/wp-content/plugins/cube-gold/images/xp.png); width: 32px; height: 23px; float:left; margin-top: 10px;"></div> <input type="text" name = "xp_admin"  style="width:25px; margin-top: 11px; margin-left: 7px; margin-right: 2px;" />  







 for:<input type="text" name = "xp_reason_admin" style="width: 145px; margin-left: 6px;"  />







 







<br />















<div style="background: url(/wp-content/plugins/cube-gold/images/gold-icon.png); width: 33px; height: 37px; float:left;"></div> <input type="text" name = "gold_admin"  style="width:25px; margin-top: 11px; margin-left: 7px; margin-right: 2px;" />  







 for:<input type="text" name = "gold_reason_admin" style="width: 145px; margin-left: 6px;"  />







 







<br />















<form action="" method="post"><input style="width: 145px; margin-left: 6px;" type="submit" value="Add" /></form>







          ', 'href' => false, 'parent' => 'gold_links'));
    $gold_sum = (int) $wpdb->get_var("select sum(gold) from wp_class_cur where login = '******'");
    $minutes_sum = (int) $wpdb->get_var("select sum(minutes) from wp_class_cur where login = '******'");
    $period_count_check_three = (int) $wpdb->get_var("select count(*) from wp_total_cur where id = {$user_id} and period_one != 0 and period_two != 0 and period_three != 0");
    if ($period_count_check_three != 0) {
        $period_count = 3;
    } else {
        $period_count_check_two = (int) $wpdb->get_var("select count(*) from wp_total_cur where id = {$user_id} and period_one != 0 and period_two != 0");
        if ($period_count_check_two != 0) {
            $period_count = 2;
        } else {
            $period_count = 1;
        }
    }
    $minutes_required = 10800 * $period_count;
    $minutes_percentage_admin = $minutes_sum / $minutes_required * 100;
    $wp_admin_bar->add_menu(array('title' => $rank, 'href' => false, 'parent' => 'prog_bar_links'));
    $wp_admin_bar->add_menu(array('title' => $xp_left . "/" . $xp_level . " (" . floor($percentage) . "%)", 'href' => false, 'parent' => 'prog_bar_links'));
    $wp_admin_bar->add_menu(array('title' => $minutes_sum . '/' . $minutes_required . ' (' . floor($minutes_percentage_admin) . '%)', 'href' => false, 'parent' => 'prog_bar_links'));
    $wp_admin_bar->add_menu(array('title' => $gold_sum . ' Gold', 'href' => false, 'parent' => 'prog_bar_links'));
    $minute_admin = $_POST['minutes_admin'];
    $gold_admin = $_POST['gold_admin'];
    $gold_admin_reason = $_POST['gold_reason_admin'];
    $minutes_admin_reason = $_POST['minutes_reason_admin'];
    $xp_admin_reason = $_POST['xp_reason_admin'];
    $xp_admin = $_POST['xp_admin'];
    if (isset($gold_admin) && isset($gold_admin_reason)) {
        if ($gold_admin != 0) {
            global $wpdb;
            $current_user = wp_get_current_user();
            $userlogin = $current_user->user_login;
            $table_name = $wpdb->prefix . "class_cur";
            $wpdb->insert($table_name, array('gold' => $gold_admin, 'gold_reason' => $gold_admin_reason, 'login' => $userlogin, 'timestamp' => date('m/d@H:i', current_time('timestamp', 0))), array('%s', '%s'));
            echo '<embed src ="/wp-content/plugins/cube-gold/CashRegister.mp3" hidden="true" autostart="true"></embed>';
        }
    }
    if (isset($xp_admin) && isset($xp_admin_reason)) {
        if ($xp_admin != 0) {
            global $wpdb;
            $current_user = wp_get_current_user();
            $user_id = $current_user->ID;
            $table_name = $wpdb->prefix . "cp";
            $points = cp_getPoints($user_id);
            $wpdb->insert($table_name, array('points' => $xp_admin, 'data' => $xp_admin_reason, 'uid' => $user_id, 'timestamp' => time(), 'type' => 'addpoints'), array('%s', '%s'));
            update_user_meta($user_id, 'cpoints', $points + $xp_admin);
            echo '<div class="noticetime"><div class="notice-wrap"><div class="notice-item-wrapper"><div style="" class="notice-item notice"><div class="notice-item-close">×</div><p>+' . $xp_admin . '</p></div></div></div></div>';
        }
    }
    if (isset($minute_admin)) {
        if ($minute_admin != 0) {
            global $wpdb;
            $current_user = wp_get_current_user();
            $userlogin = $current_user->user_login;
            $time = date('m/d@H:i', current_time('timestamp', 0));
            $table_name = $wpdb->prefix . "class_cur";
            $wpdb->insert($table_name, array('minutes' => $minute_admin, 'minutes_reason' => $minutes_admin_reason, 'login' => $userlogin, 'timestamp' => $time), array('%s'));
        }
    }
}
Example #7
0
 function cp_module_ranks_getRank($uid)
 {
     return cp_module_ranks_pointsToRank(cp_getPoints($uid));
 }
function lhg_get_karma($uid)
{
    global $lhg_price_db;
    global $lang;
    # 1. look if user is available in transcerse DB
    if ($lang == "de") {
        $sql = "SELECT * FROM `lhgtransverse_users` WHERE wpuid_de = \"" . $uid . "\" ";
    }
    if ($lang != "de") {
        $sql = "SELECT * FROM `lhgtransverse_users` WHERE wpuid = \"" . $uid . "\" ";
    }
    $results = $lhg_price_db->get_results($sql);
    $karma = $results[0]->karma_com + $results[0]->karma_de;
    # 2. default to internal routine
    if ($karma == 0 or $karma == "") {
        $karma = cp_getPoints($uid);
    }
    return $karma;
}
Example #9
0
function cp_add_points_user_update()
{
    header("Content-Type: application/json");
    if (!current_user_can('manage_options') || $_POST['id'] == '' || $_POST['points'] == '' || $_POST['description'] == '') {
        $response = json_encode(array('status' => 'failed'));
        echo $response;
        exit;
    }
    cp_points('addpoints', (int) $_POST['id'], (int) $_POST['points'], htmlentities($_POST['description']));
    $response = json_encode(array('status' => 'ok', 'newpoints' => cp_getPoints((int) $_POST['id'])));
    echo $response;
    exit;
}
Example #10
0
/**
 * CubePoints admin page: manage
 */
function cp_admin_manage()
{
    ?>

	<div class="wrap">
		<h2>CubePoints - <?php 
    _e('Manage', 'cp');
    ?>
</h2>
		<?php 
    _e('Manage the points of your users.', 'cp');
    ?>
<br /><br />
		<div class="updated" id="cp_manage_updated" style="display: none;"></div>
		<?php 
    global $wpdb;
    $results = $wpdb->get_results("SELECT * FROM `" . $wpdb->users . "` ORDER BY user_login ASC");
    ?>

		<table id="cp_manage_table" class="widefat datatables">
			<thead><tr><th scope="col" width="35"></th><th scope="col"><?php 
    _e('User', 'cp');
    ?>
</th><th scope="col" width="120"><?php 
    _e('Points', 'cp');
    ?>
</th><th scope="col" width="180"><?php 
    _e('Update', 'cp');
    ?>
</th></tr></thead>
			<tfoot><tr><th scope="col"></th><th scope="col"><?php 
    _e('User', 'cp');
    ?>
</th><th scope="col"><?php 
    _e('Points', 'cp');
    ?>
</th><th scope="col"><?php 
    _e('Update', 'cp');
    ?>
</th></tr></tfoot>
		
			<?php 
    foreach ($results as $result) {
        $user = get_userdata($result->ID);
        $username = $user->user_login;
        $user_nicename = $user->display_name;
        $gravatar = get_avatar($result->ID, $size = '32');
        ?>
				<tr>
					<td>
						<?php 
        echo $gravatar;
        ?>
					</td>
					<td title="<?php 
        echo $user_nicename;
        ?>
">
						<strong><?php 
        echo $username;
        ?>
</strong><br /><i><?php 
        echo $user->user_email;
        ?>
</i>
					</td>
					<td class="cp_manage_form_points">
						<span id="cp_manage_form_points_<?php 
        echo $result->ID;
        ?>
"><?php 
        cp_displayPoints($result->ID);
        ?>
</span>
					</td>
					<td class="cp_manage_form_update">
						<form method="post" name="cp_manage_form_<?php 
        echo $result->ID;
        ?>
" id="cp_manage_form_<?php 
        echo $result->ID;
        ?>
">
							<input type="hidden" name="cp_manage_form_id" value="<?php 
        echo $result->ID;
        ?>
" />
							<input type="text" name="cp_manage_form_points" value="<?php 
        echo cp_getPoints($result->ID);
        ?>
" />
							<input type="submit" value="<?php 
        _e('Update', 'cp');
        ?>
" />
							<img src="<?php 
        echo WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . 'assets/load.gif';
        ?>
" style="display: none;" />
						</form>
					</td>
				</tr>
			<?php 
    }
    ?>
		</table>
		
	</div>

		<script type="text/javascript">
		jQuery(document).ready(function() {
		
			jQuery(".cp_manage_form_update form").submit(function() {
				user_id = jQuery(this).children('input[name=cp_manage_form_id]').val();
				points = jQuery(this).children('input[name=cp_manage_form_points]').val();
				submit = jQuery(this).children('input[type=submit]');
				loadImg = jQuery(this).children('img');
				
				jQuery(".cp_manage_form_update form").children('input').attr('disabled', true);
				submit.hide();
				loadImg.css('display', 'inline-block');
				jQuery(this).children('input[name=cp_manage_form_points]').attr('readonly', true);
				jQuery('#cp_manage_form_points_'+user_id).hide(100);

				jQuery.post(
					'<?php 
    echo bloginfo('url') . '/wp-admin/admin-ajax.php';
    ?>
', 
					{ 
						action: 'cp_manage_form_submit',
						user_id: user_id, 
						points: points
					},
					function(data,status){
						if(status!='success'){
							message = '<?php 
    _e('Connection problem. Please check that you are connected to the internet.', 'cp');
    ?>
';
						} else if(data.error!='ok') {
							message = data.error;
						} else {
							jQuery("#cp_manage_form_points_"+user_id).html(data.points_formatted);
							jQuery("#cp_manage_form_points_"+user_id).show(100);
							jQuery('#cp_manage_form_'+data.user_id).children('input[name=cp_manage_form_points]').val(data.points);
							jQuery('#cp_manage_form_'+data.user_id).children('input[name=cp_manage_form_points]').removeAttr('readonly');
							message = '<?php 
    _e("Points updated for", 'cp');
    ?>
' + ' "' + data.username + '"';
						}
						jQuery("#cp_manage_updated").html('<p><strong>'+message+'</strong></p>');
						jQuery("#cp_manage_updated").show(100);
						loadImg.hide();
						submit.show();
						jQuery(".cp_manage_form_update form").children('input').removeAttr('disabled');
					},
					"json"
				);
				return false;
			});
			
			jQuery('#cp_manage_table').dataTable({
				"bStateSave": true,
				"bSort": false,
				"aoColumns": [  { "bSearchable": false },{},{},{ "bSearchable": false } ]
			});
			
		});

		</script>
		
	<?php 
    do_action('cp_admin_manage');
    ?>
	
<?php 
}
Example #11
0
function cube_points_gold_widget()
{
    global $wpdb;
    $current_user = wp_get_current_user();
    $userlogin = $current_user->user_login;
    echo '<script src="http://code.jquery.com/jquery-latest.js"></script>
  <script>
  $(document).ready(function(){
   setTimeout(function(){
  $("div.noticetime").fadeOut("slow", function () {
  $("div.noticetime").remove();
      });
    
}, 2000);
 });
  </script> ';
    ?>
	<table>
<form action = "" method="post">
<div style="background: url(/wp-content/plugins/cube-gold/images/clock.png); width: 34px; height: 34px; float:left; margin-right:2px;"></div><input type="text" name = "minutes" style="margin-top:8px; margin-left: 6px; width: 25px;" />  
for:<input type="text" name = "minutes_reason" style="width: 145px; margin-left: 6px;"  />

<br />
<br />
<div style="background: url(/wp-content/plugins/cube-gold/images/xp.png); width: 32px; height: 23px; float:left; margin-top: 10px;"></div> <input type="text" name = "xp"  style="width:25px; margin-top: 11px; margin-left: 7px; margin-right: 2px;" />  
 for:<input type="text" name = "xp_reason" style="width: 145px; margin-left: 6px;"  />
 
<br />
<br />
<div style="background: url(/wp-content/plugins/cube-gold/images/gold-icon.png); width: 33px; height: 37px; float:left;"></div> <input type="text" name = "gold"  style="width:25px; margin-top: 11px; margin-left: 7px; margin-right: 2px;" />  
 for:<input type="text" name = "gold_reason" style="width: 145px; margin-left: 6px;"  />
 
<br />
<br />

<?php 
    /*
    <div style="background: url(/wp-content/plugins/cube-gold/images/gold-icon.png); width: 33px; height: 37px; float:left; background-position: -32px 0px;"></div> <input type="text" name = "silver" style="width:25px; margin-top: 11px; margin-left: 6px; margin-right: 2px;" />
    for: <input type="text" name = "silver_reason" style="width: 93px; margin-left: 4px;"  />
    
    <br />
    <br />
    
    <div style="background: url(/wp-content/plugins/cube-gold/images/gold-icon.png); width: 33px; height: 37px; float:left; background-position: -65px 0px;"></div> 
    <input type="text" name = "copper" style="width:25px; margin-top: 11px; margin-left: 6px; margin-right: 2px;"  />
    for: <input type="text" name = "copper_reason" style="width: 93px; margin-left: 4px;"   />
    
    <br />
    <br />
    */
    ?>


<form action="" method="post"><input type="submit" value="Add" /></form>
          </table>
        
 <?php 
    $minute = $_POST['minutes'];
    $gold = $_POST['gold'];
    $gold_reason = $_POST['gold_reason'];
    $minutes_reason = $_POST['minutes_reason'];
    $xp_reason = $_POST['xp_reason'];
    $xp = $_POST['xp'];
    /*$silver = $_POST['silver'];
    $silver_reason= $_POST['silver_reason'];
    $copper = $_POST['copper'];
    $copper_reason = $_POST['copper_reason']; */
    if (isset($gold) && isset($gold_reason)) {
        if ($gold != 0) {
            global $wpdb;
            $current_user = wp_get_current_user();
            $userlogin = $current_user->user_login;
            $table_name = $wpdb->prefix . "class_cur";
            $wpdb->insert($table_name, array('gold' => $gold, 'gold_reason' => $gold_reason, 'login' => $userlogin, 'timestamp' => date('m/d@H:i', current_time('timestamp', 0))), array('%s', '%s'));
            echo '<embed src ="/wp-content/plugins/cube-gold/CashRegister.mp3" hidden="true" autostart="true"></embed>';
        }
    }
    if (isset($xp) && isset($xp_reason)) {
        if ($xp != 0) {
            global $wpdb;
            $current_user = wp_get_current_user();
            $user_id = $current_user->ID;
            $table_name = $wpdb->prefix . "cp";
            $points = cp_getPoints($user_id);
            $wpdb->insert($table_name, array('points' => $xp, 'data' => $xp_reason, 'uid' => $user_id, 'timestamp' => time(), 'type' => 'addpoints'), array('%s', '%s'));
            update_user_meta($user_id, 'cpoints', $points + $xp);
            echo '<div class="noticetime"><div class="notice-wrap"><div class="notice-item-wrapper"><div style="" class="notice-item notice"><div class="notice-item-close">×</div><p>+' . $xp . '</p></div></div></div></div>';
        }
    }
    /*if (isset($silver)&&isset($silver_reason)) {  if ($silver!=0){
    global $wpdb;
    $current_user = wp_get_current_user();
    $userlogin = $current_user->user_login;
    $table_name = $wpdb->prefix . "class_cur" ;
    $wpdb->insert( $table_name, array( 'silver' => $silver,'silver_reason' => $silver_reason, 'login' => $userlogin), array( '%s','%s'));} }
    if (isset($copper)&&isset($copper_reason)) {  if ($copper!=0){
    global $wpdb;
    $current_user = wp_get_current_user();
    $userlogin = $current_user->user_login;
    $table_name = $wpdb->prefix . "class_cur" ;
    $wpdb->insert( $table_name, array(  'copper' => $copper,'copper_reason' => $copper_reason, 'login' => $userlogin), array( '%s','%s'));} }*/
    if (isset($minute)) {
        if ($minute != 0) {
            global $wpdb;
            $current_user = wp_get_current_user();
            $userlogin = $current_user->user_login;
            $time = date('m/d@H:i', current_time('timestamp', 0));
            $table_name = $wpdb->prefix . "class_cur";
            $wpdb->insert($table_name, array('minutes' => $minute, 'minutes_reason' => $minutes_reason, 'login' => $userlogin, 'timestamp' => $time), array('%s', '%s'));
        }
    }
}
function lhg_donation_table_shortcode_singe_language($attr)
{
    global $region;
    global $top_users;
    global $donation;
    global $txt_cp_title;
    global $txt_cp_karma;
    global $txt_cp_points;
    global $txt_cp_donates_to;
    global $txt_cp_longtext;
    global $txt_cp_language;
    # before we create the table we update the data in the transverse DB
    lhg_update_karma_values('quarterly');
    # How many users to show for ongoing quarter
    $max_users_to_show = 10;
    $langurl = lhg_get_lang_url_from_region($region);
    #extract($args, EXTR_SKIP);
    #echo $before_widget;
    //$title = empty($instance['title']) ? '&nbsp;' : apply_filters('widget_title', $instance['title']);
    #$output .='<i class="icon-trophy menucolor"></i>&nbsp;'.$txt_cp_title;
    #if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
    //set default values
    #if($instance['num'] == '' || $instance['num'] == 0) { $instance['num'] = 1; }
    #if($instance['text'] == '') { $instance['text'] = '%user% (%points%)';}
    # Show table of top users of ongoing Quarter
    list($list_uid, $list_points) = cp_getAllQuarterlyPoints();
    #list($list_guid, $list_points_guid) = cp_getAllQuarterlyPoints_transverse();
    #print "<br>Users:";
    #var_dump($list_uid);
    $i = 0;
    if (sizeof($list_uid) > 0) {
        $output .= '<table id="quarterly-points-table">
                <tr id="quarterly-points-header-row">
                  <td class="qrtly-1" id="quarterly-points-1">Quarterly Points</td>
                  <td class="qrtly-2" id="quarterly-points-2"></td>
                  <td class="qrtly-3" id="quarterly-points-3">Username</td>
                  <td class="qrtly-4" id="quarterly-points-3">Details</td>
                  <td class="qrtly-5" id="quarterly-points-3">Total Karma</td>
                </tr>
                ';
    }
    if (sizeof($list_uid) > 0) {
        foreach ($list_uid as $uid) {
            # skip deleted users
            # skip anonymously added posts, i.e. user = user-submitted-posts
            $user = get_userdata($uid);
            if ($user !== false) {
                if ($uid != 12378) {
                    #var_dump($user);
                    #print sizeof($uid)."<p>";
                    $name = $user->first_name . " " . $user->last_name;
                    $points = $list_points[$i];
                    $avatar = get_avatar($uid, 40);
                    $user_language_txt = lhg_get_locale_from_id($uid);
                    $user_language_flag = lhg_show_flag_by_lang($user_language_txt);
                    $total_karma = cp_getPoints($uid);
                    //$num_com * 3 + $num_art * 50;
                    //registration date
                    $regdate = date("d. M Y", strtotime(get_userdata($uid)->user_registered));
                    //donates to
                    $donation_target = get_user_meta($uid, 'user_donation_target', true);
                    if ($donation_target == "") {
                        $donation_target = 1;
                    }
                    //print_r($y);
                    //if ($langurl != "") $langurl = "/".$langurl;
                    #print "Name: ".$user->user_nicename." ($uid) - $points<br>";
                    $output .= '<tr>

<td class="qrtly-1" >
	    <div class="userlist-place-quarter">' . $points . ' ' . $txt_cp_points . '
    	    </div>
</td>


<td class="quartery-points-avatar qrtly-2">
<a href="./hardware-profile/user' . $uid . '" class="recent-comments">
    <div class="userlist-avatar">' . $avatar . '
    </div>
</a>
</td>


<td class="qrtly-3">
          <div class="userlist-displayname">
		<a href="./hardware-profile/user' . $uid . '" class="recent-comments">
	            	' . $user->nickname . '
                </a>

          </div>
</td>


<td class="qrtly-4">
    <div class="quarterly-points-userlist-details">
      ' . $txt_cp_donates_to . ': ' . $donation[$donation_target]["Name"] . '<br>
      ' . $txt_cp_language . ': ' . $user_language_flag . '
    </div>
</td>

<td class="qrtly-5">
          <div class="quartly-points-totalpoints">
	     ' . $total_karma . ' ' . $txt_cp_points . '<br>
          </div>
</td>


</tr>';
                }
            }
            $i++;
            if ($i > $max_users_to_show) {
                break;
            }
        }
    }
    if (sizeof($list_uid) > 0) {
        $output .= "</table>";
    }
    return $output;
}
Example #13
0
    function attendence()
    {
        global $wpdb;
        $period = $_POST['Period'];
        $order_choice = $_POST['order'];
        if ($period != 0) {
            $wpdb->update('wp_class_cur', array(period_choice => $period), array(id => 1), array('%s'));
        }
        if ($order_choice != 0) {
            $wpdb->update('wp_class_cur', array(order_choice => $order_choice), array(id => 1), array('%s'));
            if ($order_choice == 1) {
                $order = 'temp_comp';
            } else {
                if ($order_choice == 2) {
                    $order = 'login';
                } else {
                    if ($order_choice == 3) {
                        $order = 'first_name';
                    } else {
                        if ($order_choice == 4) {
                            $order = 'last_name';
                        } else {
                            if ($order_choice == 5) {
                                $order = 'totalxp';
                            }
                        }
                    }
                }
            }
        }
        $stored_period = (int) $wpdb->get_var("SELECT period_choice  FROM wp_class_cur where id=1");
        $stored_order = (int) $wpdb->get_var("SELECT order_choice  FROM wp_class_cur where id=1");
        if ($stored_order == 1) {
            $order = 'temp_comp';
        } else {
            if ($stored_order == 2) {
                $order = 'id';
            } else {
                if ($stored_order == 3) {
                    $order = 'first_name';
                } else {
                    if ($stored_order == 4) {
                        $order = 'last_name';
                    } else {
                        if ($stored_order == 5) {
                            $order = 'xp';
                        }
                    }
                }
            }
        }
        ?>

<br />
<br />
<form method="post" action="" >
Period: <select name="Period"  onchange="form.submit()" >
  <option value="<?php 
        echo $stored_period;
        ?>
"><?php 
        echo $stored_period;
        ?>
</option>
  <option value="1">Period 1</option>
  <option value="2">Period 2</option>
  <option value="3">Period 3</option>
  <option value="4">Period 4</option>
  <option value="5">Period 5</option>
  <option value="6">Period 6</option>
  <option value="7">Period 7</option>
</select>
Order By: <select name="order"  onchange="form.submit()" >
  <option value="<?php 
        echo $stored_order;
        ?>
"><?php 
        echo $order;
        ?>
</option>
  <option value="1">comp</option>
  <option value="2">id</option>
  <option value="3">first name</option>
  <option value="4">last name</option>
  <option value="5">xp</option>
</select>
<input type="submit" value="Collect Data" name="collect"/>
</form>

<br />
<?php 
        global $wpdb;
        $upload_data = $_POST['collect'];
        if (isset($upload_data)) {
            global $wpdb;
            $students_login = $wpdb->get_results("SELECT DISTINCT user_id FROM  wp_usermeta where meta_key like 'wp_capabilities' and meta_value like '%student%'");
            foreach ($students_login as $login) {
                foreach ($login as $user_id) {
                    $user_info = get_userdata($user_id);
                    $user_login = $user_info->user_login;
                    global $wpdb;
                    $table_name_b = $wpdb->prefix . "total_cur";
                    $query = "select id from {$table_name_b} where id='{$user_id}'";
                    $query_run = mysql_query($query);
                    if (mysql_num_rows($query_run) == 0) {
                        $rows_affected = $wpdb->insert('wp_total_cur', array('login' => $user_login, 'id' => $user_id));
                    }
                    $period_one = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key = 'period' and user_id = '{$user_id}'");
                    $period_two = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key = 'periodtwo' and user_id = '{$user_id}'");
                    $period_three = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key = 'periodthree' and user_id = '{$user_id}'");
                    $comp_one = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key like 'computer' and user_id = '{$user_id}'");
                    $comp_two = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key like 'computertwo' and user_id = '{$user_id}'");
                    $comp_three = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key like computerthree' and user_id = '{$user_id}'");
                    $queryminutes = "SELECT SUM(minutes) FROM wp_class_cur where login = '******'";
                    $resultminutes = mysql_query($queryminutes) or die(mysql_error());
                    $rowminutes = mysql_fetch_array($resultminutes);
                    $totalminutes = $rowminutes['SUM(minutes)'];
                    $querygold = "SELECT SUM(gold) FROM wp_class_cur where login = '******'";
                    $resultgold = mysql_query($querygold) or die(mysql_error());
                    $rowgold = mysql_fetch_array($resultgold);
                    $gold_rnd = $rowgold['SUM(gold)'];
                    $xp = cp_getPoints($user_id);
                    $first_name = $user_info->user_firstname;
                    $last_name = $user_info->user_lastname;
                    $table_name_b = $wpdb->prefix . "total_cur";
                    $wpdb->update('wp_total_cur', array('totalgold' => $gold_rnd, 'minutes' => $totalminutes, 'totalxp' => $xp, 'period_one' => $period_one, 'period_two' => $period_two, 'period_three' => $period_three, 'computer_one' => $comp_one, 'computer_two' => $comp_two, 'computer_three' => $comp_three, 'first_name' => $first_name, 'last_name' => $last_name), array(id => $user_id), array('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s'), array('%s'));
                }
            }
        }
        $period = $_POST['Period'];
        $order_choice = $_POST['order'];
        global $wpdb;
        ?>

    
<table class="widefat" id="anyid" border="1px" bordercolor="#000000" cellpadding="3px">
<thead> <tr><th width="100px">ID</th>
 <th width="50px">Comp</th>
 <th>Name</th>
<th width="100px">Gamertag</th>
<th width="50px">Gold</th>
<th width="50px">Minutes</th>
<th width="50px">XP</th>
<th width="80px">Encountered</th> 
<th width="80px">Accepted</th> 
<th width="80px">Completed</th> 
<th width="80px">Mastered</th> </tr></thead>
 <?php 
        $studs_id = $wpdb->get_results("SELECT user_id  FROM wp_usermeta where meta_key like '%period%' and meta_value = {$period}");
        foreach ($studs_id as $id_two) {
            foreach ($id_two as $stud_id) {
                global $wpdb;
                $per = $wpdb->get_var("SELECT meta_key  FROM wp_usermeta where meta_key like '%period%' and meta_value = {$period} and user_id = {$stud_id}");
                if ($per == 'period') {
                    $comp = 'computer';
                } else {
                    if ($per == 'periodtwo') {
                        $comp = 'computertwo';
                    } else {
                        if ($per == 'periodthree') {
                            $comp = 'computerthree';
                        }
                    }
                }
                $computer_num = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key = '{$comp}' and user_id = {$stud_id}");
                $wpdb->update('wp_total_cur', array('temp_comp' => $computer_num), array('id' => $stud_id), array('%d'), array('%d'));
            }
        }
        if (isset($_POST['Period'])) {
            $period = $_POST['Period'];
        } else {
            $period = (int) $wpdb->get_var("SELECT period_choice  FROM wp_class_cur where id=1");
        }
        if (isset($_POST['order'])) {
            $order_choice = $_POST['order'];
        } else {
            $order_choice = (int) $wpdb->get_var("SELECT order_choice  FROM wp_class_cur where id=1");
        }
        if ($order_choice == 1) {
            $order = 'temp_comp';
        } else {
            if ($order_choice == 2) {
                $order = 'login';
            } else {
                if ($order_choice == 3) {
                    $order = 'first_name';
                } else {
                    if ($order_choice == 4) {
                        $order = 'last_name';
                    } else {
                        if ($order_choice == 5) {
                            $order = 'totalxp';
                        }
                    }
                }
            }
        }
        $table_name_all_users = $wpdb->prefix . "usermeta";
        $students_id = $wpdb->get_results("SELECT id\nFROM wp_total_cur\nWHERE (period_one ={$period}\nOR period_two ={$period}\nOR period_three = {$period})\norder by {$order}\n");
        $x = 0;
        $pstat_id = (int) $wpdb->get_var("select post_id from wp_postmeta where meta_key = '_wp_page_template' and meta_value = 'page.stats.php'");
        $pstat_link = get_permalink($pstat_id);
        foreach ($students_id as $id) {
            foreach ($id as $student_id) {
                $st_id_ca = (int) $wpdb->get_var("SELECT count(*) FROM wp_usermeta where meta_key = 'wp_capabilities' and meta_value like '%student%' and user_id = {$student_id} ");
                if ($st_id_ca != 0) {
                    $user_info = get_userdata($student_id);
                    $user_login_name = $user_info->user_login;
                    $first_name = $user_info->user_firstname;
                    $last_name = $user_info->user_lastname;
                    $display_name = $user_info->display_name;
                    $date = date('l jS F Y');
                    $gold = (int) $wpdb->get_var("SELECT totalgold FROM wp_total_cur where login = '******'");
                    $silver = (int) $wpdb->get_var("SELECT totalsilver FROM wp_total_cur where login = '******'");
                    $copper = (int) $wpdb->get_var("SELECT totalcopper FROM wp_total_cur where login = '******'");
                    $minutes = (int) $wpdb->get_var("SELECT minutes FROM wp_total_cur where login = '******'");
                    $xp = cp_getPoints($student_id);
                    $per = $wpdb->get_var("SELECT meta_key  FROM wp_usermeta where meta_key like '%period%' and meta_value = {$period} and user_id = {$student_id}");
                    if ($per == 'period') {
                        $comp = 'computer';
                    } else {
                        if ($per == 'periodtwo') {
                            $comp = 'computertwo';
                        } else {
                            if ($per == 'periodthree') {
                                $comp = 'computerthree';
                            }
                        }
                    }
                    $computer_nums = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key = '{$comp}' and user_id = {$student_id}");
                    ?>
 <tr> <td><a href="<?php 
                    echo $pstat_link;
                    ?>
?id=<?php 
                    echo $student_id;
                    ?>
" target="_blank"> <?php 
                    echo $letter[$x] = $user_login_name;
                    ?>
</a> </td><td> <?php 
                    echo $computer_nums;
                    ?>
 </td> <td style="width: 84px;"> <?php 
                    echo $first_name . " " . $last_name;
                    ?>
 </td> <td> <?php 
                    echo $display_name;
                    ?>
 </td><td> <?php 
                    echo $gold;
                    ?>
 </td><td> <?php 
                    echo $minutes;
                    ?>
 </td><td> <?php 
                    echo $xp;
                    ?>
 
</td><td> <?php 
                    $num_enc = (int) $wpdb->get_var("SELECT count(*) FROM wp_cp WHERE  status = 1 and uid = {$student_id}");
                    $num_acc = (int) $wpdb->get_var("SELECT count(*) FROM wp_cp WHERE  status = 2 and uid = {$student_id}");
                    $num_com = (int) $wpdb->get_var("SELECT count(*) FROM wp_cp WHERE  status = 3 and uid = {$student_id}");
                    $num_mas = (int) $wpdb->get_var("SELECT count(*) FROM wp_cp WHERE  status = 4 and uid = {$student_id}");
                    echo '(' . $num_enc . ')';
                    ?>
</td>
       <td> <?php 
                    echo '(' . $num_acc . ')';
                    ?>
</td><td> <?php 
                    echo '(' . $num_com . ')';
                    ?>
</td><td> <?php 
                    echo '(' . $num_mas . ')';
                    ?>
</td>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html><body>

<td style="width: 77px;"> <form method="post" action=""> <input type= "submit" value= "Absent" name= <?php 
                    echo 'ab' . $letter[$x];
                    ?>
 /> <input type="submit" value="Fix" name=<?php 
                    echo 'del_ab_today' . $letter[$x];
                    ?>
  /> </form> </td> <td style="width: 77px;"> <form method="post"> <input type= "submit" value= "Tardy" name= <?php 
                    echo 'ty' . $letter[$x];
                    ?>
 /> <input type="submit" value="Fix" name=<?php 
                    echo 'del_tardy_today' . $letter[$x];
                    ?>
  /> </form></td> <td style="width: 84px;"> <form method="post"> <input type= "submit" value= "Truancy" name= <?php 
                    echo 'tr' . $letter[$x];
                    ?>
 /> <input type="submit" value="Fix" name=<?php 
                    echo 'del_tr_today' . $letter[$x];
                    ?>
  /> </form></td>  <td style="width: 84px;"> <form method="post"> <input type= "submit" value= "Off Task" name= <?php 
                    echo 'ot' . $letter[$x];
                    ?>
 /> <input type="submit" value="Fix" name=<?php 
                    echo 'del_ot_today' . $letter[$x];
                    ?>
  /> </form></td>  </tr>
  <?php 
                    $tardy = $_POST['ty' . $letter[$x]];
                    if (isset($tardy)) {
                        global $wpdb;
                        $table_name_cp = $wpdb->prefix . "class_cur";
                        $wpdb->insert($table_name, array('login' => $user_login_name, 'minutes' => -30, 'minutes_reason' => "Tardy"), array('%s', '%s', '%s'));
                    }
                    $absence = $_POST['ab' . $letter[$x]];
                    if (isset($absence)) {
                        $table_name_user = $wpdb->prefix . "class_cur";
                        $wpdb->insert($table_name_user, array('login' => $user_login_name, 'minutes' => -60, 'minutes_reason' => "Absent"), array('%s', '%s', '%s'));
                    }
                    $delete_absence_today = $_POST['del_ab_today' . $letter[$x]];
                    if (isset($delete_absence_today)) {
                        global $wpdb;
                        $table_name_d = $wpdb->prefix . "class_cur";
                        $wpdb->query("delete from wp_cp where minutes_reason like 'Absent' and uid like {$student_id} limit 1");
                    }
                    $delete_tardy_today = $_POST['del_tardy_today' . $letter[$x]];
                    if (isset($delete_tardy_today)) {
                        global $wpdb;
                        $table_name_d = $wpdb->prefix . "class_cur";
                        $wpdb->query("delete from wp_cp where minutes_reason like 'Tardy' and uid like {$student_id} limit 1");
                    }
                    $truancy = $_POST['tr' . $letter[$x]];
                    if (isset($truancy)) {
                        $table_name_user = $wpdb->prefix . "class_cur";
                        $wpdb->insert($table_name_user, array('login' => $user_login_name, 'minutes' => -180, 'minutes_reason' => "Truant"), array('%s', '%s', '%s'));
                    }
                    $delete_truancy_today = $_POST['del_tr_today' . $letter[$x]];
                    if (isset($delete_truancy_today)) {
                        global $wpdb;
                        $table_name_d = $wpdb->prefix . "class_cur";
                        $wpdb->query("delete from wp_cp where minutes_reason like 'Truancy' and uid like {$student_id} limit 1");
                    }
                    $offtask = $_POST['ot' . $letter[$x]];
                    if (isset($offtask)) {
                        $table_name_user = $wpdb->prefix . "class_cur";
                        $wpdb->insert($table_name_user, array('login' => $user_login_name, 'minutes' => -30, 'minutes_reason' => "Off Task"), array('%s', '%s', '%s'));
                    }
                    $delete_offtask_today = $_POST['del_ot_today' . $letter[$x]];
                    if (isset($delete_offtask_today)) {
                        global $wpdb;
                        $table_name_d = $wpdb->prefix . "class_cur";
                        $wpdb->query("delete from wp_cp where minutes_reason like 'Off Task' and uid like {$student_id} limit 1");
                    }
                    $bonus = $_POST['bns' . $letter[$x]];
                    if (isset($bonus)) {
                        $table_name_user = $wpdb->prefix . "class_cur";
                        $wpdb->insert($table_name_user, array('login' => $user_login_name, 'minutes' => -60, 'minutes_reason' => "Bonus"), array('%s', '%s', '%s'));
                    }
                    $delete_bonus_today = $_POST['del_bns_today' . $letter[$x]];
                    if (isset($delete_offtask_today)) {
                        global $wpdb;
                        $table_name_d = $wpdb->prefix . "class_cur";
                        $wpdb->query("delete from wp_cp where minutes_reason like 'Bonus' and uid like {$student_id} limit 1");
                    }
                    $x = $x + 1;
                }
            }
        }
        ?>
 </table> 




<?php 
    }
Example #14
0
 /**
  * Return any html you want to show on the confirmation screen after checkout. This
  *  should be a payment details box and message.
  *
  * Don't forget to return!
  */
 function order_confirmation_msg($content, $order)
 {
     global $mp;
     $settings = get_option('mp_settings');
     $uid = cp_currentUser();
     $cp_points = '<div id="mp_cp_points">' . __('Your current points: ', 'mp') . cp_getPoints(cp_currentUser()) . '</div>';
     return $cp_points . $content . str_replace('TOTAL', $mp->format_currency($order->mp_payment_info['currency'], $order->mp_payment_info['total']), $settings['gateways']['cubepoints']['confirmation']);
 }
    function widget($args, $instance)
    {
        global $region;
        global $top_users;
        global $donation;
        global $txt_cp_title;
        global $txt_cp_karma;
        global $txt_cp_points;
        global $txt_cp_donates_to;
        global $txt_cp_longtext;
        global $txt_cp_language;
        # How many users to show for ongoing quarter
        $max_users_to_show = 5;
        $langurl = lhg_get_lang_url_from_region($region);
        extract($args, EXTR_SKIP);
        echo $before_widget;
        //$title = empty($instance['title']) ? '&nbsp;' : apply_filters('widget_title', $instance['title']);
        $title = '<i class="icon-trophy menucolor"></i>&nbsp;' . $txt_cp_title;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        //set default values
        if ($instance['num'] == '' || $instance['num'] == 0) {
            $instance['num'] = 1;
        }
        if ($instance['text'] == '') {
            $instance['text'] = '%user% (%points%)';
        }
        # Show table of top users of ongoing Quarter
        list($list_uid, $list_points) = cp_getAllQuarterlyPoints();
        #print "<br>Users:";
        #var_dump($list_uid);
        $i = 0;
        if (sizeof($list_uid) > 0) {
            print '<table id="quarterly-points-table">
                <tr id="quarterly-points-header-row">
                  <td class="qrtly-1" id="quarterly-points-1">Quarterly Points</td>
                  <td class="qrtly-2" id="quarterly-points-2"></td>
                  <td class="qrtly-3" id="quarterly-points-3">Username</td>
                  <td class="qrtly-4" id="quarterly-points-3">Details</td>
                  <td class="qrtly-5" id="quarterly-points-3">Total Points</td>
                </tr>
                ';
        }
        if (sizeof($list_uid) > 0) {
            foreach ($list_uid as $uid) {
                $user = get_userdata($uid);
                $name = $user->first_name . " " . $user->last_name;
                $points = $list_points[$i];
                $avatar = get_avatar($uid, 40);
                $user_language_txt = lhg_get_locale_from_id($uid);
                $user_language_flag = lhg_show_flag_by_lang($user_language_txt);
                $total_karma = cp_getPoints($uid);
                //$num_com * 3 + $num_art * 50;
                //registration date
                $regdate = date("d. M Y", strtotime(get_userdata($uid)->user_registered));
                //donates to
                $donation_target = get_user_meta($uid, 'user_donation_target', true);
                if ($donation_target == "") {
                    $donation_target = 1;
                }
                //print_r($y);
                //if ($langurl != "") $langurl = "/".$langurl;
                #print "Name: ".$user->user_nicename." ($uid) - $points<br>";
                echo '<tr>

<td class="qrtly-1" >
	    <div class="userlist-place-quarter">' . $points . ' ' . $txt_cp_points . '
    	    </div>
</td>


<td class="quartery-points-avatar qrtly-2">
<a href="./hardware-profile/user' . $uid . '" class="recent-comments">
    <div class="userlist-avatar">' . $avatar . '
    </div>
</a>
</td>


<td class="qrtly-3">
          <div class="userlist-displayname">
		<a href="./hardware-profile/user' . $uid . '" class="recent-comments">';
                echo $user->user_nicename . '
                </a>

          </div>
</td>


<td class="qrtly-4">
    <div class="quarterly-points-userlist-details">
      ' . $txt_cp_donates_to . ': ' . $donation[$donation_target]["Name"] . '<br>
      ' . $txt_cp_language . ': ' . $user_language_flag . '
    </div>
</td>

<td class="qrtly-5">
          <div class="quartly-points-totalpoints">
	      ' . $txt_cp_karma . ': ' . $total_karma . ' ' . $txt_cp_points . '<br>
          </div>
</td>

';
                print "</tr>";
                $i++;
                if ($i > $max_users_to_show - 1) {
                    break;
                }
            }
        }
        if (sizeof($list_uid) > 0) {
            print "</table>";
        }
        /*
        
        		$top = cp_getAllPoints($instance['num'],get_option('cp_topfilter'));
        		do_action('cp_topUsersWidget_before');
        		echo apply_filters('cp_topUsersWidget_before','<div class="userlist-all"><ul class="bwp-rc-ulist">');
        		$line = str_replace('%style%', $instance['style'], $line);
        		foreach($top as $x=>$y){
                                $i++;
                                $uid = $y['id'];
        			$user = get_userdata($y['id']);
                                $name = $user->first_name." ".$user->last_name;
        			$string = str_replace('%string%', '', $instance['text']);
        			$string = str_replace('%string%',$string,$line);
        			$string = apply_filters('cp_displayUserInfo',$string,$y,$x+1);
        
                                //Flag
        		        $user_language_txt = lhg_get_locale_from_id ( $uid );
                		$user_language_flag= lhg_show_flag_by_lang ( $user_language_txt );
        
                                //registration date
                                $regdate = date("d. M Y", strtotime(get_userdata( $uid ) -> user_registered ) );
        
                                //donates to
        			$donation_target = get_user_meta($uid,'user_donation_target',true);
                                if ($donation_target == "") $donation_target = 1;
        
                                $avatar = get_avatar($uid, 40);
                                //print_r($y);
                                //if ($langurl != "") $langurl = "/".$langurl;
        
        global $txt_cp_karma;
        global $txt_cp_points;
        global $txt_cp_donates_to;
        global $txt_cp_longtext;
        global $txt_cp_language;
        
                                echo '
        <a href="./hardware-profile/user'.$uid.'" class="recent-comments">
          <div class="comment-box">
        
            <div class="userlist-avatar">'.
              $avatar.'
            </div>
        
            <div class="userlist-name">
                  <div class="userlist-place">'.
                    $i.'.
                  </div>
                  <div class="userlist-displayname">';
                    //if ($name == " ") {
                    	echo $y['display_name'];
                    //}else{
                    //    echo $name;
                    //};
                    echo '
                  </div>
        
                <!-- div class="userlist-flag">'.
                  $user_language_flag.'
                </div -->
        
            </div>
        
        
            <div class="userlist-details">
              '.$txt_cp_karma.': '.$y['points'].' '.$txt_cp_points.'<br>
              '.$txt_cp_donates_to.': '.$donation[$donation_target]["Name"].'<br>
              '.$txt_cp_language.': '.$user_language_flag.'
            </div>
        
          </div>
        </a>';
        //      Registered since: '.$regdate.'<br>
        
        
        
        
                        $top_users[$i]["ID"]=$uid;
                        $top_users[$i]["Karma"]=$y['points'];
        	        $top_users[$i]["DisplayName"]=$y['display_name'];
        
                                // echo $string;
        		}
        		echo apply_filters('cp_topUsersWidget_after','</ul></div>');
        
        $topvotes = lhg_voted_donation();
        $most_voted = lhg_most_voted ($topvotes);
        $most_voted_percent = lhg_most_voted_percent ($topvotes);
        
        //$most_voted = 2;
        
                // echo "TV: $topvotes";
        */
        global $donation_total;
        /*
        Former donation code
        echo '
        
        <div class="userlist-chart">'.$txt_cp_longtext.': <b>'. $donation_total.' &euro;</b>
          '.do_shortcode('[highchart-quarterly]
        ');
        */
        echo 'Donations:<br>' . do_shortcode('[highchart_quarterly]');
        $startQrt = cp_StartOfQuarter();
        $endQrt = cp_EndOfQuarter();
        #print "Range: ".date('jS \of F Y h:i:s A',$startQrt)." to ".date('jS \of F Y h:i:s A',$endQrt);
        //   Currently, '.$most_voted_percent.'% of all users vote for "'.$donation[$most_voted]["Name"].'".
        //$topvo
        // echo '</div>';
        //end of userlist all
        do_action('cp_topUsersWidget_after');
        echo $after_widget;
    }
Example #16
0
 function cp_module_donate_do()
 {
     $recipient = $_POST['recipient'];
     $points = $_POST['points'];
     $message = htmlentities(stripslashes($_POST['message']), ENT_QUOTES, 'UTF-8');
     $user = get_userdatabylogin($recipient);
     if (!is_user_logged_in()) {
         $r['success'] = false;
         $r['message'] = __('You must be logged in to make a donation!', 'cp');
     } else {
         if ($recipient == '') {
             $r['success'] = false;
             $r['message'] = __('Please enter the username of the recipient!', 'cp');
         } else {
             if ($user->ID == '') {
                 $r['success'] = false;
                 $r['message'] = __('You have entered an invalid recipient!', 'cp');
             } else {
                 if ($user->ID == cp_currentUser()) {
                     $r['success'] = false;
                     $r['message'] = __('You cannot donate to yourself!', 'cp');
                 } else {
                     if (!is_numeric($points)) {
                         $r['success'] = false;
                         $r['message'] = __('You have entered an invalid number of points!', 'cp');
                     } else {
                         if ((int) $points < 1) {
                             $r['success'] = false;
                             $r['message'] = __('You have to donate at least one point!', 'cp');
                         } else {
                             if ((int) $points != (double) $points) {
                                 $r['success'] = false;
                                 $r['message'] = __('You have entered an invalid number of points!', 'cp');
                             } else {
                                 if ((int) $points > (int) cp_getPoints(cp_currentUser())) {
                                     $r['success'] = false;
                                     $r['message'] = __('You do not have that many points to donate!', 'cp');
                                 } else {
                                     if (strlen($message) > 160) {
                                         $r['success'] = false;
                                         $r['message'] = __('The message you have entered is too long!', 'cp');
                                     } else {
                                         $message = mb_convert_encoding($message, 'HTML-ENTITIES', 'UTF-8');
                                         $r['success'] = true;
                                         $r['message'] = __('Your donation is successful!', 'cp');
                                         cp_points('donate_from', $user->ID, $points, serialize(array("from" => cp_currentUser(), "message" => $message)));
                                         cp_points('donate_to', cp_currentUser(), -$points, serialize(array("to" => $user->ID, "message" => $message)));
                                         $r['pointsd'] = cp_displayPoints(0, 1, 1);
                                         $r['points'] = cp_displayPoints(0, 1, 0);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     echo json_encode($r);
     die;
 }
Example #17
0
    /**
     * Section template.
     */
    function section_template()
    {
        global $wpdb;
        $current_user = wp_get_current_user();
        if (isset($_GET['id'])) {
            $user_id = $_GET['id'];
            $user_info = get_userdata($user_id);
            $userlogin = $user_info->user_login;
            $gamertag = $user_info->display_name;
            $user_website = $user_info->user_url;
        } else {
            $user_id = $current_user->ID;
            $userlogin = $current_user->user_login;
            $gamertag = $current_user->display_name;
            $user_website = $current_user->user_url;
        }
        $quest_posts_ids = $wpdb->get_results("select post_id from wp_postmeta where meta_value = 'page.quest.php' and meta_key ='_wp_page_template'");
        $quest_posts_count = (int) $wpdb->get_var("select count(*) from wp_postmeta where meta_value = 'page.quest.php' and meta_key ='_wp_page_template'");
        $quests_e = (int) $wpdb->get_var("select count(data) from wp_cp where uid = {$user_id} and status = 1");
        $quests_a = (int) $wpdb->get_var("select count(data) from wp_cp where uid = {$user_id} and status = 2");
        $quests_c = (int) $wpdb->get_var("select count(data) from wp_cp where uid = {$user_id} and status = 3");
        $quests_m = (int) $wpdb->get_var("select count(data) from wp_cp where uid = {$user_id} and status = 4");
        $quests_ne = $quest_posts_count - $quests_e - $quests_a - $quests_c - $quests_m;
        //Progres Bar!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        $testing = $wpdb->get_var('select option_value from wp_options where option_name = "cp_module_ranks_data"');
        $new = unserialize($testing);
        ksort($new);
        $new_array = array(current($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new), next($new));
        reset($new);
        $rank = cp_module_ranks_getRank($user_id);
        $rank_points = array_search($rank, $new_array);
        $current_rank_points = array_search($rank, $new);
        // Get the sum of the gold, silver, and copper.
        $prev_lvl = $new_array[$rank_points];
        $xp = cp_getPoints($user_id);
        $current_lvl = array_search($next_lvl, $new);
        $next_ranks_points = $new_array[$rank_points + 1];
        $xp_level = array_search($next_ranks_points, $new);
        ?>
<input type="text" style="display:none;"  name="re_xp_in" value="<?php 
        echo 8000;
        ?>
" /></form>  <?php 
        if (isset($_POST['re_xp_in'])) {
            $xp_left = $_POST['re_xp_in'];
        } else {
            $xp_left = $xp;
        }
        $percentage_num = $xp_left - array_search($prev_lvl, $new);
        $percentage_dom = $xp_level - $current_rank_points;
        $percentage = $percentage_num / $percentage_dom * 100;
        if ($percentage <= 1) {
            $percentage = 1;
        }
        reset($new);
        $new = unserialize($testing);
        ksort($new);
        $first_value = next($new);
        $second_value = next($new);
        $third_value = next($new);
        $forth_value = next($new);
        $fifth_value = next($new);
        $sixth_value = next($new);
        $seventh_value = next($new);
        $eaighth_value = next($new);
        $nineth_value = next($new);
        $tenth_value = next($new);
        $eleventh_value = next($new);
        $twelveth_value = next($new);
        $thirteenth_value = next($new);
        $forteenth_value = next($new);
        //Gold!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        $period_count_check_three = (int) $wpdb->get_var("select count(*) from wp_total_cur where id = {$user_id} and period_one != 0 and period_two != 0 and period_three != 0");
        if ($period_count_check_three != 0) {
            $period_count = 3;
        } else {
            $period_count_check_two = (int) $wpdb->get_var("select count(*) from wp_total_cur where id = {$user_id} and period_one != 0 and period_two != 0");
            if ($period_count_check_two != 0) {
                $period_count = 2;
            } else {
                $period_count = 1;
            }
        }
        $minutes_required = 10800 * $period_count;
        $querygold = "SELECT SUM(gold) FROM wp_class_cur where login = '******'";
        $resultgold = mysql_query($querygold) or die(mysql_error());
        $rowgold = mysql_fetch_array($resultgold);
        $gold_rnd = $rowgold['SUM(gold)'];
        $queryminutes = "SELECT SUM(minutes) FROM wp_class_cur where login = '******'";
        $resultminutes = mysql_query($queryminutes) or die(mysql_error());
        $rowminutes = mysql_fetch_array($resultminutes);
        $minutes_rnd = $rowminutes['SUM(minutes)'];
        $wpdb->update($table_name_c, array('totalgold' => $gold_rnd), array(login => $userlogin), array('%d', '%d'), array('%s'));
        $qry_m = "select minutes, minutes_reason, timestamp from wp_class_cur where login = '******' and minutes IS NOT NULL order by id desc ";
        $qry_g = "select gold, gold_reason, timestamp from wp_class_cur where login = '******' and gold IS NOT NULL order by id desc";
        $qry_xp = "select type, data, points from wp_cp where uid = '{$user_id}' order by id desc";
        $qry_per = "select period_one, period_two, period_three, computer_one, computer_two, computer_three from wp_total_cur where login = '******'";
        $rt_m = mysql_query($qry_m);
        $rt_g = mysql_query($qry_g);
        $rt_xp = mysql_query($qry_xp);
        $rt_per = mysql_query($qry_per);
        $minutes_percentage = $minutes_rnd / $minutes_required * 100;
        ?>
 
 <head>
<link rel="stylesheet" href="/wp-content/themes/<?php 
        echo get_stylesheet();
        ?>
/sections/statspage/myown_js/ui-lightness/jquery-ui-1.8.21.custom.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="/wp-content/themes/<?php 
        echo get_stylesheet();
        ?>
/sections/statspage/myown_js/myown_style.css" /> 

</head>
<body>
<div id="topinfo">
<h2 id="gt"><?php 
        echo $gamertag;
        ?>
</h2>
<div id="gravatarstat">
<?php 
        echo '<div id="re_xp_p"></div>';
        echo get_avatar($user_id, '96', $default = '<path_to_url>');
        ?>
</div>
<div id="profileinfo">
<table cellpadding="0px" id="profiletable">
<tr><td width="150px"><a href="<?php 
        echo $user_website;
        ?>
" >Website</a></td><td width="150px">Ecountered: <?php 
        echo $quests_e + $quests_a + $quests_c + $quests_m;
        ?>
</td><tr>
<tr><td><?php 
        echo $rank;
        ?>
 </td><td> Accepted: <?php 
        echo $quests_a + $quests_c + $quests_m;
        ?>
</td></tr>
<tr><td> <?php 
        print $xp_left . '/' . $xp_level;
        ?>
</td><td> Completed: <?php 
        echo $quests_c + $quests_m;
        ?>
</td></tr>
<tr><td> <?php 
        print $gold_rnd;
        ?>
 Gold </td><td> Mastered: <?php 
        echo $quests_m;
        ?>
</td></tr>
<tr><td> <?php 
        echo $minutes_rnd;
        ?>
/<?php 
        echo $minutes_required;
        ?>
 Minutes</td><td>Not Encountered: <?php 
        echo $quests_ne;
        ?>
</td><tr>
</table>
</div>
<div id="progressbar">
	<?php 
        print "<div id=\"progress-bar-2\" class=\"all-rounded\">\n";
        print "<div id\n\t=\"progress-bar-percentage-stats-2\" class=\"all-rounded\" style=\"\n\t-webkit-border-radius: 5px;\n    -moz-border-radius: 5px;\n    border-radius: 5px;\n\tborder-bottom-width:100%px; \n\theight:20px;\n\tpadding: 5px 0px;\n \tcolor: #FFF;\n \tfont-weight: bold;\n\tbackground-color:#ff6600;\n\t\nbackground: -webkit-gradient(linear, left top, left bottom, \ncolor-stop(0%, #ff6600), color-stop(20%, #ff6600), color-stop(150%, rgba(255,255,255,.9))); \n\nbackground: -webkit-linear-gradient(top, #ff6600, rgba(255,255,255,.9)); \nbackground: -moz-linear-gradient(top, #ff6600 0%, #ff6600 20%, rgba(255,255,255,.9) 150%);\n \ttext-align: center; width: " . $percentage . "%\">";
        print "</div></div>";
        print $xp_left . '/' . $xp_level;
        ?>
     </div>
     <div id="progressbar2">
	<?php 
        print "<div id=\"progress-bar-3\" class=\"all-rounded\">\n";
        ?>
     
     <div id="time-indicator">
     <div id="ti"> | | | | | 
     </div>
     </div>
     <?php 
        print "<div id\n\t=\"progress-bar-percentage-stats-3\" class=\"all-rounded\" style=\"\n\t-webkit-border-radius: 5px;\n    -moz-border-radius: 5px;\n    border-radius: 5px;\n\tborder-bottom-width:100%px; \n\theight:20px;\n\tpadding: 5px 0px;\n \tcolor: #FFF;\n \tfont-weight: bold;\n\tbackground-color:#486fb3;\n\t\nbackground: -webkit-gradient(linear, left top, left bottom, \ncolor-stop(0%, #486fb3), color-stop(20%, #486fb3), color-stop(150%, rgba(255,255,255,.9))); \nbackground: -webkit-linear-gradient(top, #486fb3, rgba(255,255,255,.9)); \nbackground: -moz-linear-gradient(top, #486fb3 0%, #486fb3 20%, rgba(255,255,255,.9) 150%);\n \ttext-align: center; width: " . $minutes_percentage . "%\">";
        print "</div></div>";
        print $minutes_rnd . '/' . $minutes_required;
        ?>
  
 </div>
    </div>

<div id ="tabs">
<ul>
<li><a href="#quests">Quests</a></li>
<li><a href="#xp">XP</a></li>
<li><a href="#minutes">Minutes</a></li>
<li><a href="#gold">Gold</a></li>
<li><a href="#log">Log-ins</a></li>
</ul>
<div id="log">
<?php 
        $log_list = $wpdb->get_results("select i_datetime from wp_3wp_activity_monitor_index where user_id = {$user_id} and activity_id = 'wp_login' order by i_id desc");
        foreach ($log_list as $lg_list) {
            foreach ($lg_list as $log_lst) {
                echo $log_lst . '<br />';
            }
        }
        ?>
</div>
<div id="xp">
<table id="xp_table" rules="rows">
<tr><th>Type</th><th>Reason</th><th>XP</th></tr>
<?php 
        $j = 1;
        while ($nt = mysql_fetch_array($rt_xp)) {
            $xp_div_id = $j & 1 ? "odd" : "even";
            $data = $nt['data'];
            $type = $nt['type'];
            $xp_p = $nt['points'];
            $xp_quest_check = (int) $wpdb->get_var("select count(*) from wp_cp where data ='{$data}' and uid = {$user_id} and type = 'Quest'");
            if ($xp_quest_check != 0) {
                $xp_post_id = $wpdb->get_var("select post_parent from wp_posts where post_title = '{$data}' order by id desc limit 1");
                $xp_post_id_link = get_permalink($xp_post_id);
                echo '<tr id="' . $xp_div_id . '"><th>' . $type . '</th><th><a href="' . $xp_post_id_link . '">' . $data . '</a></th><th>' . $xp_p . '</th></tr>';
            } else {
                echo '<tr id="' . $xp_div_id . '"><th>' . $type . '</th><th>' . $data . '</th><th>' . $xp_p . '</th></tr>';
            }
            $j = $j + 1;
        }
        ?>
</table>
</div>
<div id="minutes">
<?php 
        $v = 1;
        while ($nt = mysql_fetch_array($rt_m)) {
            $minutes_div_id = $v & 1 ? "odd" : "even";
            $minutes = $nt['minutes'];
            $minutes_reason = $nt['minutes_reason'];
            echo '<div id="' . $minutes_div_id . '">' . $minutes . '-' . $minutes_reason . ' - ' . $nt['timestamp'] . '</div>';
            $v = $v + 1;
        }
        ?>
</div>
<div id="gold"
><?php 
        $g = 1;
        while ($nt = mysql_fetch_array($rt_g)) {
            $gold_div_id = $g & 1 ? "odd" : "even";
            $gold_d = $nt['gold'];
            $gold_reason_d = $nt['gold_reason'];
            $gold_check_master = (int) $wpdb->get_var("select count(*) from wp_cp where data ='{$gold_reason_d}' and uid = {$user_id} and status in(4,5)");
            $gold_check_pc = (int) $wpdb->get_var("select count(*) from wp_class_cur where gold_reason ='{$gold_reason_d}' and login = '******' and status = 5");
            if ($gold_check_master != 0) {
                $gold_post_id = $wpdb->get_var("select post_parent from wp_posts where post_title = '{$gold_reason_d}' order by id desc limit 1");
                $gold_post_id_link = get_permalink($gold_post_id);
                echo '<div id= "' . $gold_div_id . '">' . $gold_d . ' - <a href="' . $gold_post_id_link . '" >' . $gold_reason_d . '</a> - ' . $nt['timestamp'] . '</div>';
            } else {
                if ($gold_check_pc != 0) {
                    $gold_post_id = $wpdb->get_var("select post_parent from wp_posts where post_title = '{$gold_reason_d}' order by id desc limit 1");
                    $gold_post_id_link = get_permalink($gold_post_id);
                    echo '<div id= "' . $gold_div_id . '">' . $gold_d . ' - <a href="' . $gold_post_id_link . '" >' . $gold_reason_d . '</a> - ' . $nt['timestamp'] . '</div>';
                } else {
                    echo '<div id= "' . $gold_div_id . '">' . $gold_d . ' - ' . $gold_reason_d . ' - ' . $nt['timestamp'] . '</div>';
                }
            }
            $g = $g + 1;
        }
        ?>
</div>
<div id="quests">
<?php 
        $quests = $wpdb->get_results("SELECT id FROM wp_cp WHERE  status != 0 and uid = {$user_id} order by id desc");
        ?>
    <table> <tr align="left"><th> Encountered</th><th> Accepted</th><th> Completed</th><th> Mastered</th></tr><?php 
        $s = 1;
        foreach ($quests as $qst) {
            foreach ($qst as $qsts) {
                $encountered = $wpdb->get_var("SELECT data FROM wp_cp WHERE  status = 1 and uid = {$user_id} and id = {$qsts}");
                $accepted = $wpdb->get_var("SELECT data FROM wp_cp WHERE  status = 2 and uid = {$user_id} and id = {$qsts}");
                $completed = $wpdb->get_var("SELECT data FROM wp_cp WHERE  status = 3 and uid = {$user_id} and id = {$qsts}");
                $mastered = $wpdb->get_var("SELECT data FROM wp_cp WHERE  status = 4 and uid = {$user_id} and id = {$qsts}");
                $encountered_t = $wpdb->get_var("SELECT data FROM wp_cp WHERE  (status = 1 or status = 2 or status = 3 or status = 4) and uid = {$user_id} and id = {$qsts}");
                $accepted_t = $wpdb->get_var("SELECT data FROM wp_cp WHERE  ( status = 2 or status = 3 or status = 4) and uid = {$user_id} and id = {$qsts}");
                $completed_t = $wpdb->get_var("SELECT data FROM wp_cp WHERE  ( status = 3 or status = 4) and uid = {$user_id} and id = {$qsts}");
                $mastered_t = $wpdb->get_var("SELECT data FROM wp_cp WHERE  status = 4 and uid = {$user_id} and id = {$qsts}");
                $encountered_time = $wpdb->get_var("SELECT enc FROM wp_class_cur_log WHERE uid = {$user_id} and (quest ='{$encountered}' or quest = '{$accepted}' or quest = '{$completed}' or quest = '{$mastered}')");
                $accepted_time = $wpdb->get_var("SELECT acc FROM wp_class_cur_log WHERE  uid = {$user_id} and (quest ='{$encountered}' or quest = '{$accepted}' or quest = '{$completed}' or quest = '{$mastered}')");
                $completed_time = $wpdb->get_var("SELECT com FROM wp_class_cur_log WHERE  uid = {$user_id} and (quest ='{$encountered}' or quest = '{$accepted}' or quest = '{$completed}' or quest = '{$mastered}')");
                $mastered_time = $wpdb->get_var("SELECT mas FROM wp_class_cur_log WHERE  uid = {$user_id} and (quest ='{$encountered}' or quest = '{$accepted}' or quest = '{$completed}' or quest = '{$mastered}')");
                $title = $wpdb->get_var("SELECT data FROM wp_cp where id = {$qsts}");
                $ids = (int) $wpdb->get_var("SELECT post_parent FROM wp_posts WHERE  post_title = '{$title}'  order by id desc limit 1");
                $permalink = get_permalink($ids);
                ?>
                        
                       <tr id= "<?php 
                echo $s & 1 ? "odd" : "even";
                ?>
"> <td align="left" title="<?php 
                echo $encountered_time;
                ?>
"><a href="<?php 
                echo $permalink;
                ?>
"><?php 
                echo $encountered_t;
                ?>
 </a> </td> 
					<td align="left" title="<?php 
                echo $accepted_time;
                ?>
"> <a href="<?php 
                echo $permalink;
                ?>
"><?php 
                echo $accepted_t;
                ?>
</a> </td>
                     <td  align="left" title="<?php 
                echo $completed_time;
                ?>
"> <a href="<?php 
                echo $permalink;
                ?>
"><?php 
                echo $completed_t;
                ?>
 </a> </td>
                 <td align="left" title=" <?php 
                echo $mastered_time;
                ?>
"> <a href="<?php 
                echo $permalink;
                ?>
"><?php 
                echo $mastered_t;
                ?>
 </a> </td> </tr> <?php 
                $s = $s + 1;
            }
        }
        ?>
                         
                         </table>
                         
</div>

 </div>
 
 <script src="/wp-content/themes/<?php 
        echo get_stylesheet();
        ?>
/sections/statspage/myown_jquery.js"></script>
<script src="/wp-content/themes/<?php 
        echo get_stylesheet();
        ?>
/sections/statspage/myown_js/jquery-ui.js"></script>
<script src="/wp-content/themes/<?php 
        echo get_stylesheet();
        ?>
/sections/statspage/myown_js/development-bundle/external/jquery.cookie.js"></script>
<script src="/wp-content/themes/<?php 
        echo get_stylesheet();
        ?>
/sections/statspage/myown_js/ui.js"></script>



 </body>
		
	


		<?php 
        do_action('bp_after_blog_page');
        ?>

		</div><!-- .padder -->
	</div><!-- #content -->


	<?php 
    }
Example #18
0
function cp_api_do()
{
    if (get_option('cp_auth_key') != $_REQUEST['cp_api_key']) {
        $r['error'] = 'Invalid API key';
        return $r;
    }
    $s = $_REQUEST['cp_api'];
    $q = explode('/', $s);
    switch ($q[0]) {
        case 'user':
            switch ($q[1]) {
                case 'login':
                    $user = get_userdatabylogin($q[2]);
                    break;
                case 'id':
                    $user = get_userdata($q[2]);
                    break;
                default:
                    $r['error'] = 'Method not implemented';
                    return $r;
            }
            if ($user->ID == '') {
                $r['error'] = 'Invalid user';
                return $r;
            }
            switch ($q[3]) {
                case '':
                    $r = $user;
                    return $r;
                    break;
                case 'points':
                    switch ($q[4]) {
                        case '':
                            $r['points'] = cp_getPoints($user->ID);
                            return $r;
                            break;
                        case 'get':
                            $r['points'] = cp_getPoints($user->ID);
                            return $r;
                            break;
                        case 'set':
                            if (!is_numeric($q[5])) {
                                $r['error'] = 'Points must be integers';
                                return $r;
                            } else {
                                cp_updatePoints($user->ID, (int) $q[5]);
                                $r['points'] = cp_getPoints($user->ID);
                                $r['message'] = 'Points updated';
                                return $r;
                            }
                            break;
                        case 'add':
                            if (!is_numeric($q[5])) {
                                $r['error'] = 'Points must be integers';
                                return $r;
                            } else {
                                switch ($q[6]) {
                                    case '':
                                        cp_alterPoints($user->ID, $q[5]);
                                        $r['points'] = cp_getPoints($user->ID);
                                        $r['message'] = 'Points updated';
                                        return $r;
                                        break;
                                    case 'log':
                                        if ($q[7] == '') {
                                            $r['error'] = 'Log item type must not be empty';
                                            return $r;
                                        }
                                        $data = explode('/', $s, 9);
                                        cp_points($q[7], $user->ID, $q[5], $data[8]);
                                        $r['points'] = cp_getPoints($user->ID);
                                        $r['message'] = 'Points updated';
                                        return $r;
                                        break;
                                    default:
                                        $r['error'] = 'Method not implemented';
                                        return $r;
                                }
                            }
                            break;
                        default:
                            $r['error'] = 'Method not implemented';
                            return $r;
                    }
                    break;
                default:
                    $r['error'] = 'Method not implemented';
                    return $r;
            }
            break;
        default:
            $r['error'] = 'Method not implemented';
            return $r;
    }
}
/**
 * my_bp_hide_group_create_button()
 *
 * Hide group creation button for member under certain point value
 * 
 *  @version 1.9.8
 *  @since 1.0
 */
function my_bp_hide_group_create_button()
{
    global $bp;
    $cp_spammercheck = cp_getPoints($bp->loggedin_user->id);
    $cp_groupspamcheck = get_option('bp_groupcreatespamcheck_cp_bp');
    if ($cp_spammercheck < $cp_groupspamcheck) {
        $naughtygoback = get_home_url();
        echo '<style type="text/css">
			#send_message_form {display:none;}
	   	      </style>
	   	      <script type="text/javascript">
	   	      alert ("' . _e('You don\'t have enough points to create a group.', 'cp_buddypress') . '");
	   	      window.location = "' . $naughtygoback . '"
	   	      </script>
		';
    }
}
Example #20
0
/** Set points and add to logs */
function cp_points_set($type, $uid, $points, $data)
{
    $points = apply_filters('cp_points_set', $points, $type, $uid, $data);
    $difference = $points - cp_getPoints($uid);
    cp_updatePoints($uid, $points);
    cp_log($type, $uid, $difference, $data);
}
/**
 * add_bp_cubepoints_wp_menu()
 *
 * Adds the user point total to the wordpress admin bar
 * Also adds the links to the public logs under the users account
 * Also support the CubePoints Giveaway & Betting System
 * 
 *  @version 1.9.8.9
 *  @since 1.0
 */
function add_bp_cubepoints_wp_menu()
{
    if (is_user_logged_in()) {
        global $wp_admin_bar;
        $bp;
        $user = wp_get_current_user();
        $bp->cubepoint->slug = get_option('bp_slug_cp_bp');
        $points = cp_getPoints($user->ID);
        $points_url = bp_core_get_user_domain($user->id) . $bp->cubepoint->slug . '/';
        if (function_exists('cp_lottery_show_logs')) {
            $all_lottery_n_bet_active = get_option('cp_lottery1_onoff') + get_option('cp_lottery2_onoff') + get_option('cp_lottery3_onoff') + get_option('cp_lottery4_onoff') + get_option('cp_lottery5_onoff') + get_option('cp_gamble1_onoff') + get_option('cp_gamble2_onoff') + get_option('cp_gamble3_onoff') + get_option('cp_gamble4_onoff') + get_option('cp_gamble5_onoff');
        } else {
            $all_lottery_n_bet_active = 0;
        }
        if ($all_lottery_n_bet_active > 0) {
            $add_plus_icon = '<span class="ab-icon"></span>';
        } else {
            $add_plus_icon = '';
        }
        $wp_admin_bar->add_menu(array('id' => 'my-points', 'parent' => 'top-secondary', 'title' => $add_plus_icon . get_option('cp_prefix') . $points . get_option('cp_suffix'), 'href' => $points_url));
        // Put next to other BP Menu Items
        $wp_admin_bar->add_menu(array('id' => 'cb-points', 'parent' => 'my-account-buddypress', 'title' => __('Points', 'cp_buddypress'), 'href' => $points_url));
        $wp_admin_bar->add_menu(array('id' => 'cb-point_logs', 'parent' => 'cb-points', 'title' => __('Point Logs', 'cp_buddypress'), 'href' => $points_url));
        if (get_option('bp_sitewide_menu_cp_bp') == 1) {
            $wp_admin_bar->add_menu(array('id' => 'cb-point_global_logs', 'parent' => 'cb-points', 'title' => get_option('bp_sitewidemtitle_cp_bp'), 'href' => $points_url . "/table/"));
        }
        if (get_option('bp_earnpoints_menu_cp_bp') == 1) {
            $wp_admin_bar->add_menu(array('id' => 'cb-point_earn_pts', 'parent' => 'cb-points', 'title' => get_option('bp_earnpoints_menutitle_cp_bp'), 'href' => $points_url . "/earnpoints/"));
        }
        if (get_option('bp_awards_menu_onoff_cp_bp') == 1) {
            $wp_admin_bar->add_menu(array('id' => 'cb-point_awards', 'parent' => 'cb-points', 'title' => get_option('bp_awards_menutitle_cp_bp'), 'href' => $points_url . "/awards/"));
        }
    }
}