示例#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;
     }
 }
示例#2
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) {
         $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;
     }
 }
示例#3
0
 /**
  * Called upon wordpress' shutdown hook.
  * Write session data that's currently stored in memory to database
  */
 public static function sessionWrite()
 {
     global $wpdb;
     if (self::$MM_SESSION_STARTED) {
         self::sessionSetTimestamp();
         //don't store passwords in the database
         if (self::value(self::$PARAM_USER_DATA_PASSWORD) !== false) {
             self::clear(MM_Session::$PARAM_USER_DATA_PASSWORD);
         }
         $wpdb->update(MM_TABLE_SESSIONS, array('data' => self::$MM_UNTRUSTED_PLATFORM ? base64_encode(serialize(self::$MM_SESSION_DATA)) : serialize(self::$MM_SESSION_DATA), 'ip_address' => MM_Utils::getClientIPAddress(), 'expiration_date' => self::getExpirationDate()), array('id' => self::getSessionId()));
     }
 }