public function getDecodedData() { $sRaw = FlexiController::getInstance()->getRawPostContent(); if (empty($sRaw)) { return ""; } return FlexiCryptUtil::b64Decrypt($sRaw); }
public static function getMode() { if (self::$sStreamMode == null) { $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MYCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); self::$sStreamMode = $iv; } return self::$sStreamMode; }
public static function getMediaURL($asPath, $sRole = "", $sName = "", $aParam = array()) { if (empty($asPath)) { return ""; } if ($asPath[0] != "/" && substr($asPath, 1, 2) != ":\\" && substr($asPath, 1, 2) != ":/") { $sTempPath = FlexiConfig::$sRootDir . "/" . $asPath; } else { $sTempPath = $asPath; } $sTempPath = str_replace("//", "/", $sTempPath); $sPath = realpath($sTempPath); if ($sPath === false) { throw new Exception("File missing: " . $sTempPath); } //echo "path: " . $sPath; //FlexiLogger::info(__METHOD__, "isadmin: " . (FlexiConfig::$bIsAdminPath? "yes": "no") . ": " . $sPath); $oControl = FlexiController::getCurrentController(); $sQuery = "r=" . $sRole . "&path=" . $sPath . "&name=" . $sName . (count($aParam) < 1 ? "" : "&" . http_build_query($aParam)); $sFilePath = FlexiCryptUtil::b64URLEncrypt($sQuery); $sURL = $oControl->url(array("p" => $sFilePath), "GetFile", "media", true); return $sURL; }
public function getLoginURL($sUserId = "", $sPassword = "", $aOptions = null) { $sURL = FlexiConfig::$sLoginURL; $sURL .= strpos($sURL, "?") !== false ? "&" : "?"; $sURL .= "username="******"error"]) ? "&error=" . $aOptions["error"] : ""; $bStandAlone = isset($aOptions["standalone"]) ? $aOptions["standalone"] : false; if ($bStandAlone) { $sURL .= "&standalone=1"; } if (!empty($aOptions["url"])) { $sURL .= "&refurl=" . FlexiCryptUtil::b64URLEncrypt($aOptions["url"]); } //echo ($bStandAlone) ? "standalone" : "full"; return flexiURL($sURL, $bStandAlone); }
public function methodLogin() { $sUserId = $this->getPost("txtLogin"); $sPassword = $this->getPost("txtPassword"); $sRedirect = $this->getRequest("refurl"); $iStandalone = $this->getRequest("standalone", 0); $sRemember = $this->getRequest("rememberme", false); $sContext = $this->getRequest("context", ""); if (FlexiConfig::$sFramework == "modx") { $sLoginMode = $this->getRequest("webloginmode"); if (!empty($sLoginMode)) { //logout of modx core... //so we redirect to main $this->setViewName("returnhome"); return false; } } //is logout if (FlexiConfig::$sFramework == "modx2") { if ($this->getRequest("service") == "logout") { $this->setViewName("returnhome"); return false; } } //FlexiLogger::info(__METHOD__, "Attemptng to login: "******", pwd: " . $sPassword); $sRedirect = empty($sRedirect) ? "" : FlexiCryptUtil::b64Decrypt($sRedirect); if (FlexiConfig::$sFramework == "modx2") { $sRedirect = str_replace(array('?service=logout', '&service=logout', '&service=logout'), '', $sRedirect); } $aOption = array("url" => $sRedirect); $aOption["standalone"] = $iStandalone == 1 ? true : false; $aOption["rememberme"] = empty($sRemember) ? false : true; $aOption["context"] = empty($sContext) ? null : $sContext; //die("url: " . $sRedirect); $oLogin = FlexiConfig::getLoginHandler(); if (!$oLogin->existsUser($sUserId)) { $sMessage = flexiT("Login fail", "first"); $this->addMessage($sMessage, "error"); $aOption["error"] = $sMessage; FlexiLogger::error(__METHOD__, $sMessage); $sURL = FlexiConfig::getLoginHandler()->getLoginURL($sUserId, $sPassword, $aOption); //return $this->redirectURL(FlexiPlatformHandler::getReferrerURL()); return $this->redirectURL($sURL); } //FlexiLogger::error(__METHOD__, "b4"); if (FlexiConfig::$bRequireEmailVerification && !$oLogin->getIsVerified($sUserId)) { $sMessage = flexiT("Sorry, please verify your email first", "first"); FlexiLogger::error(__METHOD__, $sMessage); $this->addMessage($sMessage, "error"); $this->addMessage("<a href='" . $this->url(array("txtLogin" => $sUserId), "resendVerify") . "'>Click here to resend your verification</a>", "error"); $aOption["error"] = 1; $sURL = FlexiConfig::getLoginHandler()->getLoginURL($sUserId, $sPassword, $aOption); //return $this->redirectURL(FlexiPlatformHandler::getReferrerURL()); return $this->redirectURL($sURL); } //FlexiLogger::error(__METHOD__, "after"); $bResult = $oLogin->doLogin($sUserId, $sPassword, $aOption); if ($bResult) { FlexiLogger::debug(__METHOD__, "login ok"); $this->oView->addVar("url", $sRedirect); return true; } else { $sMessage = flexiT("Login fail", "first"); FlexiLogger::error(__METHOD__, $sMessage); $this->addMessage($sMessage, "error"); $aOption["error"] = $sMessage; //die("redirect: " . $sRedirect); $sURL = FlexiConfig::getLoginHandler()->getLoginURL($sUserId, $sPassword, $aOption); //return $this->redirectURL(FlexiPlatformHandler::getReferrerURL()); return $this->redirectURL($sURL); } }
/** * convert data to remote call data * @param Mixed $mData * @return String */ public function _prepareContent($amData) { $mData = $this->prepareContent($amData); //echo "sending: " . $mData; //encrypt data before sending return FlexiCryptUtil::b64Encrypt($mData, $this->sRemoteKey); }