Example #1
0
 function cp_module_notify_msg_filter($d)
 {
     list($m, $type, $uid, $points, $data) = $d;
     $user = get_userdata($uid);
     $m = str_replace('%npoints%', abs($points), $m);
     $m = str_replace('%points%', cp_formatPoints(abs($points)), $m);
     $m = str_replace('%type%', $type, $m);
     $m = str_replace('%username%', $user->user_login, $m);
     $m = str_replace('%user%', $user->display_name, $m);
     return array($m);
 }
Example #2
0
    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 &raquo;</a></p> 
	</div> 
	<script type="text/javascript">
		setTimeout("document.paypal_form.submit()",2000);
	</script>
</body> 
</html> 
<?php 
            exit;
        }
    }
Example #3
0
 function cp_module_pcontent_post_content($content)
 {
     global $post;
     global $cp_module_pcontent_hide;
     if (!in_array($post->ID, (array) $cp_module_pcontent_hide)) {
         return $content;
     }
     $c = '<p>' . get_option('cp_module_pcontent_text_pay') . '</p>';
     $c .= apply_filters('cp_module_pcontent_post_content_' . $post->ID, '');
     $c .= '<form method="post">';
     $c .= '<input type="hidden" name="cp_module_pcontent_pay" value="' . $post->ID . '" />';
     $c .= '<p><input type="submit" value="' . get_option('cp_module_pcontent_text_button') . '" /></p>';
     $c .= '</form>';
     if (!is_user_logged_in()) {
         $c = get_option('cp_module_pcontent_text_logout');
     }
     $c = str_replace('%points%', cp_formatPoints(get_post_meta($post->ID, 'cp_pcontent_points', 1)), $c);
     return $c;
 }
Example #4
0
/** Get points of all users into an array */
function cp_getAllPoints($amt = 0, $filter_users = array(), $start = 0)
{
    global $wpdb;
    if ($amt > 0) {
        $limit = ' LIMIT ' . $start . ',' . $amt;
    }
    $extraquery = '';
    if (count($filter_users) > 0) {
        $extraquery = ' WHERE ' . $wpdb->base_prefix . 'users.user_login != \'';
        $extraquery .= implode("' AND " . $wpdb->base_prefix . "users.user_login != '", $filter_users);
        $extraquery .= '\' ';
    }
    $array = $wpdb->get_results('SELECT ' . $wpdb->base_prefix . 'users.id, ' . $wpdb->base_prefix . 'users.user_login, ' . $wpdb->base_prefix . 'users.display_name, ' . $wpdb->base_prefix . 'usermeta.meta_value 
		FROM `' . $wpdb->base_prefix . 'users` 
		LEFT JOIN `' . $wpdb->base_prefix . 'usermeta` ON ' . $wpdb->base_prefix . 'users.id = ' . $wpdb->base_prefix . 'usermeta.user_id 
		AND ' . $wpdb->base_prefix . 'usermeta.meta_key=\'' . 'cpoints' . '\'' . $extraquery . ' 
		ORDER BY ' . $wpdb->base_prefix . 'usermeta.meta_value+0 DESC' . $limit . ';', ARRAY_A);
    foreach ($array as $x => $y) {
        $a[$x] = array("id" => $y['id'], "user" => $y['user_login'], "display_name" => $y['display_name'], "points" => $y['meta_value'] == 0 ? 0 : $y['meta_value'], "points_formatted" => cp_formatPoints($y['meta_value']));
    }
    return $a;
}