Esempio n. 1
0
 /**
  * Logs with an arbitrary level.
  *
  * @param mixed  $level
  * @param string $message
  * @param array  $context
  * @return null
  */
 public function log($level, $message, array $context = [])
 {
     $message = $this->interpolateMessage($message, $context);
     if (Config::APP_DEBUG) {
         echo $message, PHP_EOL;
     }
     if ($level == LogLevel::EMERGENCY || $level == LogLevel::ALERT || !Factory::getDBH()) {
         if (is_writeable('error_log')) {
             $handle = fopen('error_log', 'a');
             fwrite($handle, $message . PHP_EOL);
             fclose($handle);
         }
         exit;
     } else {
         array_push($this->logs, ['UserID' => Factory::getUser()->get('ID'), 'SessionID' => Factory::getSession()->getPHP_SessionID(), 'ApplicationID' => Factory::getApplication()->getApplicationID(), 'Level' => $level, 'ErrorString' => $message, 'RegisteredDate' => Utility::getDateForDB()]);
     }
 }
Esempio n. 2
0
 protected function setInSession()
 {
     if (!Config::APP_DEBUG) {
         $Language = [];
         $Language['arImportedFiles'] = $this->arImportedFiles;
         $Language['arStrings'] = $this->arStrings;
         Factory::getSession()->set('Language', $Language);
     }
 }
Esempio n. 3
0
 /**
  * @param $Element
  * @return bool
  */
 public static function assignMessages($Element)
 {
     if (!isset(self::$arSystemMessagesElement[$Element])) {
         $dbh = Factory::getDBH();
         $stmt = $dbh->prepare("SELECT SystemMessageID,Type,Message FROM SystemMessage WHERE (Element = :Element OR Element = '_system' OR Element = '_DBH') AND (UserID = :UserID OR SessionID = :SessionID) AND Viewed = 0");
         try {
             $stmt->bindValue(':Element', $Element, PDO::PARAM_STR);
             $stmt->bindValue(':UserID', Factory::getUser()->get('ID'), PDO::PARAM_INT);
             $stmt->bindValue(':SessionID', Factory::getSession()->getPHP_SessionID());
             $stmt->execute();
             foreach ($stmt->fetchAll(PDO::FETCH_OBJ) as $Message) {
                 array_push(self::$arSystemMessages, new SystemMessage($dbh, $Message));
             }
             self::$arSystemMessagesElement[$Element] = true;
             return true;
         } catch (PDOException $e) {
             Factory::getDBH()->catchException($e, $stmt->queryString);
         }
     }
     return false;
 }
Esempio n. 4
0
 /**
  * destroy the current session
  */
 public function logOut()
 {
     Factory::getSession()->_session_destroy_method();
 }