function yss_shortcode($atts)
{
    global $codes;
    $return = '';
    $allow_play = false;
    $id = isset($atts['id']) ? $atts['id'] : '';
    $player = isset($atts['plr']) ? $atts['plr'] : get_option('yss_playerofchoice');
    $width = isset($atts['width']) ? $atts['width'] : 640;
    $height = isset($atts['height']) ? $atts['height'] : 380;
    if (!$id) {
        //error out as no Video ID
        return '<p>' . __('No video ID specified', 'yss') . '</p>';
    }
    $video = yss_get($id);
    if (!$video) {
        return '<p>' . __('The video requested could not be found', 'yss') . '</p>';
    }
    var_dump($video);
    //access_check
    if (!$video->members && !$video->account_types) {
        $allow_play = true;
        //no access restriction
    } else {
        //priority given to ac check
        if ($video->account_types) {
            if ($acs = explode('||', $video->account_types)) {
                $ac = strtolower(ym_get_user_account_type());
                if (in_array($ac, $acs)) {
                    $allow_play = true;
                }
            }
        }
        //if ac check fails or is not used and post comparison is then use this...
        if ($video->members && !$allow_play) {
            $posts = yss_get_video_post_assoc($id);
            foreach ($posts as $post) {
                if (ym_user_has_access($post->post_id)) {
                    $allow_play = true;
                    break;
                }
            }
        }
    }
    //if the logic above deems access should be granted then...
    if ($allow_play) {
        $return = yss_generate_player($player, $video, $width, $height);
    } else {
        if ($message = get_option('yss_no_access_message')) {
            //else if the admin has put in a no access message this appears
            $return = $message;
        }
    }
    return $return;
}
Example #2
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));
}
function ym_member_check($account_types = array())
{
    $user_ac = ym_get_user_account_type();
    return in_array($user_ac, $account_types);
}
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $text = apply_filters('widget_text', $instance['text'], $instance);
        $available_to = explode(';', $instance['account_types']);
        $account_type = strtolower(ym_get_user_account_type());
        $access = false;
        foreach ($available_to as $available) {
            if ($account_type == strtolower($available)) {
                $access = true;
                break;
            }
        }
        //if (in_array($account_type, $available_to)) { //-had to remove for above because of case sensitivity
        if ($access) {
            echo $before_widget;
            if (!empty($title)) {
                echo $before_title . $title . $after_title;
            }
            ob_start();
            eval('?>' . $text);
            $text = ob_get_contents();
            ob_end_clean();
            $text = str_replace('[account_type]', ym_get_user_account_type(), $text);
            ?>
			
			<div class="ym_textwidget"><?php 
            echo $instance['filter'] ? wpautop($text) : $text;
            ?>
</div>			
			<?php 
            echo $after_widget;
        }
    }
Example #5
0
function ym_member_count()
{
    global $wpdb, $ym_package_types;
    $sql = 'SELECT ID
			FROM ' . $wpdb->users;
    $users = $wpdb->get_results($sql);
    $counts = array();
    foreach ($ym_package_types->types as $account_type) {
        if ($account_type != 'Guest') {
            $counts[$account_type] = 0;
        }
    }
    foreach ($users as $user) {
        $ac = ym_get_user_account_type($user->ID);
        if ($ac == 'Guest') {
            $ac = 'Free';
        }
        $counts[$ac]++;
    }
    $html = '<ul>';
    foreach ($counts as $ac => $num) {
        $html .= '<li>' . $ac . ': ' . $num . '</li>';
    }
    $html .= '</ul>';
    return $html;
}
Example #6
0
function ym_upgrade_buttons($return = false, $pack_id = false, $user_id = false)
{
    global $wpdb, $duration_str, $current_user, $ym_res, $ym_sys, $ym_packs;
    get_currentuserinfo();
    if (!$user_id) {
        $user_id = $current_user->ID;
    }
    if ($pack_id == 'all') {
        global $ym_packs;
        $html = '';
        foreach ($ym_packs->packs as $pack) {
            if (!$pack['hide_subscription']) {
                $html .= ym_upgrade_buttons(TRUE, $pack['id']);
            }
        }
        if ($return) {
            return $html;
        } else {
            echo $html;
            return;
        }
    }
    $html = '';
    $ym_home = get_option('siteurl');
    if (!$user_id) {
        $html = $ym_res->msg_header . __('Sorry but you must be logged in to upgrade your account', 'ym') . $ym_res->msg_footer;
    } else {
        $user_data = new YourMember_User($user_id);
        $account_type = ym_get_user_account_type(false, true);
        $packs = $ym_packs->packs;
        $trial_taken = get_user_meta($user_id, 'ym_trial_taken', TRUE);
        $active_modules = get_option('ym_modules');
        $modules_dir = YM_MODULES_DIR;
        $base = add_query_arg(array('ym_subscribe' => 1, 'ud' => 1, 'username' => $current_user->user_login), $ym_home);
        if ((!isset($_POST['submit']) || !isset($_POST['subs_opt'])) && !$pack_id) {
            // TODO: Does this code even run?
            $html = '<p class="message register">' . __('Choose an Account Type', 'ym') . '</p>';
            $html .= '<form action="" method="post" class="ym"><div style="clear: both; overflow: auto; padding-bottom: 10px;">';
            // RENDER2
            $packs_shown = 0;
            if ($existing_data = ym_request('ym_subscription')) {
                $default = $existing_data;
            } else {
                //				$default = ym_get_default_pack();
                $default = $user_data->pack_id;
            }
            $did_checked = FALSE;
            foreach ($packs as $pack) {
                if (!$pack['hide_subscription']) {
                    $html .= '<div class="ym_register_form_subs_row">
								<div class="ym_reg_form_pack_radio">
									<input type="radio" ';
                    if ($pack['id'] == $default && !$did_checked) {
                        $html .= 'checked="checked"';
                        $did_checked = TRUE;
                    }
                    $packs_shown++;
                    $html .= ' class="checkbox" id="ym_subscription_' . $pack['id'] . '" name="ym_subscription" value="' . $pack['id'] . '" />
							</div>
							<label for="ym_subscription_' . $pack['id'] . '" class="ym_subs_opt_label ym_reg_form_pack_name">' . ym_get_pack_label($pack['id']) . '</label>
						</div>';
                }
            }
            if (!$packs_shown) {
                $hide_label = true;
            } else {
                if (isset($entry['caption']) && $entry['caption']) {
                    $html .= '<div class="ym_clear">&nbsp;</div><div class="ym_register_form_caption">' . $entry['caption'] . '</div>' . $row;
                }
            }
            // END RENDER2
            if ($packs_shown) {
                //				$html .= '</div><input type="hidden" name="ref" value="'. md5($user_data->amount .'_'. $user_data->duration .'_'. $user_data->duration_type .'_'. $user_data->account_type) .'" />';
                $html .= '<p class="submit"><input type="submit" name="submit" value="' . __('Next &raquo;', 'ym') . '" /></p>';
            } else {
                $html .= '<p>' . __('Sorry there are currently no upgrade/downgrade options available to you.', 'ym') . '</p>';
            }
            $html .= '</form>';
        } else {
            if (!ym_post('subs_opt') && $pack_id != ym_post('ym_subscription')) {
                global $ym_res;
                $html = '<form action="" method="post" class="ym_upgrade_shortcode">';
                $html .= '<input type="hidden" name="ym_subscription" value="' . $pack_id . '" />';
                //				$html .= '<input type="hidden" name="ref" value="'. md5($user_data->amount .'_'. $user_data->duration .'_'. $user_data->duration_type .'_'. $user_data->account_type) .'" />';
                $html .= ym_get_pack_label($pack_id);
                $html .= '&nbsp;<a href="#nowhere" onClick="jQuery(this).parents(\'form\').submit();">Upgrade</a>';
                $html .= '</form>';
                return $html;
            } else {
                $pack = ym_get_pack_by_id($pack_id);
                $cost = $pack['cost'];
                if (!$pack_id) {
                    $html .= '<br /><table width="100%" cellpadding="3" cellspacing="0" border="0" align="center" class="form-table">';
                    if ($cost == 0 || $account_type == 'free') {
                        $html .= '<tr><th>' . __('Create a free account: ', 'ym') . ucwords($account_type) . '</th></tr>';
                    } else {
                        $html .= '<tr><th>' . __('Select Payment Gateway', 'ym') . '</th></tr>';
                        $html .= '<tr><th>' . ym_get_pack_label($pack['id']) . '</th></tr>';
                    }
                }
                if (count($active_modules)) {
                    $buttons_shown = array();
                    foreach ($active_modules as $module) {
                        if ($module == 'ym_free' && $pack['cost'] > 0) {
                            continue;
                        }
                        require_once $modules_dir . $module . '.php';
                        $obj = new $module();
                        $string = $obj->getButton($pack['id']);
                        if ($string) {
                            $buttons_shown[] = $module;
                            $html .= $string;
                        }
                        $string = false;
                        $obj = null;
                    }
                    if (count($buttons_shown) == 1) {
                        $module = array_pop($buttons_shown);
                        $form_code = '<div style="display:none;">' . $html . '</div>';
                        $js = 'document.forms["' . $module . '_form"].submit();';
                        $html = '  <html>
													<head>
														<title>Redirecting...</title>
														<script type="text/javascript">
															function load() {
																' . $js . '
															}
														</script>
													</head>
													<body onload="load();">';
                        $html .= '  <div style="color: #333333; font-size: 14px; margin: 30px 10px; font-family: tahoma; text-align: center; padding: 50px; border: 1px solid silver;">';
                        $html .= '  <div>' . __('You are being redirected. If this page does not refresh in 5 seconds then click', 'ym') . ' <a onclick="document.forms[\'' . $module . '_form\'].submit();">here</a>.</div>
											   <div style="margin-top: 10px;"><img alt="" src="' . YM_IMAGES_DIR_URL . 'loading.gif" /></div>';
                        $html .= '  </div>';
                        $html .= $form_code;
                        $html .= '	  </body>
												</html>';
                        echo $html;
                        die;
                    }
                } else {
                    $html .= __('There are no gateways available at this time.', 'ym');
                }
            }
        }
    }
    if ($return) {
        return $html;
    } else {
        echo $html;
    }
}
function ym_members_to_date()
{
    global $wpdb, $ym_package_types;
    $totals = array();
    foreach ($ym_package_types->types as $id => $type) {
        $type = ucwords(strtolower($type));
        if (!is_array($type)) {
            $totals[$type] = 0;
        }
    }
    if (!get_option('ym_user_counts_updated')) {
        $sql = 'SELECT ID FROM ' . $wpdb->users;
        if ($users = $wpdb->get_results($sql)) {
            foreach ($users as $i => $user) {
                $ac = ucwords(ym_get_user_account_type($user->ID, true));
                update_user_meta($user->ID, 'ym_account_type', $ac);
                $totals[$ac]++;
            }
            update_option('ym_user_counts_updated', time());
        }
    } else {
        foreach ($totals as $type => $count) {
            $totals[$type] = ym_count_users_by_type($type);
        }
    }
    echo '<table style="width:100%;">';
    echo '<tr>
				<td style="border-bottom: 1px solid #EFEFEF; font-weight:bold;">' . __('Package Type', 'ym') . '</td>
				<td style="border-bottom: 1px solid #EFEFEF; font-weight:bold; width:20%;">' . __('Users', 'ym') . '</td>
			</tr>';
    foreach ($totals as $ac => $count) {
        echo '<tr>
				<td style="border-bottom: 1px solid #EFEFEF;">' . $ac . '</td>
				<td style="border-bottom: 1px solid #EFEFEF; text-align:right;">' . $count . '</td>
			</tr>';
    }
    echo '</table>';
}