function cp_module_lcpoints_newComment($cid) { if (is_user_logged_in()) { $uid = cp_currentUser(); $timelimit = time() - 86400; // one day global $wpdb; $comments = (int) $wpdb->get_var('SELECT comment_add - comment_remove as comments from (SELECT 1 as id, count(*) as comment_add FROM `' . CP_DB . '` WHERE `type`=\'comment\' AND `uid`=' . $uid . ' AND `timestamp`>' . $timelimit . ') as t1 LEFT JOIN (SELECT 1 as id, count(*) as comment_remove FROM `' . CP_DB . '` WHERE `type`=\'comment_remove\' AND `uid`=' . $uid . ' AND `timestamp`>' . $timelimit . ') as t2 ON t1.id = t2.id'); if ($comments >= get_option('cp_module_lcpoints_limit')) { add_filter('cp_comment_points', create_function('$points', 'return 0;'), 10); } } }
function cp_module_youtube_shortcode($atts) { // return if no video id defined if ($atts['id'] == '') { return; } // get points from shortcode or use default if (is_numeric($atts['points']) && (int) $atts['points'] >= 0) { $points = (int) $atts['points']; } else { $points = get_option('cp_module_youtube_points'); } // process any ajax request $_POST['uuid'] = str_replace('__', '-', $_POST['uuid']); if ($_POST['action'] == 'cp_youtube' && $_POST['uuid'] == $atts['id']) { global $wpdb; $data = $atts['id']; $uid = cp_currentUser(); if ((int) $wpdb->get_var("SELECT COUNT(*) FROM " . CP_DB . " WHERE `uid`={$uid} AND `data`='{$data}' AND `type`='youtube'") == 0) { cp_points('youtube', cp_currentUser(), $points, $atts['id']); } exit; } // get height and width from shortcode or use default if (is_numeric($atts['height'])) { $height = (int) $atts['height']; } else { $height = "315"; } if (is_numeric($atts['width'])) { $width = (int) $atts['width']; } else { $width = "560"; } $uuid = str_replace('-', '__', $atts['id']); $video = '<script type="text/javascript"> var params = { allowScriptAccess: "always", wmode: "transparent" }; swfobject.embedSWF("' . htmlentities('http://www.youtube.com/e/' . $atts['id'] . '?enablejsapi=1&version=3&playerapiid=' . $uuid . '&rel=0&controls=0&showinfo=0') . '", "' . $uuid . '", "' . $width . '", "' . $height . '", "9.0.0", null, null, params); </script> <div id="' . $uuid . '_container" class="cp_youtube"> <div id="' . $uuid . '"></div> </div>'; $video .= '<script type="text/javascript"> function cp_youtube_' . $uuid . '_fn(state) { cp_youtube_updateState("' . $uuid . '", state); } </script>'; return $video; }
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 cp_module_dailypoints_checkTimer() { if (!is_user_logged_in()) { return; } $uid = cp_currentUser(); $time = get_option('cp_module_dailypoints_time'); $difference = time() - $time; global $wpdb; $count = (int) $wpdb->get_var("SELECT COUNT(*) FROM " . CP_DB . " WHERE `uid`={$uid} AND `timestamp`>{$difference} AND `type`='dailypoints'"); if ($count != 0) { return; } cp_points('dailypoints', $uid, get_option('cp_module_dailypoints_points'), ''); }
/** Display points */ function cp_displayPoints($uid = 0, $return = 0, $format = 1) { if ($uid == 0) { if (!is_user_logged_in()) { return false; } $uid = cp_currentUser(); } if ($format == 1) { $fpoints = cp_formatPoints(cp_getPoints($uid)); } else { $fpoints = cp_getPoints($uid); } if (!$return) { echo $fpoints; } else { return $fpoints; } }
function wppa_add_credit_points($amount, $reason = '', $id = '', $value = '') { global $user_ID; // Initialize if (!$user_ID) { get_currentuserinfo(); } $bret = false; // Must be logged in if (!is_user_logged_in()) { return $bret; } // Cube points if (function_exists('cp_alterPoints')) { cp_alterPoints(cp_currentUser(), $amount); $bret = true; } // myCred if (function_exists('mycred_add')) { $entry = $reason . ($id ? ', ' . __('Photo id =', 'wppa') . ' ' . $id : '') . ($value ? ', ' . __('Value =', 'wppa') . ' ' . $value : ''); $bret = mycred_add(str_replace(' ', '_', $reason), $user_ID, $amount, $entry, '', '', ''); // $ref_id, $data, $type ); } return $bret; }
function cp_manage_form_submit() { header("Content-Type: application/json"); if (!current_user_can('manage_options')) { $response = json_encode(array('error' => __('You do not have sufficient permission to manage points!', 'cp'))); echo $response; exit; } if ($_POST['points'] != '' && $_POST['user_id'] != '') { $points = (int) $_POST['points']; $uid = (int) $_POST['user_id']; $user = get_userdata($uid); if ($user->ID == NULL) { $response = json_encode(array('error' => __('User does not exist!', 'cp'))); echo $response; exit; } if ($points < 0) { $points = 0; } cp_points_set('admin', $uid, $points, cp_currentUser()); } else { $response = json_encode(array('error' => __('Invalid request!', 'cp'))); echo $response; exit; } $response = json_encode(array('error' => 'ok', 'points' => cp_displayPoints($uid, 1, 0), 'points_formatted' => cp_displayPoints($uid, 1, 1), 'username' => $user->user_login, 'user_id' => $user->ID)); echo $response; exit; }
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; }
function cp_module_notify_do() { cp_module_notify_displayNoticesFor(cp_currentUser()); }
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()))); } }
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')); } } }
function cp_module_paypal_pay() { if (isset($_REQUEST['cp_module_paypal_pay']) && $_REQUEST['cp_module_paypal_pay'] != '') { header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); if (get_option('cp_module_paypal_sandbox')) { $loc = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; } else { $loc = 'https://www.paypal.com/cgi-bin/webscr'; } $points = (int) $_REQUEST['points']; if (!is_user_logged_in()) { cp_module_paypal_showMessage(__('You must be logged in to purchase points!', 'cp')); } if ($points < get_option('cp_module_paypal_min')) { cp_module_paypal_showMessage(__('You must purchase a minimum of', 'cp') . ' ' . get_option('cp_module_paypal_min') . ' points!'); } $price = cp_module_paypal_round_up(get_option('cp_module_paypal_price') * $points, 2); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php _e('Processing payment...', 'cp'); ?> </title> <meta name="robots" content="noindex, nofollow" /> <link rel='stylesheet' id='thickbox-css' href='<?php echo WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . 'style.css'; ?> ' type='text/css' media='all' /> </head> <body> <form action="<?php echo $loc; ?> " method="post" name="paypal_form"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="<?php echo get_option('cp_module_paypal_account'); ?> "> <input type="hidden" name="item_name" value="<?php echo str_replace('%points%', cp_formatPoints($points), str_replace('%npoints%', $points, get_option('cp_module_paypal_item'))); ?> "> <input type="hidden" name="on1" value="User"> <input type="hidden" name="os1" value="<?php $user = get_userdata(cp_currentUser()); echo $user->user_login; ?> "> <input type="hidden" name="custom" value="<?php echo $points . '|' . cp_currentUser(); ?> "> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="return" value="<?php echo get_option('cp_module_paypal_thankyou'); ?> "> <input type="hidden" name="cbt" value="<?php _e('Return to', 'cp'); echo ' '; bloginfo('name'); ?> "> <input type="hidden" name="cancel_return" value="<?php echo get_option('cp_module_paypal_cancel'); ?> "> <input type="hidden" name="notify_url" value="<?php bloginfo('url'); ?> /?cp_module_paypal_ipn=1"> <input type="hidden" name="rm" value="2"> <input type="hidden" name="amount" value="<?php echo $price; ?> "> <input type="hidden" name="currency_code" value="<?php echo get_option('cp_module_paypal_currency'); ?> "> </form> <div id="container"> <p id="load"><img src="<?php echo WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . 'load.gif'; ?> " alt="<?php _e('Processing payment...', 'cp'); ?> " /></p> <p id="text">Processing payment...</p> <p><a href="#" onclick="document.paypal_form.submit();return false;">Click here to continue if you are not automatically redirected »</a></p> </div> <script type="text/javascript"> setTimeout("document.paypal_form.submit()",2000); </script> </body> </html> <?php exit; } }
function cp_module_ranks_widget() { if (is_user_logged_in()) { ?> <li><?php _e('Rank', 'cp'); ?> : <?php echo cp_module_ranks_getRank(cp_currentUser()); ?> </li> <?php } }
/** * 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']); }