protected function mail($subject, $content, $headers)
 {
     $subject = '=?' . CoreConfig::get('CoreDisplay', 'globalCharset') . '?B?' . base64_encode($subject) . '?=';
     if (!@mail('', $subject, $content, $headers)) {
         throw new CoreException('Sending mail failed!');
     }
 }
Example #2
0
 /**
  * Get instance
  * @return \Core\Config
  */
 public static function getInstance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #3
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #4
0
 static function instance()
 {
     if (self::$_instance == NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 public function sendHeaders()
 {
     header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
     header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
     header('Pragma: no-cache');
     header('Content-type: text/html; charset=' . strtolower(CoreConfig::get('CoreDisplay', 'globalCharset')));
 }
Example #6
0
 /**
  * getInstance()
  * Permet d'instancier la class Config
  */
 public static function getInstance($file)
 {
     if (self::$_instance === null) {
         self::$_instance = new Config($file);
     }
     return self::$_instance;
 }
Example #7
0
 public static function getInstance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new Config(ROOT . '/config/config.php');
     }
     return self::$_instance;
 }
Example #8
0
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 public function login($userName, $password, $errorMessageContainer = null)
 {
     $adminRequired = $this->isAdminRequired();
     $dao = $adminRequired ? new AdminDAO() : new UserDAO();
     $type = $adminRequired ? 'admin' : 'user';
     $record = $dao->getByNameAndPassword($userName, $password);
     $passwordOK = False;
     $accountBlocked = False;
     if ($record['id']) {
         $passwordOK = True;
     } else {
         $record = $dao->getByName($userName);
     }
     if ($record['id']) {
         $loginHistoryDAO = new CoreLoginHistoryDAO();
         $failedAttempts = $loginHistoryDAO->getRecentFailedLoginAttempts($type, $record['id']);
         if ($failedAttempts['num'] >= CoreConfig::get('Settings', $type . 'MaxLoginAttempts') && $failedAttempts['time'] > date('Y-m-d H:i:s', strtotime('-' . CoreConfig::get('Settings', $type . 'AccountBlockSeconds') . ' seconds'))) {
             $accountBlocked = True;
         } else {
             $this->updateLoginHistory($loginHistoryDAO, $type, $record['id'], $passwordOK);
         }
     }
     if ($passwordOK && !$accountBlocked) {
         $this->currentUser = $record;
         CoreServices::get('request')->setSession('currentUser', $record);
     } elseif (!empty($errorMessageContainer)) {
         $this->setLoginErrorMessage($errorMessageContainer, $type, $accountBlocked, $passwordOK);
     }
     return $passwordOK && !$accountBlocked;
 }
Example #10
0
 public static function Singleton()
 {
     if (self::$Instance == null) {
         $c = __CLASS__;
         self::$Instance = new $c();
     }
     return self::$Instance;
 }
Example #11
0
 public static function getInstance($file)
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new Config($file);
     } else {
     }
     return self::$_instance;
 }
Example #12
0
 public static function getInstance()
 {
     if (null === self::$_instance) {
         $config = CoreConfig::getInstance();
         self::$_instance = new self($config->get('dbhost'), $config->get('dbname'), $config->get('dbuser'), $config->get('dbpass'));
     }
     return self::$_instance;
 }
 public function adjustSubmittedValue($submittedValue)
 {
     if (!is_scalar($submittedValue)) {
         // assume hacking attempt
         return null;
     }
     return htmlspecialchars($submittedValue, ENT_QUOTES, CoreConfig::get('CoreDisplay', 'globalCharset'));
 }
Example #14
0
 static function removeNonSEF($non_sef)
 {
     $non_sef = trim($non_sef, " \t./\\");
     $db = CoreDBMysql::getInstance();
     $config = CoreConfig::getInstance();
     $urls_db_table = $config->get('urls_db_table');
     $query = "\n\t\t\tDELETE FROM `{$urls_db_table}` WHERE non_sef = '{$non_sef}'\n\t\t";
     $db->setQuery($query)->execute();
 }
 public function validate($messageManager)
 {
     $field = $this->form->getField($this->fieldName);
     $uploadStruct = $field->getValue();
     $allowedMimeTypes = CoreConfig::get('CoreFiles', 'allowedMimeTypes');
     if (!empty($uploadStruct) && (!in_array($uploadStruct['type'], $allowedMimeTypes['image']) || !CoreServices::get('images')->checkImageFileContent($uploadStruct['type'], $uploadStruct['tmp_name']))) {
         $messageManager->addMessage('fileTypeCheckFailed', array($this->fieldName => $field->getCaption()));
     }
 }
 protected function init()
 {
     $this->values['globalCharset'] = 'UTF-8';
     $this->values['htmlDocType'] = 'XHTML 1.0 Transitional';
     $this->values['paginationDefaultMaxRecords'] = 20;
     $this->values['paginationDefaultMaxPageLinks'] = 21;
     $this->values['paginationChars'] = array('universal' => CoreConfig::get('CoreLangs', 'allLocalCharVariants'));
     $this->values['paginationDummy'] = '?';
 }
Example #17
0
 /**
  * Return an instance of the config
  *
  * @return The config instance
  */
 protected static function getConfig()
 {
     // If the current config is null
     if (is_null(self::$config)) {
         // Loading it
         self::$config = (require 'config.php');
     }
     // Returning the loaded config
     return self::$config;
 }
 protected function reportError($message)
 {
     $from = CoreConfig::get('Environment', 'errorEmailSender');
     $listTo = array(CoreConfig::get('Environment', 'errorEmailRecipient'));
     $listCC = array();
     $lang = CoreConfig::get('CoreLangs', 'defaultLangCMS');
     $subject = CoreConfig::get('Environment', 'websiteName') . ' - ' . DictForCMS::get($lang, 'garbageCollectorFailure');
     $content = DictForCMS::get($lang, 'garbageCollectorFailure') . ":\n" . $message;
     CoreServices2::getMail()->sendPlainText($from, $listTo, $listCC, $subject, $content);
 }
Example #19
0
 /**
  * @param string $path 文件路径
  * @param array $name 文件名称
  */
 static function setConfig($path, $name)
 {
     foreach ($name as $nameValue) {
         $ConfigPath = $path . $nameValue . EXT;
         if (file_exists($ConfigPath)) {
             self::$Configs = array_merge(self::$Configs, require $ConfigPath);
         }
     }
     $GLOBALS['Config'] =& self::$Configs;
     return self::$Configs;
 }
 /**
  * Teoretycznie jest to odporne na thickboxy.
  */
 protected function checkHTTPS()
 {
     $httpsOn = CoreServices2::getUrl()->isHTTPSOn();
     $httpsRequired = CoreConfig::get('Environment', 'httpsForWebsite');
     if ($httpsRequired && !$httpsOn) {
         CoreUtils::redirect(CoreServices2::getUrl()->getCurrentExactAddress('https'));
     }
     if (!$httpsRequired && $httpsOn) {
         CoreUtils::redirect(CoreServices2::getUrl()->getCurrentExactAddress('http'));
     }
 }
Example #21
0
 static function getSEFPath($non_sef)
 {
     if (self::$sef_path !== false) {
         return self::$sef_path;
     }
     $db = CoreFactory::getDB();
     $config = CoreConfig::getInstance();
     $urls_db_table = $config->get('urls_db_table');
     $query = "\n\t\t\t\tSELECT sef FROM `{$urls_db_table}` WHERE non_sef = '{$non_sef}'\n\t\t\t";
     self::$sef_path = $db->setQuery($query)->getResult();
     return self::$sef_path;
 }
 public function validate($messageManager)
 {
     $field = $this->form->getField($this->fieldName);
     $value = $field->getOpenText();
     if (empty($value)) {
         return;
     }
     if (strlen($value) < 6 || !preg_match('/[a-zA-Z' . implode('', CoreConfig::get('CoreLangs', 'localCharsToLatinSource')) . ']/', $value) || !preg_match('/[0-9]/', $value)) {
         $messageManager->addMessage('newPasswordTooWeak', array($this->fieldName => $field->getCaption()));
         return;
     }
 }
 protected function initFeaturedItems()
 {
     $featuredRecords = $this->modelDAO->getFeaturedList(CoreConfig::get('Display', 'featuredModelsCount'));
     $this->featuredItemsList = array();
     foreach ($featuredRecords as $record) {
         $this->featuredItemsList[$record['id']] = $record;
     }
     if (!empty($this->featuredItemsList)) {
         $ids = array_keys($this->featuredItemsList);
         $this->featuredItemsImagesList = $this->fileDAO->getFirstImageListByRecordList('model', $ids, 'gallery');
     }
 }
 protected function sendPasswordRecoveryEmail(&$record)
 {
     $params = array('userRecord' => $record);
     $contentObj = new UserPasswordRecoveryEmailContent($params);
     $from = CoreConfig::get('Environment', 'passwordRecoveryEmailSender');
     $listTo = array($record['userEmail']);
     $listCC = array(CoreConfig::get('Environment', 'errorEmailRecipient'));
     $subject = $contentObj->getSubject();
     $content = $contentObj->getContent();
     $attachments = $contentObj->getAttachments();
     // CoreServices2::getMail()->sendHTML($from, $listTo, $listCC, $subject, $content, $attachments);
     CoreServices2::getMail()->sendPlainText($from, $listTo, $listCC, $subject, $content, $attachments);
 }
 public function initSession($sessionName, $sessionId = null)
 {
     $this->sessionNameSuffix = $sessionName;
     if ($this->sessionInitialized) {
         throw new CoreException('Tried to initialize session, but it was already initialized.');
     }
     $this->sessionInitialized = True;
     if (!empty($sessionId)) {
         session_id($sessionId);
     }
     session_name(CoreConfig::get('Environment', 'websiteName') . '_' . $this->sessionNameSuffix);
     session_start();
 }
 public function prepareData()
 {
     $this->checkHTTPS();
     $this->adminRoles = array_flip(CoreConfig::get('Data', 'adminRoles'));
     $this->currentUser = CoreServices::get('access')->getCurrentUserData();
     if (!$this->isControllerUsagePermitted()) {
         CoreUtils::redirect($this->getNoPermissionsAddress());
     }
     $this->initDAO();
     $this->initLayout();
     $this->initRecordList();
     $this->prepareAdditionalData();
 }
 public function __construct($host = '', $dbname = '', $user = '', $pass = '')
 {
     if (empty($dbname)) {
         $config = CoreConfig::getInstance();
         $host = $config->get('dbhost');
         $dbname = $config->get('dbname');
         $user = $config->get('dbuser');
         $pass = $config->get('dbpass');
     }
     $this->dbhost = $host;
     $this->dbname = $dbname;
     $this->user = $user;
     $this->pass = $pass;
 }
 public function get($serviceName)
 {
     switch ($serviceName) {
         case 'url':
             return new CoreUrlStandard();
             // return new CoreUrlFriendlyLinks1();
         // return new CoreUrlFriendlyLinks1();
         case 'request':
             return new CoreRequestStandard();
         case 'db':
             return new CoreDBMySQL(CoreConfig::get('Environment', 'dbHost'), CoreConfig::get('Environment', 'dbPort'), CoreConfig::get('Environment', 'dbUser'), CoreConfig::get('Environment', 'dbPassword'), CoreConfig::get('Environment', 'dbName'));
         case 'display':
             return new CoreDisplaySmarty();
         case 'lang':
             return new CoreLang();
         case 'access':
             return new CoreAccessVariant1();
         case 'modules':
             return new CoreControllerManager();
         case 'files':
             return new CoreFileManager();
             // @TODO: ?
             // case 'files1':
             //	return new CoreFileHushvizManager();
         // @TODO: ?
         // case 'files1':
         //	return new CoreFileHushvizManager();
         case 'images':
             return new CoreFileImageHandler();
         case 'attachmentLocationManager':
             return new FileHushvizUrlManager();
         case 'websiteMenuManager':
             return new SubpageUrlManager();
             // return new SubpageUrlManagerFriendlyLinks1();
         // return new SubpageUrlManagerFriendlyLinks1();
         case 'mail':
             return new CoreMailSimple();
         case 'paymentRelationLogic':
             return new CreditsPackagePaymentRelationLogic();
         case 'paymentProviderInterface':
             return new PayPal_EC();
             // return new PaymentDummy();
         // return new PaymentDummy();
         case 'errorHandler':
             return new CoreErrorHandler();
             //return new CoreErrorHandlerMail();
     }
     throw new CoreException('Service name not registered: \'' . $serviceName . '\'.');
 }
 public function adjustSubmittedValue($submittedValue)
 {
     if (!is_scalar($submittedValue)) {
         // assume hacking attempt
         //return '';
         return null;
     }
     $submittedValue = trim($submittedValue);
     if (empty($submittedValue)) {
         return null;
     }
     $submittedValue = htmlspecialchars($submittedValue, ENT_QUOTES, CoreConfig::get('CoreDisplay', 'globalCharset'));
     $submittedValue = str_replace("\n", '<br/>', $submittedValue);
     return $submittedValue;
 }
 public function adjustSubmittedValue($submittedValue)
 {
     if (!is_array($submittedValue)) {
         // assume hacking attempt
         return array();
     }
     $returnValue = array();
     foreach ($submittedValue as $simpleValue) {
         if (is_scalar($simpleValue)) {
             // else assume hacking attempt
             $returnValue[] = htmlspecialchars($simpleValue, ENT_QUOTES, CoreConfig::get('CoreDisplay', 'globalCharset'));
         }
     }
     return $returnValue;
 }