Пример #1
0
function ym_depricated_replace_tag($function, $matches, $argument = false)
{
    get_currentuserinfo();
    global $current_user, $user_data, $ym_user;
    $return = '';
    switch ($function) {
        //Checks User Account usage: [user_account_is#Member]
        // TODO: 11.0.8 deprecate in favour of ym_user_is
        case 'user_account_is':
            _doing_it_wrong(__FUNCTION__, 'Use ym_user_is shortcode', '11.0.6');
            $argument = str_replace('+', ' ', $argument);
            $user_id = false;
            if (ym_get('token') && ym_use_rss_token()) {
                $user = ym_get_user_by_token(ym_get('token'));
                $user_id = $user->ID;
            }
            if (strtolower(ym_get_user_account_type($user_id)) == strtolower($argument) || current_user_can('edit_posts')) {
                $return = $matches;
            }
            break;
    }
    return do_shortcode(stripslashes($return));
}
Пример #2
0
function ym_user_has_access($post_id = false, $user_id = false, $allow_on_purchasable = false)
{
    get_currentuserinfo();
    global $current_user, $user_data, $wpdb, $ym_sys;
    if (isset($_GET['username']) && isset($_GET['password'])) {
        $user = wp_authenticate($_GET['username'], $_GET['password']);
    } else {
        if ($user_id) {
            $user = get_userdata($user_id);
        } else {
            if (ym_get('token') && ym_use_rss_token()) {
                $user = ym_get_user_by_token(ym_get('token'));
            } else {
                $user = $current_user;
            }
        }
    }
    $return = false;
    if (!$post_id) {
        $post_id = get_the_id();
    }
    if ($post_id) {
        $post = get_post($post_id);
        $purchasable = ym_post_is_purchasable($post_id);
        $is_published = $post->post_status == 'publish';
        if ($allow_on_purchasable && $purchasable) {
            $return = true;
        } else {
            if (isset($user->caps['administrator'])) {
                $return = true;
            } else {
                if (!$is_published) {
                    $return = false;
                    // logged out purchase
                    //		} else if (ym_check_ppp_cookie($post_id)) {
                    //			$return = true;
                } else {
                    if ($user->ID > 0 && $purchasable && (ym_has_purchased_post($post_id, $user->ID) || ym_has_purchased_bundle_post_in($post_id, $user->ID))) {
                        $return = true;
                    } else {
                        $types = strtolower(get_post_meta($post_id, '_ym_account_type', true));
                        //Logic check if no YM meta has been applied to the post return TRUE
                        if (!$types) {
                            $return = true;
                        }
                        if (!is_user_logged_in() && $ym_sys->enable_metered) {
                            //metered access check
                            $cookie = stripslashes($_COOKIE['ymmeter']);
                            $cookie = unserialize($cookie);
                            $posts = $cookie['posts'];
                            if (is_array($posts)) {
                                if (in_array($post_id, $posts)) {
                                    $return = true;
                                }
                            }
                            //Check if FCF is enabled (this is a bad thing normally)
                            if ($ym_sys->enable_fcf_metered) {
                                if (stripos($_SERVER[‘HTTP_USER_AGENT’], ‘Googlebot’) !== false) {
                                    $host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
                                    if (stripos($host, 'googlebot') !== false) {
                                        //ok we think this is Google
                                        $metered_act = strtolower($ym_sys->metered_account_types);
                                        $metered_act = explode(';', $metered_act);
                                        $metered_types = explode(';', $types);
                                        foreach ($metered_types as $metered_type) {
                                            if ($metered_type = 'guest') {
                                                $return = true;
                                            } elseif (in_array($metered_type, $meterered_act)) {
                                                $return = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        $uat = ym_get_user_package_type($user->ID, true);
                        //status is implied through the type.
                        if (!$uat) {
                            $uat = 'Guest';
                        }
                        if (in_array($uat, explode(';', $types))) {
                            $return = true;
                            if ($pack_join = get_user_meta($user->ID, 'ym_account_type_join_date', TRUE)) {
                                if ($hide_old_content = get_user_meta($user->ID, 'ym_hide_old_content', TRUE)) {
                                    $post_date = strtotime($post->post_date);
                                    $return = false;
                                    if ($pack_join < $post_date) {
                                        $return = true;
                                    }
                                }
                            }
                        }
                        if ($return == true) {
                            // @TODO re-evaluate what is going on here
                            $new_array = array();
                            $min_dur = get_post_meta($post_id, '_ym_account_min_duration', true);
                            if ($min_dur) {
                                $min_dur = explode(';', $min_dur);
                                foreach ($min_dur as $keyvalues) {
                                    $array = explode('=', $keyvalues);
                                    $new_array[$array[0]] = $array[1];
                                }
                                $min_dur = $new_array;
                                $uat_min_dur = (int) $min_dur[strtolower(str_replace(' ', '_', $uat))];
                                if ($uat_min_dur > 0) {
                                    $reg = $user->user_registered;
                                    if ($sys->post_delay_start == 'pack_join') {
                                        if ($pack_join = get_user_meta($user->ID, 'ym_account_type_join_date', TRUE)) {
                                            $reg = date('Y-m-d', $pack_join);
                                        }
                                    }
                                    $reg = mktime(0, 0, 0, substr($reg, 5, 2), substr($reg, 8, 2), substr($reg, 0, 4));
                                    $user_at = $reg + 86400 * $uat_min_dur;
                                    if ($user_at >= time()) {
                                        $return = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $return = apply_filters('ym_user_has_access_additional', $return, $post_id, $user, $allow_on_purchasable);
    return $return;
}
Пример #3
0
	<div style="overflow: auto;">
	<div style="width: 500px; float: left">
	<div class="postbox" style="margin:10px 0px;">
		<h3>' . __('Subscription Information', "ym") . '</h3>
		<div class="inside">';
$html .= ym_get_user_profile();
$html .= '</div></div>';
$hist = ym_get_user_purchase_history();
if ($hist) {
    $html .= '<div class="postbox" style="margin:10px 0px;">
		<h3>' . __('Purchase History', "ym") . '</h3>
		<div class="inside">';
    $html .= $hist;
    $html .= '</div></div>';
}
$html .= '</div>';
$html .= '<div class="postbox" style="margin: 10px 0px; width: 320px; float: left; margin-left: 10px; overflow: auto;">
		<h3>' . __('Membership Information', "ym") . '</h3>
		<div class="inside">';
if (ym_use_rss_token()) {
    $html .= '<div style="margin-bottom: 10px;">
	<h4>' . __('RSS Tokens', "ym") . '</h4>
	<div style="margin-bottom: 10px;">' . sprintf(__('Your RSS Token is: <strong>%s</strong>', 'ym'), $token) . '</div>
	<div style="margin-bottom: 10px;">
	' . __('Use the following link to access your RSS feed with access to private parts of the site.', "ym") . '<br /><br /><a href="' . $rss_url . '">' . $rss_url . '</a>
</div></div>';
}
$html .= ym_get_user_unsub_button_gateway();
$html .= '</div></div>';
$html .= '</div></div>';
echo $html;