Exemple #1
0
 /**
  * This method should be called at class load, and stores the mode, ip address, and creates a session identifier, so that these things only need to 
  * happen once within the life of the interpreter process
  */
 public static function init()
 {
     if (!self::$initialized) {
         $currentMode = class_exists("MM_OptionUtils") ? MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_SAFE_MODE) : "";
         self::$SAFE_MODE_STATUS = empty($currentMode) ? self::$MODE_DISABLED : $currentMode;
         if (self::$SAFE_MODE_STATUS !== self::$MODE_DISABLED) {
             self::$IP_ADDRESS = class_exists("MM_Utils") ? MM_Utils::getClientIPAddress() : "unknown";
             //the transaction key class logic for generating random identifiers is reused here, for convenience
             self::$SESSION = class_exists("MM_TransactionKey") ? MM_TransactionKey::createRandomIdentifier(8) : "unknown";
         }
         self::$initialized = true;
     }
 }
 /**
  * This method should be called at class load, and stores the mode, ip address, and creates a session identifier, so that these things only need to 
  * happen once within the life of the interpreter process
  */
 public static function init()
 {
     if (!self::$initialized) {
         $diagnosticMode = class_exists("MM_OptionUtils") ? MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_DIAGNOSTIC_MODE) : "";
         self::$DIAGNOSTIC_MODE = empty($diagnosticMode) ? self::$MODE_OFF : $diagnosticMode;
         if (self::$DIAGNOSTIC_MODE !== self::$MODE_OFF) {
             self::$IP_ADDRESS = class_exists("MM_Utils") ? MM_Utils::getClientIPAddress() : "unknown";
             //the transaction key class logic for generating random identifiers is reused here, for convenience
             self::$SESSION = class_exists("MM_TransactionKey") ? MM_TransactionKey::createRandomIdentifier(8) : "unknown";
         }
         self::$initialized = true;
     }
 }
Exemple #3
0
 /**
  *  Auto-login users on confirmation page, using a login token, or as a result of a social media login
  */
 public function doAutoLogin($userId = "", $redirectUrl = "")
 {
     if (!is_user_logged_in()) {
         if (empty($userId) || empty($redirectUrl)) {
             $userId = 0;
             $crntUrl = MM_Utils::constructPageUrl();
             $isConfirmationPage = MM_CorePageEngine::isConfirmationPageByUrl($crntUrl);
             if ($isConfirmationPage) {
                 // validate transaction key
                 $userId = 0;
                 if (isset($_REQUEST[MM_Session::$KEY_TRANSACTION_KEY])) {
                     $transRef = MM_TransactionKey::getTransactionByKey($_REQUEST[MM_Session::$KEY_TRANSACTION_KEY]);
                     $userId = $transRef->isValid() ? $transRef->getUserId() : 0;
                     $redirectUrl = MM_Utils::constructPageUrl();
                 }
                 // invalid transaction key
                 if ($userId == 0) {
                     $url = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCESS_DENIED);
                     wp_redirect($url);
                     exit;
                 }
             } else {
                 if (isset($_REQUEST[MM_Session::$PARAM_LOGIN_TOKEN])) {
                     $loginToken = MM_LoginToken::getLoginTokenByToken($_REQUEST[MM_Session::$PARAM_LOGIN_TOKEN]);
                     $userId = $loginToken->isValid() ? $loginToken->getUserId() : 0;
                     $redirectUrl = preg_replace("/" . MM_Session::$PARAM_LOGIN_TOKEN . "=[^&]*/", "", MM_Utils::constructPageUrl());
                 }
             }
         }
         if ($userId > 0) {
             $user = new MM_User($userId);
             if ($user->isValid() && ($user->getStatus() == MM_Status::$ACTIVE || $user->getStatus() == MM_Status::$PENDING_CANCELLATION || $user->getStatus() == MM_Status::$PAUSED || $user->getStatus() == MM_Status::$OVERDUE)) {
                 MM_ActivityLog::log($user, MM_ActivityLog::$EVENT_TYPE_LOGIN);
                 wp_set_auth_cookie($userId, true, MM_Utils::isSSL());
                 wp_set_current_user($userId);
                 wp_redirect($redirectUrl);
                 exit;
             }
         }
     }
 }
Exemple #4
0
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
require_once "../../../../wp-load.php";
require_once "../includes/mm-constants.php";
require_once "../includes/init.php";
// Send connection close to allow the caller to continue processing
// ----------------------------------------------------------------
MM_ConnectionUtils::closeConnectionAndContinueProcessing();
// Set operating parameters
// ----------------------------------------------------------------
$maxExecutionTime = 600;
//in seconds
$maxBatchSize = 100;
$expiredBatchTime = gmdate("Y-m-d H:i:s", strtotime("-{$maxExecutionTime} seconds", time()));
$batchIdentifier = MM_TransactionKey::createRandomIdentifier();
// Begin synchronization
// ----------------------------------------------------------------
set_time_limit($maxExecutionTime);
$queueEmpty = false;
$queTable = MM_TABLE_QUEUED_SCHEDULED_EVENTS;
$eventTable = MM_TABLE_SCHEDULED_EVENTS;
MM_DiagnosticLog::log(MM_DiagnosticLog::$MM_SUCCESS, "Beginning Scheduled Event Queue Synchronization at " . gmdate("Y-m-d H:i:s", time()));
try {
    do {
        $currentTime = gmdate("Y-m-d H:i:s", time());
        //make this call atomic
        $lockAcquired = $wpdb->get_var("SELECT COALESCE(GET_LOCK('synchronize_mm_scheduler',10),0)");
        if ($lockAcquired != "1") {
            throw new Exception("Scheduler sync: Could not acquire lock");
        }