/** * Init compressor/minifier * * @return bool */ protected function InitCompressor() { if (Config::Get('compress.js.use')) { F::IncludeLib('JShrink-1.0.1/src/JShrink/Minifier.php'); // * Получаем параметры из конфигурации return true; } return false; }
protected function EventLibCaptcha() { if (!class_exists('KCAPTCHA', false)) { F::IncludeLib('kcaptcha/kcaptcha.php'); } $captcha = new KCAPTCHA(); $_SESSION['captcha_keystring'] = $captcha->getKeyString(); exit; }
public function get($sProp) { if (substr($sProp, -7) == '.driver') { $sDriver = E::ModuleImg()->GetDriver(); if (!class_exists('\\PHPixie\\Image\\' . $sDriver, false)) { F::IncludeLib('PHPixie/Image/' . $sDriver . '.php'); } return $sDriver; } return null; }
/** * Создает css-компрессор и инициализирует его конфигурацию * * @return bool */ protected function InitCompressor() { if (Config::Get('compress.css.use')) { F::IncludeLib('CSSTidy-1.3/class.csstidy.php'); $this->oCompressor = new csstidy(); if ($this->oCompressor) { // * Получаем параметры из конфигурации $aParams = Config::Get('compress.css.csstidy'); // * Устанавливаем параметры foreach ($aParams as $sKey => $sVal) { if ($sKey == 'template') { $this->oCompressor->load_template($sVal); } else { $this->oCompressor->set_cfg('case_properties', $sVal); } } return true; } } return false; }
/** * Запуск валидации * * @param mixed $sValue Данные для валидации * * @return bool|string */ public function validate($sValue) { if (is_array($sValue)) { return $this->getMessage(E::ModuleLang()->Get('validate_date_format_invalid', null, false), 'msg'); } if ($this->allowEmpty && $this->isEmpty($sValue)) { return true; } F::IncludeLib('DateTime/DateTimeParser.php'); $aFormats = is_string($this->format) ? array($this->format) : $this->format; $bValid = false; foreach ($aFormats as $sFormat) { $iTimestamp = DateTimeParser::parse($sValue, $sFormat, array('month' => 1, 'day' => 1, 'hour' => 0, 'minute' => 0, 'second' => 0)); if ($iTimestamp !== false) { $bValid = true; break; } } if (!$bValid) { return $this->getMessage(E::ModuleLang()->Get('validate_date_format_invalid', null, false), 'msg'); } return true; }
/** * Запуск валидации * * @param mixed $sValue Данные для валидации * * @return bool|string */ public function validate($sValue) { if ($this->allowEmpty && $this->isEmpty($sValue)) { return true; } F::IncludeLib('DateTime/DateTimeParser.php'); if ($this->type === 'integer') { $bValid = preg_match('/^[-+]?[0-9]+$/', trim($sValue)); } else { if ($this->type === 'float') { $bValid = preg_match('/^[-+]?([0-9]*\\.)?[0-9]+([eE][-+]?[0-9]+)?$/', trim($sValue)); } else { if ($this->type === 'date') { $bValid = DateTimeParser::parse($sValue, $this->dateFormat, array('month' => 1, 'day' => 1, 'hour' => 0, 'minute' => 0, 'second' => 0)) !== false; } else { if ($this->type === 'time') { $bValid = DateTimeParser::parse($sValue, $this->timeFormat) !== false; } else { if ($this->type === 'datetime') { $bValid = DateTimeParser::parse($sValue, $this->datetimeFormat, array('month' => 1, 'day' => 1, 'hour' => 0, 'minute' => 0, 'second' => 0)) !== false; } else { if ($this->type === 'array') { $bValid = is_array($sValue); } else { return true; } } } } } } if (!$bValid) { return $this->getMessage(E::ModuleLang()->Get('validate_type_error', null, false), 'msg', array('type' => $this->type)); } return true; }
/*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- * Based on * LiveStreet Engine Social Networking by Mzhelskiy Maxim * Site: www.livestreet.ru * E-mail: rus.engine@gmail.com *---------------------------------------------------------------------------- */ // For Smarty define('DS', '/'); F::IncludeLib('Smarty/libs/Smarty.class.php'); /** * Модуль обработки шаблонов используя шаблонизатор Smarty * * @package engine.modules * @since 1.0 */ class ModuleViewer extends Module { /** @var bool Устанавливаем признак предзагрузки (влияет на порядок шатдауна) */ protected $bPreloaded = true; /** * Объект Smarty * * @var Smarty */
/** * Обработка отправленого админу запроса на вступление в блог * * @return string|null */ protected function EventRequestBlog() { F::IncludeLib('XXTEA/encrypt.php'); // * Получаем код подтверждения из ревеста и дешефруем его $sCode = xxtea_decrypt(base64_decode(rawurldecode(F::GetRequestStr('code'))), Config::Get('module.blog.encrypt')); if (!$sCode) { return $this->EventNotFound(); } list($sBlogId, $sUserId) = explode('_', $sCode, 2); $sAction = $this->GetParam(0); // * Получаем текущего пользователя if (!E::ModuleUser()->IsAuthorization()) { return $this->EventNotFound(); } $this->oUserCurrent = E::ModuleUser()->GetUserCurrent(); // Получаем блог /** @var ModuleBlog_EntityBlog $oBlog */ $oBlog = E::ModuleBlog()->GetBlogById($sBlogId); if (!$oBlog || !$oBlog->getBlogType() || !($oBlog->getBlogType()->IsPrivate() || $oBlog->getBlogType()->IsReadOnly())) { return $this->EventNotFound(); } $this->oCurrentBlog = $oBlog; // Проверим, что текущий пользователь имеет право принимать решение if (!($oBlog->getUserIsAdministrator() || $oBlog->getUserIsModerator() || $oBlog->getOwnerId() == E::UserId())) { return $this->EventNotFound(); } // Получим пользователя, который запрашивает приглашение if (!($oGuestUser = E::ModuleUser()->GetUserById($sUserId))) { return $this->EventNotFound(); } // * Получаем связь "блог-пользователь" и проверяем, чтобы ее тип был REQUEST if (!($oBlogUser = E::ModuleBlog()->GetBlogUserByBlogIdAndUserId($oBlog->getId(), $oGuestUser->getId()))) { return $this->EventNotFound(); } // Пользователь уже принят в ряды if ($oBlogUser->getUserRole() >= ModuleBlog::BLOG_USER_ROLE_USER) { $sMessage = E::ModuleLang()->Get('blog_user_request_already_done'); E::ModuleMessage()->AddError($sMessage, E::ModuleLang()->Get('error'), true); R::Location(R::GetPath('talk')); return; } // У пользователя непонятный флаг if ($oBlogUser->getUserRole() != ModuleBlog::BLOG_USER_ROLE_WISHES) { return $this->EventNotFound(); } // * Обновляем роль пользователя до читателя $oBlogUser->setUserRole($sAction == 'accept' ? ModuleBlog::BLOG_USER_ROLE_USER : ModuleBlog::BLOG_USER_ROLE_NOTMEMBER); if (!E::ModuleBlog()->UpdateRelationBlogUser($oBlogUser)) { E::ModuleMessage()->AddError(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error'), true); R::Location(R::GetPath('talk')); return; } if ($sAction == 'accept') { // * Увеличиваем число читателей блога $oBlog->setCountUser($oBlog->getCountUser() + 1); E::ModuleBlog()->UpdateBlog($oBlog); $sMessage = E::ModuleLang()->Get('blog_user_request_accept'); // * Добавляем событие в ленту E::ModuleStream()->Write($oBlogUser->getUserId(), 'join_blog', $oBlog->getId()); } else { $sMessage = E::ModuleLang()->Get('blog_user_request_no_accept'); } E::ModuleMessage()->AddNotice($sMessage, E::ModuleLang()->Get('attention'), true); // * Перенаправляем на страницу личной почты R::Location(R::GetPath('talk')); }
/** * @param array $aConfig */ public static function Init($aConfig) { // Регистрация автозагрузчика классов spl_autoload_register('Loader::Autoload'); Config::Load($aConfig); $sConfigDir = Config::Get('path.dir.config'); // Load main config Config::LoadFromFile($sConfigDir . '/config.php', false); // Load additional config files if defined $aConfigLoad = F::Str2Array(Config::Get('config_load')); if ($aConfigLoad) { self::_loadConfigSections($sConfigDir, $aConfigLoad); } // Includes all *.php files from {path.root.engine}/include/ $sIncludeDir = Config::Get('path.dir.engine') . '/include/'; self::_includeAllFiles($sIncludeDir); // Load main config level (modules, local & plugins) self::_loadConfigFiles($sConfigDir, Config::LEVEL_MAIN); // Define app config dir $sAppConfigDir = Config::Get('path.dir.app') . '/config/'; // Ups config level Config::ResetLevel(Config::LEVEL_APP); // Load application config level (modules, local & plugins) self::_loadConfigFiles($sAppConfigDir, Config::LEVEL_APP); // Load additional config files (the set could be changed in this point) $aConfigLoad = F::Str2Array(Config::Get('config_load')); if ($aConfigLoad) { self::_loadConfigSections($sAppConfigDir, $aConfigLoad, Config::LEVEL_APP); } // Load include files of plugins self::_loadIncludeFiles(Config::LEVEL_MAIN); self::_loadIncludeFiles(Config::LEVEL_APP); self::_checkRequiredDirs(); $aSeekDirClasses = array(Config::Get('path.dir.app'), Config::Get('path.dir.common'), Config::Get('path.dir.engine')); Config::Set('path.root.seek', $aSeekDirClasses); if (is_null(Config::Get('path.root.subdir'))) { if (isset($_SERVER['DOCUMENT_ROOT'])) { $sPathSubdir = '/' . F::File_LocalPath(ALTO_DIR, $_SERVER['DOCUMENT_ROOT']); } elseif ($iOffset = Config::Get('path.offset_request_url')) { $aParts = array_slice(explode('/', F::File_NormPath(ALTO_DIR)), -$iOffset); $sPathSubdir = '/' . implode('/', $aParts); } else { $sPathSubdir = ''; } Config::Set('path.root.subdir', $sPathSubdir); } // Подгружаем конфиг из файлового кеша, если он есть Config::ResetLevel(Config::LEVEL_CUSTOM); $aConfig = Config::ReadCustomConfig(null, true); if ($aConfig) { Config::Load($aConfig, false, null, null, 'custom'); } // Задаем локаль по умолчанию F::IncludeLib('UserLocale/UserLocale.class.php'); // Устанавливаем признак того, является ли сайт многоязычным $aLangsAllow = (array) Config::Get('lang.allow'); if (sizeof($aLangsAllow) > 1) { UserLocale::initLocales($aLangsAllow); Config::Set('lang.multilang', true); } else { Config::Set('lang.multilang', false); } UserLocale::setLocale(Config::Get('lang.current'), array('local' => Config::Get('i18n.locale'), 'timezone' => Config::Get('i18n.timezone'))); Config::Set('i18n', UserLocale::getLocale()); F::IncludeFile(Config::Get('path.dir.engine') . '/classes/core/Engine.class.php'); }
<?php /*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- * Based on * LiveStreet Engine Social Networking by Mzhelskiy Maxim * Site: www.livestreet.ru * E-mail: rus.engine@gmail.com *---------------------------------------------------------------------------- */ F::IncludeLib('phpMailer/class.phpmailer.php'); /** * Модуль для отправки почты(e-mail) через phpMailer * <pre> * E::ModuleMail()->SetAdress('*****@*****.**','Claus'); * E::ModuleMail()->SetSubject('Hi!'); * E::ModuleMail()->SetBody('How are you?'); * E::ModuleMail()->SetHTML(); * E::ModuleMail()->Send(); * </pre> * * @package engine.modules * @since 1.0 */ class ModuleMail extends Module {
<?php /*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- */ F::IncludeLib('PHPixie/Image.php'); F::IncludeLib('PHPixie/Image/Driver.php'); class ModuleImg extends Module { protected $nError = 0; protected $sConfig = 'default'; protected $aDrivers = array('gmagick' => 'Gmagick', 'imagick' => 'Imagick', 'gd' => 'GD'); protected $sDefaultDriver = 'GD'; protected $aAvailableDrivers = array(); protected $aInitDrivers = array(); protected $aOptions = array(); public function Init() { $this->aAvailableDrivers = $this->GetDriversInfo(); $this->sDefaultDriver = F::Array_FirstKey($this->aAvailableDrivers); } /** * Info about all drivers * * @return array */
<?php /*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- * Based on * LiveStreet Engine Social Networking by Mzhelskiy Maxim * Site: www.livestreet.ru * E-mail: rus.engine@gmail.com *---------------------------------------------------------------------------- */ F::IncludeLib('Sphinx/sphinxapi_2.x.php'); /** * Модуль для работы с машиной полнотекстового поиска Sphinx * * @package modules.sphinx * @since 1.0 */ class PluginSphinx_ModuleSphinx extends Module { /** * Объект сфинкса * * @var SphinxClient|null */ protected $oSphinx = null; /**
<?php /*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- */ F::IncludeLib('less.php/Less.php'); class ModuleLess extends Module { /** * Инициализация модуля * */ public function Init() { } /** * Компилирует файл less и возвращает текст css-файла * * @param $aFile * @param $sCacheDir * @param $sMapPath * @param $aParams * @param $bCompress * @return string */ public function CompileFile($aFile, $sCacheDir, $sMapPath, $aParams, $bCompress)
<?php /*--------------------------------------------------------------------------- * @Project: Alto CMS * @Project URI: http://altocms.com * @Description: Advanced Community Engine * @Copyright: Alto CMS Team * @License: GNU GPL v2 & MIT *---------------------------------------------------------------------------- */ F::IncludeLib('XXTEA/encrypt.php'); /** * Encryption/Decryption functions for Alto CMS */ class AltoFunc_Xxtea { /** * Ключ криптования по умолчанию * * @return mixed|null */ protected static function _defaultKey() { return F::_getConfig('security.salt_auth', __DIR__); } /** * Шифрование строки * * @param string $sData * @param string|null $sKey *
/** * Обработка добавления в друзья * * @param ModuleUser_EntityUser $oUser * @param string $sUserText * @param ModuleUser_EntityUser $oFriend * * @return bool */ protected function SubmitAddFriend($oUser, $sUserText, $oFriend = null) { /** * Ограничения на добавления в друзья, т.к. приглашение отправляется в личку, то и ограничиваем по ней */ if (!E::ModuleACL()->CanSendTalkTime($this->oUserCurrent)) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('user_friend_add_time_limit'), E::ModuleLang()->Get('error')); return false; } /** * Обрабатываем текст заявки */ $sUserText = E::ModuleText()->Parse($sUserText); /** * Создаем связь с другом */ /** @var ModuleUser_EntityFriend $oFriendNew */ $oFriendNew = E::GetEntity('User_Friend'); $oFriendNew->setUserTo($oUser->getId()); $oFriendNew->setUserFrom($this->oUserCurrent->getId()); // Добавляем заявку в друзья $oFriendNew->setStatusFrom(ModuleUser::USER_FRIEND_OFFER); $oFriendNew->setStatusTo(ModuleUser::USER_FRIEND_NULL); $bStateError = $oFriend ? !E::ModuleUser()->UpdateFriend($oFriendNew) : !E::ModuleUser()->AddFriend($oFriendNew); if (!$bStateError) { E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('user_friend_offer_send'), E::ModuleLang()->Get('attention')); $sTitle = E::ModuleLang()->Get('user_friend_offer_title', array('login' => $this->oUserCurrent->getLogin(), 'friend' => $oUser->getLogin())); F::IncludeLib('XXTEA/encrypt.php'); $sCode = $this->oUserCurrent->getId() . '_' . $oUser->getId(); $sCode = rawurlencode(base64_encode(xxtea_encrypt($sCode, Config::Get('module.talk.encrypt')))); $aPath = array('accept' => R::GetPath('profile') . 'friendoffer/accept/?code=' . $sCode, 'reject' => R::GetPath('profile') . 'friendoffer/reject/?code=' . $sCode); $sText = E::ModuleLang()->Get('user_friend_offer_text', array('login' => $this->oUserCurrent->getLogin(), 'accept_path' => $aPath['accept'], 'reject_path' => $aPath['reject'], 'user_text' => $sUserText)); $oTalk = E::ModuleTalk()->SendTalk($sTitle, $sText, $this->oUserCurrent, array($oUser), false, false); /** * Отправляем пользователю заявку */ E::ModuleNotify()->SendUserFriendNew($oUser, $this->oUserCurrent, $sUserText, R::GetPath('talk') . 'read/' . $oTalk->getId() . '/'); /** * Удаляем отправляющего юзера из переписки */ E::ModuleTalk()->DeleteTalkUserByArray($oTalk->getId(), $this->oUserCurrent->getId()); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error')); } /** * Подписываем запрашивающего дружбу на */ E::ModuleStream()->SubscribeUser($this->oUserCurrent->getId(), $oUser->getId()); $oViewerLocal = $this->GetViewerLocal(); $oViewerLocal->Assign('oUserFriend', $oFriendNew); E::ModuleViewer()->AssignAjax('sToggleText', $oViewerLocal->Fetch('actions/profile/action.profile.friend_item.tpl')); }