コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * Activation routines for s2Member.
  *
  * @package s2Member\Installation
  * @since 3.5
  *
  * @return null
  */
 public static function activate($reactivation_reason = FALSE)
 {
     global $wpdb;
     global $current_site, $current_blog;
     do_action("ws_plugin__s2member_before_activation", get_defined_vars());
     c_ws_plugin__s2member_roles_caps::config_roles();
     update_option("ws_plugin__s2member_activated_levels", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]);
     if (!is_dir($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) {
         if (is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($files_dir)))) {
             mkdir($files_dir, 0777, true);
         }
     }
     if (is_dir($files_dir) && is_writable($files_dir)) {
         if (!file_exists($htaccess = $files_dir . "/.htaccess") || !apply_filters("ws_plugin__s2member_preserve_files_dir_htaccess", false, get_defined_vars())) {
             file_put_contents($htaccess, trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir_htaccess"]))));
         }
     }
     c_ws_plugin__s2member_files::write_no_gzip_into_root_htaccess();
     if (!is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) {
         if (is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir)))) {
             mkdir($logs_dir, 0777, true);
         }
     }
     if (is_dir($logs_dir) && is_writable($logs_dir)) {
         if (!file_exists($htaccess = $logs_dir . "/.htaccess") || !apply_filters("ws_plugin__s2member_preserve_logs_dir_htaccess", false, get_defined_vars())) {
             file_put_contents($htaccess, trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir_htaccess"]))));
         }
     }
     !is_array(get_option("ws_plugin__s2member_cache")) ? update_option("ws_plugin__s2member_cache", array()) : null;
     !is_array(get_option("ws_plugin__s2member_notices")) ? update_option("ws_plugin__s2member_notices", array()) : null;
     !is_array(get_option("ws_plugin__s2member_options")) ? update_option("ws_plugin__s2member_options", array()) : null;
     !is_numeric(get_option("ws_plugin__s2member_configured")) ? update_option("ws_plugin__s2member_configured", "0") : null;
     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"]) {
         $v = get_option("ws_plugin__s2member_activated_version");
         if (!$v || !version_compare($v, "3.2", ">=")) {
             $like = "`meta_key` LIKE 's2member\\_%' AND `meta_key` NOT LIKE '%s2member\\_originating\\_blog%'";
             $wpdb->query("UPDATE `" . $wpdb->usermeta . "` SET `meta_key` = CONCAT('" . $wpdb->prefix . "', `meta_key`) WHERE " . $like);
         }
         if (!$v || !version_compare($v, "3.2.5", ">=")) {
             $wpdb->query("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\\_transient\\_%'");
         }
         if (!$v || !version_compare($v, "3.2.6", ">=")) {
             $wpdb->query("DELETE FROM `" . $wpdb->postmeta . "` WHERE `meta_key` = 's2member_ccaps_req' AND `meta_value` IN('','a:0:{}','a:1:{i:0;s:0:\"\";}')");
         }
         if (!$v || !version_compare($v, "110912", ">=") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"] === array("all")) {
             $notice = '<strong>IMPORTANT:</strong> This version of s2Member changes the way your <code>Alternative View Protections</code> work. Please review your options under: <code>s2Member -› Restriction Options -› Alternative View Protections</code>.';
             c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
         }
         if ($v && version_compare($v, "130316", "<=")) {
             c_ws_plugin__s2member_menu_pages::update_all_options(array("ws_plugin__s2member_gateway_debug_logs" => "0", "ws_plugin__s2member_gateway_debug_logs_extensive" => "0"), true, false, false, false, false);
             $notice = '<strong>IMPORTANT:</strong> This version of s2Member disables s2Member\'s debug logging by default (for added security). Please see: <a href="' . esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-logs")) . '">s2Member -› Log Files (Debug) -› Configuration</a> for further details.';
             c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
             $notice = '<strong>IMPORTANT / Regarding s2Member Security Badges:</strong> If debug logging is enabled, your site will no longer qualify for an s2Member Security Badge until you disable logging (and you MUST also download, and then delete any existing log files from the past). Please see KB Article: <a href="http://www.s2member.com/kb/security-badges/" target="_blank" rel="external">s2Member Security Badges</a> for further details. If you have existing s2Member log files, you will need to delete those files from the server before your s2Member Security Badge can be re-enabled. s2Member stores log files here: <code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) . '</code>. See also: <a href="' . esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-logs")) . '">s2Member -› Log Files (Debug) -› Configuration</a> for further details.';
             c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
         }
         $notice = '<strong>s2Member</strong> has been <strong>reactivated</strong>, with ' . ($reactivation_reason === "levels" ? '<code>' . esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) . '</code> Membership Levels' : 'the latest version') . '.<br />';
         $notice .= 'You now have version ' . esc_html(WS_PLUGIN__S2MEMBER_VERSION) . '. Your existing configuration remains.';
         if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) {
             // No Changelog on a Multisite Blog Farm.
             $notice .= '<br />Have fun, <a href="' . esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-info#rm-changelog")) . '">read the Changelog</a>, and make some money! :-)';
         }
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
     } else {
         $notice = '<strong>Note:</strong> s2Member adds some new data columns to your list of Users/Members. If your list gets overcrowded, please use the <strong>Screen Options</strong> tab <em>(upper right-hand corner)</em>. With WordPress Screen Options, you can add/remove specific data columns; thereby making the most important data easier to read. For example, if you create Custom Registration/Profile Fields with s2Member, those Custom Fields will result in new data columns; which can cause your list of Users/Members to become nearly unreadable. So just use the Screen Options tab to clean things up.';
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "blog:users.php", false, false, true);
         $notice = '<strong>s2Member</strong> v' . esc_html(WS_PLUGIN__S2MEMBER_VERSION) . ' has been <strong>activated</strong>. Nice work!<br />';
         $notice .= 'Have fun, <a href="' . esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-start")) . '">read the Quick Start Guide</a>, and make some money! :-)';
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
     }
     if (is_multisite() && is_main_site()) {
         $wpdb->query("INSERT INTO `" . $wpdb->usermeta . "` (`user_id`, `meta_key`, `meta_value`) SELECT `ID`, 's2member_originating_blog', '" . esc_sql($current_site->blog_id) . "' FROM `" . $wpdb->users . "` WHERE `ID` NOT IN (SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_originating_blog')");
         $notice = '<strong>Multisite Network</strong> updated automatically by <strong>s2Member</strong> v' . esc_html(WS_PLUGIN__S2MEMBER_VERSION) . '.<br />';
         $notice .= 'You\'ll want to configure s2Member\'s Multisite options now.<br />';
         $notice .= 'In the Dashboard for your Main Site, see:<br />';
         $notice .= '<code>s2Member -› Multisite (Config)</code>.';
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
         update_site_option("ws_plugin__s2member_options", (array) get_option("ws_plugin__s2member_options"));
         update_option("ws_plugin__s2member_activated_mms_version", WS_PLUGIN__S2MEMBER_VERSION);
     }
     update_option("ws_plugin__s2member_activated_version", WS_PLUGIN__S2MEMBER_VERSION);
     do_action("ws_plugin__s2member_after_activation", get_defined_vars());
     return;
 }
コード例 #3
0
ファイル: imports-in.inc.php プロジェクト: donwea/nhap.org
 /**
  * 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;
 }
コード例 #4
0
 /**
  * Handles PayPal Return URLs.
  *
  * @package s2Member\PayPal
  * @since 3.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after redirection.
  */
 public static function paypal_return()
 {
     global $current_site, $current_blog;
     do_action("ws_plugin__s2member_before_paypal_return", get_defined_vars());
     if (!empty($_GET["s2member_paypal_return"]) && ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_business"] || !empty($_GET["s2member_paypal_proxy"]))) {
         $custom_success_redirection = !empty($_GET["s2member_paypal_return_success"]) ? esc_html(trim(stripslashes($_GET["s2member_paypal_return_success"]))) : false;
         $custom_success_redirection = $custom_success_redirection ? str_ireplace(array("&#038;", "&amp;"), "&", $custom_success_redirection) : $custom_success_redirection;
         if (is_array($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_postvars()) && ($_paypal = $paypal) && ($_paypal_s = serialize($_paypal))) {
             $paypal["s2member_log"][] = "Return-Data received on: " . date("D M j, Y g:i:s a T");
             $paypal["s2member_log"][] = "s2Member POST vars verified " . (!empty($paypal["proxy_verified"]) ? "with a Proxy Key" : "through a POST back to PayPal.");
             $paypal["subscr_gateway"] = !empty($_GET["s2member_paypal_proxy"]) ? esc_html(trim(stripslashes($_GET["s2member_paypal_proxy"]))) : "paypal";
             if (empty($_GET["s2member_paypal_proxy"]) || empty($_GET["s2member_paypal_proxy_use"]) || !preg_match("/ty-email/", $_GET["s2member_paypal_proxy_use"])) {
                 $payment_status_issues = "/^(failed|denied|expired|refunded|partially_refunded|reversed|reversal|canceled_reversal|voided)\$/i";
                 if (!empty($paypal["custom"]) && preg_match("/^" . preg_quote(preg_replace("/\\:([0-9]+)\$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $paypal["custom"])) {
                     $paypal["s2member_log"][] = "s2Member originating domain ( `\$_SERVER[\"HTTP_HOST\"]` ) validated.";
                     foreach (array_keys(get_defined_vars()) as $__v) {
                         $__refs[$__v] =& ${$__v};
                     }
                     if (!apply_filters("ws_plugin__s2member_during_paypal_return_conditionals", false, get_defined_vars())) {
                         unset($__refs, $__v);
                         if ($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_web_accept_sp::cp(get_defined_vars())) {
                             $paypal = $_paypal_cp;
                         } else {
                             if ($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_wa_ccaps_wo_level::cp(get_defined_vars())) {
                                 $paypal = $_paypal_cp;
                             } else {
                                 if ($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_subscr_or_wa_w_level::cp(get_defined_vars())) {
                                     $paypal = $_paypal_cp;
                                 } else {
                                     if ($_paypal_cp = c_ws_plugin__s2member_paypal_return_in_subscr_modify_w_level::cp(get_defined_vars())) {
                                         $paypal = $_paypal_cp;
                                     } else {
                                         $paypal["s2member_log"][] = "Unexpected `txn_type/status`. The `txn_type/status` did not match a required action.";
                                         $paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
                                         echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>ERROR:</strong> Unexpected <code>txn_type/status</code>.<br />The <code>txn_type/status</code> did not meet requirements.<br />Please contact Support for assistance.', "s2member-front", "s2member"), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
                                     }
                                 }
                             }
                         }
                     } else {
                         // Else a custom conditional has been applied by filters.
                         unset($__refs, $__v);
                     }
                 } else {
                     if ($paypal["custom"] && ($paypal["custom"] === "www." . $_SERVER["HTTP_HOST"] || "www." . $paypal["custom"] === $_SERVER["HTTP_HOST"])) {
                         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice("<strong>s2Member:</strong> Post-processing failed on at least one transaction. It appears that you have a PayPal Button configured with a <code>custom=\"\"</code> Shortcode Attribute that does NOT match up with your installation domain name. If your site uses the <code>www.</code> prefix, please include that. If it does not, please exclude the <code>www.</code> prefix. You should have <code>custom=\"" . preg_replace("/\\:([0-9]+)\$/", "", $_SERVER["HTTP_HOST"]) . "\"</code>", "*:*", true);
                     }
                     $paypal["s2member_log"][] = 'Unable to verify `$_SERVER["HTTP_HOST"]`. Please check the `custom` value in your Button Code. It MUST start with your domain name.';
                     $paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
                     echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>ERROR:</strong> Unable to verify <code>$_SERVER["HTTP_HOST"]</code>.<br />Please contact Support for assistance.<br /><br />If you are the site owner, please check the <code>custom</code> value in your Button Code. It MUST start with your domain name.', "s2member-front", "s2member"), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
                 }
             } else {
                 // In this case ... a Proxy has explicitly requested `ty-email` processing.
                 $paypal = $_paypal_cp = c_ws_plugin__s2member_paypal_return_in_proxy_ty_email::cp(get_defined_vars());
             }
         } else {
             if (!empty($_GET["s2member_paypal_proxy"]) && !empty($_GET["s2member_paypal_proxy_use"]) && preg_match("/x-preview/", $_GET["s2member_paypal_proxy_use"]) && ($paypal["subscr_gateway"] = esc_html(trim(stripslashes($_GET["s2member_paypal_proxy"]))))) {
                 $paypal = $_paypal_cp = c_ws_plugin__s2member_paypal_return_in_proxy_x_preview::cp(get_defined_vars());
             } else {
                 if (empty($_GET["tx"]) && empty($_GET["s2member_paypal_proxy"]) && ($paypal["subscr_gateway"] = "paypal")) {
                     $paypal = $_paypal_cp = c_ws_plugin__s2member_paypal_return_in_no_tx_data::cp(get_defined_vars());
                 } else {
                     if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_identity_token"]) {
                         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice("<strong>s2Member:</strong> You have no PayPal PDT Identity Token configured. PayPal Auto-Return handling failed. Please update your PayPal PDT Identity Key. See: <code>s2Member -› PayPal Options -› PayPal PDT/Auto-Return Integration</code>. Thank you!", "*:*", true);
                     }
                     $paypal["s2member_log"][] = "Unable to verify \$_POST vars. This is most likely related to an invalid configuration of s2Member, or a problem with server compatibility.";
                     $paypal["s2member_log"][] = "Please make sure that you configure a PayPal PDT Identity Token for your installation of s2Member. See: `s2Member -› PayPal Options -› PayPal PDT/Auto-Return Integration`.";
                     $paypal["s2member_log"][] = "See also, this KB article: `http://www.s2member.com/kb/server-scanner/`. We suggest that you run the s2Member Server Scanner.";
                     $paypal["s2member_log"][] = var_export($_REQUEST, true);
                     $paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message).";
                     echo c_ws_plugin__s2member_return_templates::return_template("default", _x('<strong>ERROR:</strong> Unable to verify <code>$_POST</code> vars.<br />Please contact Support for assistance.<br /><br />This is most likely related to an invalid configuration of s2Member, or a problem with server compatibility. If you are the site owner, and you\'re absolutely SURE that your configuration is valid, you may want to run some tests on your server, just to be sure <code>$_POST</code> variables are populated, and that your server is able to connect/communicate with your Payment Gateway over an HTTPS connection.<br /><br />s2Member uses the <code>WP_Http</code> class for remote connections; which will try to use <code>cURL</code> first, and then fall back on the <code>FOPEN</code> method when <code>cURL</code> is not available. On a Windows server, you may have to disable your <code>cURL</code> extension; and instead, set <code>allow_url_fopen = yes</code> in your php.ini file. The <code>cURL</code> extension (usually) does NOT support SSL connections on a Windows server.<br /><br />Please see <a href="http://www.s2member.com/forums/topic/ideal-server-configuration-for-s2member/" target="_blank">this thread</a> for details regarding the ideal server configuration for s2Member.', "s2member-front", "s2member"), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
                 }
             }
         }
         /*
         Add RTN proxy (when available) to the ``$paypal`` array.
         */
         if (!empty($_GET["s2member_paypal_proxy"])) {
             $paypal["s2member_paypal_proxy"] = $_GET["s2member_paypal_proxy"];
         }
         /*
         Add IPN proxy use vars (when available) to the ``$paypal`` array.
         */
         if (!empty($_GET["s2member_paypal_proxy_use"])) {
             $paypal["s2member_paypal_proxy_use"] = $_GET["s2member_paypal_proxy_use"];
         }
         /*
         Also add RTN proxy self-verification (when available) to the ``$paypal`` array.
         */
         if (!empty($_GET["s2member_paypal_proxy_verification"])) {
             $paypal["s2member_paypal_proxy_verification"] = $_GET["s2member_paypal_proxy_verification"];
         }
         /*
         Also add RTN success redirection URL (when available) to the ``$paypal`` array.
         */
         if (!empty($_GET["s2member_paypal_return_success"])) {
             $paypal["s2member_paypal_return_success"] = $_GET["s2member_paypal_return_success"];
         }
         /*
         Also add RTN t and r Attributes (when available) to the ``$paypal`` array.
         */
         if (!empty($_GET["s2member_paypal_return_tra"])) {
             $paypal["s2member_paypal_return_tra"] = $_GET["s2member_paypal_return_tra"];
         }
         /*
         If debugging/logging is enabled; we need to append $paypal to the log file.
         	Logging now supports Multisite Networking as well.
         */
         $logt = c_ws_plugin__s2member_utilities::time_details();
         $logv = c_ws_plugin__s2member_utilities::ver_details();
         $logm = c_ws_plugin__s2member_utilities::mem_details();
         $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
         $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
         $log2 = is_multisite() && !is_main_site() ? "paypal-rtn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-rtn.log";
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) {
             if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) {
                 if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) {
                     file_put_contents($logs_dir . "/" . $log2, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($paypal, true)) . "\n\n", FILE_APPEND);
                 }
             }
         }
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_paypal_return", get_defined_vars());
         unset($__refs, $__v);
         exit;
     }
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_after_paypal_return", get_defined_vars());
     unset($__refs, $__v);
 }
コード例 #5
0
 /**
  * Deals with Reading Option conflicts.
  *
  * @package s2Member\Option_Notices
  * @since 3.5
  *
  * @attaches-to ``add_action("load-options-reading.php");``
  *
  * @return null
  */
 public static function reading_ops_notice()
 {
     global $pagenow;
     // Need this global variable.
     do_action("ws_plugin__s2member_before_reading_ops_notice", get_defined_vars());
     if (is_blog_admin() && $pagenow === "options-reading.php" && !isset($_GET["page"])) {
         do_action("ws_plugin__s2member_during_reading_ops_notice", get_defined_vars());
         // Now check for conflicts.
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && (string) get_option("page_on_front") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && ($notice = '<strong>NOTE:</strong> Your Membership Options Page for s2Member is currently configured as your Home Page (i.e. static page) for WordPress. This causes internal conflicts with s2Member. Your Membership Options Page MUST stand alone. Please correct this.')) {
             c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "blog:" . $pagenow, true);
         }
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (string) get_option("page_on_front") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && ($notice = '<strong>NOTE:</strong> Your Login Welcome Page for s2Member is currently configured as your Home Page (i.e. static page) for WordPress. This causes internal conflicts with s2Member. Your Login Welcome Page MUST stand alone. Please correct this.')) {
             c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "blog:" . $pagenow, true);
         }
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && (string) get_option("page_for_posts") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"] && ($notice = '<strong>NOTE:</strong> Your Membership Options Page for s2Member is currently configured as your Posts Page (i.e. static page) for WordPress. This causes internal conflicts with s2Member. Your Membership Options Page MUST stand alone. Please correct this.')) {
             c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "blog:" . $pagenow, true);
         }
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (string) get_option("page_for_posts") === $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && ($notice = '<strong>NOTE:</strong> Your Login Welcome Page for s2Member is currently configured as your Posts Page (i.e. static page) for WordPress. This causes internal conflicts with s2Member. Your Login Welcome Page MUST stand alone. Please correct this.')) {
             c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "blog:" . $pagenow, true);
         }
     }
     do_action("ws_plugin__s2member_after_reading_ops_notice", get_defined_vars());
     return;
 }
コード例 #6
0
/**
* Deprecated in s2Member v3.5+.
*
* Needed by the s2Member Pro upgrader prior to s2Member Pro v1.5+.
*
* @package s2Member
* @since 3.0
*
* @deprecated Starting with s2Member v3.5+, please use:
* 	``c_ws_plugin__s2member_admin_notices::enqueue_admin_notice()``
*
* @see s2Member\Admin_Notices\c_ws_plugin__s2member_admin_notices::enqueue_admin_notice()
*/
function ws_plugin__s2member_enqueue_admin_notice($notice = FALSE, $on_pages = FALSE, $error = FALSE, $time = FALSE, $dismiss = FALSE)
{
    return c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, $on_pages, $error, $time, $dismiss);
}
コード例 #7
0
 /**
  * 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());
 }
コード例 #8
0
 /**
  * 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';
 }
コード例 #9
0
 /**
  * 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. */
 }
コード例 #10
0
 /**
  * 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. */
 }
コード例 #11
0
ファイル: menu-pages.inc.php プロジェクト: donwea/nhap.org
 /**
  * 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;
 }
コード例 #12
0
 /**
  * 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. */
 }
コード例 #13
0
 /**
  * Activation routines for s2Member.
  *
  * @package s2Member\Installation
  * @since 3.5
  *
  * @return null
  */
 public static function activate($reactivation_reason = FALSE)
 {
     global $wpdb;
     /* Global database object reference. */
     global $current_site, $current_blog;
     /* Multisite. */
     /**/
     do_action("ws_plugin__s2member_before_activation", get_defined_vars());
     /**/
     c_ws_plugin__s2member_roles_caps::config_roles();
     /* Config Roles/Caps. */
     update_option("ws_plugin__s2member_activated_levels", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]);
     /**/
     if (!is_dir($files_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir"])) {
         if (is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($files_dir)))) {
             mkdir($files_dir, 0777, true);
         }
     }
     /**/
     if (is_dir($files_dir) && is_writable($files_dir)) {
         if (!file_exists($htaccess = $files_dir . "/.htaccess") || !apply_filters("ws_plugin__s2member_preserve_files_dir_htaccess", false, get_defined_vars())) {
             file_put_contents($htaccess, trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["files_dir_htaccess"]))));
         }
     }
     /**/
     if (!is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) {
         if (is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir)))) {
             mkdir($logs_dir, 0777, true);
         }
     }
     /**/
     if (is_dir($logs_dir) && is_writable($logs_dir)) {
         if (!file_exists($htaccess = $logs_dir . "/.htaccess") || !apply_filters("ws_plugin__s2member_preserve_logs_dir_htaccess", false, get_defined_vars())) {
             file_put_contents($htaccess, trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir_htaccess"]))));
         }
     }
     /**/
     !is_array(get_option("ws_plugin__s2member_cache")) ? update_option("ws_plugin__s2member_cache", array()) : null;
     !is_array(get_option("ws_plugin__s2member_notices")) ? update_option("ws_plugin__s2member_notices", array()) : null;
     !is_array(get_option("ws_plugin__s2member_options")) ? update_option("ws_plugin__s2member_options", array()) : null;
     !is_numeric(get_option("ws_plugin__s2member_configured")) ? update_option("ws_plugin__s2member_configured", "0") : null;
     /**/
     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["configured"]) {
         $v = get_option("ws_plugin__s2member_activated_version");
         /* Currently. */
         /**/
         if (!$v || !version_compare($v, "3.2", ">=")) {
             $like = "`meta_key` LIKE 's2member\\_%' AND `meta_key` NOT LIKE '%s2member\\_originating\\_blog%'";
             $wpdb->query("UPDATE `" . $wpdb->usermeta . "` SET `meta_key` = CONCAT('" . $wpdb->prefix . "', `meta_key`) WHERE " . $like);
         }
         /**/
         if (!$v || !version_compare($v, "3.2.5", ">=")) {
             $wpdb->query("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\\_transient\\_%'");
         }
         /**/
         if (!$v || !version_compare($v, "3.2.6", ">=")) {
             $wpdb->query("DELETE FROM `" . $wpdb->postmeta . "` WHERE `meta_key` = 's2member_ccaps_req' AND `meta_value` IN('','a:0:{}','a:1:{i:0;s:0:\"\";}')");
         }
         /**/
         if (!$v || !version_compare($v, "110912", ">=") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"] === array("all")) {
             $notice = '<strong>IMPORTANT:</strong> This version of s2Member® changes the way your <code>Alternative View Protections</code> work. Please review your options under: <code>s2Member -> Restriction Options -> Alternative View Protections</code>.<br />';
             c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
         }
         /**/
         $notice = '<strong>s2Member</strong> has been <strong>reactivated</strong>, with ' . ($reactivation_reason === "levels" ? '<code>' . esc_html($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]) . '</code> Membership Levels' : 'the latest version') . '.<br />';
         $notice .= 'You now have version ' . esc_html(WS_PLUGIN__S2MEMBER_VERSION) . '. Your existing configuration remains.';
         /**/
         if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) {
             /* No Changelog on a Multisite Blog Farm. */
             $notice .= '<br />Have fun, <a href="' . esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-info#rm-changelog")) . '">read the Changelog</a>, and make some money! :-)';
         }
         /**/
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
     } else {
         $notice = '<strong>Note:</strong> s2Member adds some new data columns to your list of Users/Members. If your list gets overcrowded, please use the <strong>Screen Options</strong> tab <em>( upper right-hand corner )</em>. With WordPress® Screen Options, you can add/remove specific data columns; thereby making the most important data easier to read. For example, if you create Custom Registration/Profile Fields with s2Member, those Custom Fields will result in new data columns; which can cause your list of Users/Members to become nearly unreadable. So just use the Screen Options tab to clean things up.';
         /**/
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "blog:users.php", false, false, true);
         /**/
         $notice = '<strong>s2Member</strong> v' . esc_html(WS_PLUGIN__S2MEMBER_VERSION) . ' has been <strong>activated</strong>. Nice work!<br />';
         $notice .= 'Have fun, <a href="' . esc_attr(admin_url("/admin.php?page=ws-plugin--s2member-start")) . '">read the Quick Start Guide</a>, and make some money! :-)';
         /**/
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
     }
     /**/
     if (is_multisite() && is_main_site()) {
         foreach ((array) ($users = $wpdb->get_results("SELECT `ID` FROM `" . $wpdb->users . "`")) as $user) {
             if (!($originating_blog = get_user_meta($user->ID, "s2member_originating_blog", true))) {
                 update_user_meta($user->ID, "s2member_originating_blog", $current_site->blog_id);
             }
         }
         /**/
         $notice = '<strong>Multisite Network</strong> updated automatically by <strong>s2Member</strong> v' . esc_html(WS_PLUGIN__S2MEMBER_VERSION) . '.<br />';
         $notice .= 'You\'ll want to configure s2Member\'s Multisite options now.<br />';
         $notice .= 'In the Dashboard for your Main Site, see:<br />';
         $notice .= '<code>s2Member -> Multisite ( Config )</code>.';
         /**/
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array("blog|network:plugins.php", "blog|network:ws-plugin--s2member-start", "blog|network:ws-plugin--s2member-mms-ops", "blog|network:ws-plugin--s2member-gen-ops", "blog|network:ws-plugin--s2member-res-ops"));
         /**/
         update_site_option("ws_plugin__s2member_options", (array) get_option("ws_plugin__s2member_options"));
         /**/
         update_option("ws_plugin__s2member_activated_mms_version", WS_PLUGIN__S2MEMBER_VERSION);
     }
     /**/
     update_option("ws_plugin__s2member_activated_version", WS_PLUGIN__S2MEMBER_VERSION);
     /**/
     do_action("ws_plugin__s2member_after_activation", get_defined_vars());
     /**/
     return;
     /* Return for uniformity. */
 }
コード例 #14
0
 /**
  * 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. */
 }
コード例 #15
0
 /**
  * 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());
 }
コード例 #16
0
 /**
  * Activation routines for s2Member.
  *
  * @package s2Member\Installation
  * @since 3.5
  *
  * @param string $reactivation_reason Optional.
  */
 public static function activate($reactivation_reason = '')
 {
     global $wpdb;
     /** @var $wpdb wpdb */
     global $current_site, $current_blog;
     // Multisite.
     do_action('ws_plugin__s2member_before_activation', get_defined_vars());
     c_ws_plugin__s2member_roles_caps::config_roles();
     // Config Roles/Caps.
     update_option('ws_plugin__s2member_activated_levels', $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']);
     if (!is_dir($files_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['files_dir'])) {
         if (is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($files_dir)))) {
             mkdir($files_dir, 0777, TRUE);
         }
     }
     if (is_dir($files_dir) && is_writable($files_dir)) {
         if (!is_file($htaccess = $files_dir . '/.htaccess') || !apply_filters('ws_plugin__s2member_preserve_files_dir_htaccess', !is_writable($files_dir . '/.htaccess'), get_defined_vars())) {
             file_put_contents($htaccess, trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS['WS_PLUGIN__']['s2member']['c']['files_dir_htaccess']))));
         }
     }
     c_ws_plugin__s2member_files::write_no_gzip_into_root_htaccess();
     // Handle the root `.htaccess` file as well now, for GZIP exclusions.
     if (!is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'])) {
         if (is_writable(dirname(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir)))) {
             mkdir($logs_dir, 0777, TRUE);
         }
     }
     if (is_dir($logs_dir) && is_writable($logs_dir)) {
         if (!is_file($htaccess = $logs_dir . '/.htaccess') || !apply_filters('ws_plugin__s2member_preserve_logs_dir_htaccess', !is_writable($logs_dir . '/.htaccess'), get_defined_vars())) {
             file_put_contents($htaccess, trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir_htaccess']))));
         }
     }
     !is_array(get_option('ws_plugin__s2member_cache')) ? update_option('ws_plugin__s2member_cache', array()) : NULL;
     !is_array(get_option('ws_plugin__s2member_notices')) ? update_option('ws_plugin__s2member_notices', array()) : NULL;
     !is_array(get_option('ws_plugin__s2member_options')) ? update_option('ws_plugin__s2member_options', array()) : NULL;
     !is_numeric(get_option('ws_plugin__s2member_configured')) ? update_option('ws_plugin__s2member_configured', '0') : NULL;
     if ($GLOBALS['WS_PLUGIN__']['s2member']['c']['configured']) {
         $v = get_option('ws_plugin__s2member_activated_version');
         // Currently.
         if (!$v || !version_compare($v, '3.2', '>=')) {
             $like = "`meta_key` LIKE 's2member\\_%' AND `meta_key` NOT LIKE '%s2member\\_originating\\_blog%'";
             $wpdb->query("UPDATE `" . $wpdb->usermeta . "` SET `meta_key` = CONCAT('" . $wpdb->prefix . "', `meta_key`) WHERE " . $like);
         }
         if (!$v || !version_compare($v, '3.2.5', '>=')) {
             $wpdb->query("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\\_transient\\_%'");
         }
         if (!$v || !version_compare($v, '3.2.6', '>=')) {
             $wpdb->query("DELETE FROM `" . $wpdb->postmeta . "` WHERE `meta_key` = 's2member_ccaps_req' AND `meta_value` IN('','a:0:{}','a:1:{i:0;s:0:\"\";}')");
         }
         if (!$v || !version_compare($v, '110912', '>=') && $GLOBALS['WS_PLUGIN__']['s2member']['o']['filter_wp_query'] === array('all')) {
             $notice = '<strong>IMPORTANT:</strong> This version of s2Member changes the way your <code>Alternative View Protections</code> work. Please review your options under: <strong>s2Member → Restriction Options → Alternative View Protections</strong>.';
             c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
         }
         if ($v && version_compare($v, '130316', '<=')) {
             c_ws_plugin__s2member_menu_pages::update_all_options(array('ws_plugin__s2member_gateway_debug_logs' => '0', 'ws_plugin__s2member_gateway_debug_logs_extensive' => '0'), TRUE, FALSE, FALSE, FALSE, FALSE);
             $notice = '<strong>IMPORTANT:</strong> This version of s2Member disables s2Member\'s debug logging by default (for added security). Please see: <a href="' . esc_attr(admin_url('/admin.php?page=ws-plugin--s2member-logs')) . '">s2Member → Log Files (Debug) → Configuration</a> for further details.';
             c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
             $notice = '<strong>IMPORTANT / Regarding s2Member Security Badges:</strong> If debug logging is enabled, your site will no longer qualify for an s2Member Security Badge until you disable logging (and you must also download, and then delete any existing log files from the past). Please see KB Article: <a href="http://www.s2member.com/kb/security-badges/" target="_blank" rel="external">s2Member Security Badges</a> for further details. If you have existing s2Member log files, you will need to delete those files from the server before your s2Member Security Badge can be re-enabled. s2Member stores log files here: <code>' . esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'])) . '</code>. See also: <a href="' . esc_attr(admin_url('/admin.php?page=ws-plugin--s2member-logs')) . '">s2Member → Log Files (Debug) → Configuration</a> for further details.';
             c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
         }
         if ($v && version_compare($v, '140128', '<=')) {
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'refunds,reversals') {
                 // `refunds,reversals` => `refunds,partial_refunds,reversals`
                 c_ws_plugin__s2member_menu_pages::update_all_options(array('ws_plugin__s2member_triggers_immediate_eot' => 'refunds,partial_refunds,reversals'), TRUE, FALSE, FALSE, FALSE, FALSE);
             }
         }
         $notice = '<strong>s2Member</strong> has been <strong>reactivated</strong>, with ' . ($reactivation_reason === 'levels' ? '<code>' . esc_html($GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']) . '</code> Membership Levels' : 'the latest version') . '.<br />';
         $notice .= 'You now have version ' . esc_html(WS_PLUGIN__S2MEMBER_VERSION) . '. Your existing configuration remains.';
         if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) {
             // No Changelog on a Multisite Blog Farm.
             $notice .= '<br />Have fun, <a href="' . esc_attr(c_ws_plugin__s2member_readmes::parse_readme_value('Changelog URI')) . '" target="_blank">read the Changelog</a>, and make some money! :-)';
         }
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
     } else {
         $notice = '<strong>Note:</strong> s2Member adds some new data columns to your list of Users/Members. If your list gets overcrowded, please use the <strong>Screen Options</strong> tab <em>(upper right-hand corner)</em>. With WordPress Screen Options, you can add/remove specific data columns; thereby making the most important data easier to read. For example, if you create Custom Registration/Profile Fields with s2Member, those Custom Fields will result in new data columns; which can cause your list of Users/Members to become nearly unreadable. So just use the Screen Options tab to clean things up.';
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, 'blog:users.php', FALSE, FALSE, TRUE);
         $notice = '<strong>s2Member</strong> v' . esc_html(WS_PLUGIN__S2MEMBER_VERSION) . ' has been <strong>activated</strong>. Nice work!<br />';
         $notice .= 'Have fun, <a href="' . esc_attr(admin_url('/admin.php?page=ws-plugin--s2member-start')) . '">read the Quick Start Guide</a>, and make some money! :-)';
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
     }
     if (is_multisite() && is_main_site()) {
         $wpdb->query("INSERT INTO `" . $wpdb->usermeta . "` (`user_id`, `meta_key`, `meta_value`) SELECT `ID`, 's2member_originating_blog', '" . esc_sql($current_site->blog_id) . "' FROM `" . $wpdb->users . "` WHERE `ID` NOT IN (SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_originating_blog')");
         $notice = '<strong>Multisite Network</strong> updated automatically by <strong>s2Member</strong> v' . esc_html(WS_PLUGIN__S2MEMBER_VERSION) . '.<br />';
         $notice .= 'You\'ll want to configure s2Member\'s Multisite options now.<br />';
         $notice .= 'In the Dashboard for your Main Site, see:<br />';
         $notice .= '<strong>s2Member → Multisite (Config)</strong>.';
         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
         update_site_option('ws_plugin__s2member_options', (array) get_option('ws_plugin__s2member_options'));
         update_option('ws_plugin__s2member_activated_mms_version', WS_PLUGIN__S2MEMBER_VERSION);
     }
     update_option('ws_plugin__s2member_activated_version', WS_PLUGIN__S2MEMBER_VERSION);
     do_action('ws_plugin__s2member_after_activation', get_defined_vars());
 }
コード例 #17
0
 /**
  * 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;
 }
コード例 #18
0
 /**
  * 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. */
 }
コード例 #19
0
 /**
  * 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;
 }
コード例 #20
0
 /**
  * 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.');
         }
     }
 }
コード例 #21
0
 /**
  * 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";
 }
コード例 #22
0
ファイル: upgrader.inc.php プロジェクト: SollyNZ/damn-plugins
 /**
  * Upgrade processor.
  *
  * @package s2Member\Upgrader
  * @since 1.5
  *
  * @attaches-to ``add_action("admin_init");``
  *
  * @return null Upgrader does NOT return anything.
  */
 public static function upgrade()
 {
     global $wp_filesystem;
     if (!empty($_POST["ws_plugin__s2member_pro_upgrade"]) && ($nonce = (string) $_POST["ws_plugin__s2member_pro_upgrade"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-pro-upgrade") && ($_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)))) {
         if (@set_time_limit(0) !== "nill" && @ini_set("memory_limit", apply_filters("admin_memory_limit", WP_MAX_MEMORY_LIMIT)) !== "nill" && c_ws_plugin__s2member_pro_upgrader::abbr_bytes(@ini_get("memory_limit")) >= c_ws_plugin__s2member_pro_upgrader::abbr_bytes(apply_filters("admin_memory_limit", WP_MAX_MEMORY_LIMIT))) {
             if (!empty($_p["ws_plugin__s2member_pro_upgrade_username"]) && !empty($_p["ws_plugin__s2member_pro_upgrade_password"]) && is_array($s2_pro_upgrade = maybe_unserialize(c_ws_plugin__s2member_utils_urls::remote(add_query_arg(urlencode_deep(array("s2_pro_upgrade" => array("username" => (string) $_p["ws_plugin__s2member_pro_upgrade_username"], "password" => (string) $_p["ws_plugin__s2member_pro_upgrade_password"], "version" => WS_PLUGIN__S2MEMBER_PRO_VERSION))), c_ws_plugin__s2member_readmes::parse_readme_value("Pro Add-on / Auto-Update URL", dirname(dirname(dirname(__FILE__))) . "/readme.txt"))))) && !empty($s2_pro_upgrade["zip"]) && !empty($s2_pro_upgrade["ver"])) {
                 set_transient(md5("ws_plugin__s2member_pro_upgrade_credentials"), array("username" => (string) $_p["ws_plugin__s2member_pro_upgrade_username"], "password" => (string) $_p["ws_plugin__s2member_pro_upgrade_password"]), 5184000);
                 ob_start();
                 if (is_array($credentials = request_filesystem_credentials($_SERVER["REQUEST_URI"], false, false, dirname(dirname(dirname(dirname(__FILE__))))))) {
                     c_ws_plugin__s2member_pro_upgrader::$credentials = $credentials;
                 }
                 $credentials_form = ob_get_clean();
                 c_ws_plugin__s2member_pro_upgrader::maintenance(true);
                 if (WP_Filesystem(c_ws_plugin__s2member_pro_upgrader::$credentials, $plugins_dir = $_plugins_dir = dirname(dirname(dirname(dirname(__FILE__))))) && ($plugins_dir = rtrim($wp_filesystem->find_folder($plugins_dir), "/")) && ($plugin_dir = rtrim($wp_filesystem->find_folder($_plugin_dir = dirname(dirname(dirname(__FILE__)))), "/"))) {
                     if (($tmp_zip = wp_unique_filename($_plugins_dir, basename($plugin_dir) . ".zip")) && ($_tmp_zip = $_plugins_dir . "/" . $tmp_zip) && ($tmp_zip = $plugins_dir . "/" . $tmp_zip) && $wp_filesystem->put_contents($tmp_zip, c_ws_plugin__s2member_utils_urls::remote($s2_pro_upgrade["zip"], false, array("timeout" => 120)), FS_CHMOD_FILE)) {
                         if ((!$wp_filesystem->is_dir($plugin_dir . "-new") || $wp_filesystem->delete($plugin_dir . "-new", true)) && $wp_filesystem->mkdir($plugin_dir . "-new", FS_CHMOD_DIR)) {
                             if (!is_wp_error($unzip = unzip_file($_tmp_zip, $plugin_dir . "-new"))) {
                                 if (!$wp_filesystem->is_dir($plugin_dir) || $wp_filesystem->delete($plugin_dir, true)) {
                                     if ($wp_filesystem->move($plugin_dir . "-new/s2member-pro", $plugin_dir)) {
                                         $wp_filesystem->delete($plugin_dir . "-new", true) . $wp_filesystem->delete($tmp_zip);
                                         $notice = 's2Member Pro successfully updated to v' . esc_html($s2_pro_upgrade["ver"]) . '.';
                                         do_action("ws_plugin__s2member_pro_during_successfull_upgrade", get_defined_vars());
                                         c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, "blog|network:*");
                                         c_ws_plugin__s2member_pro_upgrader::maintenance(false);
                                         wp_redirect(self_admin_url("/plugins.php")) . exit;
                                     } else {
                                         $wp_filesystem->delete($plugin_dir . "-new", true) . $wp_filesystem->delete($tmp_zip);
                                         c_ws_plugin__s2member_pro_upgrader::$error = "Upgrade failed. Error #0009. Please upgrade via FTP.";
                                     }
                                 } else {
                                     $wp_filesystem->delete($plugin_dir . "-new", true) . $wp_filesystem->delete($tmp_zip);
                                     c_ws_plugin__s2member_pro_upgrader::$error = "Upgrade failed. Error #0008. Please upgrade via FTP.";
                                 }
                             } else {
                                 $wp_filesystem->delete($plugin_dir . "-new", true) . $wp_filesystem->delete($tmp_zip);
                                 c_ws_plugin__s2member_pro_upgrader::$error = "Upgrade failed. Error #0007. " . $unzip->get_error_message() . " ~ Please upgrade via FTP. ";
                             }
                         } else {
                             $wp_filesystem->delete($plugin_dir . "-new", true) . $wp_filesystem->delete($tmp_zip);
                             c_ws_plugin__s2member_pro_upgrader::$error = "Upgrade failed. Error #0006. Please upgrade via FTP.";
                         }
                     } else {
                         $wp_filesystem->delete($plugin_dir . "-new", true) . $wp_filesystem->delete($tmp_zip);
                         c_ws_plugin__s2member_pro_upgrader::$error = "Upgrade failed. Error #0005. Please upgrade via FTP.";
                     }
                 } else {
                     c_ws_plugin__s2member_pro_upgrader::$error = "Upgrade failed. Error #0004. Please upgrade via FTP, or supply valid Filesystem Credentials.";
                 }
                 c_ws_plugin__s2member_pro_upgrader::maintenance(false);
             } else {
                 if (!empty($s2_pro_upgrade) && $s2_pro_upgrade === "403 Forbidden") {
                     c_ws_plugin__s2member_pro_upgrader::$error = "Upgrade failed. Invalid Username/Password (or License Key); please try again.";
                 } else {
                     if (!empty($s2_pro_upgrade) && $s2_pro_upgrade === "503 Service Unavailable") {
                         c_ws_plugin__s2member_pro_upgrader::$error = "Upgrade failed. Service currently unavailable (please try again).";
                     } else {
                         c_ws_plugin__s2member_pro_upgrader::$error = "Upgrade failed. Connection failed (please try again).";
                     }
                 }
             }
         } else {
             c_ws_plugin__s2member_pro_upgrader::$error = "Not enough memory." . " Unzipping s2Member Pro via WordPress requires " . WP_MAX_MEMORY_LIMIT . " of RAM." . " Please upgrade via FTP instead.</code>.";
         }
     }
     return;
 }
コード例 #23
0
ファイル: gateways.inc.php プロジェクト: SollyNZ/damn-plugins
 /**
  * Draw attention to other payment gateways.
  *
  * @package s2Member\Gateways
  * @since 150717
  *
  * @attaches-to ``add_action('admin_init');``
  */
 public static function maybe_draw_attention_to_gateways()
 {
     if (is_network_admin()) {
         return;
     }
     // Not applicable.
     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_gateways_seen']) {
         return;
     }
     // Not applicable. Seen already.
     $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_gateways_seen'] = '1';
     update_option('ws_plugin__s2member_options', $GLOBALS['WS_PLUGIN__']['s2member']['o']);
     if (is_multisite() && is_main_site()) {
         update_site_option('ws_plugin__s2member_options', $GLOBALS['WS_PLUGIN__']['s2member']['o']);
     }
     // If `unconfigured` is not in the array of gateways they have already been configured in that scenario.
     // 	Or, perhaps this is a site that was setup prior to 150717; i.e., this notice is not applicable.
     if (!in_array('unconfigured', $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_gateways_enabled'], TRUE)) {
         return;
     }
     // Already configured these; i.e., back compatibility.
     $page = admin_url('/admin.php?page=ws-plugin--s2member-pro-other-gateways');
     $notice = '<strong>s2Member® Pro says...</strong> Please configure <a href="' . esc_attr($page) . '" style="text-decoration:underline;">Other Payment Gateways</a>; i.e., choose which payment gateways you would like to use.';
     c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, 'blog:*');
 }
コード例 #24
0
 /**
  * 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;
 }
コード例 #25
0
 /**
  * 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);
         }
     }
 }
コード例 #26
0
ファイル: mms-patches.inc.php プロジェクト: donwea/nhap.org
 /**
  * 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;
 }
コード例 #27
0
 /**
  * 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;
 }
コード例 #28
0
 /**
  * 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());
 }
コード例 #29
0
 /**
  * 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. */
 }