Example #1
0
 function get_button_code($pack, $user_id)
 {
     get_currentuserinfo();
     global $current_user;
     if ($current_user->ID == 0) {
         $current_user = ym_get_user_by_username(ym_get('username'));
     }
     $currency_codes = array('AUD' => '036', 'CAD' => '124', 'JPY' => '392', 'GBP' => '826', 'USD' => '840', 'EUR' => '978');
     if (array_key_exists(ym_get_currency($pack['id']), $currency_codes)) {
         $code = $currency_codes[ym_get_currency($pack['id'])];
     } else {
         return;
     }
     $data = array('clientAccnum' => $this->clientAccnum, 'clientSubacc' => $this->clientSubacc, 'formName' => $this->formname, 'customer_fname' => get_user_meta($current_user->ID, 'first_name', TRUE), 'customer_lname' => get_user_meta($current_user->ID, 'last_name', TRUE), 'email' => $current_user->user_email);
     if (isset($pack['id']) && $pack['id']) {
         // convert to days
         switch ($pack['duration_type']) {
             case 'y':
                 $duration = $pack['duration'] * 365;
                 break;
             case 'm':
                 $duration = $pack['duration'] * 30;
                 break;
             default:
                 $duration = $pack['duration'];
         }
         $data = array_merge($data, array('formPrice' => $pack['cost'], 'formPeriod' => $duration, 'currencyCode' => $code));
         if ($pack['trial_on']) {
             $data['formPrice'] = $pack['trial_cost'];
             // convert to days
             switch ($pack['trial_duration_type']) {
                 case 'y':
                     $duration = $pack['trial_duration'] * 365;
                     break;
                 case 'm':
                     $duration = $pack['trial_duration'] * 30;
                     break;
                 default:
                     $duration = $pack['trial_duration'];
             }
             $data['formPeriod'] = $duration;
         }
         if (isset($pack['num_cycles']) && $pack['num_cycles'] != 1) {
             // recur
             //				unset($data['formPrice'], $data['formPeriod']);
             $data['formRecurringPrice'] = $pack['cost'];
             $data['formRecurringPeriod'] = $duration;
             $data['formRebills'] = $pack['num_cycles'] == 0 ? 99 : $pack['num_cycles'];
             // gen formdigest
             $data['formDigest'] = md5($data['formPrice'] . $data['formPeriod'] . $data['formRecurringPrice'] . $data['formRecurringPeriod'] . $data['formRebills'] . $code . $this->md5salt);
         } else {
             // gen formdigest
             $data['formDigest'] = md5($data['formPrice'] . $data['formPeriod'] . $code . $this->md5salt);
         }
         $data['custom'] = 'buy_subscription_' . $pack['id'] . '_' . $user_id;
     }
     return $data;
 }
function ym_logs_search_users()
{
    ym_ajax_superuser_check();
    $users = get_users('search=*' . like_escape(ym_get('q')) . '*');
    foreach ($users as $user) {
        echo $user->user_login . "\n";
    }
    die;
}
 function init()
 {
     global $ym_sys, $ym_crons_that_exist;
     if ($ym_sys->enable_manual_cron) {
         foreach ($ym_crons_that_exist as $cron_job) {
             if ($cron_job['core'] != 2 && wp_get_schedule($cron_job['task'])) {
                 // clear
                 wp_clear_scheduled_hook($cron_job['task']);
             }
         }
     } else {
         foreach ($ym_crons_that_exist as $cron_job) {
             if ($cron_job['core'] != 2 && !wp_get_schedule($cron_job['task'])) {
                 // needs to be scheduled
                 $now = time();
                 $next = mktime($cron_job['time'][0], $cron_job['time'][1], 0, date('n', $now), date('j', $now), date('Y', $now));
                 // next, schedule, action_name
                 wp_schedule_event($next, $cron_job['schedule'], $cron_job['task']);
             }
         }
     }
     // check for manual call
     if (ym_get('ym_cron_do', FALSE)) {
         // has call
         $task = ym_get('ym_cron_job', FALSE);
         if ($task) {
             $tasks = array($task => 1);
         } else {
             $tasks = $ym_crons_that_exist;
         }
         foreach ($tasks as $task => $data) {
             echo 'do ' . $task . "\n";
             do_action($task, -1);
         }
         echo "\n";
         echo 1;
         die;
     }
 }
Example #4
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));
}
Example #5
0
function ym_app_loaded()
{
    ym_firesale_maintain_tiers();
    if (is_admin()) {
        ym_app_check_version();
        // download interrupt
        if (ym_get('app_download', FALSE)) {
            global $ym_app_version_resp;
            $ym_app_version_resp->checkForUpdates();
            $state = get_option($ym_app_version_resp->optionName);
            $download_url = $state->update->download_url;
            header('Location: ' . $download_url);
            exit;
        }
        add_filter('ym_navigation', 'ym_app_menu');
        add_action('ym_additional_context_help', 'ym_app_context_help');
        add_action('admin_head', 'ym_app_styles');
    }
    add_action('login_head', 'ym_firesale_subs');
    add_filter('ym_additional_code', 'ym_firesale_ppp', 10, 3);
    // ppp packs has widget toooo, so can't hook to additional
    add_action('wp_head', 'ym_firesale_ppp_packs');
    add_shortcode('app_counter', 'ym_fire_shortcode_parse');
}
Example #6
0
                $wpdb->query($sql);
                if ($wpdb->insert_id) {
                    echo '<p>' . __('Email Associated', 'ym_mailmanager') . '</p>';
                } else {
                    echo '<p>' . __('Email Failed to be Associated', 'ym_mailmanager') . '</p>';
                }
                ym_box_bottom();
                ym_box_top(__('Email Series', 'ym_mailmanager'));
            }
        } else {
            if ($del_id = ym_get('deleteid')) {
                $sql = 'DELETE FROM ' . $wpdb->prefix . 'mm_email_in_series WHERE id = ' . $del_id;
                $wpdb->query($sql);
            }
        }
        if ($series = ym_get('series')) {
            echo '<form action="" method="post">
			<input type="hidden" name="series" value="' . $series . '" />
			<table class="form-table">';
            $emails = mailmanager_get_emails(TRUE);
            if ($emails) {
                echo $ym_formgen->render_combo_from_array_row(__('Select Prior Email', 'ym_mailmanager'), 'email_id', $emails, '', __('Select a previously created email', 'ym_mailmanager'));
            }
            $days = array();
            for ($x = 0; $x <= 365; $x++) {
                $days[$x] = $x . ' Days';
            }
            echo $ym_formgen->render_combo_from_array_row(__('Select Delay', 'ym_mailmanager'), 'delay', $days, '', __('Select number of days between emails', 'ym_mailmanager'));
            echo '
			</table>
			<p style="text-align: right;">
        echo '</div>';
        return;
    default:
        if (ym_get('message')) {
            echo '<div id="message" class="updated fade"><p>';
        }
        if (ym_get('message') == 'ok') {
            echo __('Packages were updated', 'ym');
        }
        if (ym_get('message') == 'order') {
            echo __('Package order was updated', 'ym');
        }
        if (ym_get('message') == 'deleted') {
            echo __('The Pack was deleted', 'ym');
        }
        if (ym_get('message')) {
            echo '</p></div>';
        }
        ym_box_top('&nbsp');
        echo '<form action="' . $link . 'order" method="post" onsubmit="ym_process_sort();">';
        echo '<table class="form-table" id="sorttable">';
        $header = '<tr>
				<th style="width: 20px;">' . __('ID', 'ym') . '</th>
				<th>' . __('Label', 'ym') . '</th>
				<th>' . __('Cost', 'ym') . '</th>
				<th>' . __('Package Type', 'ym') . '</th>
				<th>' . __('WP Role', 'ym') . '</th>
				<th style="width: 40px;">' . __('Visible', 'ym') . '</th>
				<th style="width: 40px;">' . __('Group', 'ym') . '</th>
				<th style="width: 100px; text-align: center;">' . __('User Count', 'ym') . '</th>
				<th style="width: 20px;"></th><th style="width: 20px;"></th>
    foreach ($available_modules as $entry => $modules_dir) {
        $class = rtrim($entry, '.php');
        require_once $modules_dir . '/' . $entry;
        $obj = new $class();
        $status = in_array($class, (array) $ym_active_modules) ? 'Active' : 'Inactive';
        $links = '';
        if ($status == 'Active') {
            if (method_exists($obj, 'load_options')) {
                $links .= '<a href="' . YM_ADMIN_URL . '&ym_page=' . ym_get('ym_page') . '&action=modules&mode=options&sel=' . $entry . '">' . __('Settings</a>', 'ym') . '</a>';
            }
            $links .= '<br />';
            if ($entry != 'ym_free.php') {
                $links .= '<a href="' . YM_ADMIN_URL . '&ym_page=' . ym_get('ym_page') . '&action=modules&mode=deactivate&sel=' . $entry . '">' . __('Deactivate', 'ym') . '</a>';
            }
        } else {
            $activate_url = YM_ADMIN_URL . '&ym_page=' . ym_get('ym_page') . '&action=modules&mode=activate&sel=' . $entry;
            $links = sprintf(__('<a href="%s">Activate</a>', 'ym'), $activate_url);
        }
        $desc = $obj->description;
        echo '
		<tr valign="top">
			<td valign="top" width="10%"><span style="font-size: 14px;">' . $obj->name . '</span></td>
			<td valign="top">' . strip_tags($desc) . '</td>
			<td valign="top" width="7%" style="color:' . ($status == 'Active' ? '#00AA00' : '#FF0000') . ';">' . $status;
        if (isset($obj->version)) {
            echo '<br />R: ' . preg_replace('/[^0-9]/', '', $obj->version);
        }
        echo '</td>
			<td width="8%" valign="top">' . $links . '</td>
		</tr>
		';
function ym_coupon_update()
{
    $coupon_id = ym_get('coupon_id');
    $name = ym_post('name');
    $value = ym_post('value');
    $description = ym_post('description');
    $allowed = (ym_post('new_sub') ? '1' : '0') . (ym_post('upgrade') ? '1' : '0') . (ym_post('post') ? '1' : '0') . (ym_post('pack') ? '1' : '0');
    $usage_limit = ym_post('usage_limit');
    if (ym_post('save_coupon')) {
        ym_save_coupon($name, $value, $description, $allowed, $usage_limit);
    }
    if (ym_post('update_coupon')) {
        ym_edit_coupon($coupon_id, $name, $value, $description, $allowed, $usage_limit);
    }
    if (ym_get('delete_coupon')) {
        $coupon_id = ym_get('delete_coupon');
        ym_delete_coupon($coupon_id);
    }
}
Example #10
0
 function get_button_code($pack, $user_id, $override_price = FALSE)
 {
     get_currentuserinfo();
     global $current_user, $ym_sys;
     $email = isset($current_user->user_email) ? $current_user->user_email : '';
     if (!$email) {
         if ($user = ym_get('username')) {
             $user = get_user_by('login', $user);
             $email = $user->user_email;
         }
     }
     $data = array('sid' => $this->merchant_sid, 'mode' => '2CO', 'demo' => $this->status == 'live' ? 'N' : 'Y', 'return_url' => site_url($this->cancel_url), 'skip_landing' => $this->skip_landing, 'li_1_type' => 'product', 'li_1_name' => isset($pack['item_name']) && $pack['item_name'] ? $pack['item_name'] : $ym_sys->item_name, 'li_1_quantity' => 1, 'li_1_price' => $override_price ? $override_price : $pack['cost'], 'email' => $email);
     $vat = FALSE;
     if (isset($pack['vat_applicable']) && $pack['vat_applicable'] || $ym_sys->global_vat_applicable) {
         if ($ym_sys->vat_rate) {
             $data = array_merge($data, array('li_2_product_id' => 'tax', 'li_2_description' => 'Tax for Product', 'li_2_type' => 'tax', 'li_2_name' => 'Tax', 'li_2_quantity' => 1, 'li_2_price' => $ym_sys->vat_rate));
             $vat = TRUE;
         }
     }
     if ($vat_rate = apply_filters('ym_vat_override', false, $user_id)) {
         $data = array_merge($data, array('li_2_product_id' => 'tax', 'li_2_description' => 'Tax for Product', 'li_2_type' => 'tax', 'li_2_name' => 'Tax', 'li_2_quantity' => 1, 'li_2_price' => $vat_rate));
         $vat = TRUE;
     }
     // addition per type
     if (isset($pack['num_cycles']) && $pack['num_cycles'] != 1 && $pack['duration_type']) {
         // subscription
         $data['li_1_product_id'] = 'buy_subscription_' . $pack['id'] . '_' . $user_id;
         // start up feed
         if (isset($pack['2checkout_startupfee']) && $pack['2checkout_startupfee']) {
             $data['li_1_startup_fee'] = $pack['2checkout_startupfee'];
         }
         // recurring
         // patch
         if ($pack['duration_type'] == 'd') {
             $pack['duration'] = number_format($pack['duration'] / 7, 0);
             $pack['duration_type'] == 'w';
         }
         $duration_str = array('w' => 'Week', 'm' => 'Month', 'y' => 'Year');
         $data = array_merge($data, array('li_1_duration' => $pack['num_cycles'] ? $pack['num_cycles'] : 'forever', 'li_1_recurrence' => $pack['duration'] . ' ' . $duration_str[$pack['duration_type']]));
         if ($vat) {
             $data['li_2_duration'] = $data['li_1_duration'];
             $data['li_2_recurrence'] = $data['li_1_recurrence'];
         }
     } else {
         // post/single
         if (isset($pack['id'])) {
             $data['li_1_product_id'] = 'buy_subscription_' . $pack['id'] . '_' . $user_id;
         } else {
             // post
             if (isset($pack['ppp_pack_id'])) {
                 $data['li_1_product_id'] = 'buy_bundle_' . $pack['ppp_pack_id'] . '_' . $user_id;
             } else {
                 if (isset($pack['ppp_adhoc_posts'])) {
                     $data['li_1_product_id'] = 'buy_post_' . implode(',', $pack['ppp_adhoc_posts']) . '_' . $user_id;
                 } else {
                     $data['li_1_product_id'] = 'buy_post_' . ($pack['post_id'] ? $pack['post_id'] : get_the_ID()) . '_' . $user_id;
                 }
             }
         }
     }
     $data['x_receipt_link_url'] = esc_html(site_url('?ym_process=' . $this->code));
     $data['custom_return_url'] = $this->redirectlogic($pack);
     return $data;
 }
Example #11
0
 function do_process()
 {
     // IPN Handler
     echo __('One Moment... Processing', 'ym');
     if (!ym_get('msgType') || !ym_get('installation') || !ym_post('M_item_number')) {
         header('HTTP/1.1 400 Bad Request');
         echo 'Error in IPN. Missing msgType, installation or item_number.';
         exit;
     }
     if (ym_get('installation') != ym_post('installation') || ym_post('installation') != $this->inst_id) {
         header('HTTP/1.1 401 Unauthorized');
         echo 'Error in IPN. Missing installation ID or Invalid';
         exit;
     }
     if ($this->callbackPW && ym_post('callbackPW') != $this->callbackPW) {
         header('HTTP/1.1 401 Unauthorized');
         echo 'Error in IPN. Missing callbackPW or invalid.';
         exit;
     }
     $array = array('Merchant Cancelled', 'Customer Cancelled');
     if (ym_post('futurePayStatusChange') && in_array(ym_post('futurePayStatusChange'), $array)) {
         // expired!
         $this->common_process(ym_post('M_item_number'), ym_post('cost'), FALSE, FALSE);
     }
     if (ym_post('rawAuthCode') == 'A') {
         // && ym_post('rawAuthMessage') == 'authorised') {
         // pre 11 catch
         if (isset($_POST['M_custom'])) {
             // is pre
             list($duration, $amount, $currency, $user_id, $account_type, $duration_type) = explode('_', $_POST['M_custom']);
             global $ym_packs;
             foreach ($ym_packs->packs as $pack) {
                 if ((md5($pack['account_type']) == strtolower($account_type) || md5(strtolower($pack['account_type'])) == strtolower($account_type)) && $pack['cost'] == $amount && $pack['duration'] == $duration && strtolower($pack['duration_type']) == strtolower($duration_type)) {
                     $pack_id = $pack['id'];
                     break;
                 }
             }
             if ($pack_id) {
                 $item = 'buy_subscription_' . $pack_id . '_' . $test[3];
             } else {
                 $admin = get_userdata(1);
                 $admin_email = $admin->user_email;
                 ym_email($admin_email, 'YM 10 Packet failed', 'Could not determine what the user is buying after looping thru all packets Debug: <pre>' . print_r($_POST, TRUE)) . "\n\n\n" . print_r($ym_packs, TRUE) . '</pre>';
                 header('HTTP/1.1 400 Bad Request');
                 exit;
             }
         } else {
             $item = ym_post('M_item_number');
         }
         // success
         $this->common_process($item, ym_post('cost'), TRUE, FALSE);
         $url = ym_post('M_return');
         if (ym_post('futurePayId')) {
             list($buy, $what, $id, $user_id) = explode('_', $item);
             update_user_meta($user_id, 'ym_worldpay_futurepay_id', ym_post('futurePayId'));
         }
     } else {
         // must be C - cancelled payment
         // where go?
         if (isset($this->cancel_url) && $this->cancel_url) {
             $url = site_url($this->cancel_url);
         } else {
             $url = site_url('/');
         }
     }
     echo '<meta http-equiv="refresh" content="0;' . $url . '" />';
     exit;
 }
function ym_check_for_gift_sub()
{
    global $wpdb;
    // gift sub
    if (ym_post('submit')) {
        if (ym_post('post_id')) {
            $sql = 'SELECT COUNT(id)
								FROM ' . $wpdb->prefix . 'posts_purchased
								WHERE
										user_id = ' . ym_post('user_id') . '
										AND post_id = ' . ym_post('post_id');
            if (!$wpdb->get_var($sql)) {
                $sql = 'INSERT INTO ' . $wpdb->prefix . 'posts_purchased (user_id, post_id, unixtime)
								VALUES (' . $_POST['user_id'] . ', ' . $_POST['post_id'] . ', UNIX_TIMESTAMP())';
                $wpdb->query($sql);
                ym_display_message(__('Post has been successfully gifted', 'ym'));
            } else {
                ym_display_message(__('User has already purchased that post', 'ym'), 'error');
            }
        } else {
            ym_display_message(__('Please select a post to gift before submitting the form', 'ym'), 'error');
        }
    }
    if (ym_get('delete')) {
        $sql = 'DELETE FROM ' . $wpdb->prefix . 'posts_purchased
							WHERE id=' . $_GET['delete'];
        if ($wpdb->query($sql)) {
            ym_display_message(__('Purchased post has been successfully deleted', 'ym'));
        }
    }
    // end
}
Example #13
0
<?php

if (ym_get('login', FALSE)) {
    ym_fbook_wp_login_form();
    return;
}
if (ym_get('ym_fb_profile', FALSE)) {
    ym_fbook_profile(TRUE);
    return;
}
//	query_posts();
if (have_posts()) {
    while (have_posts()) {
        the_post();
        echo '
<div class="post">
	<h2><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to ' . the_title_attribute(array('echo' => false)) . '"';
        if ($facebook_settings->post_breakout) {
            echo ' target="_parent" ';
        }
        echo '>' . get_the_title() . '</a></h2>
';
        //		if ($facebook_settings->use_excerpt && !is_singular()) {
        //echo do_shortcode(get_the_excerpt());
        //			the_excerpt();
        //		} else {
        //echo do_shortcode(get_the_content());
        the_content();
        //		}
        echo ym_fbook_render_like_button(get_permalink(), 'post');
        echo '</div>';
if (isset($error) && !empty($error)) {
    ym_display_mesage($error, 'error');
}
if (isset($sort_msg) && !empty($sort_msg)) {
    ym_display_message($sort_msg);
}
if (isset($sort_error) && !empty($sort_error)) {
    ym_display_mesage($sort_error, 'error');
}
if (!$ym_sys->modified_registration) {
    ym_display_message(__('Modified registration is currently turned off. Custom fields will only show on the profile', 'ym'), 'error');
}
echo '
<div class="wrap" id="poststuff">
';
if (ym_get('mode') != 'edit') {
    echo ym_start_box('&nbsp;');
    echo '<form name="frm" action="" method="post" onsubmit="ym_process_custom_field_sort();">
 <table width="60%" border="0" cellpadding="5" cellspacing="5" align="center" class="form-table" id="sorttable">';
    $head = '
 <tr>
	<th scope="col">' . __('Enable', 'ym') . '</th>
 <th scope="col">' . __('ID', 'ym') . '</th>
 <th scope="col">' . __('Name', 'ym') . '</th>
 <th scope="col">' . __('Label', 'ym') . '</th>
 <th scope="col">' . __('Caption', 'ym') . '</th>
 <th scope="col">' . __('Type', 'ym') . '</th>
 <th scope="col">' . __('Required', 'ym') . '</th>
 <th scope="col">' . __('Read Only', 'ym') . '</th>
 <th scope="col">' . __('Profile Only', 'ym') . '</th>
 <th scope="col">' . __('Hide On Profile', 'ym') . '</th>
 function save()
 {
     if (isset($this->version)) {
         unset($this->version);
         //never store the version
     }
     update_option($this->code, $this);
     if (ym_get('ym_page')) {
         echo '<div id="message" class="updated fade"><p>' . sprintf(__('Updated Settings for %s', 'ym'), $this->name) . '</div>';
     }
 }
function ym_register_catch_gateway()
{
    if (ym_get('gateway_return') && !ym_post('ym_did_gateway_return')) {
        // callback script
        $_GET['from_gateway'] = ym_get('gateway_return');
        ym_login_js();
        // continue
        echo '
<form action="" method="post" id="ym_register_flow_form">
	<input type="hidden" name="ym_register_flow_page" value="' . $_REQUEST['ym_register_flow_page'] . '" />
	<input type="hidden" name="ym_register_flow_next_page" value="' . $_REQUEST['ym_register_flow_next_page'] . '" />
	';
        if (!$_REQUEST['ym_register_flow_next_page']) {
            echo '<input type="hidden" name="flowcomplete" value="1" />';
        }
        echo '
	<input type="hidden" name="ym_did_gateway_return" value="1" />
	<input type="submit" value="' . __('Continue', 'ym') . '" />
</form>	

<script type="text/javascript">
	document.forms["ym_register_flow_form"].submit();
</script>
';
        exit;
    }
}
Example #17
0
function ym_loaded()
{
    // last globals
    global $current_user, $ym_user;
    get_currentuserinfo();
    if (is_user_logged_in()) {
        // as the user is logged in....
        $ym_user = new YourMember_User($current_user->ID);
    } else {
        // blank one
        $ym_user = new YourMember_User();
    }
    global $wpdb, $ym_auth, $ym_dl_db, $ym_dl_post_assoc, $ym_sys, $plugin_file;
    global $wp_upload, $ym_upload_root, $ym_upload_url;
    if (ym_get('ym_go') == 'support') {
        header('Location: ' . YM_SUPPORT_LINK);
        exit;
    }
    // TODO: tidy all these calls up again
    //Localization
    add_action('init', 'ym_load_lang');
    // admin bar
    add_action('init', 'ym_admin_nav');
    add_action('admin_bar_menu', 'ym_admin_bar', 90);
    // context help (help in the top right)
    if (is_admin()) {
        add_action('ym_pre_admin_loader', 'ym_database_updater', 10, 1);
        // interrupt?
        if (ym_request('do_munch')) {
            ym_admin_loader();
            exit;
        }
        // main drag
        add_action('admin_menu', 'ym_admin_page');
        //Plugin Panel Hooks
        add_filter('plugin_action_links', 'ym_action_link', 10, 2);
        // user edit
        add_action('user_edit_form_tag', 'ym_form_enctype');
        // conf bypasses
        ym_conf_bypass();
        //		add_action('load-toplevel_page_ym/admin/ym-index', 'ym_context_help');
        add_action('load-toplevel_page_' . YM_ADMIN_FUNCTION, 'ym_context_help');
        add_action('load-your-members_page_' . YM_ADMIN_DIR . 'ym-about', 'ym_context_help');
    } else {
        // SSL
        add_action('init', 'ym_go_ssl');
        add_action('posts_selection', 'ym_go_ssl_pages');
        if ($ym_sys->enable_metered) {
            add_action('init', 'ym_check_metered_access');
        }
        add_action('get_footer', 'ym_affiliate_link');
    }
    // call version check
    ym_check_version();
    if ($ym_auth->ym_check_key()) {
        $wp_upload = wp_upload_dir();
        if ($wp_upload['error']) {
            if (is_admin() && ym_get('page') == YM_ADMIN_FUNCTION && !ym_request('ym_page')) {
                echo '<div id="message" class="error"><p>' . $wp_upload['error'] . '</p></div>';
            }
        } else {
            $ym_upload_root = $wp_upload['path'];
            $ym_upload_url = $wp_upload['url'];
        }
        ym_create_log_constants();
        //Must be first for any logging that occurs from hereonin
        ym_suppress_enclosure_check();
        add_action('mod_rewrite_rules', 'ym_block_wp_login_action_register');
        add_action('admin_init', 'ym_block_wp_login_action_register_flush');
        if (!is_admin()) {
            ym_download_response();
            //checks for a download id in the url
            global $ym_manage_access;
            $ym_manage_access = new YourMember_Manage_Access();
            if ($ym_sys->protect_mode) {
                add_action('template_redirect', array($ym_manage_access, 'exit_check'));
            }
            add_shortcode('private', 'ym_shortcode_parse');
            add_shortcode('no_access', 'ym_shortcode_parse');
            add_shortcode('user_has_access', 'ym_shortcode_parse');
            add_shortcode('ym_user_profile', 'ym_edit_custom_field_standalone');
            add_shortcode('ym_rss_token', 'ym_get_rss_token');
            add_shortcode('ym_upgrade', 'ym_shortcode_parse');
            add_shortcode('ym_packs', 'ym_shortcode_parse');
            add_shortcode('private_or', 'ym_shortcode_parse');
            add_shortcode('private_and', 'ym_shortcode_parse');
            add_shortcode('ym_membership_content', 'ym_membership_content_shortcode');
            // TODO: Deprecate 11.0.6
            add_shortcode('user_account_is', 'ym_shortcode_parse');
            add_shortcode('private_username_is', 'ym_shortcode_parse');
            // Replace with
            add_shortcode('ym_user_is', 'ym_user_is');
            add_shortcode('ym_user_is_not', 'ym_user_is_not');
            add_shortcode('ym_user_custom_is', 'ym_user_custom_is');
            add_shortcode('ym_user_custom_is_not', 'ym_user_custom_is_not');
            add_shortcode('ym_profile', 'ym_get_user_profile');
            add_shortcode('ym_purchase_history', 'ym_get_user_purchase_history_shortcode');
            add_shortcode('ym_gateway_cancel', 'ym_get_user_unsub_button_gateway');
            add_shortcode('ym_gravatar', 'ym_gravatar_render');
            // start content
            // buy now
            add_shortcode('ym_buy_content', 'ym_buy_button_content');
            add_filter('the_content', 'ym_buy_button_content_filter', 1, 1);
            add_shortcode('ym_buy_bundle', 'ym_buy_button_bundle');
            add_filter('the_content', 'ym_buy_button_bundle_filter', 1, 1);
            // end buy now
            // indexy
            add_shortcode('ym_all_content', 'ym_get_all_content_buttons');
            add_shortcode('ym_all_bundles', 'ym_get_all_bundle_buttons');
            add_shortcode('ym_featured_content', 'ym_get_featured_content_buttons');
            // end indexy
            add_shortcode('ym_content_units_left', 'ym_content_units_left');
            add_shortcode('ym_bundle_units_left', 'ym_bundle_units_left');
            //pass ID
            add_shortcode('ym_content_units_sold', 'ym_content_units_sold');
            add_shortcode('ym_bundle_units_sold', 'ym_bundle_units_sold');
            //pass ID
            add_shortcode('ym_content_units_limit', 'ym_content_units_limit');
            add_shortcode('ym_bundle_units_limit', 'ym_bundle_units_limit');
            //pass ID
            add_shortcode('ym_content_expiry_date', 'ym_post_purchased_expiry');
            // so that an expiry date can be shown once a post has been purchased
            add_shortcode('ym_content_purchase_date', 'ym_post_last_purchased_date');
            //so that a purchase date can be shown once a post has been purchased
            add_shortcode('ym_bundle_expiry_date', 'ym_bundle_purchased_expiry');
            add_shortcode('ym_bundle_purchase_date', 'ym_bundle_last_purchased_date');
            // end content
            add_shortcode('ym_register', 'ym_shortcode_parse');
            add_shortcode('ym_login', 'ym_shortcode_parse');
            add_shortcode('ym_drip_date', 'ym_shortcode_parse');
            add_shortcode('ym_user_password_form', 'ym_user_password_form');
            add_shortcode('ym_user_profile_form', 'ym_user_profile_form');
            add_shortcode('ym_user_unsubscribe', 'ym_user_unsubscribe');
            add_shortcode('ym_promote', 'ym_shortcode_aff_link');
            $hook = $ym_sys->download_hook ? $ym_sys->download_hook : 'download';
            add_shortcode($hook, 'ym_dl_ins');
            //Profile Data
            add_shortcode('ym_user_register_date', 'ym_shortcode_user');
            add_shortcode('ym_user_email', 'ym_shortcode_user');
            add_shortcode('ym_user_first_name', 'ym_shortcode_user');
            add_shortcode('ym_user_last_name', 'ym_shortcode_user');
            add_shortcode('ym_user_username', 'ym_shortcode_user');
            add_shortcode('ym_user_description', 'ym_shortcode_user');
            add_shortcode('ym_user_custom', 'ym_shortcode_user');
        }
        //CSS
        add_action('wp_enqueue_scripts', 'ym_styles');
        add_action('login_enqueue_scripts', 'ym_login_styles');
        //	if ($ym_auth->ym_check_key()) {
        add_action('init', array('ym_cron', 'init'), 20);
        // run manual cron if needed, check schedules if not
        add_filter('wp_authenticate_user', 'ym_authenticate');
        if ($ym_sys->modified_registration) {
            add_action('user_register', 'ym_register', 10, 1);
            add_action('register_form', 'ym_register_form', 10, 6);
            add_action('register_post', 'ym_register_post', 10, 3);
        } else {
            add_action('user_register', 'ym_register_default', 10, 1);
        }
        /**
        WP Admin block/login redirect
        Logout redirect
        */
        add_action('login_head', 'ym_login_redirect');
        add_action('wp_login', 'ym_wp_login', 1, 2);
        add_action('admin_head', 'ym_stop_wp_admin', 1);
        add_action('wp_logout', 'ym_wp_logout', 1);
        /**
        Loginism
        */
        add_action('login_head', 'ym_login_js');
        // fire on non login page
        add_action('wp_head', 'ym_login_js');
        /**
        Login Register
        */
        // custom messages for login form
        add_filter('login_message', 'ym_login_message');
        // remove password string?
        //		add_action('login_head', 'ym_login_remove_password_string');
        /**
        Login themeing
        */
        // login page overrides
        if ($ym_sys->wp_login_header_url) {
            add_filter('login_headerurl', 'ym_login_headerurl');
            add_filter('login_headertitle', 'ym_login_headertitle');
        }
        if ($ym_sys->wp_login_header_logo) {
            add_action('login_head', 'ym_login_header_logo');
        }
        add_action('init', 'ym_subscribe_response');
        add_action('init', 'ym_upgrade_response');
        add_action('init', 'ym_register_catch_gateway');
        add_action('admin_enqueue_scripts', 'ym_admin_script_init');
        add_action('wp_head', 'ym_js_varibles');
        add_action('init', 'ym_process_response');
        add_action('parse_query', 'ym_thank_you_response');
        add_action('init', 'ym_init');
        /**
        		custom fields
        		**/
        if (is_admin()) {
            // hook for catching core fields and updating out own (wp-admin)
            add_action('profile_update', 'ym_update_custom_fields');
        }
        add_action('show_user_profile', 'ym_edit_custom_fields');
        add_action('edit_user_profile', 'ym_edit_custom_fields');
        //		add_filter('print_scripts_array', 'ym_fix_tinymce_conflict');
        add_filter('rewrite_rules_array', 'ym_rewrite_rule');
        /**
        widgets
        */
        add_action('init', 'ym_widget_init');
        add_action('init', 'ym_sidebar_init');
        add_action('init', 'ym_register_sidebar_init');
        add_filter('widget_text', 'do_shortcode');
        /**
        Email
        */
        // Replaces the From Name and Address with custom info
        if ($ym_sys->filter_all_emails) {
            add_filter('wp_mail_from', 'ym_mail_from');
            add_filter('wp_mail_from_name', 'ym_mail_from_name');
        }
        /**
        RSS Repair
        */
        add_action('atom_head', 'ym_rss_stop_payments');
        add_action('rdf_head', 'ym_rss_stop_payments');
        add_action('rss_head', 'ym_rss_stop_payments');
        add_action('rss2_head', 'ym_rss_stop_payments');
        if (is_admin()) {
            // new data export/import
            if (ym_post('ym_exporting_users')) {
                ym_export_users(ym_post('offset', 0), ym_post('limit', 300), ym_post('bkpackagetype', 'all'), ym_post('bkpackage', 'all'), ym_post('bkinactive', 0));
                exit;
            }
            ym_import_users_from_csv();
            //check for CSV import request in post
            //			add_action('after_plugin_row','ym_info_note', 10, 3);
            // only add TinyMCE buttons to Post/Page/Custom Post Type new Content/Edit Content WP Editor Field
            // if user has access to admin
            // and if the request_uri matches a known post editor location
            if (ym_admin_user_has_access(true) && strpos($_SERVER['REQUEST_URI'], 'wp-admin/post')) {
                add_action('add_meta_boxes', 'ym_meta_box_setup');
                add_action('save_post', 'ym_account_save');
                add_action('init', 'ym_tinymce_addbuttons');
            }
            // tos check
            //			ym_tos_check();
            // hooks that can result in a dialog/iframe
            add_action('admin_notices', 'ym_get_advert');
            $ym_upgrade_action = ym_check_upgrade();
            // lightbox and message hook
            if (ym_get(YM_ADMIN_FUNCTION . '_activated')) {
                add_action('admin_notices', 'ym_do_welcome_box');
                add_action('admin_notices', 'ym_activated_thanks_box');
            } else {
                if ($ym_upgrade_action) {
                    add_action('admin_notices', 'ym_do_welcome_box');
                    add_action('admin_notices', 'ym_upgrade_nag_box');
                }
            }
        }
    }
    do_action('ym_loaded_complete');
}
            if ($this_job['core'] == 2) {
                // try for do_action
                do_action($cron_task);
                echo '<div class="updated" id="message"><p>';
                echo __('Task Complete', 'ym');
                echo '</p></div>';
            } else {
                echo '<div class="error" id="message"><p>';
                echo __('Could Not Execute Class Not Found', 'ym');
                echo '</p></div>';
            }
        }
    }
    return;
}
if (ym_get('reschedule', FALSE)) {
    echo '<div id="message" class="updated fade"><p>' . __('Rescheduling Tasks Complete', 'ym') . '</p></div>';
}
echo '<div class="wrap" id="poststuff">
<form action="" method="post">';
echo ym_box_top(__('Manual Cron Control', 'ym'));
echo '<table class="form-table">';
echo $ym_formgen->render_form_table_radio_row(__('Use Manual Cron (crontab) rather than WP Cron?', 'ym'), 'enable_manual_cron', $ym_sys->enable_manual_cron, __('For larger sites its recommended to set this to true and use crontab. The command is below. This will run YM Cron functions only not other WP Cron Tasks'));
echo '</table>';
echo '<p>' . __('Add the following line to your crontab if enabled, the first argument (59), is the minute, the second argument (23) the hour, together make up the time to run the task. More Information <a href="http://en.wikipedia.org/wiki/Cron#Predefined_scheduling_definitions">Here</a>', 'ym');
echo '<br /><pre>';
echo '59 23 * * * wget -O cronresult.html ' . site_url('?ym_cron_do=1');
echo '</pre><br /></p>';
echo '<p>' . __('Rather than Running all tasks, you can instead call a specific task', 'ym') . '</p>';
echo '<ul>';
foreach ($ym_crons_that_exist as $cron_job) {
Example #19
0
    $connection_string = YM_DEACTIVATE_URL . '&email=' . get_option('ym_license_key');
    $response = ym_remote_request($connection_string);
    delete_option('ym_license_key');
    delete_option('ym_tos_version_accepted');
    if (ym_get('ym_uninstall')) {
        // nuke it all!
        ym_deactivate();
    }
    echo '<meta http-equiv="refresh" content="0;plugins.php?deactivate=true" />';
    exit;
}
// Database updates can be called on this hook
do_action('ym_pre_admin_loader');
get_currentuserinfo();
global $current_user, $ym_auth, $ym_res, $ym_sys;
$ym_page = ym_get('ym_page');
if ($ym_auth->ym_check_key()) {
    if (!ym_tos_checks()) {
        // no TOS stuff in progress
        echo '<div class="wrap"><h2>' . YM_ADMIN_NAME . '</h2>';
        // wizard
        ym_wizard_render();
        // loop
        ym_admin_menu();
        echo '<div style="clear: both; padding: 0px; margin: 0px;">';
        ym_admin_loader();
        echo '</div>';
        ym_admin_menu_end();
        // end
        echo '</div>';
    }
Example #20
0
function mailmanager_unsub_check()
{
    if (ym_get('ym_mm_action') == 'unsubscribe') {
        /*
        $current_settings = get_option('ym_other_mm_settings');
        if ($current_settings->mail_gateway != 'wp_mail') {
        	// hook
        	$callback = 'ym_mm_' . $current_settings->mail_gateway . '_unsub_block';
        	if (function_exists($callback)) {
        		$break = FALSE;
        		call_user_func($callback, $list, $user, &$break);
        		if ($break) {
        			return;
        		}
        	}
        }
        */
        $series = ym_get('series_id');
        $user = ym_get('user_id');
        if ($series && $user) {
            // the_content
            global $wpdb;
            $sql = 'SELECT recipient_list FROM ' . $wpdb->prefix . 'mm_user_series_assoc WHERE series_id = \'' . $series . '\'';
            $list = $wpdb->get_var($sql);
            $sql = 'INSERT INTO ' . $wpdb->prefix . 'mm_list_unsubscribe (list_name, user_id) VALUES (' . $list . ', ' . $user . ')';
            $wpdb->query($sql);
            $current_settings = get_option('ym_other_mm_settings');
            header('Location: ' . $current_settings->unsubscribe_page);
            exit;
        }
    }
}
function ym_fbook_init()
{
    global $facebook_settings, $location;
    //	session_start();// wp does this
    if (ym_request('destroy')) {
        session_destroy();
        header('Location: ' . site_url());
        exit;
    }
    $location = get_permalink() ? get_permalink() : 'http' . (is_ssl() ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    /********************************************/
    /* AWAKE?
    	/********************************************/
    if (!ym_facebook_settings()) {
        // no settings
        // iframe break out if iframe present
        add_action('wp_head', 'ym_fbook_init_iframe_breakout');
        // abort
        return;
    }
    if (!$facebook_settings->enabled) {
        // not enabled
        // iframe break out if iframe present
        add_action('wp_head', 'ym_fbook_init_iframe_breakout');
        // abort
        return;
    }
    /********************************************/
    /* Aborts
    	/********************************************/
    if (is_admin()) {
        // in the admin system
        return;
    }
    // abort login
    if (FALSE !== strpos($_SERVER['REQUEST_URI'], 'wp-login')) {
        return;
    }
    // IPN
    if (ym_request('ym_process')) {
        return;
    }
    // Cron
    if (ym_request('doing_wp_cron')) {
        return;
    }
    /********************************************/
    /* basic defines
    	/********************************************/
    define('YM_FBOOK_APPID', $facebook_settings->app_id);
    define('YM_FBOOK_SECRET', $facebook_settings->app_secret);
    $Location = str_replace('?logged_out=1', '', $location);
    define('YM_FBOOK_IN_HERE', $location);
    // app target
    define('YM_FBOOK_APP_TARGET', 'https://apps.facebook.com/' . $facebook_settings->canvas_url . str_replace(site_url(), '', $location));
    define('YM_FBOOK_PAGE_TARGET', 'https://facebook.com/' . $facebook_settings->page_url . '?sk=app_' . YM_FBOOK_APPID);
    // can't take args
    if (isset($_SESSION['facebook_last_page']) && $_SESSION['facebook_last_page']) {
        define('YM_FBOOK_LAST_PAGE', $_SESSION['facebook_last_page']);
    } else {
        // TODO: use location for now, but should be defined FB Root URL based on page/app
        define('YM_FBOOK_LAST_PAGE', $location);
    }
    $_SESSION['facebook_last_page'] = $location;
    /********************************************/
    /* Linter
    	/********************************************/
    // come back to this if needed
    $test = 'facebookexternalhit';
    if (substr($_SERVER['HTTP_USER_AGENT'], 0, strlen($test)) == $test) {
        return;
    }
    /********************************************/
    /* Scope
    	/********************************************/
    $scope = array();
    global $scopes;
    foreach ($scopes as $fbsetting => $entry) {
        if (isset($facebook_settings->{$fbsetting}) && $facebook_settings->{$fbsetting}) {
            $scope[] = $entry;
        }
    }
    if (count($scope)) {
        $scope = '&scope=' . implode(',', $scope);
    } else {
        $scope = '';
    }
    /********************************************/
    /* Defines
    	/********************************************/
    // oauth target
    $base = 'http://www.facebook.com/dialog/oauth/?client_id=' . YM_FBOOK_APPID . $scope . '&redirect_uri=';
    define('YM_FBOOK_AUTH_APP', $base . urlencode(YM_FBOOK_APP_TARGET));
    define('YM_FBOOK_AUTH_PAGE', $base . urlencode(YM_FBOOK_PAGE_TARGET));
    define('YM_FBOOK_AUTH_NO', $base . urlencode($location));
    /********************************************/
    /* Exceptions
    	/********************************************/
    if (isset($_SESSION['in_facebook']) && $_SESSION['in_facebook'] == 1 && ym_request('leavefacebook') == 1 && $facebook_settings->enable_leave_facebook) {
        // leaving :-(
        unset($_SESSION['in_facebook']);
        // route to last page, not current page (aka location)
        // as that is leavefacebook = 1
        echo '<script type="text/javascript">top.location.href="' . $_SESSION['facebook_last_page'] . '";</script>';
        exit;
    }
    if (ym_request('loggedout') == 1) {
        wp_logout();
        $in_facebook = isset($_SESSION['in_facebook']) ? $_SESSION['in_facebook'] : FALSE;
        $in_facebook_page = isset($_SESSION['in_facebook_page']) ? $_SESSION['in_facebook_page'] : FALSE;
        session_destroy();
        session_start();
        $_SESSION['in_facebook'] = $in_facebook;
        $_SESSION['in_facebook_page'] = $in_facebook_page;
        $r = ym_fbook_oauth_go();
        //		echo $r . '<br />';
        $r = str_replace(array('loggedout=1&', 'loggedout=1'), '', $r);
        $r = str_replace(array(urlencode('loggedout=1&'), urlencode('loggedout=1')), '', $r);
        //		$_SESSION['ym_fb_auth_target'] = $r;
        $_SESSION['ym_fb_auth_target'] = str_replace(array(urlencode('loggedout=1&'), urlencode('loggedout=1'), 'loggedout=1'), '', $_SESSION['ym_fb_auth_target']);
        //		echo $r;
        //echo $_SESSION['ym_fb_auth_target'];
        //echo '<script type="text/javascript">top.location.href="' . $_SESSION['ym_fb_auth_target'] . '";</script>';
        echo '<script type="text/javascript">top.location.href="' . $r . '";</script>';
        exit;
    }
    // Ping check to see if facebook exists and is alive
    // Most commonly analytics
    if (ym_get('ymfbook')) {
        $_SESSION['in_facebook'] = 1;
    }
    if ($_SESSION['in_facebook']) {
        wp_enqueue_script('ym-fb', site_url('wp-content/plugins/ym_facebook/js/fb.js'), array('jquery'), YM_FB_PLUGIN_VERSION);
        wp_enqueue_style('ym-fb-login', site_url('wp-content/plugins/ym_facebook/css/ym_fbook_login.css'), array(), YM_FB_PLUGIN_VERSION);
    }
    // height controls
    if ($facebook_settings->iframe_size == 'scrollbars') {
        if ($facebook_settings->iframe_size_height) {
            define('YM_FBOOK_HEIGHT', 'FB.Canvas.setSize({height: ' . $facebook_settings->iframe_size_height . '});');
        } else {
            define('YM_FBOOK_HEIGHT', '');
            // height of window-ish
        }
    } else {
        define('YM_FBOOK_HEIGHT', 'FB.Canvas.setAutoResize();');
    }
    // width controls
    if (isset($_SESSION['in_facebook_page']) && $_SESSION['in_facebook_page']) {
        $width = 450;
    } else {
        $width = 600;
    }
    define('YM_FBOOK_WIDTH', $width);
    /********************************************/
    /* post or session
    	/********************************************/
    if (ym_post('signed_request', false)) {
        // landed in facebook from the outside world
        // store the request
        $_SESSION['facebook_signed_request'] = $_POST['signed_request'];
        // set in facebook here as we are defo. in facebook
        // cant do it on data uncode as we could be on the main site
        // using a wordpress side facebook like wall
        // for example
        $_SESSION['in_facebook'] = TRUE;
        // if in_facebook then redirect there
        // if in_facebook and in_facebook_page then go to page
        // if in_facebook_page only do nothing (as not in facebook)
        $_SESSION['facebook_signed_request'] = $_POST['signed_request'];
    }
    /********************************************/
    /* force
    	/********************************************/
    if ($facebook_settings->force_facebook && !$_SESSION['in_facebook']) {
        // force
        $_SESSION['in_facebook'] = 1;
        if ($facebook_settings->page_url) {
            $_SESSION['in_facebook_page'] = 1;
        }
        header('Location: ' . ym_fbook_oauth_go());
        //header('Location: ' . ($facebook_settings->page_url ? YM_FBOOK_PAGE_TARGET : YM_FBOOK_APP_TARGET));
        exit;
    }
    /********************************************/
    /* interupt for auth
    	/********************************************/
    // check for a get code
    if (ym_get('code')) {
        // landed with a code
        // oAuth return, validate
        // get token
        if ($_SESSION['in_facebook_page'] && $facebook_settings->page_url) {
            $url = 'https://facebook.com/' . $facebook_settings->page_url . '/';
        } else {
            $url = 'https://apps.facebook.com/' . $facebook_settings->canvas_url . '/';
        }
        if (!$_SESSION['ym_fb_auth_target']) {
            // no target
            ym_fbook_oauth_go();
        }
        // generate auth code
        //		$_SESSION['ym_fb_auth_target'] = str_replace(array(urlencode('loggedout=1&'), urlencode('loggedout=1'), 'loggedout=1&', 'loggedout=1'), '', $_SESSION['ym_fb_auth_target']);
        //			'&redirect_uri=' . urlencode($_SESSION['ym_fb_auth_target']) .
        $auth_code = '?client_id=' . YM_FBOOK_APPID . '&redirect_uri=' . urlencode($url) . '&client_secret=' . YM_FBOOK_SECRET . '&code=' . $_GET['code'];
        //		echo $auth_code;//exit;
        // exchange
        $facebook_auth = new Facebook('', $auth_code);
        // decode
        $auth = $facebook_auth->auth;
        $test = json_decode($auth);
        if ($test->error->message) {
            echo $test->error->message;
            ym_fbook_add_message(str_replace('_', ' ', $test->error->message));
            return;
        }
        parse_str($auth, $query);
        $_SESSION['facebook_oauth_token'] = $query['access_token'];
        $_SESSION['facebook_oauth_start'] = time();
        $_SESSION['facebook_oauth_expires'] = $query['expires'];
        // clean
        $_SESSION['ym_fb_auth_target'] = str_replace('code=' . ym_get('code'), '', $_SESSION['ym_fb_auth_target']);
        echo '<script type="text/javascript">top.location.href="' . $_SESSION['ym_fb_auth_target'] . '"</script>';
        unset($_SESSION['ym_fb_auth_target']);
        // and GO BABY GO!!!!!!!!!!!
        exit;
    }
    /********************************************/
    /* munch
    	/********************************************/
    if (isset($_SESSION['facebook_signed_request']) && $_SESSION['facebook_signed_request']) {
        // exisiting session
        // validate
        $data = facebook_uncode($_SESSION['facebook_signed_request']);
        if ($data) {
            // last control
            if (isset($_SESSION['facebook_use_last_page']) && $_SESSION['facebook_use_last_page']) {
                unset($_SESSION['facebook_use_last_page']);
                header('Location: ' . YM_FBOOK_LAST_PAGE);
                exit;
            }
            if (isset($data->page) && $data->page) {
                $_SESSION['facebook_page'] = $data->page;
                // defo in a page
                // should only occur on landing on the page
                $_SESSION['in_facebook_page'] = TRUE;
                // ALERT LANDING TRIGGER LANDING CONTROLLER
                if ($facebook_settings->page_landing && $_SERVER['REQUEST_URI'] != $facebook_settings->page_landing && $_POST['signed_request']) {
                    // somewhere to land
                    header('Location: /' . $facebook_settings->page_landing);
                    exit;
                }
                define('ym_fbphp_dev_in_page', TRUE);
            } else {
                define('ym_fbphp_dev_in_page', TRUE);
            }
            // landing control needed?
            if ($facebook_settings->canvas_landing && $_SERVER['REQUEST_URI'] != $facebook_settings->canvas_landing && $_POST['signed_request'] && !$_SESSION['facebook_has_landed'] && !$_SESSION['in_facebook_page']) {
                // landing control if the Root Page is requested
                header('Location: /' . $facebook_settings->canvas_landing);
                exit;
            }
            $_SESSION['facebook_has_landed'] = TRUE;
            // oauth
            $_SESSION['facebook_oauth_token'] = $data->oauth_token;
            $_SESSION['facebook_oauth_start'] = $data->issued_at;
            $_SESSION['facebook_oauth_expires'] = $data->expires;
        }
    } else {
        if (isset($_SESSION['facebook_oauth_token']) && $_SESSION['facebook_oauth_token']) {
            // we have a facebook session
        } else {
            // no session
            ym_fbook_do_template();
            return;
        }
    }
    // GIVE ME A CLIENT
    global $facebook_client;
    $facebook_client = new Facebook($_SESSION['facebook_oauth_token']);
    if (!$facebook_client->initok) {
        $facebook_client = FALSE;
    } else {
        // permissions check
        // check oauth granted match what we need
        // in case the game has changed.
        $permissions = $facebook_client->permissions();
        global $scopes;
        $scope_copy = $scopes;
        foreach ($scope_copy as $fbsetting => $entry) {
            if (isset($facebook_settings->{$fbsetting}) && $facebook_settings->{$fbsetting}) {
                // check presence
                if (isset($permissions->data[0]->{$entry}) && $permissions->data[0]->{$entry} == 1) {
                    unset($scope_copy[$fbsetting]);
                }
            } else {
                // not requested
                unset($scope_copy[$fbsetting]);
            }
        }
        if (count($scope_copy)) {
            add_action('ym_fbook_messages', 'ym_fbook_messages');
            add_action('template_redirect', 'ym_fbook_template');
            define('FBOOK_TEMPLATE_OVERRIDE', 'login');
            return;
        }
    }
    if ($facebook_client && !$data) {
        // build data
        $data = new stdClass();
        $data->user_id = $facebook_client->user_data->id;
        $data->locale = $facebook_client->user_data->locale;
    }
    // facebook user ID
    $_SESSION['facebook_user_id'] = $data->user_id;
    $_SESSION['locale'] = isset($data->locale) ? $data->locale : 'en_GB';
    // check facebook login
    if ($facebook_settings->force_facebook_auth && !$data->user_id) {
        // require login
        // redirect to facebook login
        // use template login template
        add_action('ym_fbook_messages', 'ym_fbook_messages');
        add_action('template_redirect', 'ym_fbook_template');
        define('FBOOK_TEMPLATE_OVERRIDE', 'login');
        return;
    }
    if (isset($data->id) && $data->id) {
        ym_fbook_has_oauth_expired();
    }
    // check wordpress login
    ym_fbook_maintain_wordpress();
    /*
    if ($_REQUEST['register'] == 1 && !$_SESSION['facebook_registering']) {
    	// need login.....
    	$_SESSION['facebook_use_last_page'] = 1;
    	$_SESSION['facebook_registering'] = 1;
    	unset($_SESSION['ym_facebook_me_cache']);
    	echo '<script type="text/javascript">top.location.href="' . ym_fbook_oauth_go() . '"</script>';
    	exit;
    }
    if ($_REQUEST['register'] == 1 && $_SESSION['facebook_registering']) {
    	// go register dammit
    	add_action('ym_fbook_messages', 'ym_fbook_messages');
    	add_action('template_redirect', 'ym_fbook_template');
    	define('FBOOK_TEMPLATE_OVERRIDE', 'register');
    	return;
    }
    */
    // Hidden Reg
    if ($facebook_settings->register_with_facebook_hidden && $_SESSION['facebook_user_id'] && !$_SESSION['wordpress_user_id']) {
        // not logged into WP
        // go hidden reg
        ym_fbook_hidden_register();
    }
    // action cases
    if (ym_request('dolink', false)) {
        // go for link
        $_SESSION['dolink'] = 1;
        echo '<script type="text/javascript">top.location.href="' . ym_fbook_oauth_go() . '"</script>';
        exit;
    }
    if (ym_session('dolink')) {
        if (!$_SESSION['facebook_user_id']) {
            header('Location: ' . ym_fbook_oauth_go());
            exit;
        }
        ym_fbook_dolink();
    }
    if (ym_request('dounlink')) {
        // unlink
        ym_fbook_dounlink();
    }
    ym_fbook_do_template();
}
<?php

echo '	<div class="wrap" id="poststuff">';
ym_coupon_update();
if ($coupon_id = ym_get('coupon_id')) {
    $coupon = ym_get_coupon($coupon_id);
    if (ym_post('edit')) {
        echo ym_start_box(__('Edit coupon: "', 'ym') . $coupon->name . '"');
        ym_render_coupon_edit($coupon_id);
        echo ym_end_box();
    }
    if (ym_post('view')) {
        echo ym_start_box(__('View Users who used Coupon: "', 'ym') . $coupon->name . '"');
        ym_render_coupon_view($coupon_id);
        echo '<form method="POST">
		<input type="hidden" name="ym_coupon_id" value="' . $coupon_id . '" />
		<input class="button" type="submit" name="ym_start_xls_coupon" value="' . __('Export Data', 'ym') . '" />
		 </form>';
        echo ym_end_box();
    }
} else {
    echo ym_start_box(__('Coupon', 'ym'));
    ym_render_coupons();
    echo ym_end_box();
}
echo '</div>';
/**
Non Flow Register/Upgrade
*/
function ym_available_modules($username = false, $return = false, $coupon_type = 0)
{
    //	echo 'ym_available_modules: ' . $username . ', ' . $return . ', ' . $coupon_type . '<br />';
    global $ym_active_modules, $ym_packs;
    //coupons
    $user_id = ym_get_user_id();
    $ym_custom_fields = ym_get_custom_field_array($user_id);
    $ym_home = site_url();
    $base = $ym_home . '/index.php?ym_subscribe=1&username='******'';
    if ($pack_id = ym_get('pack_id')) {
        // pack ID has been selected
        $pack = ym_get_pack_by_id($pack_id);
        // strip commas
        $cost = str_replace(',', '', $pack['cost']);
        $override = FALSE;
        $code_to_use = 'custom';
        // coupon check
        if (isset($ym_custom_fields['coupon']) && $ym_custom_fields['coupon']) {
            $cost = ym_apply_coupon($ym_custom_fields['coupon'], $coupon_type, $cost);
            if (substr($cost, 0, 4) == 'pack') {
                $pack_id = substr($cost, 5);
                // apply new pack
                $pack = ym_get_pack($pack_id);
                // import data
                $cost = $pack['cost'];
                $duration = $pack['duration'];
                $duration_type = $pack['duration_type'];
                $account_type = $pack['account_type'];
                $num_cycles = $pack['num_cycles'];
            } else {
                // makre sure formatted ok
                $cost = number_format($cost, 2);
                $override = $cost;
                $code_to_use = 'freebie_code';
            }
            ym_register_coupon_use($ym_custom_fields['coupon'], ym_get_user_id(), 'buy_subscription_' . $pack_id);
        }
        // is it free?
        if ($cost == 0) {
            // auto redirect
            $redirector = ym_get('redirector');
            // attempt to redirect to the processor.
            // if attempt fails, we show the button
            $loc = $ym_home . '/index.php?ym_process=ym_free&' . (ym_get('ym_autologin') ? 'ym_autologin=1&' : '') . $code_to_use . '=buy_subscription_' . $pack['id'] . '_' . ym_get_user_id() . '&redirector=' . urlencode($redirector);
            if (!headers_sent()) {
                header('Location: ' . $loc);
                exit;
            } else {
                echo '<script type="text/javascript">window.location = "' . $loc . '";</script>';
            }
            die;
        }
        // gateway selection BuyNow
        $shown = 0;
        $shown_name = '';
        $shown_button = '';
        foreach ($ym_active_modules as $module) {
            $get_button = FALSE;
            if ($module == 'ym_free') {
                continue;
            } else {
                // do pack gateway check
                $get_button = TRUE;
            }
            if ($get_button) {
                ${$module} = new $module();
                $this_button = ${$module}->getButton($pack_id, $override, 'ym_available_modules');
                // a button pay not be returned (pack restrict gateway)
                if ($this_button) {
                    $shown_name = $module;
                    $shown_button = $this_button;
                    $shown++;
                    $html .= $this_button;
                }
            }
        }
        if ($shown == 0) {
            $html .= __('There are no payment gateways available at this time.', 'ym');
        } else {
            if ($shown == 1) {
                if (!method_exists(${$shown_name}, 'abort_auto')) {
                    // TODO: Are we on a page where HTML has been outputted?
                    // auto fire
                    $html = '<html>
						<head>
							<title>Redirecting...</title>
							<script type="text/javascript">
								function load() {
									document.forms["' . $shown_name . '_form"].submit();
								}
							</script>
						</head>
						<body onload="load();">';
                    $html .= '<div style="display: none;">' . $shown_button . '</div>' . '<div style="color: #333333; font-size: 14px; margin: 180px 250px; font-family: tahoma; text-align: center; padding: 50px; border: 1px solid silver;" id="ym_pay_redirect">' . '<div>You are being redirected. If this page does not refresh in 5 seconds then click <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>' . '</div>' . '</body></html>';
                    echo $html;
                    die;
                } else {
                    // aborted the auto fire step
                    $html .= ${$shown_name}->abort_auto();
                }
            }
        }
    } else {
        if (!ym_get('sel', FALSE)) {
            $html .= '<table width="100%" cellpadding="3" cellspacing="0" border="0" align="center" class="like_form">' . '<tr>' . '<th><h3 class="ym_register_heading">' . __('Select Payment Gateway', 'ym') . '</h3></th>' . '</tr>';
            /**
            No Gateway Selected
            Show Gateway Selection
            */
            $shown = 0;
            $shown_name = '';
            foreach ($ym_active_modules as $module) {
                $pay = new $module();
                $packs = $ym_packs->packs;
                $packs = apply_filters('ym_packs', $packs, $pay->code);
                if (count($packs)) {
                    $html .= '<tr>' . '<td align="center" style="padding: 5px; text-align: center;">' . '<a href="' . $base . '&sel=' . $module . '">' . '<div class="ym_module_name"><strong>' . $pay->name . '</strong></div>' . '<img class="ym_module_logo" src="' . $pay->logo . '" alt="' . $pay->name . '" title="' . $pay->name . '" />' . '</a>' . '</td>' . '</tr>';
                    $shown++;
                    $no_gateway = FALSE;
                    $shown_name = $module;
                }
                unset($pay, $packs);
            }
            $html .= '</table>';
            if ($shown == 0) {
                $html .= __('There are no payment gateways available at this time.', 'ym');
            } else {
                if ($shown == 1) {
                    // we only have one to show....
                    // auto fire
                    $loc = $base . '&sel=' . $shown_name;
                    if (!headers_sent()) {
                        header('Location: ' . $loc);
                    } else {
                        echo '<script type="text/javascript">window.location="' . $loc . '";</script>';
                    }
                    exit;
                }
            }
        } else {
            if ($selected = ym_get('sel')) {
                /**
                Gateway selected
                Show Buy Now Buttons for this gateway
                */
                // user has selected a gateway
                if (!class_exists($selected)) {
                    wp_die(sprintf(__('Unknown Module: %s', 'ym'), $selected));
                }
                $pay = new $selected();
                $html .= $pay->generateButtons(true);
            } else {
                /**
                Should not get here
                */
                wp_die(__('An error Occured (Code: YM_AVAILABLE_MODULES'));
            }
        }
    }
    /**
    Return
    */
    if ($return) {
        return $html;
    } else {
        echo $html;
        return;
    }
}
Example #24
0
function ym_fbook_admin()
{
    global $wpdb, $ym_formgen, $facebook_settings;
    include YM_FBOOK_BASE_DIR . 'includes/ym_facebook_constants.php';
    ym_facebook_settings(TRUE);
    $pricing_data = get_option('ym_fbook_pricing');
    if ($_POST) {
        foreach ($settings as $setting) {
            $facebook_settings->{$setting} = $_POST[$setting];
        }
        // images
        foreach ($images as $image) {
            if (is_uploaded_file($_FILES[$image]['tmp_name'])) {
                $file = $_FILES[$image];
                $ym_upload = new ym_dl_file_upload();
                $ym_upload->upload_dir = $ym_upload_root;
                $ym_upload->max_length_filename = 100;
                $ym_upload->rename_file = false;
                $ym_upload->the_temp_file = $file['tmp_name'];
                $ym_upload->the_file = $file['name'];
                $ym_upload->http_error = $file['error'];
                $ym_upload->replace = "y";
                $ym_upload->do_filename_check = "n";
                if ($ym_upload->upload()) {
                    $filename = $ym_upload_url . $ym_upload->file_copy;
                    $facebook_settings->{$image} = $filename;
                } else {
                    ym_display_message(sprintf(__('unable to move file to %s', 'ym'), $ym_upload->upload_dir), 'error');
                }
            }
        }
        update_option('ym_fbook_options', $facebook_settings);
        echo '<div id="message" class="updated fade"><p>Settings were updated</p></div>';
        $packs = ym_get_packs();
        foreach ($packs as $pack) {
            $id = 'pack_' . $pack['id'];
            $post = 'override_price_' . $id;
            $price = ym_post($post);
            if ($price) {
                $price = number_format((double) $price, 0);
            }
            $pricing_data->{$id} = $price;
        }
        $query = 'SELECT post_id FROM ' . $wpdb->prefix . 'postmeta WHERE meta_key = \'ym_post_purchasable\' AND meta_value = 1';
        foreach ($wpdb->get_results($query) as $post) {
            $id = 'post_' . $post->post_id;
            $post = 'override_price_' . $id;
            $price = ym_post($post);
            if ($price) {
                $price = number_format((double) $price, 0);
            }
            $pricing_data->{$id} = $price;
        }
        $query = 'SELECT id, name FROM ' . $wpdb->prefix . 'ym_post_pack ORDER BY id ASC';
        foreach ($wpdb->get_results($query) as $bundle) {
            $id = 'bundle_' . $bundle->id;
            $post = 'override_price_' . $id;
            $price = ym_post($post);
            if ($price) {
                $price = number_format((double) $price, 0);
            }
            $pricing_data->{$id} = $price;
        }
        $price = ym_post('override_price_post_override');
        if ($price) {
            $price = number_format((double) $price, 0);
        }
        $pricing_data->post_override = $price;
        $price = ym_post('override_price_bundle_override');
        if ($price) {
            $price = number_format((double) $price, 0);
        }
        $pricing_data->bundle_override = $price;
        update_option('ym_fbook_pricing', $pricing_data);
        echo '<div id="message" class="updated fade"><p>Pricings were updated</p></div>';
    }
    echo '
<script type="text/javascript">
	jQuery(document).ready(function() {
		jQuery(\'#ym_fbook_tabs\').tabs({
			fx: {opacity: \'toggle\'},
			selected: ' . ym_post('ym_fb_tab_select', ym_get('ym_fb_tab_select', 0)) . '
		});
		jQuery(\'.subtabs\').tabs({
			fx: {opacity: \'toggle\'}
		});
		jQuery(\'#tabkiller\').click(function() {
			jQuery(this).hide();
			jQuery(\'.subtabs\').slideUp(function() {
				jQuery(\'.subtabs\').tabs(\'destroy\');
				jQuery(\'.subtabs ul\').hide();
				jQuery(\'.subtabs\').slideDown();
			});
			jQuery(\'#ym_fbook_tabs\').slideUp(function() {
				jQuery(\'#ym_fbook_tabs\').tabs(\'destroy\');
				jQuery(\'#ym_fbook_tabs ul\').hide();
				jQuery(\'#transaction_logging\').hide();
				jQuery(\'#ym_fbook_tabs\').slideDown();
			});
		});
		jQuery(\'#ym_fb\').submit(function() {
			var selected = jQuery(\'#ym_fbook_tabs\').tabs(\'option\', \'selected\');
			jQuery(\'#ym_fb_tab_select\').val(selected);
		});
		jQuery(\'table\').after(\'<p class="submit" style="text-align: right;"><input type="submit" value="Save Settings" /></p>\');
	});
</script>
';
    echo '<div class="wrap" id="poststuff">';
    //	echo '<h2>YourMembers in Facebook | Settings</h2>';
    //	echo '<p style="text-align: right;"><a href="#nowhere" id="tabkiller">Remove Tabs/All Settings on a single page</a></p>';
    echo '<div id="ym_fbook_tabs">';
    echo '<form action="" method="post" enctype="multipart/form-=data" id="ym_fb">';
    $credits = FALSE;
    global $ym_active_modules;
    if (in_array('ym_facebook_credits', $ym_active_modules)) {
        //	if (get_option('ym_facebook_credits')) {
        $credits = TRUE;
    }
    echo '
<ul>
	<li><a href="#guide">Guide</a></li>
	<li><a href="#facebook_settings">Facebook</a></li>
	<li><a href="#settings_settings">Settings</a></li>
	<li><a href="';
    if ($credits) {
        echo '#facebook_credits';
    }
    echo '">Facebook Credits</a></li>
	<li><a href="';
    if ($credits) {
        echo '#facebook_pricing';
    }
    echo '">Facebook Pricing</a></li>
	<li><a href="#share_control">Like/Share</a></li>
	<li><a href="#open_graph">Open Graph</a></li>
	<li><a href="';
    if ($credits) {
        echo '#transaction_logging';
    }
    echo '">Transaction Log</a></li>
</ul>';
    echo '<div id="guide">';
    ym_box_top('Guide');
    echo '<div id="message" class="updated">';
    echo '<p>We have written a guide that should help you get Your Members Facebook Integration Up and Running, you can read it <a href="http://www.yourmembers.co.uk/the-support/guides-tutorials/your-members-facebook-integration/" target="_blank">here</a></p>';
    echo '</div>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="facebook_settings" class="subtabs">';
    echo '
<ul>
	<li><a href="#master_enable">Master Enable</a></li>
	<li><a href="#keys_settings">Application Keys</a></li>
	<li><a href="#canvas_settings">Canvas Settings</a></li>
	<li><a href="#page_settings">Page Settings</a></li>
	<li><a href="#dim_settings">Dimensions</a></li>
	<li><a href="#permissions">Permissions</a></li>
</ul>
';
    echo '<div id="master_enable">';
    ym_box_top('Enable Facebook');
    $review = '';
    if (!$facebook_settings->app_id) {
        $review .= '<div id="message" class="updated"><p>If you havn&#39;t created an app yet, you can do so <a href="http://developers.facebook.com/setup" target="_new">here</a></p></div>';
    }
    echo $review;
    echo '<table class="form-table">';
    $ym_formgen->render_form_table_radio_row('Enable Facebook', 'enabled', $facebook_settings->enabled, 'If not enabled if a users access the app, they are redirected to the site');
    echo '</table>';
    ym_box_bottom();
    echo '</div>
<div id="keys_settings">';
    ym_box_top('Application Keys');
    $review .= '<p>You can find and review these settings <a href="https://developers.facebook.com/apps/';
    if ($facebook_settings->app_id) {
        $review .= $facebook_settings->app_id;
    }
    $review .= '" target="_new">Here</a></p>';
    echo $review;
    echo '<table class="form-table">';
    $ym_formgen->render_form_table_text_row('Facebook Application ID', 'app_id', $facebook_settings->app_id, 'The application ID');
    $ym_formgen->render_form_table_text_row('Facebook Application Secret', 'app_secret', $facebook_settings->app_secret, 'The application secret');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="canvas_settings">';
    ym_box_top('Canvas Settings');
    echo $review;
    echo '<table class="form-table">';
    echo '<tr><th>Facebook Canvas Name</th><td>http://apps.facebook.com/<input class="ym_input" type="text" name="canvas_url" id="canvas_url" value="' . $facebook_settings->canvas_url . '" /></td></tr>';
    echo '<tr><th>Facebook Canvas Landing</th><td>' . site_url('/') . '<input class="ym_input" type="text" name="canvas_landing" id="canvas_landing" value="' . $facebook_settings->canvas_landing . '" /></td></tr>';
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="page_settings">';
    ym_box_top('Page Settings');
    echo $review;
    echo '<p>If you have a (fan) page vanity url specified the app will do its best to stay in the (fan) page if the session starts on the (fan) page</p>';
    if ($facebook_settings->app_id) {
        echo '<p>You will have needed to have added your Application as a Tab to your Facebook Fan Page, you can do that <a href="http://www.facebook.com/apps/application.php?id=' . $facebook_settings->app_id . '">here</a> and then click <strong>Add to my Page</strong></p>';
    }
    echo '<table class="form-table">';
    echo '<tr><th>Facebook (fan) Page Vanity Url</th><td>http://www.facebook.com/<input class="ym_input" type="text" name="page_url" id="page_url" value="' . $facebook_settings->page_url . '" /></td></tr>';
    echo '<tr><th>Facebook Page Landing</th><td>' . site_url('/') . '<input class="ym_input" type="text" name="page_landing" id="page_landing" value="' . $facebook_settings->page_landing . '" /></td></tr>';
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="dim_settings">';
    ym_box_top('Dimension Settings');
    echo '<table class="form-table">';
    $ym_formgen->render_combo_from_array_row('IFrame Size', 'iframe_size', $iframe_options, $facebook_settings->iframe_size, 'Make sure this setting is set identical to the setting in Facebook Application settings');
    $ym_formgen->render_form_table_text_row('IFrame Height', 'iframe_size_height', $facebook_settings->iframe_size_height, 'If you are using Scrollbars you can specify the height you want here, in px');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="permissions">';
    ym_box_top('Permissions');
    echo '<table class="form-table">';
    echo '<tr><td></td><td style="width: 50px;"></td></tr>';
    $ym_formgen->render_form_table_radio_row('Likewalls - user_likes', 'permission_likewall', $facebook_settings->permission_likewall, 'If using likewalls, we need to extended permissions to get User Likes, as some users have their Likes set to Private');
    $ym_formgen->render_form_table_radio_row('Email Address - email', 'permission_email', $facebook_settings->permission_email, 'For the registration with Facebook you can enable this to pre fill the email entry with their Primary Facebook Email Address. Users will be asked to accept additional permissions.');
    $ym_formgen->render_form_table_radio_row('Offline Access - offline_access', 'permission_offline_access', $facebook_settings->permission_offline_access, 'Access Tokens are on average valid for about an hour. Which means once an hour we have to send the user thru a loop, normally this is transparent. However if you do not want this you can enable offline access to get a longer access key');
    $ym_formgen->render_form_table_radio_row('Offline Access - publish_actions', 'permission_publish_actions', $facebook_settings->permission_publish_actions, 'Part of the new Open Graph Actions');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '</div>';
    echo '<div id="settings_settings" class="subtabs">';
    echo '
<ul>
	<li><a href="#access_settings">Access Settings</a></li>
	<li><a href="#registration_settings">Registration Settings</a></li>
	<li><a href="#content_settings">Content Settings</a></li>
	<li><a href="#comment_settings">Comment Settings</a></li>
	<li><a href="#analytics_settings">Analytics Settings</a></li>
</ul>
';
    echo '<div id="access_settings">';
    ym_box_top('Access Settings');
    echo '<table class="form-table">';
    $ym_formgen->render_form_table_radio_row('Force Facebook', 'force_facebook', $facebook_settings->force_facebook, 'Make YM Facebook only, force users visting the Website to access via Facebook');
    $ym_formgen->render_form_table_radio_row('Force Application Add', 'force_facebook_auth', $facebook_settings->force_facebook_auth, 'Force a user to be logged into Facebook and authorised the Application');
    $ym_formgen->render_form_table_radio_row('Force WordPress Login', 'force_wordpress_auth', $facebook_settings->force_wordpress_auth, 'Force a user to be logged into WordPress');
    $ym_formgen->render_form_table_radio_row('Require Link', 'require_link', $facebook_settings->require_link, 'Require a User to link their Facebook and WordPress Accounts if Logged in (unless superseeded by above)');
    $ym_formgen->render_form_table_radio_row('Disable the Link Suggested Message', 'disable_link_message', $facebook_settings->disable_link_message, 'When a user is logged out do not prompt them to link/login');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="registration_settings">';
    ym_box_top('Registration Settings');
    echo '<p>Using Hidden Register? You might want to turn on the Email Permission on the Facebook->Permissions Tab</p>';
    echo '<table class="form-table">';
    //	$ym_formgen->render_form_table_radio_row('Register with Facebook', 'register_with_facebook', $facebook_settings->register_with_facebook, 'Allow a user to register a WordPress accout using their Facebook Account as a Base');
    $ym_formgen->render_form_table_radio_row('Hidden Register with Facebook', 'register_with_facebook_hidden', $facebook_settings->register_with_facebook_hidden, 'If a User uses the Facebook App and are not logged into WordPress create them a WordPress Account. If they are found by their username or email address, the two accounts are Auto Linked. (Implies Require Link and Force Redirect)');
    //	$ym_formgen->render_form_table_radio_row('Email Address', 'permission_emailb', $facebook_settings->permission_email, 'For the registration with Facebook you can enable this to pre fill the email entry with their Primary Facebook Email Address. Users will be asked to accept additional permissions.');
    $packs = ym_get_packs();
    $ym_packs = array();
    $ym_packs[0] = 'No Account';
    foreach ($packs as $pack) {
        $ym_packs[$pack['id']] = ym_get_pack_label($pack['id']);
    }
    $ym_formgen->render_combo_from_array_row('Hidden Register Subscription', 'register_with_facebook_hidden_subid', $ym_packs, $facebook_settings->register_with_facebook_hidden_subid, 'Which Subscription To Put a Hidden Regsiter User on. It will <strong>not</strong> prompt for Payment');
    $ym_formgen->render_form_table_text_row('Hidden Register Redirect', 'register_with_facebook_hidden_redirect', $facebook_settings->register_with_facebook_hidden_redirect, 'On Hidden Register Complete Redirect the users to a page');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="content_settings">';
    ym_box_top('Content Settings');
    echo '<p>fb.php status is: ';
    $result = locate_template('fb.php');
    if (empty($result)) {
        echo 'Not Present';
    } else {
        echo 'Present';
    }
    echo '</p>';
    echo '<table class="form-table">';
    $ym_formgen->render_form_table_radio_row('fb.php', 'enable_fb_php', $facebook_settings->enable_fb_php, 'Enable the use of the Theme File fb.php instead of YM FB Theme, if fb.php is present');
    echo '</table>';
    echo '<p>If you use a theme fb.php file, most of these options are redundant, unless you implement them in your Theme File</p>';
    echo '<table class="form-table">';
    $ym_formgen->render_form_table_radio_row('Allow Leave Facebook', 'enable_leave_facebook', $facebook_settings->enable_leave_facebook, 'Allow a user to start a website session from inside facebook, if a user vists the blog on Facebook first, they will stay inside Facebook, (is overriden by force facebook)');
    $ym_formgen->render_form_table_radio_row('Post Breakout', 'post_breakout', $facebook_settings->post_breakout, 'when viewing the end post, breakout (overrides Force Facebook)');
    $ym_formgen->render_form_table_radio_row('Page Breakout', 'page_breakout', $facebook_settings->page_breakout, 'when viewing the end page, breakout (overrides Force Facebook)');
    $ym_formgen->render_form_table_radio_row('Use excerpt', 'use_excerpt', $facebook_settings->use_excerpt, 'Use excerpts on post pages? (Template dependant)');
    $menus = array('Auto', 'Slug');
    $query = 'SELECT name FROM ' . $wpdb->prefix . 'term_taxonomy tt LEFT JOIN ' . $wpdb->prefix . 'terms t ON t.term_id = tt.term_id WHERE taxonomy = \'nav_menu\'';
    foreach ($wpdb->get_results($query) as $row) {
        $menus[] = $row->name;
    }
    $ym_formgen->render_combo_from_array_row('Menu Control', 'menu', $menus, $facebook_settings->menu, 'We can use the First non blank menu, or you can pick your own. Menus are controlled <a href="' . site_url('/wp-admin/nav-menus.php') . '">here</a>');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="comment_settings">';
    ym_box_top('Comment Settings');
    echo '<p>You can replace the standard comment form with a Facebook Powered comment form</p>';
    echo '<table class="form-table">';
    $ym_formgen->render_form_table_radio_row('Use Facebook Comments on Facebook', 'use_facebook_comments', $facebook_settings->use_facebook_comments);
    $ym_formgen->render_form_table_radio_row('Use Facebook Comments on the Site', 'use_facebook_comments_on_site', $facebook_settings->use_facebook_comments_on_site);
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="analytics_settings">';
    ym_box_top('Analytics');
    echo '<p>You need to set the Website URL of the Profile to <strong>' . site_url('?ymfbook=googleanalytics') . '</strong> in order for Check Status to succeed</p>';
    echo '<p>Its recommended you use a separate profile under the same domain to track the Facebook Application</p>';
    echo '<table class="form-table">';
    $ym_formgen->render_form_table_text_row('Google Analytics Profile ID', 'google_analytics_profile_id', $facebook_settings->google_analytics_profile_id, 'Uses the Standard code with this ID');
    $ym_formgen->render_form_table_textarea_row('Tracking Code', 'analytics_tracking_code', $facebook_settings->analytics_tracking_code, 'This will override the standard Google Analytics Code');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '</div>';
    if ($credits) {
        echo '<div id="facebook_credits">';
        ym_box_top(__('Facebook Credits', 'ym_facebook'));
        echo __('<p>Facebook Credits can only be used inside Facebook</p>', 'ym_facebook');
        echo sprintf(__('<p>You will need a Credits Callback URL, please use this: <strong>%s</strong></p>', 'ym_facebook'), site_url('?ym_process=ym_facebook_credits'));
        ym_box_bottom();
        ym_box_top(__('Primary Button', 'ym_facebook'));
        echo __('<p>In line with the Facebook Credits branding guide, you have a choice of three Pay with Facebook Credits Icons</p>', 'ym_facebook');
        $select = $facebook_settings->logo;
        echo '<table class="form-table">';
        echo '<tr><th>' . __('Option A', 'ym_facebook') . '</th>
			<td>
				<input type="radio" name="logo" id="logoa" value="' . YM_IMAGES_DIR_URL . 'pg/facebook_credits_a.png" ' . ($select == YM_IMAGES_DIR_URL . 'pg/facebook_credits_a.png' ? 'checked="checked"' : '') . ' />
				<label for="logoa">
					<img src="' . YM_IMAGES_DIR_URL . 'pg/facebook_credits_a.png" />
				</label>
			</td>
		</tr>';
        echo '<tr><th>' . __('Option B', 'ym_facebook') . '</th>
			<td>
				<input type="radio" name="logo" id="logob" value="' . YM_IMAGES_DIR_URL . 'pg/facebook_credits_b.png" ' . ($select == YM_IMAGES_DIR_URL . 'pg/facebook_credits_b.png' ? 'checked="checked"' : '') . ' />
				<label for="logob">
					<img src="' . YM_IMAGES_DIR_URL . 'pg/facebook_credits_b.png" />
				</label>
			</td>
		</tr>';
        echo '<tr><th>' . __('Option C', 'ym_facebook') . '</th>
			<td>
				<input type="radio" name="logo" id="logoc" value="' . YM_IMAGES_DIR_URL . 'pg/facebook_credits_c.png" ' . ($select == YM_IMAGES_DIR_URL . 'pg/facebook_credits_c.png' ? 'checked="checked"' : '') . ' />
				<label for="logoc">
					<img src="' . YM_IMAGES_DIR_URL . 'pg/facebook_credits_c.png" />
				</label>
			</td>
		</tr>';
        echo '</table>';
        ym_box_bottom();
        ym_box_top(__('Credits Dialog Images', 'ym_facebook'));
        echo __('<p>When purchasing a item users are shown a title, description, cost and a icon/logo. You can crontol these logos here</p>', 'ym_facebook');
        echo '<table class="form-table">';
        echo '
		<tr>
			<th>' . __('Subscription Purchase Image', 'ym_facebook') . '</th>
			<td>
				<input type="file" name="credits_purchase_sub_image" id="credits_purchase_sub_image" />';
        if ($facebook_settings->credits_purchase_sub_image) {
            echo '<div style="margin-top: 5px;"><img src="' . $facebook_settings->credits_purchase_sub_image . '" alt="' . __('Subscription Purchase Image', 'ym_facebook') . '" /></div>';
        }
        echo '
			</td>
		</tr>
		<tr>
			<th>' . __('Post Purchase Image', 'ym_facebook') . '</th>
			<td>
				<input type="file" name="credits_purchase_post_image" id="credits_purchase_post_image" />';
        if ($facebook_settings->credits_purchase_post_image) {
            echo '<div style="margin-top: 5px;"><img src="' . $facebook_settings->credits_purchase_post_image . '" alt="' . __('Post Purchase Image', 'ym_facebook') . '" /></div>';
        }
        echo '
			</td>
		</tr>
		<tr>
			<th>' . __('Bundle Purchase Image', 'ym_facebook') . '</th>
			<td>
				<input type="file" name="credits_purchase_bundle_image" id="credits_purchase_bundle_image" />';
        if ($facebook_settings->credits_purchase_bundle_image) {
            echo '<div style="margin-top: 5px;"><img src="' . $facebook_settings->credits_purchase_bundle_image . '" alt="' . __('Bundle Purchase Image', 'ym_facebook') . '" /></div>';
        }
        echo '
			</td>
		</tr>
		';
        echo '</table>';
        ym_box_bottom();
        ym_box_top(__('Other Settings', 'ym_facebook'));
        echo '<table class="form-table">';
        $ym_formgen->render_form_table_radio_row('Exclusive Facebook Credits', 'credits_exclusive', $facebook_settings->credits_exclusive, 'Use only Facebook Credits when inside Facebook');
        echo '<tr><td></td><td><p>';
        echo 'Facebook takes a 30% fee on all transactions.<br />' . 'For Transactions in non USD Facebook pays out based on:<br />' . 'Each Facebook Credit is $0.10 and then converts this into your native currency based on that days exchange rate<br />' . 'So 10 Credits is $1 and 100 is $10<br />' . 'Transactions can only occur in whole credits, so if any math involved results in a decimal prices will be rounded up<br />' . 'Costs can only be in Whole Credits';
        global $ym_res;
        if ($ym_res->currency != 'USD') {
            echo '<br /><br />So you can either specify an exchange rate, or set a Facebook credits price per item on the Facebook Pricing Tab';
            echo '</p></td></tr>';
            $ym_formgen->render_form_table_text_row('Specify a Exchange Rate', 'exchange_rate', $facebook_settings->exchange_rate, 'If you specify an exchange rate, it will be used. Its the Exchange rate for your Currency to USD');
        } else {
            echo '<br /><br />You are using USD, so you do not need to worry about an exchange rate, but you can still set a Facebook credits price per item on the Facebook Pricing Tab';
            echo '</p></td></tr>';
        }
        $ym_formgen->render_combo_from_array_row('Rounding', 'exchange_round', $round_options, $facebook_settings->exchange_round, 'You can control the rounding method if any');
        echo '</table>';
        ym_box_bottom();
        echo '</div>';
        echo '<div id="facebook_pricing" class="subtabs">';
        echo '
<ul>
	<li><a href="#pack_pricing">Pack</a></li>
	<li><a href="#post_pricing">Post</a></li>
	<li><a href="#bundle_pricing">Bundle</a></li>
</ul>
';
        echo '<div id="pack_pricing">';
        ym_box_top('Pack Pricing');
        echo '<p>Remember: 1 Credit is USD 0.10 and pricing is in whole credits, if a override price is set Exchange Rates and Rouding is ignored</p>';
        echo '<table class="form-table">';
        $pricing_data = get_option('ym_fbook_pricing');
        // subs
        $packs = ym_get_packs();
        foreach ($packs as $pack) {
            $id = 'pack_' . $pack['id'];
            $ym_formgen->render_form_table_text_row('Pack Price: ' . ym_get_pack_label($pack['id']), 'override_price_' . $id, $pricing_data->{$id});
        }
        echo '</table>';
        ym_box_bottom();
        echo '</div>';
        echo '<div id="post_pricing">';
        ym_box_top('Post Pricing');
        echo '<p>Remember: 1 Credit is USD 0.10 and pricing is in whole credits, if a override price is set Exchange Rates and Rouding is ignored</p>';
        echo '<table class="form-table">';
        $query = 'SELECT post_id FROM ' . $wpdb->prefix . 'postmeta WHERE meta_key = \'ym_post_purchasable\' AND meta_value = 1';
        foreach ($wpdb->get_results($query) as $post) {
            $id = 'post_' . $post->post_id;
            $postdata = get_post($post);
            $ym_formgen->render_form_table_text_row('Post Price: ' . $postdata->post_title, 'override_price_' . $id, $pricing_data->{$id});
        }
        if (!$wpdb->num_rows) {
            echo '<tr><td></td><th>No Available Posts</th></tr>';
        }
        $ym_formgen->render_form_table_text_row('Default Override Pack Price', 'override_price_post_override', $pricing_data->post_override, 'You can set a default price to override if one is not set');
        echo '</table>';
        ym_box_bottom();
        echo '</div>';
        echo '<div id="bundle_pricing">';
        ym_box_top('Bundle Pricing');
        echo '<p>Remember: 1 Credit is USD 0.10 and pricing is in whole credits, if a override price is set Exchange Rates and Rouding is ignored</p>';
        echo '<table class="form-table">';
        $query = 'SELECT id, name FROM ' . $wpdb->prefix . 'ym_post_pack ORDER BY id ASC';
        foreach ($wpdb->get_results($query) as $bundle) {
            $id = 'bundle_' . $bundle->id;
            $ym_formgen->render_form_table_text_row('Bundle Price: ' . $bundle->name, 'override_price_' . $id, $pricing_data->{$id});
        }
        if (!$wpdb->num_rows) {
            echo '<tr><td></td><th>No Available Bundles</th></tr>';
        }
        $ym_formgen->render_form_table_text_row('Default Override Bundle Price', 'override_price_bundle_override', $pricing_data->bundle_override, 'You can set a default price to override if one is not set');
        echo '</table>';
        ym_box_bottom();
        echo '</div>';
        echo '</div>';
    }
    echo '<div id="share_control" class="subtabs">';
    echo '
<ul>
	<li><a href="#post_control">Post Like/Share</a></li>
	<li><a href="#footer_control">Footer Like/Share</a></li>
	<li><a href="#shortcode_control">Shortcode Like/Share</a></li>
	<li><a href="#likewall_control">Likewall Like/Share</a></li>
</ul>
';
    echo '<div id="post_control">';
    ym_box_top('Post Share Control');
    echo '<p>This are the options for adding Share/Send buttons to Posts/Pages</p>';
    echo '<table class="form-table">';
    $ym_formgen->render_form_table_radio_row('Enable Facebook Share', 'enable_share', $facebook_settings->enable_share, 'Allow people to share content to Facebook Feeds from within the App');
    $ym_formgen->render_form_table_radio_row('Enable Facebook Send', 'enable_send', $facebook_settings->enable_send, 'Allow people to share content via PM (needs Share to be on)');
    $ym_formgen->render_combo_from_array_row('Share Box to Use', 'share_box', $sharebox_options, $facebook_settings->share_box);
    $ym_formgen->render_form_table_radio_row('Show faces', 'show_faces', $facebook_settings->show_faces, 'Show the faces of Friend who have shared the same link');
    $ym_formgen->render_combo_from_array_row('Verb to Use', 'verb', $verbs, $facebook_settings->verb);
    $ym_formgen->render_combo_from_array_row('Color Scheme', 'color_scheme', $color_schemes, $facebook_settings->color_scheme);
    $ym_formgen->render_combo_from_array_row('Font', 'font', $fonts, $facebook_settings->font, 'The Font to use for the Buttons');
    //	$ym_formgen->render_form_table_text_row('Add a Ref', 'ref', $facebook_settings->ref, 'A reference for tracking');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="footer_control">';
    ym_box_top('Footer Share Control');
    echo '<table class="form-table">';
    $ym_formgen->render_form_table_radio_row('Enable Facebook Share Footer', 'enable_share_footer', $facebook_settings->enable_share_footer, 'Add a Share button for the whole site in the footer');
    $ym_formgen->render_form_table_radio_row('Enable Facebook Send Footer', 'enable_send_footer', $facebook_settings->enable_send_footer, 'Allow people to share content via PM (needs Share to be on)');
    $ym_formgen->render_combo_from_array_row('Share Box to Use', 'share_box_footer', $sharebox_options, $facebook_settings->share_box_footer);
    $ym_formgen->render_form_table_radio_row('Show faces', 'show_faces_footer', $facebook_settings->show_faces_footer, 'Show the faces of Friend who have shared the same link');
    $ym_formgen->render_combo_from_array_row('Verb to Use', 'verb_footer', $verbs, $facebook_settings->verb_footer);
    $ym_formgen->render_combo_from_array_row('Color Scheme', 'color_scheme_footer', $color_schemes, $facebook_settings->color_scheme_footer);
    $ym_formgen->render_combo_from_array_row('Font', 'font_footer', $fonts, $facebook_settings->font_footer, 'The Font to use for the Buttons');
    //	$ym_formgen->render_form_table_text_row('Add a Ref', 'ref_footer', $facebook_settings->ref_footer, 'A reference for tracking');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="shortcode_control">';
    ym_box_top('Shortcode Share Control');
    echo '<p>You can use the shortcode [ym_fb_like]</p>';
    echo '<p>You can specify a shareurl to use, if not the post permalink will be used</p>';
    //	echo '<p>You can specify a type to use, if not the "post" tab settings will be used, specify "shortcode" to use the below settings, or "footer" to use the footer tab settings</p>';
    echo '<table class="form-table">';
    $ym_formgen->render_form_table_radio_row('Enable Facebook Share Shortcode', 'enable_share_shortcode', $facebook_settings->enable_share_shortcode);
    $ym_formgen->render_form_table_radio_row('Auto Add to the bottom of posts on non Facebook Pages', 'enable_share_auto_nonfb', $facebook_settings->enable_share_auto_nonfb, 'Add a Share button to the bottom of all posts on non Facebook Framed Pages');
    $ym_formgen->render_form_table_radio_row('Enable Facebook Send Shortcode', 'enable_send_shortcode', $facebook_settings->enable_send_shortcode, 'Allow people to share content via PM (needs Share to be on)');
    $ym_formgen->render_combo_from_array_row('Share Box to Use', 'share_box_shortcode', $sharebox_options, $facebook_settings->share_box_shortcode);
    $ym_formgen->render_form_table_radio_row('Show faces', 'show_faces_shortcode', $facebook_settings->show_faces_shortcode, 'Show the faces of Friend who have shared the same link');
    $ym_formgen->render_combo_from_array_row('Verb to Use', 'verb_shortcode', $verbs, $facebook_settings->verb_shortcode);
    $ym_formgen->render_combo_from_array_row('Color Scheme', 'color_scheme_shortcode', $color_schemes, $facebook_settings->color_scheme_shortcode);
    $ym_formgen->render_combo_from_array_row('Font', 'font_shortcode', $fonts, $facebook_settings->font_shortcode, 'The Font to use for the Buttons');
    //	$ym_formgen->render_form_table_text_row('Add a Ref', 'ref_shortcode', $facebook_settings->ref_shortcode, 'A reference for tracking');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<div id="likewall_control">';
    ym_box_top('Likewall Share Control');
    echo '<table class="form-table">';
    //		$ym_formgen->render_form_table_radio_row('Enable Facebook Share LikeWall', 'enable_share_likewall', $facebook_settings->enable_share_likewall, 'Add a Share button for the whole site in the likewall');
    //		$ym_formgen->render_form_table_radio_row('Enable Facebook Send LikeWall', 'enable_send_likewall', $facebook_settings->enable_send_likewall, 'Allow people to share content via PM (needs Share to be on)');
    $ym_formgen->render_combo_from_array_row('Share Box to Use', 'share_box_likewall', $sharebox_options, $facebook_settings->share_box_likewall);
    $ym_formgen->render_form_table_radio_row('Show faces', 'show_faces_likewall', $facebook_settings->show_faces_likewall, 'Show the faces of Friend who have shared the same link');
    $ym_formgen->render_combo_from_array_row('Verb to Use', 'verb_likewall', $verbs, $facebook_settings->verb_likewall);
    $ym_formgen->render_combo_from_array_row('Color Scheme', 'color_scheme_likewall', $color_schemes, $facebook_settings->color_scheme_likewall);
    $ym_formgen->render_combo_from_array_row('Font', 'font_likewall', $fonts, $facebook_settings->font_likewall, 'The Font to use for the Buttons');
    //	$ym_formgen->render_form_table_text_row('Add a Ref', 'ref_likewall', $facebook_settings->ref_likewall, 'A reference for tracking');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '</div>';
    echo '<div id="open_graph">';
    ym_box_top('Open Graph Options');
    echo '<table class="form-table">';
    echo '
	<tr>
		<th>Open Graph Image
			<div style="color: gray; margin-top: 5px; font-size: 11px;">This image is used when a user links/shares content from your site.</div>
		</th>
		<td>
			<input type="file" name="open_graph_image" id="open_graph_image" />';
    if ($facebook_settings->open_graph_image) {
        echo '<div style="margin-top: 5px;"><img src="' . $facebook_settings->open_graph_image . '" alt="Open Graph Image" /></div>';
    }
    echo '
		</td>
	</tr>
	';
    $ym_formgen->render_combo_from_array_row('Default Open Graph Type', 'open_graph_type', $types, $facebook_settings->open_graph_type);
    $ym_formgen->render_form_table_text_row('Admin Ids', 'open_graph_admins', $facebook_settings->open_graph_admins, 'Users who should be linked/denoted as admins for your YM in Facebook, comma separated');
    echo '</table>';
    ym_box_bottom();
    echo '</div>';
    echo '<input type="hidden" name="ym_fb_tab_select" id="ym_fb_tab_select" value="0" />';
    echo '</form>';
    if ($credits) {
        // facebook credits appears to be enabled in YM
        echo '<div id="transaction_logging">';
        ym_box_top('Facebook Credits Transaction Logging');
        include YM_FBOOK_BASE_DIR . 'admin/ym_facebook_transaction_log.php';
        ym_box_bottom();
        echo '</div>';
    }
    echo '</div>';
    echo '</div>';
}
Example #25
0
<?php

/*
* $Id: ym-dev-tools.php 2283 2012-08-08 10:30:09Z bcarlyon $
* $Revision: 2283 $
* $Date: 2012-08-08 11:30:09 +0100 (Wed, 08 Aug 2012) $
*/
global $ym_sys;
if (!defined('ym_dev') || !$ym_sys->dev_tools) {
    return;
}
if (ym_get('do_munch')) {
    $var = ym_get('option_name');
    $var2 = ym_get('user_meta_name');
    $user_id = ym_get('user_id');
    if ($var) {
        $data = get_option($var);
        print_r(get_option($var));
    } else {
        if ($var2) {
            $data = get_user_meta($user_id, $var2);
            print_r($data);
        } else {
            echo 'No Var';
        }
    }
    exit;
}
global $wpdb;
$name = FALSE;
echo '<div class="wrap" id="poststuff">';
Example #26
0
        header('location: ' . $ym_home);
    }
} else {
    if ($another_page_needed = ym_request('another_page_needed')) {
        //	echo 'using another page';exit;
        $html = $header;
        $html .= ym_get_additional_registration_form_page($another_page_needed, $page);
        $html .= $footer;
    } else {
        if (isset($_GET['ud']) && $_GET['ud'] == 1) {
            $html = $header;
            $user_id = false;
            if ($username = ym_get('username')) {
                $user_id = ym_get_user_id_by_username($username);
            } else {
                if ($email = ym_get('email')) {
                    $user_id = ym_get_user_id_by_email($email);
                }
            }
            $pack_id = ym_post('ym_subscription', FALSE);
            $html .= ym_upgrade_buttons(true, $pack_id, $user_id);
            $html .= $footer;
        } else {
            if (ym_request('username')) {
                $errors = false;
                $html = $header;
                if ($page > 1) {
                    $wp_error = new WP_Error();
                    ym_register_post(ym_request('username'), '', $wp_error, $page);
                    //error checking
                    if ($wp_error->get_error_code()) {
Example #27
0
 function do_process()
 {
     $action = strtolower(ym_request('Action'));
     if (!ym_get('ZombaioGWPass')) {
         header('HTTP/1.0 401 Unauthorized');
         echo '<h1>Zombaio Gateway 1.1</h1><h3>Authentication failed.</h3>No pass';
         exit;
     }
     $gw_pass = ym_get('ZombaioGWPass');
     if ($gw_pass != $this->gw_pass) {
         header('HTTP/1.0 401 Unauthorized');
         echo '<h1>Zombaio Gateway 1.1</h1><h3>Authentication failed.</h3>Mismatch';
         exit;
     }
     if (!$this->verify_ipn_ip()) {
         header('HTTP/1.0 401 Unauthorized');
         echo '<h1>Zombaio Gateway 1.1</h1><h3>Authentication failed, you are not Zombaio.</h3>';
         exit;
     }
     // test hit from zombaio
     $test = substr(ym_request('username'), 0, 4);
     if ($test == 'Test' && !ym_request('extra')) {
         // test mode
         echo 'OK';
         exit;
     }
     // verify site ID, first catch user.add/delete second credits
     $site_id = ym_request('SITE_ID', ym_request('SiteID'));
     if ($site_id && $site_id != $this->site_id) {
         header('HTTP/1.0 401 Unauthorized');
         echo '<h1>Zombaio Gateway 1.1</h1><h3>Authentication failed.</h3>site id';
         exit;
     }
     // verify price ID exists
     $data = ym_request('extra');
     $complete = FALSE;
     switch ($action) {
         case 'user.add':
             $complete = TRUE;
             list($buy, $subscription, $pack_id, $user_id) = explode('_', $data);
             if ($this->use_password && ym_get('password')) {
                 // use password
                 $user_pass = wp_hash_password(ym_get('password'));
                 global $wpdb;
                 $query = 'UPDATE ' . $wpdb->users . ' SET user_pass = \'' . $user_pass . '\' WHERE ID = \'' . $user_id . '\'';
                 $wpdb->query($query);
             }
             // store SUBSCRIPTION_ID
             $subscription_id = ym_get('SUBSCRIPTION_ID');
             update_user_meta($user_id, 'ym_zombaio_subscription_id', $subscription_id);
             break;
         case 'rebill':
             // renewal
             $subscription_id = ym_get('SUBSCRIPTION_ID');
             if (!$subscription_id) {
                 header('HTTP/1.0 401 Unauthorized');
                 echo '<h1>Zombaio Gateway 1.1</h1><h3>Missing Subscription ID.</h3>';
                 exit;
             }
             //get user ID by subscription ID
             global $wpdb;
             $query = 'SELECT user_id FROM ' . $wpdb->usermeta . ' WHERE meta_key = \'ym_zombaio_subscription_id\' AND meta_value = \'' . $subscription_id . '\'';
             $user_id = $wpdb->get_var($query);
             if (!$user_id) {
                 header('HTTP/1.0 401 Unauthorized');
                 echo '<h1>Zombaio Gateway 1.1</h1><h3>User Not Known.</h3>';
                 exit;
             }
             $success = ym_request('Success', 0);
             // 0 FAIL 2 FAIL retry in 5 days
             if ($success == 1) {
                 $complete = TRUE;
             }
             $data = new YourMember_User($user_id);
             $pack_id = $data->pack_id;
             $data = 'buy_subscription_' . $pack_id . '_' . $user_id;
             break;
         case 'user.delete':
             $user = get_user_by('username', ym_get('username'));
             if (!$user) {
                 header('HTTP/1.0 401 Unauthorized');
                 echo '<h1>Zombaio Gateway 1.1</h1><h3>User Not Known.</h3>';
                 exit;
             }
             $user_id = $user->ID;
             $data = new YourMember_User($user_id);
             $pack_id = $data->pack_id;
             $data = 'end_subscription_' . $pack_id . '_' . $user_id;
             break;
         case 'user.addcredits':
             $complete = FALSE;
             // no support
             $data = 'buy_credits_1_1';
     }
     $this->common_process($data, $this->code, $complete, FALSE);
     echo 'OK';
     exit;
 }
                $query = 'UPDATE ' . $pages_table . ' SET page_name = \'' . $page_name . '\' WHERE page_id = ' . $wpdb->insert_id;
                $wpdb->query($query);
            }
        } else {
            if ($page_id) {
                echo '<div id="message" class="error"><p>' . __('Failed to update your Flow page, or no changes needed', 'ym') . '</p></div>';
            } else {
                echo '<div id="message" class="error"><p>' . __('Failed to save your Flow page', 'ym') . '</p></div>';
            }
        }
        $action = '';
        break;
}
if ($action == 'edit') {
    $what = ym_get('what');
    $id = ym_get('id');
    if ($what == 'flow' && $id) {
        $action = 'createflow';
    } else {
        if ($what == 'page' && $id) {
            $action = 'createpage';
        }
    }
}
switch ($action) {
    case 'createflow':
        $flow = $flow_name = $complete_url = $complete_text = $complete_button = '';
        if ($what) {
            $query = 'SELECT * FROM ' . $flows_table . ' WHERE flow_id = ' . $id;
            $flow = $wpdb->get_results($query);
            $flow = $flow[0];
function ym_login_js_cb_bundle($atts, $content)
{
    if (ym_get('post_pack_id')) {
        return $content;
    }
    return '';
}
Example #30
0
<?php

/*
* $Id: sql_update_3.php 2166 2012-05-25 14:16:20Z bcarlyon $
* $Revision: 2166 $
* $Date: 2012-05-25 15:16:20 +0100 (Fri, 25 May 2012) $
*/
/**
Users
*/
if (!is_admin()) {
    return;
    // don't block if not admin so front end still runs
}
global $wpdb;
$user_start = ym_get('user_start', '0');
if ($user_start != 'done') {
    $limit = 300;
    $did = 0;
    $query = 'SELECT * FROM ' . $wpdb->users . ' ORDER BY ID ASC LIMIT ' . $user_start . ',' . $limit;
    echo '<pre>';
    foreach ($wpdb->get_results($query) as $user) {
        $data = new YourMember_User($user->ID);
        // process
        //last_pay_date - expire_date -
        $last_pay_date = $data->last_pay_date;
        if (strpos($last_pay_date, '-')) {
            // invalid
            if (strpos($last_pay_date, ' ')) {
                list($last_pay_date, $rubbish) = explode(' ', $last_pay_date);
            }