public function authenticateLogin() { $error = false; if (isset($_POST['log']) && $_POST['log'] == '' || isset($_POST['pwd']) && $_POST['pwd'] == '') { $error = true; } if (class_exists("MM_CorePageEngine") && $error) { MM_Messages::addError("Please enter your username and password."); if (!defined("DOING_AJAX") || !DOING_AJAX) { wp_redirect(MM_CorePageEngine::getUrl(MM_CorePageType::$LOGIN_PAGE)); exit; } else { MM_Session::value('redirect_to', MM_CorePageEngine::getUrl(MM_CorePageType::$LOGIN_PAGE)); return true; } } }
/** * This function keeps default core page from being trashed */ public function trashPostHandler($post_id) { if (MM_CorePage::isDefaultCorePage($post_id)) { MM_Messages::addError("MemberMouse default core pages cannot be deleted."); wp_publish_post($post_id); wp_redirect("edit.php?post_type=page"); exit; } if (MM_CorePageEngine::isCorePage($post_id)) { // We don't want non-default core pages sitting in the trash to retain their associations because it // can cause issues with other non-default core pages that are currently published, so let's treat even // sending a non-default core page to trash just the same as permanently deleting the page altogether $this->deletePostHandler($post_id); } }
public static function getPluginWarnings() { $problemPlugins = array(); $problemPlugins["W3 Total Cache"] = "w3-total-cache/w3-total-cache.php"; $problemPlugins["WP Super Cache"] = "wp-super-cache/wp-cache.php"; $plugins = get_option('active_plugins'); foreach ($problemPlugins as $name => $location) { if (in_array($location, $plugins)) { if (!MM_Messages::isMessageHidden($location)) { $hideWarningUrl = MM_Messages::getHideMessageUrl(self::constructPageUrl(), $location); MM_Messages::addError("<i class=\"fa fa-exclamation-triangle\"></i> <strong>MemberMouse Warning</strong>: The <em>{$name}</em> plugin is known to cause issues with MemberMouse. <a href='https://membermouse.uservoice.com/knowledgebase/articles/319203-plugins-that-cause-problems' target='_blank'>Learn more</a> | <a href='{$hideWarningUrl}'>Hide this warning</a>"); } } } // check if client is using Visual Composer $visualComposerPlugin = "js_composer/js_composer.php"; if (in_array($visualComposerPlugin, $plugins)) { if (!MM_Messages::isMessageHidden($visualComposerPlugin)) { $hideWarningUrl = MM_Messages::getHideMessageUrl(self::constructPageUrl(), $visualComposerPlugin); $visualEditorMsg = "<p><i class=\"fa fa-exclamation-triangle\"></i> <strong>MemberMouse Warning: Visual Composer</strong></p>"; $visualEditorMsg .= "<div style=\"margin-left:20px;\"><i class=\"fa fa-caret-right\"></i> "; $visualEditorMsg .= "You're using Visual Composer. To avoid issues make sure to follow the instructions in this article when <a href='http://membermouse.uservoice.com/knowledgebase/articles/792249' target='_blank'>using SmartTags</a> | <a href='{$hideWarningUrl}'>Hide this warning</a>"; $visualEditorMsg .= "</div>"; MM_Messages::addError($visualEditorMsg); } } // check if client is using WP Engine if (class_exists("WPE_API", false) || defined("WPE_APIKEY") || defined("WPE_ISP")) { if (!MM_Messages::isMessageHidden("wp-engine-warning")) { $hideWarningUrl = MM_Messages::getHideMessageUrl(self::constructPageUrl(), "wp-engine-warning"); MM_Messages::addError("<i class=\"fa fa-exclamation-triangle\"></i> <strong>MemberMouse Warning</strong>: You're using WP Engine. Follow the instructions in this article to <a href='http://membermouse.uservoice.com/knowledgebase/articles/356866-configuring-wp-engine-hosting' target='_blank'>work with WP Engine to ensure your server is configured to allow MemberMouse to run properly</a>. | <a href='{$hideWarningUrl}'>Hide this warning</a>"); } } // TODO this code can be removed after no active license is on a version less than 2.2.4 $captchaSiteKey = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_CAPTCHA_KEY); $captchaPrivateKey = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_CAPTCHA_PRIVATE_KEY); $mmVersion = MemberMouse::getPluginVersion(); // check if client is using recaptcha and on version 2.2.4 of MM if ($mmVersion == "2.2.4" && !empty($captchaSiteKey) && !empty($captchaPrivateKey)) { if (!MM_Messages::isMessageHidden("recaptcha-upgrade-warning")) { $hideWarningUrl = MM_Messages::getHideMessageUrl(self::constructPageUrl(), "recaptcha-upgrade-warning"); MM_Messages::addError("<div style='width:750px;'><i class=\"fa fa-exclamation-triangle\"></i> <strong>MemberMouse Warning</strong>: It appears that you're currently using reCaptcha. In this version of MemberMouse reCaptcha has been upgraded and your <strong>action is required</strong> to ensure your checkout process continues to function correctly. <a href='http://membermouse.uservoice.com/knowledgebase/articles/718512#recaptcha-upgrade' target='_blank'>Watch this video for details</a>. | <a href='{$hideWarningUrl}'>Hide this warning</a></div>"); } } }
public function showNotices() { $this->checkVersion(); // check to see if cache is being used $writeableDir = MM_PLUGIN_ABSPATH . "/com/membermouse/cache"; $usingDbCache = false; if (class_exists("MM_Session")) { $usingDbCache = MM_Session::value(MM_Session::$KEY_USING_DB_CACHE); if (empty($usingDbCache)) { $usingDbCache = false; } } if (!isset($_GET['module']) || $_GET['module'] != MM_MODULE_REPAIR_INSTALL) { $cacheRepairUrl = MM_ModuleUtils::getUrl(MM_MODULE_GENERAL_SETTINGS, MM_MODULE_REPAIR_INSTALL); if (!file_exists($writeableDir) || is_dir($writeableDir) && !is_writeable($writeableDir)) { MM_Messages::addMessage("Currently MemberMouse can't utilize the cache. <a href='{$cacheRepairUrl}'>Click here to correct this.</a>"); if (!file_exists($writeableDir)) { @mkdir($writeableDir); //if the cache directory is missing, attempt to create it silently if possible } } else { if ($usingDbCache) { //this means the dbcache is in use, but the cache is now writeable, show banner and see if refresh is available MM_Messages::addMessage("Currently MemberMouse can't utilize the cache. <a href='{$cacheRepairUrl}'>Click here to correct this.</a>"); $lastAuth = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_LAST_CODE_REFRESH); $minInterval = time() - 60; //(1 min) if (class_exists("MM_MemberMouseService") && (empty($lastAuth) || $lastAuth <= $minInterval)) { $refreshSuccess = MM_MemberMouseService::authorize(); MM_OptionUtils::setOption(MM_OptionUtils::$OPTION_KEY_LAST_CODE_REFRESH, time()); } MM_Session::clear(MM_Session::$KEY_USING_DB_CACHE); } } } // check to see if this is a beta version if (MM_IS_BETA == true) { $mmVersion = self::getPluginVersion(); $msg = "<div style='width:750px;'><em class='mm-beta'>beta</em><strong>MemberMouse {$mmVersion}</strong>"; $msg .= "<div style='margin-left:20px; margin-top:5px; line-height:22px;'>This is a Beta version of MemberMouse.<br/>"; $msg .= "<i class=\"fa fa-caret-right\"></i> <a href='http://membermouse.com/beta-release-notes.php?version={$mmVersion}' target='_blank'>Beta {$mmVersion} Release Notes</a><br/>"; $msg .= "<i class=\"fa fa-caret-right\"></i> Email <a href='mailto:beta@membermouse.com'>beta@membermouse.com</a> for support or questions on the beta version</div>"; $msg .= "</div>"; MM_Messages::addError($msg); } // check to see if there's a new version of MM available if (class_exists("MM_MemberMouseService")) { // check if there's an upgrade available $crntMajorVersion = self::getPluginVersion(); $upgradeVersion = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_UPGRADE_NOTICE); if (!empty($upgradeVersion)) { if (version_compare($upgradeVersion, $crntMajorVersion, ">") || MM_IS_BETA == true && version_compare($upgradeVersion, $crntMajorVersion, "==")) { // verify that customer is on PHP 5.3+ if ((double) phpversion() < 5.3) { $phpWarning = "<div style='width:750px;'><i class=\"fa fa-exclamation-triangle\"></i> <strong>Warning:</strong> A new version of MemberMouse is available. In order to upgrade to the latest version of MemberMouse you will need to upgrade to PHP 5.3 or higher.</div>"; MM_Messages::addError($phpWarning); } else { if (strpos($_SERVER["PHP_SELF"], "plugins.php") === false && !(isset($_GET["action"]) && $_GET["action"] == "upgrade-plugin")) { MM_Messages::addMessage("<a href='https://membermouse.uservoice.com/knowledgebase/articles/319210-membermouse-versions' target='_blank'>MemberMouse {$upgradeVersion}</a> is available! <a href='plugins.php?plugin_update=membermouse&version={$upgradeVersion}'>Please update now</a>."); } } } } // check if plugin needs to be upgraded global $wpdb; $sql = "SELECT count(u.wp_user_id) as total FROM " . MM_TABLE_USER_DATA . " u, " . MM_TABLE_MEMBERSHIP_LEVELS . " m WHERE "; $sql .= "u.membership_level_id = m.id AND (u.status = '" . MM_Status::$ACTIVE . "' OR u.status = '" . MM_Status::$PENDING_CANCELLATION . "') "; $result = $wpdb->get_row($sql); if ($result) { $activeMembers = intval($result->total); $memberLimit = intval(MM_MemberMouseService::getMemberLimit()); $upgradeUrl = MM_MemberMouseService::getUpgradeUrl(); if ($memberLimit != -1 && $activeMembers > $memberLimit) { MM_Messages::addMessage("MemberMouse is currently over the limit of " . number_format($memberLimit) . " members and will be deactivated within a week of going over the limit. Please <a href='{$upgradeUrl}' target='_blank'>upgrade your account</a> to avoid any service interruptions."); } } // check to see if in Safe Mode $safeMode = MM_SafeMode::getMode(); if ($safeMode == MM_SafeMode::$MODE_ENABLED) { $safeModeUrl = MM_ModuleUtils::getUrl(MM_MODULE_GENERAL_SETTINGS, MM_MODULE_SAFE_MODE); MM_Messages::addError("<i class=\"fa fa-life-saver\"></i> MemberMouse Safe Mode is Enabled. <a href='{$safeModeUrl}'>Safe Mode Settings</a>"); } //check to see if payment subsystem is in test mode or if test data is being used. $testPaymentSrvcEnabled = class_exists("MM_TestPaymentService") && MM_TestPaymentService::isSiteUsingTestService(); $testDataEnabled = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_USE_CHECKOUT_FORM_TEST_DATA) == "1" ? true : false; if ($testPaymentSrvcEnabled || $testDataEnabled) { $errorMsg = "<i class=\"fa fa-flask\"></i> <strong>MemberMouse Testing Enabled</strong>"; $errorMsg .= "<div style='margin-left:20px;'>"; if ($testPaymentSrvcEnabled) { $paymentSettingsUrl = MM_ModuleUtils::getUrl(MM_MODULE_PAYMENT_SETTINGS, MM_MODULE_PAYMENT_METHODS); $errorMsg .= "<i class=\"fa fa-caret-right\"></i> Test Payment Service is enabled. "; $errorMsg .= "All charges will be processed by the test payment service. "; $errorMsg .= "<a href='{$paymentSettingsUrl}'>Payment Method Settings</a><br/>"; } if ($testDataEnabled) { $testDataSettingsUrl = MM_ModuleUtils::getUrl(MM_MODULE_PAYMENT_SETTINGS, MM_MODULE_TEST_DATA); $errorMsg .= "<i class=\"fa fa-caret-right\"></i> Test Data is enabled. All checkout forms will be prepopulated with test data. <a href='{$testDataSettingsUrl}'>Test Data Settings</a>"; } $errorMsg .= "</div>"; MM_Messages::addError($errorMsg); } } // check PHP version if ((double) phpversion() < 5.3) { $phpWarning = "<div style='width:750px;'><i class=\"fa fa-exclamation-triangle\"></i> <strong>Warning:</strong> Your webserver is running PHP "; $phpWarning .= phpversion(); $phpWarning .= ", which is an obsolete version of PHP. MemberMouse isn't compatible with versions of PHP lower than 5.3 and you will experience issues "; $phpWarning .= "using the MemberMouse plugin. Please contact your hosting provider and request a more recent version of PHP. "; $phpWarning .= "For more information, <a href='http://membermouse.uservoice.com/knowledgebase/articles/534052' target='_blank'>click here</a>.</div>"; MM_Messages::addError($phpWarning); } // check to see if any trouble plugins are activated MM_Utils::getPluginWarnings(); // get error messages $errors = MM_Messages::get(MM_Session::$KEY_ERRORS); $output = ""; if (is_array($errors) && count($errors) > 0) { $output .= "<div class=\"error\">"; foreach ($errors as $msg) { $output .= "<p>{$msg}</p>"; } $output .= "</div>"; } // get notices $messages = MM_Messages::get(MM_Session::$KEY_MESSAGES); if (is_array($messages) && count($messages) > 0) { $output .= "<div class=\"updated\">"; foreach ($messages as $msg) { $output .= "<p>{$msg}</p>"; } $output .= "</div>"; } echo $output; MM_Messages::clear(); }