/**
  * Builds the Forms page for this Payment Gateway.
  *
  * @package s2Member\Menu_Pages
  * @since 140617
  */
 public static function stripe_forms_page()
 {
     if (c_ws_plugin__s2member_pro_stripe_responses::stripe_form_api_validation_errors()) {
         // Report error if Stripe Options are not yet configured.
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <strong>s2Member → Stripe Options</strong> first. Once all of your Stripe Options are configured, return to this page &amp; generate your Stripe Form(s).', TRUE);
     }
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . '/menu-pages/stripe-forms.inc.php';
 }
 /**
  * Builds the Buttons panel for this Payment Gateway.
  *
  * @package s2Member\Menu_Pages
  * @since 1.5
  *
  * @return null
  */
 public static function ccbill_buttons_page()
 {
     if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_id"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_client_sid"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_form_name"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_dl_user"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_dl_pass"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_ccbill_salt_key"]) {
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <code>s2Member -> ccBill® Options</code> first. Once all of your cBill® Options have been configured, return to this page &amp; generate your ccBill® Button(s).', true);
     }
     /**/
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/menu-pages/ccbill-buttons.inc.php";
     /**/
     return;
     /* Return for uniformity. */
 }
 /**
  * Builds the Buttons panel for this Payment Gateway.
  *
  * @package s2Member\Menu_Pages
  * @since 1.5
  *
  * @return null
  */
 public static function google_buttons_page()
 {
     if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_key"]) {
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <strong>s2Member → Google Options</strong> first. Once all of your Google Options have been configured, return to this page &amp; generate your Google Wallet Button(s).', true);
     }
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/menu-pages/google-buttons.inc.php";
     return;
 }
 /**
  * Builds the Pro Forms page for this Payment Gateway.
  *
  * @package s2Member\Menu_Pages
  * @since 1.5
  *
  * @return null
  */
 public static function paypal_forms_page()
 {
     if (c_ws_plugin__s2member_pro_paypal_responses::paypal_form_api_validation_errors()) {
         /* Report error if PayPal® Options are not yet configured. */
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <code>s2Member -> PayPal® Options</code> first. Once all of your PayPal® Options are configured; including your Email Address, API Username, Password, and Signature; return to this page &amp; generate your PayPal® Pro Form(s).', true);
     }
     /**/
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/menu-pages/paypal-forms.inc.php";
     /**/
     return;
     /* Return for uniformity. */
 }
 /**
  * Builds the Buttons panel for this Payment Gateway.
  *
  * @package s2Member\Menu_Pages
  * @since 1.5
  *
  * @return null
  */
 public static function alipay_buttons_page()
 {
     if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_alipay_seller_email"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_alipay_partner_id"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_alipay_security_code"]) {
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <strong>s2Member ⥱ AliPay Options</strong> first. Once all of your AliPay Options have been configured, return to this page &amp; generate your AliPay Button(s).', true);
     }
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/menu-pages/alipay-buttons.inc.php";
     return;
 }
 /**
  * Builds the Forms page for this Payment Gateway.
  *
  * @package s2Member\Menu_Pages
  * @since 1.5
  *
  * @return null
  */
 public static function authnet_forms_page()
 {
     if (c_ws_plugin__s2member_pro_authnet_responses::authnet_form_api_validation_errors()) {
         /* Report error if Authorize.Net® Options are not yet configured. */
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <code>s2Member -> Authorize.Net® Options</code> first. Once all of your Authorize.Net® Options are configured, return to this page &amp; generate your Authorize.net® Form(s).', true);
     }
     /**/
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/menu-pages/authnet-forms.inc.php";
     /**/
     return;
     /* Return for uniformity. */
 }
 /**
  * Builds the Forms page for this Payment Gateway.
  *
  * @package s2Member\Menu_Pages
  * @since 1.5
  *
  * @return null
  */
 public static function authnet_forms_page()
 {
     if (c_ws_plugin__s2member_pro_authnet_responses::authnet_form_api_validation_errors()) {
         // Report error if Authorize.Net Options are not yet configured.
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <strong>s2Member → Authorize.Net Options</strong> first. Once all of your Authorize.Net Options are configured, return to this page &amp; generate your Authorize.net Form(s).', true);
     }
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/menu-pages/authnet-forms.inc.php";
     return;
 }
 /**
  * Builds the Pro Forms page for this Payment Gateway.
  *
  * @package s2Member\Menu_Pages
  * @since 1.5
  *
  * @return null
  */
 public static function paypal_forms_page()
 {
     if (c_ws_plugin__s2member_pro_paypal_responses::paypal_form_api_validation_errors()) {
         // Report error if PayPal Options are not yet configured.
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <code>s2Member -› PayPal Options</code> first. Once all of your PayPal Options are configured; including your Email Address, API Username, Password, and Signature; return to this page &amp; generate your PayPal Pro Form(s).<br /><br />*NOTE: If you\'re ONLY planning to use Free Registration Forms (e.g. you\'re NOT going to accept payments), you can safely ignore this warning and continue to use the Free Registration Form shortcode provided below.', true);
     }
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/menu-pages/paypal-forms.inc.php";
     return;
 }
 /**
  * Processes all administrative notices.
  *
  * @package s2Member\Admin_Notices
  * @since 3.5
  *
  * @attaches-to ``add_action("admin_notices");``
  * @attaches-to ``add_action("user_admin_notices");``
  * @attaches-to ``add_action("network_admin_notices");``
  * @todo Update to ``add_action("all_admin_notices");``.
  */
 public static function admin_notices()
 {
     global $pagenow;
     do_action("ws_plugin__s2member_before_admin_notices", get_defined_vars());
     if (is_admin() && is_array($notices = get_option("ws_plugin__s2member_notices")) && !empty($notices)) {
         $a = is_blog_admin() ? "blog" : "";
         $a = is_user_admin() ? "user" : $a;
         $a = is_network_admin() ? "network" : $a;
         $a = !$a ? "blog" : $a;
         foreach ($notices as $i => $notice) {
             foreach (!$notice["on_pages"] ? array("*") : (array) $notice["on_pages"] as $page) {
                 if (!preg_match("/^(.+?)\\:/", $page)) {
                     $page = "blog:" . ltrim($page, ":");
                 }
                 $adms = preg_split("/\\|/", preg_replace("/\\:(.*)\$/i", "", $page));
                 $page = preg_replace("/^([^\\:]*)\\:/i", "", $page);
                 if (empty($adms) || in_array("*", $adms) || in_array($a, $adms)) {
                     if (!$page || "*" === $page || $pagenow === $page || @$_GET["page"] === $page) {
                         if (strtotime("now") >= (int) $notice["time"]) {
                             foreach (array_keys(get_defined_vars()) as $__v) {
                                 $__refs[$__v] =& ${$__v};
                             }
                             do_action("ws_plugin__s2member_during_admin_notices_before_display", get_defined_vars());
                             unset($__refs, $__v);
                             if (!$notice["dismiss"] || !empty($_GET["ws-plugin--s2member-dismiss-admin-notice"]) && $_GET["ws-plugin--s2member-dismiss-admin-notice"] === md5($notice["notice"])) {
                                 unset($notices[$i]);
                             }
                             if (!$notice["dismiss"] || empty($_GET["ws-plugin--s2member-dismiss-admin-notice"]) || $_GET["ws-plugin--s2member-dismiss-admin-notice"] !== md5($notice["notice"])) {
                                 c_ws_plugin__s2member_admin_notices::display_admin_notice($notice["notice"], $notice["error"], $notice["dismiss"]);
                             }
                             do_action("ws_plugin__s2member_during_admin_notices_after_display", get_defined_vars());
                         }
                         continue 2;
                     }
                 }
             }
         }
         $notices = array_merge($notices);
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_admin_notices", get_defined_vars());
         unset($__refs, $__v);
         update_option("ws_plugin__s2member_notices", $notices);
     }
     do_action("ws_plugin__s2member_after_admin_notices", get_defined_vars());
 }
 /**
  * Processes all administrative notices.
  *
  * @package s2Member\Admin_Notices
  * @since 3.5
  *
  * @attaches-to ``add_action('admin_notices');``
  * @attaches-to ``add_action('user_admin_notices');``
  * @attaches-to ``add_action('network_admin_notices');``
  * @todo Update to ``add_action('all_admin_notices');``.
  */
 public static function admin_notices()
 {
     global $pagenow;
     // This holds the current page filename.
     do_action('ws_plugin__s2member_before_admin_notices', get_defined_vars());
     if (is_admin() && is_array($notices = get_option('ws_plugin__s2member_notices')) && !empty($notices)) {
         $a = is_blog_admin() ? 'blog' : '';
         $a = is_user_admin() ? 'user' : $a;
         $a = is_network_admin() ? 'network' : $a;
         $a = !$a ? 'blog' : $a;
         // Default blog admin.
         foreach ($notices as $i => $notice) {
             // Check several things about each notice.
             foreach (!$notice['on_pages'] ? array('*') : (array) $notice['on_pages'] as $page) {
                 if (!preg_match('/^(.+?)\\:/', $page)) {
                     // NO prefix?
                     $page = 'blog:' . ltrim($page, ':');
                 }
                 // `blog:`
                 $adms = preg_split('/\\|/', preg_replace('/\\:(.*)$/i', '', $page));
                 $page = preg_replace('/^([^\\:]*)\\:/i', '', $page);
                 if (empty($adms) || in_array('*', $adms) || in_array($a, $adms)) {
                     if (!$page || '*' === $page || $pagenow === $page || @$_GET['page'] === $page) {
                         if (strtotime('now') >= (int) $notice['time']) {
                             foreach (array_keys(get_defined_vars()) as $__v) {
                                 $__refs[$__v] =& ${$__v};
                             }
                             do_action('ws_plugin__s2member_during_admin_notices_before_display', get_defined_vars());
                             unset($__refs, $__v);
                             // Allow variables to be modified by reference.
                             if (!$notice['dismiss'] || !empty($_GET['ws-plugin--s2member-dismiss-admin-notice']) && $_GET['ws-plugin--s2member-dismiss-admin-notice'] === md5($notice['notice'])) {
                                 unset($notices[$i]);
                             }
                             // Clear this administrative notice now?
                             if (!$notice['dismiss'] || empty($_GET['ws-plugin--s2member-dismiss-admin-notice']) || $_GET['ws-plugin--s2member-dismiss-admin-notice'] !== md5($notice['notice'])) {
                                 c_ws_plugin__s2member_admin_notices::display_admin_notice($notice['notice'], $notice['error'], $notice['dismiss']);
                             }
                             do_action('ws_plugin__s2member_during_admin_notices_after_display', get_defined_vars());
                         }
                         continue 2;
                         // This notice processed; continue.
                     }
                 }
             }
         }
         $notices = array_merge($notices);
         // Re-index array.
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action('ws_plugin__s2member_during_admin_notices', get_defined_vars());
         unset($__refs, $__v);
         // Allow variables to be modified by reference.
         update_option('ws_plugin__s2member_notices', $notices);
     }
     do_action('ws_plugin__s2member_after_admin_notices', get_defined_vars());
 }
 /**
  * Processes all administrative notices.
  *
  * @package s2Member\Admin_Notices
  * @since 3.5
  *
  * @attaches-to ``add_action("admin_notices");``
  * @attaches-to ``add_action("user_admin_notices");``
  * @attaches-to ``add_action("network_admin_notices");``
  * @todo Update to ``add_action("all_admin_notices");``.
  *
  * @return null
  */
 public static function admin_notices()
 {
     global $pagenow;
     /* This holds the current page filename. */
     /**/
     do_action("ws_plugin__s2member_before_admin_notices", get_defined_vars());
     /**/
     if (is_admin() && is_array($notices = get_option("ws_plugin__s2member_notices")) && !empty($notices)) {
         $a = is_blog_admin() ? "blog" : $a;
         $a = is_user_admin() ? "user" : $a;
         $a = is_network_admin() ? "network" : $a;
         $a = !$a ? "blog" : $a;
         /* Default Blog Admin. */
         /**/
         foreach ($notices as $i => $notice) {
             /* Check several things about each Notice. */
             foreach (!$notice["on_pages"] ? array("*") : (array) $notice["on_pages"] as $page) {
                 if (!preg_match("/^(.+?)\\:/", $page)) {
                     /* NO prefix? */
                     $page = "blog:" . ltrim($page, ":");
                 }
                 /* `blog:` */
                 /**/
                 $adms = preg_split("/\\|/", preg_replace("/\\:(.*)\$/i", "", $page));
                 $page = preg_replace("/^([^\\:]*)\\:/i", "", $page);
                 /**/
                 if (empty($adms) || in_array("*", $adms) || in_array($a, $adms)) {
                     if (!$page || "*" === $page || $pagenow === $page || $_GET["page"] === $page) {
                         if (strtotime("now") >= (int) $notice["time"]) {
                             eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                             do_action("ws_plugin__s2member_during_admin_notices_before_display", get_defined_vars());
                             unset($__refs, $__v);
                             /* Unset defined __refs, __v. */
                             /**/
                             if (!$notice["dismiss"] || !empty($_GET["ws-plugin--s2member-dismiss-admin-notice"]) && $_GET["ws-plugin--s2member-dismiss-admin-notice"] === md5($notice["notice"])) {
                                 unset($notices[$i]);
                             }
                             /* Clear this administrative notice now? */
                             /**/
                             if (!$notice["dismiss"] || empty($_GET["ws-plugin--s2member-dismiss-admin-notice"]) || $_GET["ws-plugin--s2member-dismiss-admin-notice"] !== md5($notice["notice"])) {
                                 c_ws_plugin__s2member_admin_notices::display_admin_notice($notice["notice"], $notice["error"], $notice["dismiss"]);
                             }
                             /**/
                             do_action("ws_plugin__s2member_during_admin_notices_after_display", get_defined_vars());
                         }
                         /**/
                         continue 2;
                         /* This Notice processed; continue. */
                     }
                 }
             }
         }
         /**/
         $notices = array_merge($notices);
         /* Re-index array. */
         /**/
         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
         do_action("ws_plugin__s2member_during_admin_notices", get_defined_vars());
         unset($__refs, $__v);
         /* Unset defined __refs, __v. */
         /**/
         update_option("ws_plugin__s2member_notices", $notices);
     }
     /**/
     do_action("ws_plugin__s2member_after_admin_notices", get_defined_vars());
     /**/
     return;
     /* Return for uniformity. */
 }
 /**
  * Builds and handles the PayPal Button Generator page.
  * 
  * @package s2Member\Menu_Pages
  * @since 3.5
  * 
  * @return null
  */
 public static function paypal_buttons_page()
 {
     do_action("ws_plugin__s2member_before_paypal_buttons_page", get_defined_vars());
     /**/
     if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"]) {
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <code>s2Member -> PayPal® Options</code> first. Once all of your PayPal® Options are configured; including your Email Address, API Username, Password, and Signature; return to this page &amp; generate your PayPal® Button(s).', true);
     }
     /**/
     include_once dirname(dirname(__FILE__)) . "/menu-pages/paypal-buttons.inc.php";
     /**/
     do_action("ws_plugin__s2member_after_paypal_buttons_page", get_defined_vars());
     /**/
     return;
     /* Return for uniformity. */
 }
Exemple #13
0
 /**
  * Builds and handles the Logs page.
  *
  * @package s2Member\Menu_Pages
  * @since 120310
  *
  * @return null
  */
 public static function logs_page()
 {
     do_action("ws_plugin__s2member_before_logs_page", get_defined_vars());
     c_ws_plugin__s2member_menu_pages::update_all_options();
     c_ws_plugin__s2member_menu_pages::archive_logs_start_fresh();
     c_ws_plugin__s2member_menu_pages::delete_logs_start_fresh();
     $logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"];
     if (!is_dir($logs_dir) && is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir)))) {
         mkdir($logs_dir, 0777, true) . clearstatcache();
     }
     $htaccess = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"] . "/.htaccess";
     $htaccess_contents = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir_htaccess"])));
     if (is_dir($logs_dir) && is_writable($logs_dir) && !file_exists($htaccess)) {
         file_put_contents($htaccess, $htaccess_contents) . clearstatcache();
     }
     if (!is_dir($logs_dir)) {
         c_ws_plugin__s2member_admin_notices::display_admin_notice('The security-enabled logs directory (<code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($logs_dir)) . '</code>) does not exist. Please create this directory manually &amp; make it writable (chmod 777).', true);
     } else {
         if (!is_writable($logs_dir)) {
             c_ws_plugin__s2member_admin_notices::display_admin_notice('Permissions error. The security-enabled logs directory (<code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($logs_dir)) . '</code>) is not writable. Please make this directory writable (chmod 777).', true);
         }
     }
     if (!file_exists($htaccess)) {
         c_ws_plugin__s2member_admin_notices::display_admin_notice('The .htaccess protection file (<code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)) . '</code>) does not exist. Please create this file manually. Inside your .htaccess file, add this:<br /><pre>' . esc_html($htaccess_contents) . '</pre>', true);
     } else {
         if (!preg_match("/deny from all/i", file_get_contents($htaccess))) {
             c_ws_plugin__s2member_admin_notices::display_admin_notice('Unprotected. The .htaccess protection file (<code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)) . '</code>) does not contain <code>deny from all</code>. Inside your .htaccess file, add this:<br /><pre>' . esc_html($htaccess_contents) . '</pre>', true);
         }
     }
     if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) {
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Logging is currently disabled by your configuration.');
     }
     include_once dirname(dirname(__FILE__)) . "/menu-pages/logs.inc.php";
     do_action("ws_plugin__s2member_after_logs_page", get_defined_vars());
     return;
 }
 /**
  * Handles the importation of options.
  *
  * @package s2Member\Imports
  * @since 110815
  */
 public static function import_ops()
 {
     if (!empty($_POST['ws_plugin__s2member_pro_import_ops']) && ($nonce = $_POST['ws_plugin__s2member_pro_import_ops']) && wp_verify_nonce($nonce, 'ws-plugin--s2member-pro-import-ops') && current_user_can('create_users')) {
         @set_time_limit(0);
         // Make time for processing large import files.
         @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
         if (!empty($_FILES['ws_plugin__s2member_pro_import_ops_file']) && empty($_FILES['ws_plugin__s2member_pro_import_ops_file']['error'])) {
             $file = file_get_contents($_FILES['ws_plugin__s2member_pro_import_ops_file']['tmp_name'], 'r');
         }
         if (!empty($file)) {
             if (is_array($import = c_ws_plugin__s2member_pro_utils_ops::op_replace(@unserialize($file), TRUE)) && !empty($import) && ($import['configured'] = '1')) {
                 unset($import['options_checksum'], $import['options_version']);
                 foreach ($import as $key => $value) {
                     is_array($value) ? array_unshift($value, 'update-signal') : NULL;
                     $import['ws_plugin__s2member_' . $key] = $value;
                     unset($import[$key]);
                 }
                 c_ws_plugin__s2member_menu_pages::update_all_options($import, TRUE, TRUE, FALSE, FALSE, FALSE);
             } else {
                 $errors[] = 'Invalid data received. Please try again.';
             }
             // Unserialization failed?
         } else {
             $errors[] = 'No data was received. Please try again.';
         }
         // The upload failed, or it was empty.
         if (!empty($errors)) {
             // Here is where a detailed error log will be returned to the Site Owner; as a way of clarifying what just happened during importation.
             c_ws_plugin__s2member_admin_notices::display_admin_notice('<strong>The following errors were encountered during importation:</strong><ul style="font-size:80%; list-style:disc outside; margin-left:25px;"><li>' . implode('</li><li>', $errors) . '</li></ul>', TRUE);
         } else {
             c_ws_plugin__s2member_admin_notices::display_admin_notice('Operation complete. Options imported.');
         }
     }
 }
 /**
  * Builds the Buttons panel for this Payment Gateway.
  *
  * @package s2Member\Menu_Pages
  * @since 1.5
  *
  * @return null
  */
 public static function clickbank_buttons_page()
 {
     if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_clickbank_username"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_clickbank_clerk_key"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_clickbank_developer_key"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_clickbank_secret_key"]) {
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <strong>s2Member → ClickBank Options</strong> first. Once all of your ClickBank Options have been configured, return to this page &amp; generate your ClickBank Button(s).', true);
     }
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/menu-pages/clickbank-buttons.inc.php";
     return;
 }
Exemple #16
0
 /**
  * Handles the importation of options.
  *
  * @package s2Member\Imports
  * @since 110815
  *
  * @return null
  */
 public static function import_ops()
 {
     if (!empty($_POST["ws_plugin__s2member_pro_import_ops"]) && ($nonce = $_POST["ws_plugin__s2member_pro_import_ops"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-pro-import-ops") && current_user_can("create_users")) {
         @set_time_limit(0);
         // Make time for processing large import files.
         @ini_set("memory_limit", apply_filters("admin_memory_limit", WP_MAX_MEMORY_LIMIT));
         if (!empty($_FILES["ws_plugin__s2member_pro_import_ops_file"]) && empty($_FILES["ws_plugin__s2member_pro_import_ops_file"]["error"])) {
             $file = file_get_contents($_FILES["ws_plugin__s2member_pro_import_ops_file"]["tmp_name"], "r");
         }
         if (!empty($file)) {
             if (is_array($import = c_ws_plugin__s2member_pro_utils_ops::op_replace(@unserialize($file), true)) && !empty($import) && ($import["configured"] = "1")) {
                 unset($import["options_checksum"], $import["options_version"]);
                 foreach ($import as $key => $value) {
                     is_array($value) ? array_unshift($value, "update-signal") : null;
                     $import["ws_plugin__s2member_" . $key] = $value;
                     unset($import[$key]);
                 }
                 c_ws_plugin__s2member_menu_pages::update_all_options($import, true, true, false, false, false);
             } else {
                 $errors[] = "Invalid data received. Please try again.";
             }
             // Unserialization failed?
         } else {
             $errors[] = "No data was received. Please try again.";
         }
         // The upload failed, or it was empty.
         if (!empty($errors)) {
             // Here is where a detailed error log will be returned to the Site Owner; as a way of clarifying what just happened during importation.
             c_ws_plugin__s2member_admin_notices::display_admin_notice('<strong>The following errors were encountered during importation:</strong><ul style="font-size:80%; list-style:disc outside; margin-left:25px;"><li>' . implode("</li><li>", $errors) . '</li></ul>', true);
         } else {
             c_ws_plugin__s2member_admin_notices::display_admin_notice('Operation complete. Options imported.');
         }
     }
     return;
 }
 /**
  * Builds the Pro-Forms page for this Payment Gateway.
  *
  * @package s2Member\Menu_Pages
  * @since 1.5
  *
  * @return null
  */
 public static function paypal_forms_page()
 {
     if (c_ws_plugin__s2member_pro_paypal_responses::paypal_form_api_validation_errors()) {
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <strong>s2Member → PayPal Options</strong> first. Once all of your PayPal Options are configured; including your Email Address, API Username, Password, and Signature; return to this page &amp; generate your PayPal Pro-Form(s).', TRUE);
         c_ws_plugin__s2member_admin_notices::display_admin_notice('<strong>Tip:</strong> If you\'re <em>only</em> planning to use Free Registration Forms (e.g., if you\'re not going to accept payments), you can safely ignore this warning and continue to use the Free Registration Form shortcode provided below.');
     } else {
         if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_merchant_id"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_username"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_password"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_api_signature"]) {
             c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <strong>s2Member → PayPal Options</strong> first. Once all of your PayPal Options are configured; including your Email Address, Merchant ID, API Username, Password, and Signature; return to this page &amp; generate your PayPal Pro-Form(s).', TRUE);
             c_ws_plugin__s2member_admin_notices::display_admin_notice('<strong>Tip:</strong> If you\'re <em>only</em> planning to use Free Registration Forms (e.g., if you\'re not going to accept payments), you can safely ignore this warning and continue to use the Free Registration Form shortcode provided below.');
         }
     }
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/menu-pages/paypal-forms.inc.php";
 }
Exemple #18
0
 /**
  * Handles patches on a Multisite Network installation.
  *
  * @package s2Member\Main_Multisite_Patches
  * @since 3.5
  *
  * @param bool $display_notices Defaults to false. If true, notices are displayed.
  * @return bool True if Multisite patches were processed, else false.
  */
 public static function mms_patches($display_notices = FALSE)
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_mms_patches", get_defined_vars());
     unset($__refs, $__v);
     if (is_multisite() && is_admin() && is_main_site() && $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"]) {
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_auto_patch"] && (!defined("DISALLOW_FILE_MODS") || !DISALLOW_FILE_MODS)) {
             do_action("ws_plugin__s2member_during_mms_patches_before", get_defined_vars());
             $wp_login_file = ABSPATH . "wp-login.php";
             // This works for WordPress 3.0, 3.1, all the way up to 3.7. WordPress 3.1+ uses: `site_url('wp-signup.php')`. WordPress 3.5+ uses: `network_site_url('wp-signup.php')`. WordPress v3.7 uses `$sign_up_url`.
             $wp_login_section = "/(\\s+)(wp_redirect( *?)\\(( *?)apply_filters( *?)\\(( *?)['\"]wp_signup_location['\"]( *?),( *?)(site_url( *?)\\(( *?)['\"]wp-signup\\.php['\"]( *?)\\)|network_site_url( *?)\\(( *?)['\"]wp-signup\\.php['\"]( *?)\\)|get_bloginfo( *?)\\(['\"]wpurl['\"]\\)( *?)\\.( *?)['\"]\\/wp-signup\\.php['\"]|\\\$sign_?up_url)( *?)\\)( *?)\\)( *?);)(\\s+)(exit( *?);)/";
             $wp_login_replace = "\n\t\t// Modified for full plugin compatiblity.\n\t\t//wp_redirect( apply_filters( 'wp_signup_location', \$sign_up_url ) );\n\t\t//exit;";
             if (file_exists($wp_login_file) && ($wp_login = file_get_contents($wp_login_file)) && is_writable($wp_login_file)) {
                 if (($wp_login_written = file_put_contents($wp_login_file, preg_replace($wp_login_section, $wp_login_replace, $wp_login, 1, $wp_login_patched))) && $wp_login_patched || ($wp_login_patched_already = $wp_login_patched = strpos($wp_login, $wp_login_replace))) {
                     $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-login.php</code> file ' . ($wp_login_patched_already ? 'is patched' : 'has been patched successfully') . '.') : null;
                 } else {
                     if (!$wp_login_written) {
                         // Otherwise, we need to report that /wp-login.php could NOT be updated. Possibly a permissions error.
                         $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-login.php</code> file could NOT be patched. Patch NOT written.', true) : null;
                     } else {
                         if (!$wp_login_patched) {
                             // Otherwise, we need to report that /wp-login.php could NOT be updated. Wrong WordPress version?
                             $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-login.php</code> file could NOT be patched. Unverifiable.', true) : null;
                         }
                     }
                 }
             } else {
                 // Otherwise, we need to report that /wp-login.php could NOT be updated. Possibly a permissions error.
                 $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-login.php</code> file could NOT be patched. File NOT writable.', true) : null;
             }
             $load_file = ABSPATH . WPINC . "/load.php";
             $load_section = "/([\r\n\t\\s ]+)(if( *?)\\(( *?)empty( *?)\\(( *?)\\\$active_plugins( *?)\\)( *?)\\|\\|( *?)defined( *?)\\(( *?)['\"]WP_INSTALLING['\"]( *?)\\)( *?)\\))/";
             $load_replace = "\n\n\t// Modified for full plugin compatiblity.\n\t//if ( empty( \$active_plugins ) || defined( 'WP_INSTALLING' ) )\n\tif ( empty( \$active_plugins ) || ( defined( 'WP_INSTALLING' ) && !preg_match(\"/\\/wp-activate\\.php/\", \$_SERVER[\"REQUEST_URI\"]) ) )";
             if (file_exists($load_file) && ($load = file_get_contents($load_file)) && is_writable($load_file)) {
                 if (($load_written = file_put_contents($load_file, preg_replace($load_section, $load_replace, $load, 1, $load_patched))) && $load_patched || ($load_patched_already = $load_patched = strpos($load, $load_replace))) {
                     $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-includes/load.php</code> file ' . ($load_patched_already ? 'is patched' : 'has been patched successfully') . '.') : null;
                 } else {
                     if (!$load_written) {
                         // Otherwise, we need to report that /wp-includes/load.php could NOT be updated. Possibly a permissions error.
                         $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-includes/load.php</code> file could NOT be patched. Patch NOT written.', true) : null;
                     } else {
                         if (!$load_patched) {
                             // Otherwise, we need to report that /wp-includes/load.php could NOT be updated. Wrong WordPress version?
                             $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-includes/load.php</code> file could NOT be patched. Unverifiable.', true) : null;
                         }
                     }
                 }
             } else {
                 // Otherwise, we need to report that /wp-includes/load.php could NOT be updated. Possibly a permissions error.
                 $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-includes/load.php</code> file could NOT be patched. File NOT writable.', true) : null;
             }
             $user_new_file = ABSPATH . "wp-admin/user-new.php";
             $user_new_section = "/([\r\n\t\\s ]+)(wpmu_signup_user( *?)\\(( *?)\\\$new_user_login,( *?)\\\$_REQUEST\\[( *?)'email'( *?)\\],( *?)array( *?)\\(( *?)'add_to_blog'( *?)\\=\\>( *?)\\\$wpdb->blogid,( *?)'new_role'( *?)\\=\\>( *?)\\\$_REQUEST\\[( *?)'role'( *?)\\]( *?)\\)( *?)\\);)/";
             $user_new_replace = "\n\t\t\t// Modified for full plugin compatiblity.\n\t\t\t//wpmu_signup_user( \$new_user_login, \$_REQUEST[ 'email' ], array( 'add_to_blog' => \$wpdb->blogid, 'new_role' => \$_REQUEST[ 'role' ] ) );\n\t\t\twpmu_signup_user( \$new_user_login, \$_REQUEST[ 'email' ], apply_filters( 'add_signup_meta', array( 'add_to_blog' => \$wpdb->blogid, 'new_role' => \$_REQUEST[ 'role' ] ) ) );";
             if (file_exists($user_new_file) && ($user_new = file_get_contents($user_new_file)) && is_writable($user_new_file)) {
                 if (($user_new_written = file_put_contents($user_new_file, preg_replace($user_new_section, $user_new_replace, $user_new, 1, $user_new_patched))) && $user_new_patched || ($user_new_patched_already = $user_new_patched = strpos($user_new, $user_new_replace))) {
                     $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-admin/user-new.php</code> file ' . ($user_new_patched_already ? 'is patched' : 'has been patched successfully') . '.') : null;
                 } else {
                     if (!$user_new_written) {
                         // Otherwise, we need to report that /wp-admin/user-new.php could NOT be updated. Possibly a permissions error.
                         $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-admin/user-new.php</code> file could NOT be patched. Patch NOT written.', true) : null;
                     } else {
                         if (!$user_new_patched) {
                             // Otherwise, we need to report that /wp-admin/user-new.php could NOT be updated. Wrong WordPress version?
                             $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-admin/user-new.php</code> file could NOT be patched. Unverifiable.', true) : null;
                         }
                     }
                 }
             } else {
                 // Otherwise, we need to report that /wp-admin/user-new.php could NOT be updated. Possibly a permissions error.
                 $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-admin/user-new.php</code> file could NOT be patched. File NOT writable.', true) : null;
             }
             $ms_functions_file = ABSPATH . "wp-includes/ms-functions.php";
             $ms_functions_section = "/([\r\n\t\\s ]+)(return new WP_Error( *?)\\(( *?)'user_already_exists'( *?),( *?)__( *?)\\(( *?)'That username is already activated.'( *?)\\),( *?)\\\$signup( *?)\\);)/";
             $ms_functions_replace = "\n\t\t\t// Modified for full plugin compatiblity.\n\t\t\t//return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), \$signup);\n\t\t\treturn apply_filters('_wpmu_activate_existing_error_', new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), \$signup), get_defined_vars());";
             if (file_exists($ms_functions_file) && ($ms_functions = file_get_contents($ms_functions_file)) && is_writable($ms_functions_file)) {
                 if (($ms_functions_written = file_put_contents($ms_functions_file, preg_replace($ms_functions_section, $ms_functions_replace, $ms_functions, 1, $ms_functions_patched))) && $ms_functions_patched || ($ms_functions_patched_already = $ms_functions_patched = strpos($ms_functions, $ms_functions_replace))) {
                     $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-includes/ms-functions.php</code> file ' . ($ms_functions_patched_already ? 'is patched' : 'has been patched successfully') . '.') : null;
                 } else {
                     if (!$ms_functions_written) {
                         // Otherwise, we need to report that /wp-includes/ms-functions.php could NOT be updated. Possibly a permissions error.
                         $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-includes/ms-functions.php</code> file could NOT be patched. Patch NOT written.', true) : null;
                     } else {
                         if (!$ms_functions_patched) {
                             // Otherwise, we need to report that /wp-includes/ms-functions.php could NOT be updated. Wrong WordPress version?
                             $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-includes/ms-functions.php</code> file could NOT be patched. Unverifiable.', true) : null;
                         }
                     }
                 }
             } else {
                 // Otherwise, we need to report that /wp-includes/ms-functions.php could NOT be updated. Possibly a permissions error.
                 $display_notices ? c_ws_plugin__s2member_admin_notices::display_admin_notice('Your <code>/wp-includes/ms-functions.php</code> file could NOT be patched. File NOT writable.', true) : null;
             }
             $ran_mms_patches = true;
             // Flag indicating this routine was indeed processed.
             do_action("ws_plugin__s2member_during_mms_patches_after", get_defined_vars());
         }
     }
     do_action("ws_plugin__s2member_after_mms_patches", get_defined_vars());
     return !empty($ran_mms_patches) ? $ran_mms_patches : false;
 }
 /**
  * Handles the importation of Users/Members.
  *
  * @package s2Member\Imports
  * @since 110815
  */
 public static function import_users()
 {
     if (!empty($_POST['ws_plugin__s2member_pro_import_simple_users']) && ($nonce = $_POST['ws_plugin__s2member_pro_import_simple_users']) && wp_verify_nonce($nonce, 'ws-plugin--s2member-pro-import-users') && current_user_can('create_users')) {
         global $wpdb;
         // Global database object reference.
         global $current_site, $current_blog;
         // Multisite Networking.
         @set_time_limit(0);
         // Make time for processing large import files.
         @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
         remove_all_actions('profile_update') . remove_all_actions('user_register');
         remove_all_actions('added_existing_user') . remove_all_actions('add_user_to_blog');
         if (!empty($_FILES['ws_plugin__s2member_pro_import_users_file']) && empty($_FILES['ws_plugin__s2member_pro_import_users_file']['error'])) {
             $file = fopen($_FILES['ws_plugin__s2member_pro_import_users_file']['tmp_name'], 'r');
         } else {
             if (!empty($_POST['ws_plugin__s2member_pro_import_users_direct_input'])) {
                 fwrite($file = tmpfile(), trim(stripslashes($_POST['ws_plugin__s2member_pro_import_users_direct_input']))) . fseek($file, 0);
             }
         }
         $imported = $line = 0;
         // Initialize these counters.
         if (isset($file) && is_resource($file)) {
             $custom_field_vars = array();
             // Initialize this array.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
                 foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) {
                     $custom_field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                     $custom_field_vars[] = $custom_field_var;
                 }
             }
             sort($custom_field_vars, SORT_STRING);
             // Always sort this array.
             while (($data = version_compare(PHP_VERSION, '5.3', '>=') ? fgetcsv($file, 0, ',', '"', '"') : fgetcsv($file, 0, ',', '"')) !== FALSE) {
                 $line = (int) $line + 1;
                 // CSV lines.
                 $data = c_ws_plugin__s2member_utils_strings::trim_deep($data);
                 $data = stripslashes_deep($data);
                 if ($line === 1 && strtoupper($data[0]) === 'ID') {
                     $line = $line - 1;
                     continue;
                 }
                 if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) {
                     $ID = $data[0];
                     $user_login = is_multisite() ? strtolower($data[1]) : $data[1];
                     $user_login = sanitize_user($user_login, is_multisite());
                     $user_pass = (string) '';
                     $first_name = $data[2];
                     $last_name = $data[3];
                     $display_name = $data[4];
                     $user_email = sanitize_email($data[5]);
                     $user_url = $data[6];
                     $role = $data[7];
                     $custom_capabilities = $data[8];
                     $user_registered = $data[9] ? date('Y-m-d H:i:s', strtotime($data[9])) : '';
                     $paid_registration_times = $data[10] ? maybe_unserialize($data[10]) : '';
                     $last_payment_time = $data[11] ? strtotime($data[11]) : '';
                     $auto_eot_time = $data[12] ? strtotime($data[12]) : '';
                     $custom = $data[13];
                     $subscr_id = $data[14];
                     $subscr_gateway = strtolower($data[15]);
                     $custom_fields = array();
                     // Initialize.
                     if (count($data) > 16) {
                         // Now loop through Custom Fields.
                         for ($i = 16, $j = 0; $i < count($data); $i++, $j++) {
                             if (isset($custom_field_vars[$j])) {
                                 // A field in this position?
                                 $custom_fields[$custom_field_vars[$j]] = maybe_unserialize($data[$i]);
                             }
                         }
                     }
                 } else {
                     $ID = $data[0];
                     $user_login = is_multisite() ? strtolower($data[1]) : $data[1];
                     $user_login = sanitize_user($user_login, is_multisite());
                     $user_pass = $data[2];
                     $first_name = $data[3];
                     $last_name = $data[4];
                     $display_name = $data[5];
                     $user_email = sanitize_email($data[6]);
                     $user_url = $data[7];
                     $role = $data[8];
                     $custom_capabilities = $data[9];
                     $user_registered = $data[10] ? date('Y-m-d H:i:s', strtotime($data[10])) : '';
                     $paid_registration_times = $data[11] ? maybe_unserialize($data[11]) : '';
                     $last_payment_time = $data[12] ? strtotime($data[12]) : '';
                     $auto_eot_time = $data[13] ? strtotime($data[13]) : '';
                     $custom = $data[14];
                     $subscr_id = $data[15];
                     $subscr_gateway = strtolower($data[16]);
                     $custom_fields = array();
                     // Initialize.
                     if (count($data) > 17) {
                         // Now loop through Custom Fields.
                         for ($i = 17, $j = 0; $i < count($data); $i++, $j++) {
                             if (isset($custom_field_vars[$j])) {
                                 // A field in this position?
                                 $custom_fields[$custom_field_vars[$j]] = maybe_unserialize($data[$i]);
                             }
                         }
                     }
                 }
                 $role = is_numeric($role) ? $role == 0 ? 'subscriber' : 's2member_level' . $role : $role;
                 if ($paid_registration_times && !is_array($paid_registration_times)) {
                     $paid_registration_times = array('level' => strtotime($paid_registration_times));
                 }
                 $paid_registration_times = !$paid_registration_times || !is_array($paid_registration_times) ? array() : $paid_registration_times;
                 $user_details = compact('ID', 'user_login', 'user_pass', 'first_name', 'last_name', 'display_name', 'user_email', 'user_url', 'role', 'user_registered');
                 if (empty($user_details['user_pass'])) {
                     // If there was NO Password given.
                     unset($user_details['user_pass']);
                 }
                 // Unset the Password array element.
                 if ($ID) {
                     if (is_object($user = new WP_User($ID)) && $user->ID) {
                         if (!is_multisite() || is_user_member_of_blog($ID)) {
                             if ((!is_multisite() || !is_super_admin($ID)) && !$user->has_cap('administrator')) {
                                 if (strtolower($role) !== 'administrator') {
                                     if ($user_email && is_email($user_email)) {
                                         if ($user_login) {
                                             if (validate_username($user_login)) {
                                                 if (($_same_email = strtolower($user_email) === strtolower($user->user_email)) || !email_exists($user_email)) {
                                                     if (($_same_login = strtolower($user_login) === strtolower($user->user_login)) || !username_exists($user_login)) {
                                                         if (!is_multisite() || $_same_email && $_same_login || ($_ = wpmu_validate_user_signup($user_login, $user_email)) && (!is_wp_error($_['errors']) || !$_['errors']->get_error_code())) {
                                                             if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) {
                                                                 unset($user_details['user_login'], $user_details['user_pass']);
                                                             }
                                                             if ($user_id = wp_update_user(wp_slash($user_details))) {
                                                                 $user = new WP_User($ID);
                                                                 // Refresh object value.
                                                                 update_user_option($user_id, 's2member_custom', $custom);
                                                                 update_user_option($user_id, 's2member_subscr_id', $subscr_id);
                                                                 update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
                                                                 update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
                                                                 update_user_option($user_id, 's2member_paid_registration_times', $paid_registration_times);
                                                                 update_user_option($user_id, 's2member_last_payment_time', $last_payment_time);
                                                                 update_user_option($user_id, 's2member_custom_fields', $custom_fields);
                                                                 foreach ($user->allcaps as $cap => $cap_enabled) {
                                                                     if (preg_match('/^access_s2member_ccap_/', $cap)) {
                                                                         $user->remove_cap($ccap = $cap);
                                                                     }
                                                                 }
                                                                 if ($custom_capabilities && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $custom_capabilities))) {
                                                                     foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $custom_capabilities))) as $ccap) {
                                                                         if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
                                                                             $user->add_cap('access_s2member_ccap_' . $ccap);
                                                                         }
                                                                     }
                                                                 }
                                                                 $imported = $imported + 1;
                                                             } else {
                                                                 $errors[] = 'Line #' . $line . '. User ID# <code>' . $ID . '</code> could NOT be updated. Unknown error, please try again.';
                                                             }
                                                         } else {
                                                             $errors[] = 'Line #' . $line . '. Network. The Username and/or Email (<code>' . esc_html($user_login) . '</code> / <code>' . esc_html($user_email) . '</code>) are in conflict w/ Network rules.';
                                                         }
                                                     } else {
                                                         $errors[] = 'Line #' . $line . '. Conflicting. The Username (<code>' . esc_html($user_login) . '</code>), already exists.';
                                                     }
                                                 } else {
                                                     $errors[] = 'Line #' . $line . '. Conflicting. The Email address (<code>' . esc_html($user_email) . '</code>), already exists.';
                                                 }
                                             } else {
                                                 $errors[] = 'Line #' . $line . '. Invalid Username (<code>' . esc_html($user_login) . '</code>). Lowercase alphanumerics are required.';
                                             }
                                         } else {
                                             $errors[] = 'Line #' . $line . '. Missing Username; please try again.';
                                         }
                                         // We have two separate errors for Usernames. This provides clarity.
                                     } else {
                                         $errors[] = 'Line #' . $line . '. Missing or invalid Email address (<code>' . esc_html($user_email) . '</code>); please try again.';
                                     }
                                 } else {
                                     $errors[] = 'Line #' . $line . '. User ID# <code>' . $ID . '</code> cannot be updated to an Administrator. Bypassing this line for security.';
                                 }
                             } else {
                                 $errors[] = 'Line #' . $line . '. User ID# <code>' . $ID . '</code> belongs to an Administrator. Bypassing this line for security.';
                             }
                         } else {
                             $errors[] = 'Line #' . $line . '. User ID# <code>' . $ID . '</code> does NOT belong to an existing User on this site.';
                         }
                     } else {
                         $errors[] = 'Line #' . $line . '. User ID# <code>' . $ID . '</code> does NOT belong to an existing User.';
                     }
                 } else {
                     if (is_multisite() && ($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($user_login, $user_email)) && !is_super_admin($user_id)) {
                         if (strtolower($role) !== 'administrator') {
                             if (add_existing_user_to_blog(array('user_id' => $user_id, 'role' => $role))) {
                                 if (is_object($user = new WP_User($user_id)) && $user->ID) {
                                     update_user_option($user_id, 's2member_custom', $custom);
                                     update_user_option($user_id, 's2member_subscr_id', $subscr_id);
                                     update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
                                     update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
                                     update_user_option($user_id, 's2member_paid_registration_times', $paid_registration_times);
                                     update_user_option($user_id, 's2member_last_payment_time', $last_payment_time);
                                     update_user_option($user_id, 's2member_custom_fields', $custom_fields);
                                     foreach ($user->allcaps as $cap => $cap_enabled) {
                                         if (preg_match('/^access_s2member_ccap_/', $cap)) {
                                             $user->remove_cap($ccap = $cap);
                                         }
                                     }
                                     if ($custom_capabilities && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $custom_capabilities))) {
                                         foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $custom_capabilities))) as $ccap) {
                                             if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
                                                 $user->add_cap('access_s2member_ccap_' . $ccap);
                                             }
                                         }
                                     }
                                     $imported = $imported + 1;
                                 } else {
                                     $errors[] = 'Line #' . $line . '. Unknown object error, please try again.';
                                 }
                             } else {
                                 $errors[] = 'Line #' . $line . '. Unknown User/site addition error, please try again.';
                             }
                         } else {
                             $errors[] = 'Line #' . $line . '. Role cannot be Administrator. Bypassing this line for security.';
                         }
                     } else {
                         if (strtolower($role) !== 'administrator') {
                             if ($user_email && is_email($user_email)) {
                                 if ($user_login) {
                                     if (validate_username($user_login)) {
                                         if (!email_exists($user_email)) {
                                             if (!username_exists($user_login)) {
                                                 if (!is_multisite() || ($_ = wpmu_validate_user_signup($user_login, $user_email)) && (!is_wp_error($_['errors']) || !$_['errors']->get_error_code())) {
                                                     if ($user_id = wp_insert_user(wp_slash(empty($user_details['user_pass']) ? array_merge($user_details, array('user_pass' => wp_generate_password(12, FALSE))) : $user_details))) {
                                                         if (is_object($user = new WP_User($user_id)) && $user->ID) {
                                                             if ($user_pass) {
                                                                 // If we are given an 'un-encrypted Password'.
                                                                 wp_update_user(wp_slash(array('ID' => $user_id, 'user_pass' => $user_pass)));
                                                             }
                                                             if (is_multisite()) {
                                                                 // New Users on a Multisite Network need this too.
                                                                 update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id);
                                                             }
                                                             update_user_option($user_id, 's2member_custom', $custom);
                                                             update_user_option($user_id, 's2member_subscr_id', $subscr_id);
                                                             update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
                                                             update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
                                                             update_user_option($user_id, 's2member_paid_registration_times', $paid_registration_times);
                                                             update_user_option($user_id, 's2member_last_payment_time', $last_payment_time);
                                                             update_user_option($user_id, 's2member_custom_fields', $custom_fields);
                                                             foreach ($user->allcaps as $cap => $cap_enabled) {
                                                                 if (preg_match('/^access_s2member_ccap_/', $cap)) {
                                                                     $user->remove_cap($ccap = $cap);
                                                                 }
                                                             }
                                                             if ($custom_capabilities && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $custom_capabilities))) {
                                                                 foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $custom_capabilities))) as $ccap) {
                                                                     if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
                                                                         $user->add_cap('access_s2member_ccap_' . $ccap);
                                                                     }
                                                                 }
                                                             }
                                                             $imported = $imported + 1;
                                                         } else {
                                                             $errors[] = 'Line #' . $line . '. Unknown object error, please try again.';
                                                         }
                                                     } else {
                                                         $errors[] = 'Line #' . $line . '. Unknown insertion error, please try again.';
                                                     }
                                                 } else {
                                                     $errors[] = 'Line #' . $line . '. Network. The Username and/or Email (<code>' . esc_html($user_login) . '</code> / <code>' . esc_html($user_email) . '</code>) are in conflict w/ Network rules.';
                                                 }
                                             } else {
                                                 $errors[] = 'Line #' . $line . '. Conflicting. The Username (<code>' . esc_html($user_login) . '</code>), already exists.';
                                             }
                                         } else {
                                             $errors[] = 'Line #' . $line . '. Conflicting. The Email address (<code>' . esc_html($user_email) . '</code>), already exists.';
                                         }
                                     } else {
                                         $errors[] = 'Line #' . $line . '. Invalid Username (<code>' . esc_html($user_login) . '</code>). Lowercase alphanumerics are required.';
                                     }
                                 } else {
                                     $errors[] = 'Line #' . $line . '. Missing Username; please try again.';
                                 }
                                 // We have two separate errors for Usernames. This provides clarity.
                             } else {
                                 $errors[] = 'Line #' . $line . '. Missing or invalid Email address (<code>' . esc_html($user_email) . '</code>); please try again.';
                             }
                         } else {
                             $errors[] = 'Line #' . $line . '. Role cannot be Administrator. Bypassing this line for security.';
                         }
                     }
                 }
             }
             fclose($file);
             // Close the file resource handle now.
         } else {
             $errors[] = 'No data was received. Please try again.';
         }
         // The upload failed, or it was empty.
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Operation complete. Users/Members imported: <code>' . (int) $imported . '</code>.');
         if (!empty($errors)) {
             // Here is where a detailed error log will be returned to the Site Owner; as a way of clarifying what just happened during importation.
             c_ws_plugin__s2member_admin_notices::display_admin_notice('<strong>The following errors were encountered during importation:</strong><ul style="font-size:80%; list-style:disc outside; margin-left:25px;"><li>' . implode('</li><li>', $errors) . '</li></ul>', TRUE);
         }
     }
 }
 /**
  * Builds and handles the Logs page.
  *
  * @package s2Member\Menu_Pages
  * @since 120310
  */
 public static function logs_page()
 {
     do_action('ws_plugin__s2member_before_logs_page', get_defined_vars());
     c_ws_plugin__s2member_menu_pages::update_all_options();
     c_ws_plugin__s2member_menu_pages::archive_logs_start_fresh();
     c_ws_plugin__s2member_menu_pages::delete_logs_start_fresh();
     $logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'];
     if (!is_dir($logs_dir) && is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir)))) {
         mkdir($logs_dir, 0777, TRUE) . clearstatcache();
     }
     $htaccess = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'] . '/.htaccess';
     $htaccess_contents = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir_htaccess'])));
     if (is_dir($logs_dir) && is_writable($logs_dir) && !file_exists($htaccess)) {
         file_put_contents($htaccess, $htaccess_contents) . clearstatcache();
     }
     if (!is_dir($logs_dir)) {
         // If the security-enabled logs directory does not exist yet.
         c_ws_plugin__s2member_admin_notices::display_admin_notice('The security-enabled logs directory (<code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($logs_dir)) . '</code>) does not exist. Please create this directory manually &amp; make it writable (chmod 777).', TRUE);
     } else {
         if (!is_writable($logs_dir)) {
             // If the logs directory is not writable yet.
             c_ws_plugin__s2member_admin_notices::display_admin_notice('Permissions error. The security-enabled logs directory (<code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($logs_dir)) . '</code>) is not writable. Please make this directory writable (chmod 777).', TRUE);
         }
     }
     if (!file_exists($htaccess)) {
         // If the .htaccess file has not been created yet.
         c_ws_plugin__s2member_admin_notices::display_admin_notice('The .htaccess protection file (<code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)) . '</code>) does not exist. Please create this file manually. Inside your .htaccess file, add this:<br /><pre>' . esc_html($htaccess_contents) . '</pre>', TRUE);
     } else {
         if (!preg_match('/deny from all/i', file_get_contents($htaccess))) {
             // Else if the .htaccess file does not offer the required protection.
             c_ws_plugin__s2member_admin_notices::display_admin_notice('Unprotected. The .htaccess protection file (<code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($htaccess)) . '</code>) does not contain <code>deny from all</code>. Inside your .htaccess file, add this:<br /><pre>' . esc_html($htaccess_contents) . '</pre>', TRUE);
         }
     }
     if (!$GLOBALS['WS_PLUGIN__']['s2member']['o']['gateway_debug_logs']) {
         // Logging disabled?
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Logging is currently disabled by your configuration.');
     }
     include_once dirname(dirname(__FILE__)) . '/menu-pages/logs.inc.php';
     do_action('ws_plugin__s2member_after_logs_page', get_defined_vars());
 }
 /**
  * Builds the Buttons panel for this Payment Gateway.
  *
  * @package s2Member\Menu_Pages
  * @since 1.5
  *
  * @return null
  */
 public static function google_buttons_page()
 {
     if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"] || !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_key"]) {
         c_ws_plugin__s2member_admin_notices::display_admin_notice('Please configure <code>s2Member -> Google® Options</code> first. Once all of your Google® Options have been configured, return to this page &amp; generate your Google® Checkout Button(s).', true);
     }
     /**/
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/menu-pages/google-buttons.inc.php";
     /**/
     return;
     /* Return for uniformity. */
 }