Example #1
0
 public function send($email)
 {
     try {
         $aParse['email'] = htmlspecialchars($email);
         UsersForgot::send($email);
     } catch (Exception $e) {
         CMSLog::addMessage('users', $e);
         if (!empty($_REQUEST['ajaxRequest'])) {
             $this->aParse['forgotFailed'] = true;
             $this->output('');
         } else {
             /**
              * @todo Избавиться от этой зависимости
              */
             $this->addAlert(\plugins\MessageDictionary\Plugin::getMessage('users.forgot.accountNotFound'));
             $this->jumpBack();
         }
     }
     if (!empty($_REQUEST['ajaxRequest'])) {
         $this->aParse['forgotSuccess'] = true;
         $this->output();
     } else {
         /**
          * @todo Избавиться от этой зависимости
          */
         $this->addAlert(\plugins\MessageDictionary\Plugin::getMessage('users.forgot.sent'));
         $this->jumpBack();
     }
 }
Example #2
0
 public static function getInstance()
 {
     if (!is_object(self::$instance)) {
         self::$instance = new CMSLog();
     }
     return self::$instance;
 }
Example #3
0
 protected function action()
 {
     $log = Log::getByName($this->getParam('name'));
     $log->critical->setValue(intval($this->getParam('priority')));
     $log->update();
     \CMSLog::addMessage(__CLASS__, sprintf('Log "%s" priority changed to - "%d"', $this->getParam('name'), $this->getParam('priority')));
     return true;
 }
Example #4
0
 protected function action()
 {
     $log = Log::getByName($this->getParam('name'));
     $log->obj_enable_logging->setValue(intval($this->getParam('enable_logging')));
     $log->update();
     \CMSLog::addMessage(__CLASS__, sprintf('Log `%s` logging updated. Logging set to - "%d" ', $this->getParam('name'), $this->getParam('enable_logging')));
     return true;
 }
Example #5
0
 protected function action()
 {
     $schema = CConfig::getSchema(Record::CriticalEmailSchemaName);
     $result = $schema->getControlByName('to');
     $result->setValue($this->getParam('notification_emails'));
     $register = new \SystemRegister(self::RegisterPath);
     $register->maximumLogLength = $this->getParam('maximumLogLength');
     \SystemRegisterSample::createCache();
     \CMSLog::addMessage(self::LogName, sprintf('Audit settings updated. New log length - "%s", Notification emails account - "%s"', $this->getParam('notification_emails'), $this->getParam('maximumLogLength')));
     return true;
 }
Example #6
0
 public static function detect()
 {
     self::loadConfig();
     if (!empty($_SERVER['REMOTE_ADDR'])) {
         self::$ip = $_SERVER['REMOTE_ADDR'];
         self::storeConnection();
         if (self::isLimitExceeded()) {
             \CMSLog::addMessage(__CLASS__, sprintf('DDOS attempt detected. Ip - "%s" ', self::$ip));
             die(self::$config['Message']);
         }
     }
 }
Example #7
0
 public static function quickRegister($user, $authPassed, $method = 'default')
 {
     if (!empty($_SERVER['REMOTE_ADDR'])) {
         $ip = $_SERVER['REMOTE_ADDR'];
         if ('::1' == $ip) {
             $ip = '127.0.0.1';
         }
     } else {
         $ip = '127.0.0.1';
     }
     $userId = !empty($user) ? $user->id->getValue() : 0;
     \Faid\DBSimple::insert(self::TableName, array('host' => ip2long($ip), 'date' => date('Y-m-d H:i:s'), 'user_id' => $userId, 'status' => !empty($authPassed) ? self::SuccessStatus : self::FailStatus, 'method' => $method));
     \CMSLog::addMessage(__CLASS__, sprintf('Login attemp into user with id="%d", operation status - %s', $userId, !empty($authPassed) ? 'success' : 'fail'));
 }
Example #8
0
 public static function send($email)
 {
     CMSLog::addMessage(self::LogName, sprintf('Email - "%s"', $email));
     self::validateLoginAttempts($email);
     //
     $aAccount = self::lookForEmail($email);
     //
     $schema = CConfig::getSchema(self::EmailConfigName);
     $values = $schema->getValues();
     //
     $szContent = UParser::parsePHPCode($values['request_content'], $aAccount);
     //
     Email_Controller::send($aAccount['email'], $values['request_subject'], $szContent);
     //
 }
Example #9
0
 protected static function storeExtraRecords()
 {
     \CMSLog::addMessage(__CLASS__, 'Cleaning log table');
     $found = DBSimple::select(Record::tableName, array(), sprintf('id desc limit %d,1', self::$maximumLogLength));
     if (empty($found)) {
         return;
     }
     $data = DBSimple::select(Record::tableName, '1', sprintf('id asc limit 0,%d', self::$maximumLogLength));
     if (!empty($data)) {
         $lastId = $data[sizeof($data) - 1]['id'];
         $fileName = sprintf('%s%s%s.log', SYS_ROOT, self::OutputDir, date('Y-m-d H:i:s'));
         file_put_contents($fileName, json_encode($data));
         DBSimple::delete(Record::tableName, array(sprintf('id <= %d', $lastId)));
         \CMSLog::addMessage(__CLASS__, 'Extra messages exported in local folder: ' . $fileName);
     }
 }
Example #10
0
 protected function loadConfigurationFile()
 {
     try {
         $sql = sprintf('truncate %s ', Job::TableName);
         DB::post($sql);
         $path = \Faid\Configure\Configure::read(self::ConfigureKey);
         $validator = new ReadableFile($path);
         if ($validator->isValid()) {
             include $path;
         }
         \CMSLog::addMessage(__CLASS__, 'Schedule restarted');
     } catch (\Exception $e) {
         \CMSLog::addMessage(__CLASS__, $e);
         return ['error' => 'internal error'];
     }
     return;
 }
Example #11
0
 protected function post($sitemapId)
 {
     $this->getModel($sitemapId);
     $this->checkUserHasEnoughRights();
     try {
         $result = $this->document->updateFromPost($_POST);
         if ($result == true) {
             // Если успешно, пишем всё ок
             $this->addAlert(_msg('Документ был успешно обновлен'));
         } else {
             // Если нет, пишем всё галимо
             $this->addAlert(_msg('Ошибки при обновлении документа, попробуйте позже'));
         }
         SitemapCMSForms::updateSitemapPageFromPost($this->aSitemap);
     } catch (SiteMapException $e) {
         CMSLog::addMessage('sitemap', $e);
         $this->addError('При обновлении документа произошла ошибка сохранения в базе документов');
     }
     // Показываем страницу
     $url = 'edit.php?id=' . $sitemapId;
     $this->jump($url);
 }
Example #12
0
 protected static function callEventListener($eventListener, $arguments)
 {
     if (!empty($eventListener['file'])) {
         self::loadFile($eventListener['class'], $eventListener['function'], $eventListener['file']);
     }
     if (!empty($eventListener['class'])) {
         $func = array($eventListener['class'], $eventListener['function']);
     } elseif (!empty($eventListener['function'])) {
         $func = $eventListener['function'];
     } else {
         throw new EventException('Don`t know how to call that event listener. Listener info:' . print_r($eventListener, true));
     }
     if (is_callable($func)) {
         $result = call_user_func_array($func, $arguments);
     } else {
         $errorMsg = sprintf('Event listener [%s] not callable ', is_array($func) ? $func[0] . ':' . $func[1] : $func);
         CMSLog::addMessage('events', $errorMsg);
         return null;
     }
     return $result;
 }
Example #13
0
 protected function action()
 {
     DBSimple::update(Record::tableName, array('viewed' => 1), array());
     \CMSLog::addMessage(__CLASS__, sprintf('All log records set as read'));
 }
Example #14
0
 protected static function loadGuestUserRights()
 {
     try {
         $actual = SimpleCache::isActual(self::CacheKey);
     } catch (SimpleCacheException $e) {
         $actual = false;
     }
     if (!$actual) {
         try {
             $user = UserAccount::getByLogin('guest');
             $result = self::extractUserGrants($user);
         } catch (Exception $e) {
             CMSLog::addMessage('acl', $e);
             $result = array();
         }
         SimpleCache::set(self::CacheKey, $result, self::CacheLifeTime);
     } else {
         $result = SimpleCache::get(self::CacheKey);
     }
     return $result;
 }
Example #15
0
 public function blockUser(\UserAccount $user)
 {
     \CMSLog::addMessage(self::LogName, sprintf('Users with login %s blocked ', $user->login->getValue()));
     $user->confirmation_code = \UsersRegistration::getConfirmationCode();
     $user->update();
 }
Example #16
0
 /**
  *
  * @param unknown $login
  * @param unknown $password
  * @param unknown $email
  *
  * @throws Exception
  */
 public function signup($login, $password, $email)
 {
     try {
         self::testCaptcha(isset($_POST['kcaptcha']) ? $_POST['kcaptcha'] : '');
         $userId = UsersRegistration::signup($login, $password, $email, $_POST);
         $user = \UserAccount::getById($userId);
         $avatar = $this->acceptFile('avatar');
         if (!empty($avatar)) {
             $user->avatar->copyFrom($avatar);
             $user->update();
             if (file_exists($avatar)) {
                 unlink($avatar);
             }
         }
         $this->jump('/signup/?success=1');
     } catch (Exception $e) {
         CMSLog::addMessage('registration', $e);
         $this->main($_POST, $e->getMessage());
     }
 }
Example #17
0
 /**
  *   -------------------------------------------------------------------------------------------
  *   Получает данные
  * @return
  *   -------------------------------------------------------------------------------------------
  */
 public function getData()
 {
     try {
         $this->aItem = Sitemap_PagesOperations::selectChildWithAdditional($this->nParent, $this->nPagingSize, intval($this->nPage) * $this->nPagingSize, $this->orderCondition);
         $this->nTotalCount = ceil(Sitemap_PagesOperations::$nTotalCount / $this->nPagingSize);
     } catch (Exception $e) {
         CMSLog::addMessage('data-list', $e);
         throw $e;
     }
     $this->aItem = $this->filterNotEditableDocuments($this->aItem);
     if (empty($this->aItem) && $this->nPage > 0) {
         $this->jump('index.php' . '?page=0');
     }
 }
Example #18
0
 public function __construct($message = '', $code = 0, $previous = null)
 {
     \CMSLog::addMessage(__CLASS__, $message);
     parent::__construct($message, $code, $previous = null);
 }
Example #19
0
 public function update($id)
 {
     $aData = $_POST;
     $user = new UserAccount();
     $found = $user->get($id);
     if (empty($found)) {
         throw new \Exception("User not found");
     }
     \CMSLog::addMessage(__CLASS__, sprintf('User account `%s` updated', $user->login->getValue()));
     // Вызов проверки форм
     $result = \EventController::callFilter('users_admin_profile_check', $aData);
     if ($result) {
         $user->updateFromPost($result);
     }
     $msg = sprintf(self::msgUpdatedSuccessfully, htmlspecialchars($user->login->getValue()));
     $this->goToEditPage($msg, $user->id->getValue());
 }
Example #20
0
 public static function regenerateGuestCache($user)
 {
     $isGuest = $user->login->getValue() == self::GuestUser;
     if ($isGuest) {
         $data = self::extractUserGrants($user);
         SimpleCache::set(self::CacheKey, $data, self::CacheLifeTime);
         \CMSLog::addMessage(__CLASS__, 'Guest user permissions regenerated');
     }
 }