public function run() { try { $this->oRequest = $this->_run(); $oRequest =& $this->oRequest; $this->sServiceModule = $oRequest->module; $this->sServiceMethod = $oRequest->method; $this->sServiceToken = $oRequest->token; FlexiLogger::info(__METHOD__, "Running service: " . $this->sServiceModule . "::" . $this->sServiceMethod); FlexiLogger::debug(__METHOD__, "Token: " . $this->sServiceToken); //throw new Exception("Token: " . $this->sServiceToken); //if ($this->sServiceMethod!="login") throw new Exception("Token: " . $this->sServiceToken); FlexiConfig::getLoginHandler()->doLoginByToken($this->sServiceToken); //if ($this->sServiceMethod!="login") throw new Exception("Logged in as: " . FlexiConfig::getLoginHandler()->getLoggedInUserId()); FlexiLogger::debug(__METHOD__, "Logged in as: " . FlexiConfig::getLoginHandler()->getLoggedInUserId()); $this->mRequestData = array(); if (isset($oRequest->data)) { $this->mRequestData = $oRequest->data; } $mResult = FlexiController::getInstance()->runService($this->sServiceModule, $this->sServiceMethod, $this->mRequestData); unset($mResult["control"]); FlexiLogger::debug(__METHOD__, "Done service: " . $this->sServiceModule . "::" . $this->sServiceMethod); echo $this->returnResult($mResult); } catch (Exception $e) { echo $this->returnResult(array("status" => false, "return" => null, "msg" => $e->getMessage())); } }
public function permission($sMethod) { return FlexiConfig::getLoginHandler()->isSuperUser(); // if (strtolower($sMethod) == "synctable") { // return FlexiConfig::getLoginHandler()->hasPermission($sTitle); // } }
function renderViews() { $this->oView->addVar("header", $this->renderView("header")); $this->oView->addVar("top", FlexiConfig::getLoginHandler()->getUserLanguage()); $this->oView->addVar("left", "left-"); $this->oView->addVar("right", "-right"); $this->oView->addVar("footer", "-footer-"); }
function renderViews() { if (FlexiConfig::$sFramework == "modx" || FlexiConfig::$sFramework == "modx2") { $this->oView->addVar("header", $this->renderView("header")); $this->oView->addVar("top", FlexiConfig::getLoginHandler()->getUserLanguage()); $this->oView->addVar("left", "left-"); $this->oView->addVar("right", "-right"); $this->oView->addVar("footer", "-footer-"); } if (!empty(FlexiConfig::$sFramework)) { $this->setLayout(""); } else { $this->oView->setTemplate(FlexiConfig::$sAdminTemplate); } }
public function permission($sTitle) { return FlexiConfig::getLoginHandler()->hasAccessToPolicy("settings"); //return FlexiConfig::getLoginHandler()->isSuperUser(); //return FlexiConfig::getLoginHandler()->hasPermission("admin"); }
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ //#login.form is the rendered html for login $aLoginForm = !isset($vars["#login.form"]) ? FlexiConfig::getLoginHandler()->getLoginForm() : $vars["#login.form"]; echo $this->renderMarkup($aLoginForm, "login_form");
/** * Get login handler for logged in user / guest user * @return FlexiLoginBaseHandler */ public function getLoginHandler() { return FlexiConfig::getLoginHandler(); }
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); } }
<? $aMessage = $vars["#message"]; if (count($aMessage) > 0) { ?> <div id="divNotice" class="flexiNotice"> <? foreach($aMessage as $aMsg) {?> <div class="notice<?php echo ucfirst(strtolower($aMsg["type"])); ?> "> <?php echo $aMsg["msg"]; ?> </div> <? } ?> </div> <? } ?> <? FlexiConfig::$bRenderedNotice = true; ?>
<?php global $aFlexiSetting; require_once $aFlexiSetting["basedir"] . "/lib/Doctrine/Doctrine.php"; if ($aFlexiSetting["doctrine"]) { spl_autoload_register(array('Doctrine', 'autoload')); } require_once $aFlexiSetting["basedir"] . "/base/Flexi/objectclass/FlexiConfig.php"; FlexiConfig::configure($aFlexiSetting); //include this file to integrate flexi controller require_once FlexiConfig::$sBaseDir . "/functions.php"; spl_autoload_register(array("FlexiConfig", "autoLoad")); require_once FlexiConfig::$sBaseDir . "/base/Flexi/controller.php"; FlexiController::$iLogLevel = FlexiConfig::$iLogLevel; //setting up DB Module $oFlexiModelUtil = FlexiModelUtil::getInstance(); $oFlexiModelUtil->setDBSetting(FlexiConfig::$sDBType, FlexiConfig::$sDBHost, FlexiConfig::$iDBPort, FlexiConfig::$sDBUser, FlexiConfig::$sDBPass, FlexiConfig::$sDBName); FlexiConfig::finalize(); //initialising main controller $oFlexi = FlexiController::getInstance();
/** * return multi-lingual text based on user language * @param String $sText * @param String $sType: normal, * first: ucfirst, * cap: all capital * @return String */ function flexiT($sText, $sType = "normal") { $sLang = FlexiConfig::getLoginHandler()->getUserLanguage(); $sPath = FlexiConfig::$sLanguagePath . "/" . $sLang . ".lang.php"; $sResult = ""; if (is_file($sPath)) { require $sPath; if (isset($aLanguage[$sText])) { $sResult = $aLanguage[$sText]; } else { if (isset($aLanguage[strtolower($sText)])) { $sResult = $aLanguage[strtolower($sText)]; } else { $sResult = $sText; } } } else { $sResult = $sText; } if ($sType == "first") { $sResult = ucfirst($sResult); } if ($sType == "cap") { $sResult = strtoupper($sResult); } if ($sType == "lower") { $sResult = strtolower($sResult); } return $sResult; }
/** * Set login handler * @param FlexiLoginBaseHandler */ public static function setLoginHandler(FlexiLoginBaseHandler $oLogin) { self::$oLoginHandler = $oLogin; }
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ ?> <div><?php echo flexiT("sorry, you do not have the needed credential to access this section", "first"); ?> .</div> <div><?php echo flexiT("have you logged in", "first"); ?> ?</div> <div><a href="<?php echo FlexiConfig::getLoginHandler()->getLoginURL(); ?> "><?php echo flexiT("please click here to login", "first"); ?> </a></div>
public function __destruct() { //if view is rendered, reset messages if (FlexiConfig::$bRenderedNotice && !empty(FlexiConfig::$aMessage)) { FlexiConfig::$aMessage = array(); } $this->setSession("#messages", FlexiConfig::$aMessage); }
public function checkPermission($sTitle) { if (!$this->hasAccessToContent($sTitle)) { FlexiLogger::error(__METHOD__, "Permission denied: " . get_class($this) . ":" . $sTitle); FlexiController::getInstance()->redirectURL(FlexiConfig::$sBaseURL . "?" . FlexiConfig::getRequestModuleVarName() . "=FlexiLogin&" . FlexiConfig::getRequestMethodVarName() . "=denied"); } FlexiPlatformHandler::getPlatformHandler()->forceDie(); }