Esempio n. 1
0
 public function getDecodedData()
 {
     $sRaw = FlexiController::getInstance()->getRawPostContent();
     if (empty($sRaw)) {
         return "";
     }
     return FlexiCryptUtil::b64Decrypt($sRaw);
 }
Esempio n. 2
0
 /**
  * Do call to remote url
  * @param String $asURL
  * @param String $asModule
  * @param String $asMethod
  * @return boolean: true/false
  */
 public function callRemote($asURL = "http://localhost", $asModule = "", $asMethod = "")
 {
     FlexiLogger::debug(__METHOD__, "Calling URL: " . $asURL);
     $bDebug = false;
     $sURL = $asURL;
     $sModule = empty($asModule) ? "default" : $asModule;
     $sMethod = empty($asMethod) ? "default" : $asMethod;
     //$sURL = "temp/bloomberg-stocks.html";
     $aHeader = $this->getHeaders();
     $opts = array('http' => array('method' => "POST", 'header' => implode("\r\n", $aHeader), 'content' => $this->getRequestContent($sModule, $sMethod)));
     FlexiLogger::debug(__METHOD__, "Content: " . $opts["http"]["content"]);
     $context = stream_context_create($opts);
     FlexiLogger::debug(__METHOD__, "Processing URL: " . $sURL);
     $sResult = file_get_contents($sURL, false, $context);
     if ($sResult === false || empty($sResult)) {
         throw new Exception("Remote returned empty or false");
     }
     try {
         $this->mResult = FlexiCryptUtil::b64Decrypt($sResult, $this->sRemoteKey);
     } catch (Exception $e) {
         throw new Exception($e->getMessage() . "<br/>\nOriginal Remote result: " . $sResult);
     }
     //echo "<hr/>";
     if ($bDebug) {
         echo "\r\n" . __METHOD__ . ": " . $sResult . "<Br/>\r\n";
     }
     //var_dump($this->mResult);
     if (empty($this->mResult)) {
         throw new Exception("Unknown result: " . $sResult);
     }
     FlexiLogger::debug(__METHOD__, "Result raw: " . $this->mResult);
     $aResult = $this->getResult();
     if (empty($aResult)) {
         throw new Exception("Remote returned malformed result: " . $sResult);
     }
     return $aResult->status;
 }
Esempio n. 3
0
 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', '&amp;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);
     }
 }