Example #1
0
 protected function __construct()
 {
     $this->oMailer = new PHPMailer(true);
     //New instance, with exceptions enabled
     $mail =& $this->oMailer;
     $mail->WordWrap = 80;
     if (FlexiConfig::$sMailer == "smtp") {
         $mail->IsSMTP();
         // tell the class to use SMTP
         $mail->SMTPAuth = true;
         // enable SMTP authentication
         $mail->Port = FlexiConfig::$sMailerPort;
         // set the SMTP server port
         $mail->Host = FlexiConfig::$sMailerHost;
         // SMTP server
         $mail->Username = FlexiConfig::$sMailerUserId;
         // SMTP server username
         $mail->Password = FlexiConfig::$sMailerPassword;
         // SMTP server password
     } else {
         if (FlexiConfig::$sMailer == "sendmail") {
             $mail->IsSendmail();
             // tell the class to use Sendmail
         } else {
             if (FlexiConfig::$sMailer == "mail") {
                 $mail->IsMail();
                 // tell the class to use Sendmail
             } else {
                 if (FlexiConfig::$sMailer == "qmail") {
                     $mail->IsQmail();
                 } else {
                     throw new FlexiException(flexiT("Unknown mailer type") . ": " . FlexiConfig::$sMailer, ERROR_UNKNOWNTYPE);
                 }
             }
         }
     }
     $this->setFrom(FlexiConfig::$sSupportEmail);
 }
 public function getLoginForm($aRow = null, $bReload = false)
 {
     if ($this->aLoginForm != null) {
         return $this->aLoginForm;
     }
     if (!empty($aRow["error"])) {
         FlexiPlatformHandler::getPlatformHandler()->addMessage($aRow["error"], "error");
     }
     $iSize = 25;
     $this->aLoginForm = $aForm = array("txtLogin" => array("#type" => "textfield", "#title" => flexiT("User-Id", "first"), "#weight" => 5, "#maxlength" => 100, "#required" => true, "#size" => $iSize, "#default_value" => ""), "txtPassword" => array("#type" => "password", "#title" => flexiT("Password", "first"), "#weight" => 7, "#maxlength" => 50, "#required" => true, "#size" => $iSize, "#default_value" => ""), "txtURL" => array("#type" => "hidden", "#default_value" => FlexiConfig::$sBaseURL), "bSubmit" => array("#type" => "submit", "#value" => flexiT("Login", "first"), "#weight" => 57));
     //fill in form value
     FlexiFormUtil::mergeFormWithData($aForm, $aRow);
     $aTheForm = array_merge($aForm, array("#type" => "form", "#upload" => false, "#method" => "post", "#action" => flexiURL("mod=FlexiLogin&method=login")));
     $aTheLoginForm = array("#type" => "div", "#title" => flexiUCFirstT("login form"), "form" => $aTheForm, "#attributes" => array("class" => "flexiphp_login_div"));
     //todo event for form before output
     $this->aLoginForm = $aTheLoginForm;
     return $this->aLoginForm;
 }
Example #3
0
 /**
  * validate a form value populated by $_REQUEST
  * @param array $aForm merged with request value
  * @return boolean 
  */
 public function validateForm(&$aForm)
 {
     $bOK = true;
     foreach ($aForm as $sKey => &$mValue) {
         FlexiLogger::debug(__METHOD__, "validating: " . $sKey . ",val: " . @$mValue["#value"]);
         //is a form field, and is not already set value
         if ($sKey[0] != "#") {
             $bRequired = isset($mValue["#required"]) ? $mValue["#required"] : false;
             //echo $sKey. "\r\n<br>";
             if ($bRequired && (!isset($mValue["#value"]) || isset($mValue["#value"]) && strlen($mValue["#value"]) == 0)) {
                 //echo "is empty!";
                 //var_dump($mValue["#value"]);
                 FlexiLogger::debug(__METHOD__, "validating: " . $sKey . ", is empty");
                 if (!isset($mValue["#notice"])) {
                     $mValue["#notice"] = array("msg" => "");
                 }
                 $mValue["#notice"]["msg"] .= flexiT("field is required") . "\r\n<br/>";
                 $bOK = false;
             }
             if ($mValue["#type"] == "email" && !empty($mValue["#value"])) {
                 $bValid = FlexiStringUtil::isValidEmail($mValue["#value"]);
                 if (!$bValid) {
                     $bOK = false;
                     if (!isset($mValue["#notice"])) {
                         $mValue["#notice"] = array("msg" => "");
                     }
                     //echo "invalid email";
                     FlexiLogger::debug(__METHOD__, "validating: " . $sKey . ", invalid email");
                     $mValue["#notice"]["msg"] .= flexiT("field must be an email") . "\r\n<br/>";
                 }
             }
         }
     }
     return $bOK;
 }
Example #4
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);
     }
 }
Example #5
0
<?php

/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<h3>Account Verification</h3>
<?
if ($vars["verified"]) {
?>
<?php 
echo flexiT("Thank you", "first");
?>
.<br/>
<?php 
echo flexiT("You account has been verified", "first");
?>
.<br/>
<a href=""><?php 
echo flexiT("Please click here to login", "first");
?>
</a>...
<? } else { ?>
<?php 
echo flexiT("Sorry, invalid verification request", "first");
?>
!<br/>
<?
}
?>
Example #6
0
function flexiUCFirstT($sText)
{
    return ucfirst(flexiT($sText));
}
Example #7
0
 /**
  * Validate file upload
  * @param String $sFormName
  * @param int $iMaxUploadSize in bytes
  * @param String $sAllowedExtension, comma separated supported file
  * @return <type>
  */
 public static function validateFileUpload($sFormName, $aiMaxUploadSize = null, $sAllowedExtension = null)
 {
     $iMaxUploadSize = $aiMaxUploadSize;
     if (is_null($iMaxUploadSize) && (FlexiConfig::$sFramework == "modx" || FlexiConfig::$sFramework == "modx2")) {
         global $modx;
         $iMaxUploadSize = $modx->config["upload_maxsize"];
     }
     $bUploadErr = false;
     $iSize = self::getUploadedFileSize($sFormName);
     if (!empty($iMaxUploadSize) && $iSize > $iMaxUploadSize) {
         $sNotice = flexiT("File Upload exceed permitted size", "first") . ": " . $iSize . " / " . $iMaxUploadSize;
         return array("status" => false, "msg" => $sNotice);
     }
     $sExtension = strtolower(trim(FlexiFileUtil::getUploadedFileExtension($sFormName)));
     if (!empty($sAllowedExtension)) {
         $sAllowed = "";
         switch ($sAllowedExtension) {
             case "image":
             case "media":
                 $sAllowed = "jpg,jpeg,png,gif";
             case "video":
             case "media":
                 $sAllowed .= "mp4,wma,avi,mpeg,mov,flv";
             case "sound":
             case "media":
                 $sAllowed .= "mp3,wav";
         }
         $sAllowed = empty($sAllowed) ? $sAllowedExtension : $sAllowed;
         $aAllowed = explode(",", $sAllowed);
         if (!in_array($sExtension, $aAllowed)) {
             $sNotice = flexiT("Only of type", "first") . ": jpeg or png " . flexiT("are permitted") . ", " . flexiT("you have uploaded") . ": " . $sExtension;
             return array("status" => false, "msg" => $sNotice);
         }
         //if not in allowed extension
     }
     //allowed extension is set
     return array("status" => true, "msg" => "");
 }
Example #8
0
<?php

/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<div><?php 
echo flexiT("sorry, you have no access to this section", "first");
?>
.</div>
<div><a href=""><?php 
echo flexiT("please click here to login", "first");
?>
</a></div>
Example #9
0
<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$status = (int)$vars["status"];

if ($status == 1) {
?>
  <?=flexiT("No such user", "first")?>
<? } elseif($status==2) { ?>
  <?=flexiT("Verification e-mail resent","first")?>
<? } elseif($status==3) { ?>
  <?=flexiT("E-mail is missing","first")?>
<?
}
?>

<div>
  <a href=""><?=flexiT("Click here to return","first") ?></a>
</div>
Example #10
0
 public function doFlexiAdminLogin($asUserId, $asPassword)
 {
     if (empty(FlexiConfig::$sAdminUserId) || empty(FlexiConfig::$sAdminPassword)) {
         throw new FlexiException(flexiT("Admin login configuration not set", "first"), ERROR_CONFIGURATION);
     }
     if ($asUserId == FlexiConfig::$sAdminUserId && $asPassword == FlexiConfig::$sAdminPassword) {
         FlexiController::getInstance()->setSession("flexi.userid", FlexiConfig::$iAdminId);
         $this->doForceLogin(FlexiConfig::$iAdminId);
         return true;
     }
     return false;
 }
Example #11
0
 public static function processUpload($sFieldName, $sSavePath, $aExtension, $sSaveName, $aiMaxUpload = null, $bReplace = true, $sOldPath = null)
 {
     $iMaxUpload = self::getMaxUploadFileSize($aiMaxUpload);
     if (FlexiFileUtil::getIsUploaded($sFieldName)) {
         $iSize = FlexiFileUtil::getUploadedFileSize($sFieldName);
         if ($iSize > $iMaxUpload) {
             $sNotice = flexiT("File Upload exceed permitted size", "first") . ": " . $iSize . " / " . $iMaxUpload;
             throw new FlexiException($sNotice, ERROR_FILESIZE);
         }
         $sExtension = strtolower(trim(FlexiFileUtil::getUploadedFileExtension($sFieldName)));
         if (!in_array($sExtension, $aExtension)) {
             $sNotice = flexiT("File type not permitted", "first") . ", " . flexiT("you have uploaded") . ": " . $sExtension;
             throw new FlexiException($sNotice, ERROR_FILETYPE);
         }
         //replace photo if already exists
         if ($bReplace && !empty($sOldPath)) {
             //fix windows path issue
             $sOldFile = substr($sOldPath, 0, 1) == "/" || substr($sOldPath, 1, 2) == ":\\" ? $sOldPath : FlexiFileUtil::getBasePath() . "/" . $sOldPath;
             @unlink($sOldFile);
         }
         $aStatus = FlexiFileUtil::doUploadFile($sFieldName, $sSavePath, $sSaveName . ".");
         //
         return $aStatus;
     }
     //is upload
     return false;
 }
Example #12
0
<h3><?php 
echo flexiT("Error", "first");
?>
 404</h3>
<div><?php 
echo flexiT("sorry, path " . $vars["path"] . " file not found", "first");
?>
.</div>
<div><?php 
echo flexiT("please contact site administrator", "first");
?>
</div>
<div><a href=""><?php 
echo flexiT("Click here to return", "first");
?>
</a></div>