public function deployRelease($rest)
 {
     $post = $rest->getRequest()->getPost();
     MM_LogApi::logRequest(json_encode($post), "/deployRelease");
     if (!isset($post["version"])) {
         return new Response($rest, "Major version number is required", RESPONSE_ERROR_MESSAGE_MISSING_PARAMS . " : version", RESPONSE_ERROR_CODE_MISSING_PARAMS, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS);
     }
     $majorVersion = $post["version"];
     $minorVersion = isset($post["minor_version"]) ? $post["minor_version"] : MM_MemberMouseService::$DEFAULT_MINOR_VERSION;
     $crntVersion = MemberMouse::getPluginVersion();
     if ($crntVersion != $majorVersion) {
         MM_OptionUtils::setOption(MM_OptionUtils::$OPTION_KEY_UPGRADE_NOTICE, $majorVersion);
         return new Response($rest, "Major version do not match. A notification will be displayed to the customer informing them an update is available.", "Major version do not match. A notification will be displayed to the customer informing them an update is available.", RESPONSE_ERROR_CODE_BAD_REQUEST, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS);
     }
     // if major versions match, update cache with the latest files from central
     $writeableDir = MM_Utils::getCacheDir();
     // delete existing cache
     if (is_dir($writeableDir)) {
         if (is_writeable($writeableDir)) {
             if ($handle = opendir($writeableDir)) {
                 while (false !== ($file = readdir($handle))) {
                     if (!is_dir($file)) {
                         @unlink($writeableDir . "/" . $file);
                     }
                 }
                 closedir($handle);
             }
         }
     }
     // get updated classes from central
     MM_OptionUtils::setOption(MM_OptionUtils::$OPTION_KEY_MINOR_VERSION, $minorVersion);
     $ret = MM_MemberMouseService::authorize(true);
     if (MM_Response::isError($ret)) {
         return new Response($rest, "Could not find classes associated with version {$majorVersion}.{$minorVersion}", "Invalid major/minor version combination", RESPONSE_ERROR_CODE_BAD_REQUEST, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS);
     }
     if (defined("DB_NAME")) {
         global $wpdb;
         if (file_exists($writeableDir . "/membermouse_schema.sql")) {
             $phpObj = new MM_PhpObj($wpdb, DB_NAME);
             if (!$phpObj->importFile($writeableDir . "/membermouse_schema.sql", true)) {
                 return new Response($rest, "Could not update MemberMouse database", "Could not update MemberMouse database", RESPONSE_ERROR_CODE_BAD_REQUEST, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS);
             }
         }
     } else {
         return new Response($rest, "DB_NAME not defined", "DB_NAME not defined", RESPONSE_ERROR_CODE_BAD_REQUEST, RESPONSE_ERROR_MESSAGE_MISSING_PARAMS);
     }
     $version = $majorVersion;
     if (!empty($minorVersion)) {
         $version .= "-" . $minorVersion;
     }
     $versionRelease = MM_VersionRelease::findByVersion($version);
     $versionRelease->setVersion($version);
     $versionRelease->commitData();
     return new Response($rest);
 }
Example #2
0
<?php

$showContent = true;
$error = "";
if (isset($_GET["update"]) && $_GET["update"] == "true") {
    MM_MemberMouseService::authorize();
    $reportingDashboard = MM_ModuleUtils::getUrl(MM_MODULE_REPORTING);
    if (MM_MemberMouseService::hasPermission(MM_MemberMouseService::$FEATURE_REPORTING_SUITE) == MM_MemberMouseService::$ACTIVE) {
        ?>
			<h2 class="mm-dashboard-title">Congratulations! Advanced Reporting has been activated.</h2>
			
			<p style="line-height:30px;"><a href="<?php 
        echo $reportingDashboard;
        ?>
" class="mm-ui-button green">Go to Reporting Dashboard</a></p>
	<?php 
        $showContent = false;
    } else {
        $error = "Your license doesn't have access to the advanced reporting suite. Contact <a href='mailto:support@membermouse.com'>MemberMouse support</a> if you need assistance upgrading.";
    }
}
if ($showContent) {
    $getReportingUrl = MM_ModuleUtils::getUrl(MM_MODULE_GET_REPORTING);
    if (!empty($error)) {
        echo "<div class='error'><p>{$error}</p></div>";
    }
    ?>
<style>
#mm-upgrade-container { }
#mm-upgrade-content { padding-right:60px; }
#mm-upgrade-col-left { float: left; width: 700px; }
Example #3
0
<?php

/**
 *
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
if (isset($_REQUEST["mm-update-license"])) {
    MM_MemberMouseService::authorize(false);
}
$license = new MM_License();
$permissions = $license->getPermissions();
if (!empty($permissions)) {
    $permissions = "";
    $obj = json_decode($license->getPermissions());
    if ($obj) {
        foreach ($obj as $key => $value) {
            $permissions .= $key . ": " . $value . "<br/>";
        }
    } else {
        $permissions = $data->{$fieldName};
    }
}
?>
<div class="mm-wrap">
    <p class="mm-header-text">License</p>
	
	<form method="post">
		<input type="hidden" name="mm-update-license" value="1" />
		<input type='submit' value='Update License' class="mm-ui-button blue" />
	</form>
Example #4
0
 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();
 }
Example #5
0
 public static function load($className, $canRecurse = true)
 {
     if (!$canRecurse) {
         LogMe::write("Missing {$className} from cache");
         showLoadedClasses($className, "Eval Missing {$className} from cache");
     }
     /** only try to load MemberMouse classes **/
     if (strpos($className, "MM_") !== 0 && !preg_match("/LogMe/", $className)) {
         return false;
     }
     $exclusions = array("MemberMouse");
     if (in_array($className, $exclusions)) {
         return false;
     }
     /** end exclusions **/
     $classFileName = str_replace("MM_", "", $className);
     if (self::includeLimitedLocalFiles($className, $classFileName)) {
         return true;
     }
     $forceUseDBCache = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_FORCE_USE_DB_CACHE) == "1" ? true : false;
     if (isLocalInstall("localhost") && !$forceUseDBCache) {
         // look locally
         if (self::includeLocalFiles($className, $classFileName)) {
             return true;
         }
         if (class_exists($className, false) || interface_exists($className, false)) {
             return true;
         } else {
             if (self::includeCacheFiles($className, $classFileName)) {
                 return true;
             }
             /// get db class
             if (self::includeDBClass($className, $classFileName)) {
                 if ($classFileName != "MemberMouseService") {
                     MM_Session::value(MM_Session::$KEY_USING_DB_CACHE, true);
                 }
                 return true;
             }
         }
     } else {
         if (class_exists($className, false) || interface_exists($className, false)) {
             return true;
         } else {
             if (self::includeCacheFiles($className, $classFileName)) {
                 return true;
             }
             // get class from DB
             if (self::includeDBClass($className, $classFileName)) {
                 if ($classFileName != "MemberMouseService") {
                     MM_Session::value(MM_Session::$KEY_USING_DB_CACHE, true);
                 }
                 return true;
             }
         }
         // look locally
         if (self::includeLocalFiles($className, $classFileName)) {
             return true;
         }
     }
     //if execution gets here, then a needed class is unloadable, meaning its not in the cache or in the dbcache
     //reauth if we haven't already done so in the last 10 mins, and attempt to populate both
     $lastAuth = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_LAST_CODE_REFRESH);
     $minInterval = time() - 600;
     //(600 secs = 10 min)
     if ($canRecurse && class_exists("MM_MemberMouseService") && (empty($lastAuth) || $lastAuth <= $minInterval)) {
         $authSuccess = MM_MemberMouseService::authorize();
         MM_OptionUtils::setOption(MM_OptionUtils::$OPTION_KEY_LAST_CODE_REFRESH, time());
         if ($authSuccess) {
             return MM_ClassLoader::load($className, false);
             //this will break if the session doesnt work.. but then you have bigger problems...
         }
     }
     return false;
 }
Example #6
0
 public function authenticateWithMM()
 {
     if (class_exists("MM_MemberMouseService")) {
         return MM_MemberMouseService::authorize();
     }
     return false;
 }