public function Authenticate() { $Credentials = Input::getVar('Login', 'POST'); $Authentication = false; $this->setLanguageFile(); if (count($Credentials) == 2 && isset($Credentials['Email']) && isset($Credentials['Password'])) { if (Factory::getUser()->authenticate($Credentials['Email'], $Credentials['Password'], true)) { $Authentication = true; } } if ($Authentication) { Factory::getApplication()->redirectHome(); } else { SystemMessage::addMessage('COM_AUTHENTICATION', SystemMessage::MSG_ERROR, 'COM_LOGIN-FAILED'); if (isset($Credentials['Email'])) { Factory::getApplication()->redirect('Authentication/Login/', ['Login[Email]' => $Credentials['Email']]); } else { Factory::getApplication()->redirectLogin(); } } }
/** * @param $Element * @param $Type * @param $Message * @param bool|true $Language */ public static function addMessage($Element, $Type, $Message, $Language = true) { if ($Language) { $Message = Factory::getLanguage()->_($Message); } try { $Message = new SystemMessage(Factory::getDBH(), ['UserID' => Factory::getUser()->get('ID'), 'SessionID' => Factory::getSession()->getPHP_SessionID(), 'Element' => $Element, 'Message' => $Message, 'Type' => $Type, 'Viewed' => 0, 'RegisteredDate' => Utility::getDateForDB()], false); $Message->save(); } catch (PDOException $e) { Factory::getDBH()->catchException($e); } }
/** * @param PDOException $exception * @param null|string $SSQL * @return bool */ public static function catchException(PDOException $exception, $SSQL = null) { if (count($exception->errorInfo) == 3) { $DriverCode = $exception->errorInfo[1]; $DriverMessage = htmlentities($exception->errorInfo[2]); } else { $DriverCode = 'PDO_ENGINE'; $DriverMessage = htmlentities($exception->getMessage()); } Factory::getLogger()->warning('DBH Exception: DriverCode: {DriverCode} Message: {Message} File: {File} ({Line})', ['DriverCode' => $DriverCode, 'Message' => $DriverMessage, 'Line' => $exception->getLine(), 'File' => $exception->getFile()]); if ($SSQL) { array_push(self::$arErrorDebugSSQL, $SSQL); } if (self::inDebug()) { SystemMessage::addMessage('_DBH', 'alert', $DriverMessage, false); } return true; }
public function display() { if (!$this->Rendered) { $eApplication = Factory::getApplication(); $ContentType = $eApplication->get('ContentType'); $XHRequest = $eApplication->get('XHRequest'); $ContentType = strtolower($ContentType); if ($ContentType === 'text/html') { header('Content-type: text/html;'); if ($XHRequest) { $View = $this->get('DefaultXHRTemplate'); } else { $View = $this->get('DefaultTemplate'); } echo new View($this->getViewPath(), $View, null, ['SystemMessages' => SystemMessage::getMessages()]); } $this->Rendered = true; } }
private function checkNotNulls() { if ($this->objPDO->getAttribute(PDO::ATTR_ERRMODE) != PDO::ERRMODE_EXCEPTION) { foreach ($this->arModifiedFields as $Key => $V) { $NotNull = isset($this->arRules[$Key]) && is_array($this->arRules[$Key]) ? $this->arRules[$Key][1] : false; if ($NotNull && is_null($this->{$Key})) { $Message = "Field '{$Key}' can not be null"; if (!Debug::inDebug()) { SystemMessage::addMessage('_system', SystemMessage::MSG_WARNING, $Message, false); } throw new PDOException($Message); } } } }