public function EventDownloadFile() { $this->SetTemplate(false); $sTopicId = $this->GetParam(0); $sFieldId = $this->GetParam(1); E::ModuleSecurity()->ValidateSendForm(); if (!($oTopic = E::ModuleTopic()->GetTopicById($sTopicId))) { return parent::EventNotFound(); } if (!($this->oType = E::ModuleTopic()->GetContentType($oTopic->getType()))) { return parent::EventNotFound(); } if (!($oField = E::ModuleTopic()->GetContentFieldById($sFieldId))) { return parent::EventNotFound(); } if ($oField->getContentId() != $this->oType->getContentId()) { return parent::EventNotFound(); } //получаем объект файла $oFile = $oTopic->getFieldFile($oField->getFieldId()); //получаем объект поля топика, содержащий данные о файле $oValue = $oTopic->getField($oField->getFieldId()); if ($oFile && $oValue) { if (preg_match("/^(http:\\/\\/)/i", $oFile->getFileUrl())) { $sFullPath = $oFile->getFileUrl(); R::Location($sFullPath); } else { $sFullPath = Config::Get('path.root.dir') . $oFile->getFileUrl(); } $sFilename = $oFile->getFileName(); /* * Обновляем данные */ $aFileObj = array(); $aFileObj['file_name'] = $oFile->getFileName(); $aFileObj['file_url'] = $oFile->getFileUrl(); $aFileObj['file_size'] = $oFile->getFileSize(); $aFileObj['file_extension'] = $oFile->getFileExtension(); $aFileObj['file_downloads'] = $oFile->getFileDownloads() + 1; $sText = serialize($aFileObj); $oValue->setValue($sText); $oValue->setValueSource($sText); //сохраняем E::ModuleTopic()->UpdateContentFieldValue($oValue); /* * Отдаем файл */ header('Content-type: ' . $oFile->getFileExtension()); header('Content-Disposition: attachment; filename="' . $sFilename . '"'); F::File_PrintChunked($sFullPath); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('content_download_file_error')); return R::Action('error'); } }
/** * Инициализация * */ public function Init() { // * Проверяем авторизован ли юзер if (!E::ModuleUser()->IsAuthorization()) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('not_access'), E::ModuleLang()->Get('error')); return R::Action('error'); } // * Получаем текущего юзера $this->oUserCurrent = E::ModuleUser()->GetUserCurrent(); $this->SetDefaultEvent('profile'); // * Устанавливаем title страницы E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('settings_menu')); }
public function EventEsTheme() { if (!E::User() || !C::Get('plugin.estheme.use_client')) { return R::Action('error'); } $aProcessData = $this->PluginEstheme_Estheme_GetProcessData(); if (getRequest('submit_estheme')) { $sCSSDownloadPath = F::File_Dir2Url(C::Get('plugin.estheme.path_for_download') . E::UserId() . '/theme.custom.css'); $aCompiledData = $this->_processConfig($aProcessData, TRUE); $this->PluginEstheme_Estheme_CompileTheme($aCompiledData, TRUE); } else { $sCSSDownloadPath = FALSE; $this->_processConfig($aProcessData, FALSE); } E::ModuleViewer()->Assign('sCSSDownloadPath', $sCSSDownloadPath); }
/** * Обработка хука инициализации экшенов */ public function InitAction() { // * Проверяем наличие директории install if (is_dir(rtrim(Config::Get('path.root.dir'), '/') . '/install') && (!isset($_SERVER['HTTP_APP_ENV']) || $_SERVER['HTTP_APP_ENV'] != 'test')) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('install_directory_exists')); R::Action('error'); } // * Проверка на закрытый режим $oUserCurrent = E::ModuleUser()->GetUserCurrent(); if (!$oUserCurrent && Config::Get('general.close.mode')) { $aEnabledActions = F::Str2Array(Config::Get('general.close.actions')); if (!in_array(R::GetAction(), $aEnabledActions)) { return R::Action('login'); } } return null; }
/** * Default homepage * * @return string */ public function EventDefault() { E::ModuleViewer()->Assign('sMenuHeadItemSelect', 'homepage'); $sHomepage = Config::Get('router.config.homepage'); if ($sHomepage) { $sHomepageSelect = Config::Get('router.config.homepage_select'); if ($sHomepageSelect == 'page') { // if page not active or deleted then this homepage is off $oPage = E::ModulePage()->GetPageByUrlFull($sHomepage, 1); if ($oPage) { $sHomepage = $oPage->getUrlPath(); } else { $sHomepage = ''; } } else { if ($sHomepageSelect == 'category_homepage') { $sHomepageSelect = 'plugin-category-homepage'; } $aHomePageSelect = explode('-', $sHomepageSelect); // if homepage was from plugin and plugin is not active then this homepage is off if ($aHomePageSelect[0] == 'plugin' && isset($aHomePageSelect[1])) { if (!E::ActivePlugin($aHomePageSelect[1])) { $sHomepage = ''; } } } if ($sHomepage == 'home') { if (E::ModuleViewer()->TemplateExists('actions/homepage/action.homepage.index.tpl')) { $this->SetTemplateAction('index'); return; } } elseif ($sHomepage) { return R::Action($sHomepage); } } return R::Action('index'); }
protected function _eventRecovery($bAjax = false) { if ($this->IsPost()) { // Was POST request $sEmail = F::GetRequestStr('mail'); // Пользователь с таким емайлом существует? if ($sEmail && F::CheckVal($sEmail, 'mail')) { if ($this->_eventRecoveryRequest($sEmail)) { if (!$bAjax) { E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('password_reminder_send_link')); } return; } } E::ModuleMessage()->AddError(E::ModuleLang()->Get('password_reminder_bad_email'), E::ModuleLang()->Get('error')); } elseif ($sRecoveryCode = $this->GetParam(0)) { // Was recovery code in GET if (F::CheckVal($sRecoveryCode, 'md5')) { // Проверка кода подтверждения if ($this->_eventRecoverySend($sRecoveryCode)) { return null; } E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('password_reminder_bad_code_txt'), E::ModuleLang()->Get('password_reminder_bad_code')); if (!$bAjax) { return R::Action('error'); } return; } } }
/** * Страница создания письма */ protected function EventAdd() { $this->sMenuSubItemSelect = 'add'; E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('talk_menu_inbox_create')); // * Получаем список друзей $aUsersFriend = E::ModuleUser()->GetUsersFriend($this->oUserCurrent->getId()); if ($aUsersFriend['collection']) { E::ModuleViewer()->Assign('aUsersFriend', $aUsersFriend['collection']); } // * Проверяем отправлена ли форма с данными if (!F::isPost('submit_talk_add')) { return false; } // * Проверка корректности полей формы if (!$this->checkTalkFields()) { return false; } // * Проверяем разрешено ли отправлять инбокс по времени if (!E::ModuleACL()->CanSendTalkTime($this->oUserCurrent)) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('talk_time_limit'), E::ModuleLang()->Get('error')); return false; } // * Отправляем письмо if ($oTalk = E::ModuleTalk()->SendTalk(E::ModuleText()->Parser(strip_tags(F::GetRequestStr('talk_title'))), E::ModuleText()->Parser(F::GetRequestStr('talk_text')), $this->oUserCurrent, $this->aUsersId)) { E::ModuleMresource()->CheckTargetTextForImages('talk', $oTalk->getId(), $oTalk->getText()); R::Location(R::GetPath('talk') . 'read/' . $oTalk->getId() . '/'); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('system_error')); return R::Action('error'); } }
/** * @return null|string */ protected function RssPersonalBlog() { $sUserLogin = $this->GetParam(0); $aParams = $this->GetParams(); array_shift($aParams); if ($iMaxItems = intval(C::Get('module.topic.max_rss_count'))) { C::Set('module.topic.per_page', $iMaxItems); } $oUser = E::ModuleUser()->GetUserByLogin($sUserLogin); if ($oUser && ($oBlog = E::ModuleBlog()->GetPersonalBlogByUserId($oUser->getId()))) { E::ModuleHook()->AddHandler('action_after', array($this, 'ShowRssBlog')); return R::Action('blog', $oBlog->getId(), $aParams); } else { $this->_displayEmptyRss(); } return null; }
/** * Вызывается в том случаи если не найден евент который запросили через URL * По дефолту происходит перекидывание на страницу ошибки, это можно переопределить в наследнике * * @see Router::Action * * @return string */ protected function EventNotFound() { return R::Action('error', '404'); }
/** * Обработка кода приглашения при включеном режиме инвайтов * */ protected function EventInvite() { if (!Config::Get('general.reg.invite')) { return parent::EventNotFound(); } // Обработка отправки формы с кодом приглашения if (F::isPost('submit_invite')) { // проверяем код приглашения на валидность if ($this->CheckInviteRegister()) { $sInviteCode = $this->GetInviteRegister(); } else { $sInviteCode = trim(F::GetRequestStr('invite_code')); } $oInvite = E::ModuleUser()->GetInviteByCode($sInviteCode); if ($oInvite) { if (!$this->CheckInviteRegister()) { E::ModuleSession()->Set('invite_code', $oInvite->getCode()); } return R::Action('registration'); } else { E::ModuleMessage()->AddError(E::ModuleLang()->Get('registration_invite_code_error'), E::ModuleLang()->Get('error')); } } }
/** * Удаление блога * */ protected function EventDeleteBlog() { E::ModuleSecurity()->ValidateSendForm(); // * Проверяем передан ли в УРЛе номер блога $nBlogId = intval($this->GetParam(0)); if (!$nBlogId || !($oBlog = E::ModuleBlog()->GetBlogById($nBlogId))) { return parent::EventNotFound(); } $this->oCurrentBlog = $oBlog; // * Проверям авторизован ли пользователь if (!E::ModuleUser()->IsAuthorization()) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('not_access'), E::ModuleLang()->Get('error')); return R::Action('error'); } // * проверяем есть ли право на удаление блога if (!($nAccess = E::ModuleACL()->IsAllowDeleteBlog($oBlog, $this->oUserCurrent))) { return parent::EventNotFound(); } $aTopics = E::ModuleTopic()->GetTopicsByBlogId($nBlogId); switch ($nAccess) { case ModuleACL::CAN_DELETE_BLOG_EMPTY_ONLY: if (is_array($aTopics) && count($aTopics)) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('blog_admin_delete_not_empty'), E::ModuleLang()->Get('error'), true); R::Location($oBlog->getUrlFull()); } break; case ModuleACL::CAN_DELETE_BLOG_WITH_TOPICS: /* * Если указан идентификатор блога для перемещения, * то делаем попытку переместить топики. * * (-1) - выбран пункт меню "удалить топики". */ $nNewBlogId = intval(F::GetRequestStr('topic_move_to')); if ($nNewBlogId > 0 && is_array($aTopics) && count($aTopics)) { if (!($oBlogNew = E::ModuleBlog()->GetBlogById($nNewBlogId))) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('blog_admin_delete_move_error'), E::ModuleLang()->Get('error'), true); R::Location($oBlog->getUrlFull()); } // * Если выбранный блог является персональным, возвращаем ошибку if ($oBlogNew->getType() == 'personal') { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('blog_admin_delete_move_personal'), E::ModuleLang()->Get('error'), true); R::Location($oBlog->getUrlFull()); } // * Перемещаем топики E::ModuleTopic()->MoveTopics($nBlogId, $nNewBlogId); } break; default: return parent::EventNotFound(); } // * Удаляяем блог и перенаправляем пользователя к списку блогов E::ModuleHook()->Run('blog_delete_before', array('sBlogId' => $nBlogId)); if ($this->_deleteBlog($oBlog)) { E::ModuleHook()->Run('blog_delete_after', array('sBlogId' => $nBlogId)); E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('blog_admin_delete_success'), E::ModuleLang()->Get('attention'), true); R::Location(R::GetPath('blogs')); } else { R::Location($oBlog->getUrlFull()); } }
/** * AJAX установка описания фото * */ protected function EventAjaxPhotoDescription() { /** * Устанавливаем формат Ajax ответа */ E::ModuleViewer()->SetResponseAjax('json'); /** * Проверяем авторизован ли юзер */ if (!E::ModuleUser()->IsAuthorization()) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('not_access'), E::ModuleLang()->Get('error')); return R::Action('error'); } /** * Поиск фото по id */ $oPhoto = E::ModuleTopic()->GetTopicPhotoById(F::GetRequestStr('id')); if ($oPhoto) { $sDescription = htmlspecialchars(strip_tags(F::GetRequestStr('text'))); if ($sDescription != $oPhoto->getDescription()) { if ($oPhoto->getTopicId()) { // проверяем права на топик $oTopic = E::ModuleTopic()->GetTopicById($oPhoto->getTopicId()); if ($oTopic && E::ModuleACL()->IsAllowEditTopic($oTopic, $this->oUserCurrent)) { $oPhoto->setDescription(htmlspecialchars(strip_tags(F::GetRequestStr('text')))); E::ModuleTopic()->UpdateTopicPhoto($oPhoto); } } else { $oPhoto->setDescription(htmlspecialchars(strip_tags(F::GetRequestStr('text')))); E::ModuleTopic()->UpdateTopicPhoto($oPhoto); } E::ModuleMessage()->AddNotice(E::ModuleLang()->Get('topic_photoset_description_done')); } } }
protected function EventLibCaptcha() { return R::Action('Captcha'); }
/** * Ошибочные экшены отдаём как ошибку неизвестного API метода * @return string */ protected function EventNotFound() { E::ModuleApi()->SetLastError(E::ModuleApi()->ERROR_CODE_0002); return R::Action('api', 'error'); }