예제 #1
0
 public static function sessionSetSessionLifespan($lifespan = null)
 {
     if ($lifespan !== null && is_numeric($lifespan)) {
         self::$MM_SESSION_LIFESPAN = $lifespan;
     } else {
         self::$MM_SESSION_LIFESPAN = self::$MM_DEFAULT_SESSION_LIFESPAN;
     }
 }
예제 #2
0
 function loginRedirect($redirectTo, $request, $user)
 {
     // clear login form session parameters
     MM_Session::clear(MM_Session::$KEY_LOGIN_FORM_USER_ID);
     MM_Session::clear(MM_Session::$KEY_LOGIN_FORM_USERNAME);
     $newRedirectTo = "";
     $allowUserOverride = true;
     if (class_exists("MM_CorePageEngine")) {
         if ($user instanceof WP_User && isset($user->data->ID) && intval($user->data->ID) > 0) {
             // check if this is an employee
             $employee = MM_Employee::findByUserId($user->data->ID);
             if ($employee->isValid()) {
                 MM_Preview::clearPreviewMode();
                 MM_Preview::getData();
                 $newRedirectTo = $employee->getHomepage();
             }
             if (empty($newRedirectTo)) {
                 $mmUser = new MM_User($user->data->ID);
                 if ($mmUser->getStatus() == MM_Status::$EXPIRED) {
                     $allowUserOverride = false;
                     $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_EXPIRED, $mmUser);
                     wp_logout();
                 } else {
                     if ($mmUser->getStatus() == MM_Status::$CANCELED) {
                         $allowUserOverride = false;
                         $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_CANCELED, $mmUser);
                         wp_logout();
                     } else {
                         if ($mmUser->getStatus() == MM_Status::$LOCKED) {
                             $allowUserOverride = false;
                             $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_LOCKED, $mmUser);
                             wp_logout();
                         } else {
                             if ($mmUser->getStatus() == MM_Status::$OVERDUE) {
                                 $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$MY_ACCOUNT, "", $mmUser);
                             } else {
                                 MM_Preview::clearPreviewMode();
                                 $setting = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_ON_LOGIN_USE_WP_FRONTPAGE);
                                 if ($setting == "1") {
                                     $newRedirectTo = MM_OptionUtils::getOption("siteurl");
                                 } else {
                                     $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$MEMBER_HOME_PAGE, "", $mmUser);
                                 }
                                 $lastAccessDeniedPageID = MM_Session::value(MM_OptionUtils::$OPTION_KEY_LAST_PAGE_DENIED);
                                 // check if current member has access to the last access denied page
                                 $pce = new MM_ProtectedContentEngine();
                                 if (intval($lastAccessDeniedPageID) > 0 && $pce->canAccessPost($lastAccessDeniedPageID, $mmUser->getId())) {
                                     $corePageEngine = new MM_CorePageEngine();
                                     if (!$corePageEngine->arePermalinksUsed()) {
                                         $newRedirectTo = get_page_link($lastAccessDeniedPageID);
                                     } else {
                                         $newRedirectTo = get_permalink($lastAccessDeniedPageID);
                                     }
                                 }
                                 MM_Session::clear(MM_OptionUtils::$OPTION_KEY_LAST_PAGE_DENIED);
                                 MM_ActivityLog::log($mmUser, MM_ActivityLog::$EVENT_TYPE_LOGIN);
                                 if ($mmUser->hasReachedMaxIPCount()) {
                                     global $current_user, $user;
                                     $mmUser->setStatus(MM_Status::$LOCKED);
                                     $mmUser->commitData();
                                     $newRedirectTo = MM_CorePageEngine::getUrl(MM_CorePageType::$ERROR, MM_Error::$ACCOUNT_LOCKED, $mmUser);
                                     wp_logout();
                                 }
                             }
                         }
                     }
                 }
                 if (empty($newRedirectTo)) {
                     $newRedirectTo = MM_OptionUtils::getOption("siteurl");
                 }
             }
         }
         // give customer an opportunity to redirect the user
         if ($allowUserOverride) {
             $currentUrl = !empty($newRedirectTo) ? $newRedirectTo : $redirectTo;
             $infoObj = new stdClass();
             $infoObj->currentUrl = $currentUrl;
             $infoObj->user = $user;
             $redirectOverride = apply_filters(MM_Filters::$LOGIN_REDIRECT, $infoObj);
             if (is_string($redirectOverride) && !empty($redirectOverride) && $redirectOverride != $currentUrl) {
                 if (!defined("DOING_AJAX") || !DOING_AJAX) {
                     wp_redirect($redirectOverride);
                     exit;
                 } else {
                     return $redirectOverride;
                 }
             }
         }
         if (!empty($newRedirectTo)) {
             return $newRedirectTo;
         }
         return $redirectTo;
     }
 }
예제 #3
0
<?php

if (!isset($_GET["file_path"]) && !isset($_GET["data"])) {
    exit;
}
$fileType = isset($_GET["file_type"]) ? $_GET["file_type"] : "text/php";
//data
if (isset($_GET["data"])) {
    $fileName = isset($_GET["filename"]) ? $_GET["filename"] : Date("Y-m-d") . ".txt";
    header("Content-type: " . $fileType);
    header("Content-Disposition: filename=" . $fileName);
    header("Pragma: no-cache");
    header("Expires: 0");
    echo MM_Session::value($_GET["data"]);
    exit;
}
//file path
$filePath = $_GET["file_path"];
if (!file_exists($filePath)) {
    exit;
}
$filePathArray = explode("/", $filePath);
$fileName = array_pop($filePathArray);
header("Content-type: " . $fileType);
header("Content-Disposition: filename=" . $fileName);
header("Pragma: no-cache");
header("Expires: 0");
echo file_get_contents($filePath);
exit;
예제 #4
0
파일: index.php 프로젝트: huynp/Critical
 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();
 }
예제 #5
0
파일: init.php 프로젝트: huynp/Critical
 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;
 }
예제 #6
0
        $csvRow[] = $user->getShippingZipCode();
        $csvRow[] = $user->getShippingCountryName();
        $fields = MM_CustomField::getCustomFieldsList();
        foreach ($fields as $id => $val) {
            $customField = new MM_CustomField($id);
            if ($customField->isValid()) {
                $csvRow[] = stripslashes($user->getCustomDataByFieldId($customField->getId())->getValue());
            }
        }
        $csvRows[] = $csvRow;
    }
}
// store CSV in session
if ($doGenerateCsv) {
    $csv = "";
    foreach ($csvRows as $row) {
        $csvRow = "";
        foreach ($row as $elem) {
            $csvRow .= "\"" . preg_replace("/[\"]+/", "", $elem) . "\",";
        }
        $csv .= preg_replace("/(\\,)\$/", "", $csvRow) . "\n";
    }
    MM_Session::value(MM_Session::$KEY_CSV, $csv);
}
$dataGrid->setHeaders($headers);
$dataGrid->setRows($datagridRows);
$dgHtml = $dataGrid->generateHtml();
if (empty($dgHtml)) {
    $dgHtml = "<p><i>No members found.</i></p>";
}
echo $dgHtml;