function write()
 {
     global $current_user;
     /* @var $current_user CurrentUser */
     $mask = array('user_id' => 'int', 'hash' => array('type' => 'string', 'regexp' => '/^[A-Za-z0-9]+$/', 'min_length' => 32, 'max_length' => 32));
     $params = Request::checkParameters(Request::getAllParameters(), $mask);
     // проверяем, есть ли в базе неподтвержденный юзер с таким хешем
     $query = 'SELECT * FROM `users` WHERE `id`=' . (int) $params['user_id'];
     $res = Database::sql2row($query);
     if (!$res || $res['hash'] != $params['hash']) {
         if ($res['hash'] != '') {
             $this->setWriteParameter('emailconfirm_module', 'error', 'Неправильный код подтверждения.');
         } else {
             if ($res['id']) {
                 $this->setWriteParameter('emailconfirm_module', 'error', 'Почта пользователя уже подтверждена');
             } else {
                 $this->setWriteParameter('emailconfirm_module', 'error', 'Такого пользователя не существует');
             }
         }
     } else {
         // ура! авторизуем пользователя
         $current_user->load($res);
         $current_user->setRole(User::ROLE_READER_CONFIRMED);
         $current_user->authorized = true;
         $current_user->onLogin();
         $current_user->save();
         // затираем ему хеш и меняем роль на авторизованного пользователя
         $this->setWriteParameter('emailconfirm_module', 'success', 1);
     }
 }
Example #2
0
 function checkCacheSettings()
 {
     global $current_user;
     // только если это чужой миниблок
     if (Request::$pageName == 'user') {
         $id = Request::get(0, false);
         if ($id != $current_user->id) {
             $this->cache_enabled = true;
         }
     }
     if (isset($this->settings['cache']) && $this->settings['cache'] || isset($this->props['params']['cache']) && $this->props['params']['cache']) {
         $this->xml_cache_name = Request::$pageName . '_' . $this->moduleName . '_' . implode('', Request::getAllParameters());
         if (isset($this->settings['xHTML']) && $this->settings['xHTML']) {
             if (Request::$responseType == 'xsl' || Request::$responseType == 'xml') {
                 // при просмотре xml и xslt отрубаем кеширование
                 $this->cache_enabled = false;
                 $this->xHTMLCachingEnabled = false;
             } else {
                 $this->xHTMLCachingEnabled = true;
             }
         }
     }
     return $this->cache_enabled;
 }
Example #3
0
 protected function checkCacheSettings()
 {
     if (isset($this->settings['cache']) && $this->settings['cache'] || isset($this->props['params']['cache']) && $this->props['params']['cache']) {
         $this->xml_cache_name = Request::$pageName . '_' . $this->moduleName . '_' . implode('', Request::getAllParameters());
         $this->cache_enabled = true;
         if (isset($this->settings['xHTML']) && $this->settings['xHTML']) {
             if (Request::$responseType == 'xsl' || Request::$responseType == 'xml') {
                 // при просмотре xml и xslt отрубаем кеширование
                 $this->cache_enabled = false;
                 $this->xHTMLCachingEnabled = false;
             } else {
                 $this->xHTMLCachingEnabled = true;
             }
         }
     }
     return $this->cache_enabled;
 }
Example #4
0
 function processParams()
 {
     $mask = array('id' => 'int', 'action' => array('type' => 'string', '*' => true));
     $params = Request::checkParameters(Request::getAllParameters(), $mask);
     return $params;
 }
Example #5
0
	protected function checkCacheSettings() {
		if ((isset($this->settings['cache']) && $this->settings['cache']) || (isset($this->props['params']['cache']) && $this->props['params']['cache'] )) {
			$this->xml_cache_name = Request::$pageName . '_' . $this->moduleName . '_' . (implode('', Request::getAllParameters()));
			$this->cache_enabled = true;
		}
		return $this->cache_enabled;
	}
Example #6
0
 function generateData()
 {
     $requested_uri = $_SERVER['REQUEST_URI'];
     $this->data['requested_uri'] = '/' . Request::$pageName . '/' . implode('/', Request::getAllParameters());
 }