Пример #1
0
 public static function get_blog_info($blog_id)
 {
     global $wpdb, $psts;
     $is_recurring = $psts->is_blog_recurring($blog_id);
     $trialing = ProSites_Helper_Registration::is_trial($blog_id);
     $trial_message = '';
     if ($trialing) {
         // assuming its recurring
         $trial_message = '<div id="psts-general-error" class="psts-warning">' . __('You are still within your trial period. Once your trial finishes your account will be automatically charged.', 'psts') . '</div>';
     }
     $end_date = date_i18n(get_option('date_format'), $psts->get_expire($blog_id));
     $level_id = $psts->get_level($blog_id);
     $level = $psts->get_level_setting($level_id, 'name');
     $cancel_info_message = '<p class="prosites-cancel-description">' . sprintf(__('If you choose to cancel your subscription this site should continue to have %1$s features until %2$s.', 'psts'), $level, $end_date) . '</p>';
     $cancel_label = __('Cancel Your Subscription', 'psts');
     // CSS class of <a> is important to handle confirmations
     $cancel_info_link = '<p class="prosites-cancel-link"><a class="cancel-prosites-plan button" href="' . wp_nonce_url($psts->checkout_url($blog_id) . '&action=cancel', 'psts-cancel') . '" title="' . esc_attr($cancel_label) . '">' . esc_html($cancel_label) . '</a></p>';
     // Get other information from database
     $result = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = %d", $blog_id));
     $period = false;
     $last_amount = false;
     $last_gateway = false;
     if ($result) {
         $period = (int) $result->term;
         $last_amount = floatval($result->amount);
         $last_gateway = $result->gateway;
     }
     $args = apply_filters('psts_blog_info_args', array('level_id' => apply_filters('psts_blog_info_level_id', $level_id, $blog_id), 'level' => apply_filters('psts_blog_info_level', $level, $blog_id), 'expires' => apply_filters('psts_blog_info_expires', $end_date, $blog_id), 'trial' => apply_filters('psts_blog_info_trial', $trial_message, $blog_id), 'recurring' => apply_filters('psts_blog_info_recurring', $is_recurring, $blog_id), 'pending' => apply_filters('psts_blog_info_pending', '', $blog_id), 'complete_message' => apply_filters('psts_blog_info_complete_message', '', $blog_id), 'thanks_message' => apply_filters('psts_blog_info_thanks_message', '', $blog_id), 'visit_site_message' => apply_filters('psts_blog_info_thanks_message', '', $blog_id), 'cancel' => apply_filters('psts_blog_info_cancelled', false, $blog_id), 'cancellation_message' => apply_filters('psts_blog_info_cancellation_message', '', $blog_id), 'period' => apply_filters('psts_blog_info_period', $period, $blog_id), 'payment_type' => apply_filters('psts_blog_info_payment_type', false, $blog_id), 'payment_reminder' => apply_filters('psts_blog_info_payment_reminder', false, $blog_id), 'payment_reminder_location' => apply_filters('psts_blog_info_payment_remind_location', 'end', $blog_id), 'payment_expire_month' => apply_filters('psts_blog_info_payment_expire_month', false, $blog_id), 'payment_expire_year' => apply_filters('psts_blog_info_payment_expire_year', false, $blog_id), 'last_payment_date' => apply_filters('psts_blog_info_last_payment_date', false, $blog_id), 'last_payment_amount' => apply_filters('psts_blog_info_last_payment_amount', $last_amount, $blog_id), 'last_payment_gateway' => apply_filters('psts_blog_info_last_payment_gateway', $last_gateway, $blog_id), 'next_payment_date' => apply_filters('psts_blog_info_next_payment_date', false, $blog_id), 'cancel_info' => apply_filters('psts_blog_info_cancel_message', $cancel_info_message, $blog_id), 'cancel_info_link' => $cancel_info_link, 'receipt_form' => $psts->receipt_form($blog_id), 'all_fields' => apply_filters('psts_blog_info_all_fields', true, $blog_id)), $blog_id);
     return $args;
 }
    public static function get_existing_user_information($blog_id, $domain, $get_all = true)
    {
        global $psts, $wpdb;
        $args = array();
        $prev_billing = $next_billing = $content = '';
        if (!$blog_id) {
            return;
        }
        $img_base = $psts->plugin_url . 'images/';
        $cancel_label = __('Cancel Your Subscription', 'psts');
        //Check if blog is still under trial
        $trialing = ProSites_Helper_Registration::is_trial($blog_id);
        if ($trialing) {
            $args['trial'] = '<div id="psts-general-error" class="psts-warning">' . __('You are still within your trial period. Once your trial finishes your account will be automatically charged.', PSTS_TEXT_DOMAIN) . '</div>';
        }
        //Check if payment is not yet confirmed
        if (!empty($blog_id) && 1 == get_blog_option($blog_id, 'psts_waiting_step')) {
            //Fetch, if payment status is pending and reason is stored
            $psts_payment_details = get_user_meta(get_current_user_id(), 'psts_payment_details', true);
            if (!empty($psts_payment_details['pending_reason'])) {
                $args['pending'] = '<div id="psts-general-error" class="psts-warning message">' . $psts_payment_details['pending_reason'] . __('<br/>If you have enabled payment review for PayPal, make sure you accept the payment to avail the premium services.', PSTS_TEXT_DOMAIN) . '</div>';
            } else {
                $args['pending'] = '<div id="psts-general-error" class="psts-warning">' . __('There are pending changes to your account. This message will disappear once these pending changes are completed.', PSTS_TEXT_DOMAIN) . '</div>';
            }
        }
        //Check if its a recurring subscription or not
        $is_recurring = $psts->is_blog_recurring($blog_id);
        $args['recurring'] = $is_recurring;
        //if Payment was successful display a complete message
        if (self::$complete_message) {
            $content = '<div id="psts-complete-msg">' . self::$complete_message . '</div>';
            $args['complete_message'] = $content;
            $args['thanks_message'] = '<p>' . $psts->get_setting('pypl_thankyou') . '</p>';
            $args['visit_site_message'] = '<p><a href="' . get_admin_url($blog_id, '', 'http') . '">' . __('Visit your newly upgraded site »', 'psts') . '</a></p>';
        }
        // Cancellation message
        if (self::$cancel_message) {
            $args['cancel'] = true;
            $args['cancellation_message'] = self::$cancel_message;
            self::$cancel_message = false;
        }
        //check if pro/express user
        if ($profile_id = self::get_profile_id($blog_id)) {
            $end_date = date_i18n(get_option('date_format'), $psts->get_expire($blog_id));
            $level = $psts->get_level_setting($psts->get_level($blog_id), 'name');
            $content = '<div id="psts_existing_info">';
            //show sub details
            $resArray = PaypalApiHelper::GetRecurringPaymentsProfileDetails($profile_id);
            if (($resArray['ACK'] == 'Success' || $resArray['ACK'] == 'SuccessWithWarning') && $resArray['STATUS'] == 'Active') {
                if (isset($resArray['LASTPAYMENTDATE'])) {
                    $prev_billing = strtotime($resArray['LASTPAYMENTDATE']);
                } else {
                    if ($last_payment = $psts->last_transaction($blog_id)) {
                        $prev_billing = $last_payment['timestamp'];
                    } else {
                        //					$prev_billing = __( "None yet with this subscription <small>(only initial separate single payment has been made, or you've recently modified your subscription)</small>", 'psts' );
                    }
                }
                if (isset($resArray['NEXTBILLINGDATE'])) {
                    $next_billing = strtotime($resArray['NEXTBILLINGDATE']);
                } else {
                    //					$next_billing = __( "None", 'psts' );
                }
                $content .= '<h3>' . stripslashes($resArray['DESC']) . '</h3><ul>';
                if (is_pro_site($blog_id)) {
                    $args['level'] = $level;
                }
                if (isset($resArray['ACCT'])) {
                    //credit card
                    $month = substr($resArray['EXPDATE'], 0, 2);
                    $year = substr($resArray['EXPDATE'], 2, 4);
                    $args['card_type'] = $resArray['CREDITCARDTYPE'];
                    $args['card_reminder'] = $resArray['ACCT'];
                    $args['card_digit_location'] = 'end';
                    $args['card_expire_month'] = $month;
                    $args['card_expire_year'] = $year;
                } else {
                    //paypal
                    $content .= '<li>' . __('Payment Method: <strong>Your PayPal Account</strong>', 'psts') . '</li>';
                }
                $args['last_payment_date'] = $prev_billing;
                $args['next_payment_date'] = $next_billing;
                // Cancellation link
                if ($is_recurring) {
                    if (is_pro_site($blog_id)) {
                        $args['cancel_info'] = '<p class="prosites-cancel-description">' . sprintf(__('If you choose to cancel your subscription this site should continue to have %1$s features until %2$s.', 'psts'), $level, $end_date) . '</p>';
                        // CSS class of <a> is important to handle confirmations
                        $args['cancel_link'] = '<p class="prosites-cancel-link"><a class="cancel-prosites-plan button" href="' . wp_nonce_url($psts->checkout_url($blog_id) . '&action=cancel', 'psts-cancel') . '" title="' . esc_attr($cancel_label) . '">' . esc_html($cancel_label) . '</a></p>';
                    }
                }
            } else {
                if (($resArray['ACK'] == 'Success' || $resArray['ACK'] == 'SuccessWithWarning') && $resArray['STATUS'] == 'Cancelled') {
                    if ($is_recurring) {
                        $args['cancel'] = true;
                        $args['cancellation_message'] = '<div class="psts-cancel-notification">
													<p class="label"><strong>' . __('Your subscription has been canceled', 'psts') . '</strong></p>
													<p>' . sprintf(__('This site should continue to have %1$s features until %2$s.', 'psts'), $level, $end_date) . '</p>';
                    }
                } else {
                    if ($resArray['ACK'] == 'Success' || $resArray['ACK'] == 'SuccessWithWarning') {
                        $content .= '<h3>' . sprintf(__('Your subscription is: %s', 'psts'), $resArray['STATUS']) . '</h3>';
                        $content .= '<p>' . __('Please update your payment information below to resolve this.', 'psts') . '</p>';
                        if (is_pro_site($blog_id)) {
                            $args['cancel_info'] = '<p>' . sprintf(__('If you choose to cancel your subscription this site should continue to have %1$s features until %2$s.', 'psts'), $level, $end_date) . '</p>';
                        }
                        $args['cancel_link'] = '<p><a id="pypl_cancel" href="' . wp_nonce_url($psts->checkout_url($blog_id) . '&action=cancel', 'psts-cancel') . '" title="' . $cancel_label . '"><img src="' . $img_base . 'cancel_subscribe_gen.gif" /></a></p>';
                    } else {
                        $content .= '<div class="psts-error">' . __("There was a problem accessing your subscription information: ", 'psts') . self::parse_error_string($resArray) . '</div>';
                    }
                }
            }
            //print receipt send form
            $args['receipt_form'] = $psts->receipt_form($blog_id);
        } else {
            if (is_pro_site($blog_id)) {
                $end_date = date_i18n(get_option('date_format'), $psts->get_expire($blog_id));
                $level = $psts->get_level_setting($psts->get_level($blog_id), 'name');
                $old_gateway = $wpdb->get_var("SELECT gateway FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '{$blog_id}'");
                $content .= '<div id="psts_existing_info">';
                $content .= '<h3>' . __('Your Subscription Information', 'psts') . '</h3><ul>';
                $args['level'] = $level;
                if ($old_gateway == 'PayPal') {
                    $content .= '<li>' . __('Payment Method: <strong>Your PayPal Account</strong>', 'psts') . '</li>';
                } else {
                    if ($old_gateway == 'Amazon') {
                        $content .= '<li>' . __('Payment Method: <strong>Your Amazon Account</strong>', 'psts') . '</li>';
                    } else {
                        if ($psts->get_expire($blog_id) >= 9999999999.0) {
                            $content .= '<li>' . __('Expire Date: <strong>Never</strong>', 'psts') . '</li>';
                        } else {
                            $content .= '<li>' . sprintf(__('Expire Date: <strong>%s</strong>', 'psts'), $end_date) . '</li>';
                        }
                    }
                }
                $content .= '</ul><br />';
                if ($old_gateway == 'PayPal' || $old_gateway == 'Amazon') {
                    $args['cancel_info'] = '<p>' . sprintf(__('If your subscription is still active your next scheduled payment should be %1$s.', 'psts'), $end_date) . '</p>';
                    $args['cancel_info'] .= '<p>' . sprintf(__('If you choose to cancel your subscription this site should continue to have %1$s features until %2$s.', 'psts'), $level, $end_date) . '</p>';
                    //show instructions for old gateways
                    if ($old_gateway == 'PayPal') {
                        $args['cancel_link'] = '<p><a id="pypl_cancel" target="_blank" href="https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&alias=' . urlencode(get_site_option("supporter_paypal_email")) . '" title="' . $cancel_label . '"><img src="' . $psts->plugin_url . 'images/cancel_subscribe_gen.gif" /></a><br /><small>' . __('You can also cancel following <a href="https://www.paypal.com/helpcenter/main.jsp;jsessionid=SCPbTbhRxL6QvdDMvshNZ4wT2DH25d01xJHj6cBvNJPGFVkcl6vV!795521328?t=solutionTab&ft=homeTab&ps=&solutionId=27715&locale=en_US&_dyncharset=UTF-8&countrycode=US&cmd=_help-ext">these steps</a>.', 'psts') . '</small></p>';
                    } else {
                        if ($old_gateway == 'Amazon') {
                            $args['cancel_link'] = '<p>' . __('To cancel your subscription, simply go to <a id="pypl_cancel" target="_blank" href="https://payments.amazon.com/">https://payments.amazon.com/</a>, click Your Account at the top of the page, log in to your Amazon Payments account (if asked), and then click the Your Subscriptions link. This page displays your subscriptions, showing the most recent, active subscription at the top. To view the details of a specific subscription, click Details. Then cancel your subscription by clicking the Cancel Subscription button on the Subscription Details page.', 'psts') . '</p>';
                        }
                    }
                }
                //print receipt send form
                $args['receipt_form'] = $psts->receipt_form($blog_id);
            }
        }
        // Show all is true
        $args['all_fields'] = true;
        return $args;
    }
Пример #3
0
    /**
     * Populate an array with existing user information
     *
     * Array will be rendered by ProSites_View_Front_Gateway
     *
     * @param $blog_id
     * @param $domain
     * @param bool $get_all
     *
     * @return array|bool
     */
    public static function get_existing_user_information($blog_id, $domain, $get_all = true)
    {
        global $psts;
        $args = array();
        $img_base = $psts->plugin_url . 'images/';
        $trialing = ProSites_Helper_Registration::is_trial($blog_id);
        if ($trialing) {
            $args['trial'] = '<div id="psts-general-error" class="psts-warning">' . __('You are still within your trial period. Once your trial finishes your account will be automatically charged.', 'psts') . '</div>';
        }
        // Pending information
        /**
         * @todo: Hook psts_blog_info_pending (Front/Gateway.php)
         */
        if (!empty($blog_id) && 1 == get_blog_option($blog_id, 'psts_stripe_waiting')) {
            $args['pending'] = '<div id="psts-general-error" class="psts-warning">' . __('There are pending changes to your account. This message will disappear once these pending changes are completed.', 'psts') . '</div>';
        }
        // Successful payment
        if (self::$complete_message) {
            // @todo: Hook psts_blog_info_complete_message
            $args['complete_message'] = '<div id="psts-complete-msg">' . self::$complete_message . '</div>';
            // @todo: Hook psts_blog_info_thanks_message
            $args['thanks_message'] = '<p>' . $psts->get_setting('stripe_thankyou') . '</p>';
            //If Checking out on signup, there wouldn't be a blogid probably
            //			if ( ! empty ( $domain ) ) {
            //				//Hardcoded, TODO: Search for alternative
            //				$admin_url = is_ssl() ? trailingslashit( "https://$domain" ) . 'wp-admin/' : trailingslashit( "http://$domain" ) . 'wp-admin/';
            //				$args['visit_site_message'] = '<p><a href="' . $admin_url . '">' . __( 'Visit your newly upgraded site &raquo;', 'psts' ) . '</a></p>';
            //			} else {
            $args['visit_site_message'] = '<p><a href="' . get_admin_url($blog_id, '', 'http') . '">' . __('Go to your site &raquo;', 'psts') . '</a></p>';
            //			}
            self::$complete_message = false;
        }
        // Cancellation message
        if (self::$cancel_message) {
            $args['cancel'] = true;
            $args['cancellation_message'] = self::$cancel_message;
            self::$cancel_message = false;
        }
        // Existing customer information --- only if $get_all is true (default)
        $customer_id = self::get_customer_data($blog_id)->customer_id;
        if (!empty($customer_id) && $get_all) {
            try {
                $customer_object = Stripe_Customer::retrieve($customer_id);
            } catch (Exception $e) {
                $error = $e->getMessage();
            }
            // Move to render info class
            $end_date = date_i18n(get_option('date_format'), $psts->get_expire($blog_id));
            $level = $psts->get_level_setting($psts->get_level($blog_id), 'name');
            $is_recurring = $psts->is_blog_recurring($blog_id);
            $args['recurring'] = $is_recurring;
            // If invoice cant be created, its not looking good. Cancel.
            try {
                $invoice_object = Stripe_Invoice::upcoming(array("customer" => $customer_id));
            } catch (Exception $e) {
                if ($is_recurring) {
                    $args['cancel'] = true;
                    $args['cancellation_message'] = '<div class="psts-cancel-notification">
													<p class="label"><strong>' . __('Your subscription has been canceled', 'psts') . '</strong></p>
													<p>' . sprintf(__('This site should continue to have %1$s features until %2$s.', 'psts'), $level, $end_date) . '</p>';
                }
            }
            $args['level'] = $level;
            $args['expires'] = $end_date;
            // All good, keep populating the array.
            if (!isset($args['cancel'])) {
                // Get the last valid card
                if (isset($customer_object->cards->data[0]) && isset($customer_object->default_card)) {
                    foreach ($customer_object->cards->data as $tmpcard) {
                        if ($tmpcard->id == $customer_object->default_card) {
                            $card = $tmpcard;
                            break;
                        }
                    }
                } elseif (isset($customer_object->active_card)) {
                    //for API pre 2013-07-25
                    $card = $customer_object->active_card;
                }
                $args['card_type'] = $card->brand;
                $args['card_reminder'] = $card->last4;
                $args['card_digit_location'] = 'end';
                $args['card_expire_month'] = $card->exp_month;
                $args['card_expire_year'] = $card->exp_year;
                // Get the period
                $plan_parts = explode('_', $customer_object->subscriptions->data[0]->plan->id);
                $period = array_pop($plan_parts);
                $args['period'] = $period;
                // Get last payment date
                try {
                    $existing_invoice_object = Stripe_Invoice::all(array("customer" => $customer_id, "count" => 1));
                } catch (Exception $e) {
                    $error = $e->getMessage();
                }
                if (isset($existing_invoice_object->data[0]) && $customer_object->subscriptions->data[0]->status != 'trialing') {
                    $args['last_payment_date'] = $existing_invoice_object->data[0]->date;
                }
                // Get next payment date
                if (isset($invoice_object->next_payment_attempt)) {
                    $args['next_payment_date'] = $invoice_object->next_payment_attempt;
                }
                // Cancellation link
                if ($is_recurring) {
                    if (is_pro_site($blog_id)) {
                        $args['cancel_info'] = '<p class="prosites-cancel-description">' . sprintf(__('If you choose to cancel your subscription this site should continue to have %1$s features until %2$s.', 'psts'), $level, $end_date) . '</p>';
                        $cancel_label = __('Cancel Your Subscription', 'psts');
                        // CSS class of <a> is important to handle confirmations
                        $args['cancel_link'] = '<p class="prosites-cancel-link"><a class="cancel-prosites-plan button" href="' . wp_nonce_url($psts->checkout_url($blog_id) . '&action=cancel', 'psts-cancel') . '" title="' . esc_attr($cancel_label) . '">' . esc_html($cancel_label) . '</a></p>';
                    }
                }
                // Receipt form
                $args['receipt_form'] = $psts->receipt_form($blog_id);
            }
            // Show all is true
            $args['all_fields'] = true;
        }
        return empty($args) ? array() : $args;
    }
Пример #4
0
 public static function get_existing_user_information($blog_id, $domain, $get_all = true)
 {
     global $psts;
     $args = array();
     $img_base = $psts->plugin_url . 'images/';
     $trialing = ProSites_Helper_Registration::is_trial($blog_id);
     if ($trialing) {
         $args['trial'] = '<div id="psts-general-error" class="psts-warning">' . __('You are still within your trial period. Once your trial finishes your account will be automatically charged.', 'psts') . '</div>';
     }
     // Pending information
     if (!empty($blog_id) && 1 == get_blog_option($blog_id, 'psts_stripe_waiting')) {
         $args['pending'] = '<div id="psts-general-error" class="psts-warning">' . __('There are pending changes to your account. This message will disappear once these pending changes are completed.', 'psts') . '</div>';
     }
     return empty($content) ? array() : $content;
 }
        /**
         * "This blog" widget callback
         */
        public function blog_info_widget_cb()
        {
            $comments_count = wp_count_comments();
            ?>
            <table cellpadding="5" cellspacing="0" width="100%" class="siw_tbl">
                <tr>
                    <th><?php 
            _e('Title', 'siw');
            ?>
</th>
                    <td><?php 
            bloginfo('name');
            ?>
</td>
                </tr>
                <tr>
                    <th><?php 
            _e('Tagline', 'siw');
            ?>
</th>
                    <td><?php 
            bloginfo('description');
            ?>
</td>
                </tr>
                <tr>
                    <th><?php 
            _e('Theme', 'siw');
            ?>
</th>
                    <td><?php 
            echo get_current_theme();
            ?>
</td>
                </tr>
                <tr>
                    <th><?php 
            _e('Privacy', 'siw');
            ?>
</th>
                    <td><?php 
            echo get_option('blog_public') == 1 ? __('Blog is visible to everyone, including search engines (like Google, Sphere, Technorati) and archivers.', 'siw') : __('Blog is invisible to search engines, but allow normal visitors.', 'siw');
            ?>
</td>
                </tr>
                <tr>
                    <th><?php 
            _e('Comments', 'siw');
            ?>
</th>
                    <td><?php 
            printf(__('%s Pending | %s Spam', 'siw'), $comments_count->moderated, $comments_count->spam);
            ?>
</td>
                </tr>
            </table>
            <?php 
            // Check if WPMU pro sites plugin activated
            if (class_exists('ProSites')) {
                global $psts;
                $blog_id = get_current_blog_id();
                $levels = (array) get_site_option('psts_levels');
                $current_level = $psts->get_level($blog_id);
                $expire = $psts->get_expire($blog_id);
                $trialing = ProSites_Helper_Registration::is_trial($blog_id);
                $active_trial = $trialing ? __('(Active trial)', 'siw') : '';
                $quota = get_space_allowed();
                $used = get_space_used();
                if ($used > $quota) {
                    $percentused = '100';
                } else {
                    $percentused = $used / $quota * 100;
                }
                $used = round($used, 2);
                $percentused = number_format($percentused);
                ?>
                <table cellpadding="5" cellspacing="0" width="100%" class="siw_tbl">
                    <tr>
                        <th><?php 
                _e('Level', 'siw');
                ?>
</th>
                        <td>
                            <?php 
                echo $current_level . ' - ' . @$levels[$current_level]['name'];
                ?>
                            <a class="manage_pro" href="<?php 
                echo $psts->checkout_url($blog_id);
                ?>
"><?php 
                _e('Manage Pro Account', 'siw');
                ?>
</a>
                        </td>
                    </tr>
                    <tr>
                        <th><?php 
                _e('Renewal Date', 'siw');
                ?>
</th>
                        <td><?php 
                echo date_i18n(get_option('date_format'), $expire) . ' ' . $active_trial;
                ?>
</td>
                    </tr>
                    <tr>
                        <th><?php 
                _e('Storage', 'siw');
                ?>
</th>
                        <td>
                            <?php 
                echo $percentused;
                _e('% used of ', 'siw');
                echo number_format_i18n($quota);
                _e('M total', 'siw');
                ?>
                        </td>
                    </tr>
                </table>
                <?php 
            }
        }
Пример #6
0
	function admin_modify() {
		global $wpdb, $current_user;

		if ( ! is_super_admin() ) {
			echo "<p>" . __( 'Nice Try...', 'psts' ) . "</p>"; //If accessed properly, this message doesn't appear.
			return;
		}

		//add manual log entries
		if ( isset( $_POST['log_entry'] ) ) {
			$this->log_action( (int) $_GET['bid'], $current_user->display_name . ': "' . strip_tags( stripslashes( $_POST['log_entry'] ) ) . '"' );
			echo '<div id="message" class="updated fade"><p>' . __( 'Log entry added.', 'psts' ) . '</p></div>';
		}

		//extend blog
		if ( isset( $_POST['psts_extend'] ) ) {
			check_admin_referer( 'psts_extend' ); //check nonce

			if ( isset( $_POST['extend_permanent'] ) ) {
				$extend = 9999999999;
			} else {
				$months = $_POST['extend_months'];
				$days   = $_POST['extend_days'];
				$extend = strtotime( "+$months Months $days Days" ) - time();
			}
			$this->extend( (int) $_POST['bid'], $extend, __( 'Manual', 'psts' ), $_POST['extend_level'], false, false, true, true );
			echo '<div id="message" class="updated fade"><p>' . __( 'Site Extended.', 'psts' ) . '</p></div>';
		}

		if ( isset( $_POST['psts_transfer_pro'] ) ) {
			$new_bid     = (int) $_POST['new_bid'];
			$current_bid = (int) $_GET['bid'];
			if ( ! $new_bid ) {
				echo '<div id="message" class="error"><p>' . __( 'Please enter the Blog ID of a site to transfer to.', 'psts' ) . '</p></div>';
			} else if ( is_pro_site( $new_bid ) ) {
				echo '<div id="message" class="error"><p>' . __( 'Could not transfer Pro Status: The chosen site already is a Pro Site. You must remove Pro status and cancel any existing subscriptions tied to that site.', 'psts' ) . '</p></div>';
			} else {
				$current_level = $wpdb->get_row( "SELECT * FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '$current_bid'" );
				$new_expire    = $current_level->expire - time();
				$this->extend( $new_bid, $new_expire, $current_level->gateway, $current_level->level, $current_level->amount );
				$wpdb->query( "UPDATE {$wpdb->base_prefix}pro_sites SET term = '{$current_level->term}' WHERE blog_ID = '$new_bid'" );
				$this->withdraw( $current_bid );
				$this->log_action( $current_bid, sprintf( __( 'Pro Status transferred by %s to BlogID: %d', 'psts' ), $current_user->display_name, $new_bid ) );
				$this->log_action( $new_bid, sprintf( __( 'Pro Status transferred by %s from BlogID: %d', 'psts' ), $current_user->display_name, $current_bid ) );
				do_action( 'psts_transfer_pro', $current_bid, $new_bid ); //for gateways to hook into for api calls, etc.
				echo '<div id="message" class="updated fade"><p>' . sprintf( __( 'Pro Status transferred to BlogID: %d', 'psts' ), (int) $_POST['new_bid'] ) . '</p></div>';
			}
		}

		//remove blog
		if ( isset( $_POST['psts_modify'] ) ) {
			check_admin_referer( 'psts_modify' ); //check nonce

			do_action( 'psts_modify_process', (int) $_POST['bid'] );

			if ( isset( $_POST['psts_remove'] ) ) {
				$this->withdraw( (int) $_POST['bid'] );
				echo '<div id="message" class="updated fade"><p>' . __( 'Pro Site Status Removed.', 'psts' ) . '</p></div>';
			}

			if ( isset( $_POST['psts_receipt'] ) ) {
				$this->email_notification( (int) $_POST['bid'], 'receipt', $_POST['receipt_email'] );
				echo '<div id="message" class="updated fade"><p>' . __( 'Email receipt sent.', 'psts' ) . '</p></div>';
			}

		}

		//check blog_id
		if ( isset( $_GET['bid'] ) ) {
			$blog_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->base_prefix}blogs WHERE blog_ID = %d", (int) $_GET['bid'] ) );
			if ( ! $blog_count ) {
				echo '<div id="message" class="updated fade"><p>' . __( 'Invalid blog ID. Please try again.', 'psts' ) . '</p></div>';
				$blog_id = false;
			} else {
				$blog_id = (int) $_GET['bid'];
			}
		} else {
			$blog_id = false;
		}

		$activation_key = false;
		if ( isset( $_GET['activation_key'] ) ) {
			$activation_key = $_GET['activation_key'];
		}

		?>
		<div class="wrap">
		<script type="text/javascript">
			jQuery(document).ready(function () {
				jQuery('input.psts_confirm').click(function () {
					var answer = confirm("<?php _e('Are you sure you really want to do this?', 'psts'); ?>")
					if (answer) {
						return true;
					} else {
						return false;
					}
					;
				});
			});
		</script>
		<div class="icon32"><img src="<?php echo $this->plugin_url . 'images/modify.png'; ?>"/></div>
		<h2><?php _e( 'Pro Sites Management', 'psts' ); ?></h2>

		<?php
		if( $activation_key ) {
			$result = ProSites_Helper_Registration::activate_blog( $activation_key );
			$blog_id = $result;
		}

		if ( $blog_id ) { ?>
			<h3><?php _e( 'Manage Site', 'psts' ) ?>
			<?php
			if ( $name = get_blog_option( $blog_id, 'blogname' ) ) {
				echo ': ' . $name . ' (Blog ID: ' . $blog_id . ')';
			}

			echo '</h3>';

			$levels        = (array) get_site_option( 'psts_levels' );
			$current_level = $this->get_level( $blog_id );
			$expire        = $this->get_expire( $blog_id );
			$result        = $wpdb->get_row( "SELECT * FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '$blog_id'" );
			if ( $result ) {
				if ( $result->term == 1 || $result->term == 3 || $result->term == 12 ) {
					$term = sprintf( _n( '%s Month','%s Months', $result->term, 'psts' ), $result->term );
				} else {
					$term = $result->term;
				}
			} else {
				$term = 0;
			}

			if ( $expire && $expire > time() ) {
				echo '<p><strong>' . __( 'Current Pro Site', 'psts' ) . '</strong></p>';

				echo '<ul>';
				if ( $expire > 2147483647 ) {
					echo '<li>' . __( 'Pro Site privileges will expire: <strong>Never</strong>', 'psts' ) . '</li>';
				} else {
					$trialing = ProSites_Helper_Registration::is_trial( $blog_id );
					$active_trial = $trialing ? __( '(Active trial)', 'psts') : '';

					echo '<li>' . sprintf( __( 'Pro Site privileges will expire on: <strong>%s</strong>', 'psts' ), date_i18n( get_option( 'date_format' ), $expire ) ) . ' ' . $active_trial . '</li>';
				}

				echo '<li>' . sprintf( __( 'Level: <strong>%s</strong>', 'psts' ), $current_level . ' - ' . @$levels[ $current_level ]['name'] ) . '</li>';
				if ( $result->gateway ) {
					$nicename = ProSites_Helper_Gateway::get_nice_name( $result->gateway );
					echo '<li>' . sprintf( __( 'Payment Gateway: <strong>%s</strong>', 'psts' ), $nicename ) . '</li>';
				}
				if ( $term ) {
					echo '<li>' . sprintf( __( 'Payment Term: <strong>%s</strong>', 'psts' ), $term ) . '</li>';
				}
				echo '</ul>';

			} else if ( $expire && $expire <= time() ) {
				echo '<p><strong>' . __( 'Expired Pro Site', 'psts' ) . '</strong></p>';

				echo '<ul>';
				echo '<li>' . sprintf( __( 'Pro Site privileges expired on: <strong>%s</strong>', 'psts' ), date_i18n( get_option( 'date_format' ), $expire ) ) . '</li>';

				echo '<li>' . sprintf( __( 'Previous Level: <strong>%s</strong>', 'psts' ), $current_level . ' - ' . @$levels[ $current_level ]['name'] ) . '</li>';
				if ( $result->gateway ) {
					$nicename = ProSites_Helper_Gateway::get_nice_name( $result->gateway );
					echo '<li>' . sprintf( __( 'Previous Payment Gateway: <strong>%s</strong>', 'psts' ), $nicename ) . '</li>';
				}
				if ( $term ) {
					echo '<li>' . sprintf( __( 'Previous Payment Term: <strong>%s</strong>', 'psts' ), $term ) . '</li>';
				}
				echo '</ul>';

			} else {
				echo '<p><strong>"' . get_blog_option( $blog_id, 'blogname' ) . '" ' . __( 'has never been a Pro Site.', 'psts' ) . '</strong></p>';
			}

			//meta boxes hooked by gateway plugins
			if ( has_action( 'psts_subscription_info' ) || has_action( 'psts_subscriber_info' ) ) {
				?>
				<div class="metabox-holder">
					<?php if ( has_action( 'psts_subscription_info' ) ) { ?>
						<div style="width: 49%;" class="postbox-container">
							<div class="postbox">
								<h3 class="hndle" style="cursor:auto;">
									<span><?php _e( 'Subscription Information', 'psts' ); ?></span></h3>

								<div class="inside">
									<?php do_action( 'psts_subscription_info', $blog_id ); ?>
								</div>
							</div>
						</div>
					<?php } ?>

					<?php if ( has_action( 'psts_subscriber_info' ) ) { ?>
						<div style="width: 49%;margin-left: 2%;" class="postbox-container">
							<div class="postbox">
								<h3 class="hndle" style="cursor:auto;">
									<span><?php _e( 'Subscriber Information', 'psts' ); ?></span></h3>

								<div class="inside">
									<?php do_action( 'psts_subscriber_info', $blog_id ); ?>
								</div>
							</div>
						</div>
					<?php } ?>

					<div class="clear"></div>
				</div>
			<?php } ?>

			<div id="poststuff" class="metabox-holder">
				<div class="postbox">
					<h3 class="hndle" style="cursor:auto;"><span><?php _e( 'Account History', 'psts' ) ?></span></h3>

					<div class="inside">
						<span class="description"><?php _e( 'This logs basically every action done in the system regarding the site for an audit trail.', 'psts' ); ?></span>

						<div style="height:150px;overflow:auto;margin-top:5px;margin-bottom:5px;">
							<table class="widefat">
								<?php
								$log = get_blog_option( $blog_id, 'psts_action_log' );
								$time_offset = ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
								if ( is_array( $log ) && count( $log ) ) {
									$log = array_reverse( $log, true );
									foreach ( $log as $timestamp => $memo ) {
										$class = ( isset( $class ) && $class == 'alternate' ) ? '' : 'alternate';
										$localtime = $timestamp + $time_offset;
										echo '<tr class="'.$class.'"><td><strong>' . date_i18n( __('Y-m-d g:i:s a', 'psts'), $localtime ) . '</strong></td><td>' . esc_html($memo) . '</td></tr>';
									}
								} else {
									echo '<tr><td colspan="2">' . __( 'No history recorded for this site yet.', 'psts' ) . '</td></tr>';
								}
								?>
							</table>
						</div>
						<form method="post" action="">
							<input type="text" placeholder="<?php _e( 'Add a custom log entry...', 'psts' ); ?>" name="log_entry" style="width:91%;"/>
							<input type="submit" class="button-secondary" name="add_log_entry" value="<?php _e( 'Add &raquo;', 'psts' ) ?>" style="width:8%;float:right;"/>
						</form>
					</div>
				</div>
			</div>


			<div id="poststuff" class="metabox-holder">

				<div style="width: 49%;" class="postbox-container">
					<div class="postbox">
						<h3 class="hndle" style="cursor:auto;">
							<span><?php _e( 'Manually Extend Pro Site Status', 'psts' ) ?></span></h3>

						<div class="inside">
							<span class="description"><?php _e( 'Please note that these changes will not adjust the payment dates or level for any existing subscription.', 'psts' ); ?></span>

							<form method="post" action="">
								<table class="form-table">
									<?php wp_nonce_field( 'psts_extend' ) ?>
									<input type="hidden" name="bid" value="<?php echo $blog_id; ?>"/>
									<tr valign="top">
										<th scope="row"><?php _e( 'Period', 'psts' ) ?></th>
										<td><select name="extend_months">
												<?php
												for ( $counter = 0; $counter <= 36; $counter += 1 ) {
													echo '<option value="' . $counter . '">' . $counter . '</option>' . "\n";
												}
												?>
											</select><?php _e( 'Months', 'psts' ); ?>
											<select name="extend_days">
												<?php
												for ( $counter = 0; $counter <= 30; $counter += 1 ) {
													echo '<option value="' . $counter . '">' . $counter . '</option>' . "\n";
												}
												?>
											</select><?php _e( 'Days', 'psts' ); ?>
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'or', 'psts' ); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											<label><input type="checkbox" name="extend_permanent" value="1"/> <?php _e( 'Permanent', 'psts' ); ?>
											</label>
											<br/><?php _e( 'Period you wish to extend the site. Leave at zero to only change the level.', 'psts' ); ?>
										</td>
									</tr>
									<tr valign="top">
										<th scope="row"><?php _e( 'Level', 'psts' ) ?></th>
										<td><select name="extend_level">
												<?php
												foreach ( $levels as $level => $value ) {
													?>
													<option value="<?php echo $level; ?>"<?php selected( $current_level, $level ) ?>><?php echo $level . ': ' . esc_attr( $value['name'] ); ?></option><?php
												}
												?>
											</select>
											<br/><?php _e( 'Choose what level the site should have access to.', 'psts' ); ?>
										</td>
									</tr>
									<tr valign="top">
										<td colspan="2" style="text-align:right;">
											<input class="button-primary" type="submit" name="psts_extend" value="<?php _e( 'Extend &raquo;', 'psts' ) ?>"/>
										</td>
									</tr>
								</table>
								<hr/>
								<table class="form-table">
									<tr valign="top">
										<td><label>Transfer Pro status to Blog ID:
												<input type="text" name="new_bid" size="3"/></label></td>
										<td style="text-align:right;">
											<input class="button-primary psts_confirm" type="submit" name="psts_transfer_pro" value="<?php _e( 'Transfer &raquo;', 'psts' ) ?>"/>
										</td>
									</tr>
								</table>
							</form>
						</div>
					</div>
				</div>

				<?php if ( is_pro_site( $blog_id ) || has_action( 'psts_modify_form' ) ) { ?>
					<div style="width: 49%;margin-left: 2%;" class="postbox-container">
						<div class="postbox">
							<h3 class="hndle" style="cursor:auto;">
								<span><?php _e( 'Modify Pro Site Status', 'psts' ) ?></span></h3>

							<div class="inside">
								<form method="post" action="">
									<?php wp_nonce_field( 'psts_modify' ) ?>
									<input type="hidden" name="bid" value="<?php echo $blog_id; ?>"/>

									<?php do_action( 'psts_modify_form', $blog_id ); ?>

									<?php if ( is_pro_site( $blog_id ) ) { ?>
										<p>
											<label><input type="checkbox" name="psts_remove" value="1"/> <?php _e( 'Remove Pro status from this site.', 'psts' ); ?>
											</label></p>
									<?php } ?>

									<?php if ( $last_payment = $this->last_transaction( $blog_id ) ) { ?>
										<p>
											<label><input type="checkbox" name="psts_receipt" value="1"/> <?php _e( 'Email a receipt copy for last payment to:', 'psts' ); ?>
												<input type="text" name="receipt_email" value="<?php echo get_blog_option( $blog_id, 'admin_email' ); ?>"/></label>
										</p>
									<?php } ?>

									<p class="submit">
										<input type="submit" name="psts_modify" class="button-primary psts_confirm" value="<?php _e( 'Modify &raquo;', 'psts' ) ?>"/>
									</p>
								</form>
							</div>
						</div>
					</div>
				<?php } ?>
			</div>
			<?php

			//show blog_id form
		} else {
			?>
			<div class="metabox-holder">
				<div class="postbox">
					<h3 class="hndle" style="cursor:auto;"><span><?php _e( 'Manage a Site', 'psts' ) ?></span></h3>

					<div class="inside">
						<form method="get" action="">
							<table class="form-table">
								<input type="hidden" name="page" value="psts"/>
								<tr valign="top">
									<th scope="row"><?php _e( 'Blog ID:', 'psts' ) ?></th>
									<td><input type="text" size="17" name="bid" value=""/>
										<input class="button-secondary" type="submit" value="<?php _e( 'Continue &raquo;', 'psts' ) ?>"/>
									</td>
								</tr>
							</table>
						</form>
						<hr />
						<form method="get" action="">
							<table class="form-table">
								<input type="hidden" name="page" value="psts"/>
								<tr valign="top">
									<th scope="row"><?php _e( 'Activation Key:', 'psts' ) ?></th>
									<td><input type="text" size="17" name="activation_key" value=""/>
										<input class="button-secondary" type="submit" value="<?php _e( 'Activate Blog &raquo;', 'psts' ) ?>"/>
									</td>
								</tr>
							</table>
						</form>
						<hr/>
						<form method="get" action="sites.php" name="searchform">
							<table class="form-table">
								<tr valign="top">
									<th scope="row"><?php _e( 'Or search for a site:<br /><small>By Blog ID, IP address or Path/Domain</small>', 'psts' ) ?></th>
									<td><input type="text" size="17" value="" name="s"/>
										<input class="button-secondary" type="submit" value="<?php _e( 'Search Sites &raquo;', 'psts' ) ?>" id="submit_sites" name="submit"/>
									</td>
								</tr>
							</table>
						</form>
					</div>
				</div>
			</div>
		<?php
		}
		echo '</div>';
	}