Beispiel #1
0
 public function EventConfig()
 {
     $sFile = Plugin::GetPath(__CLASS__) . 'config/sphinx-src.conf';
     $sText = F::File_GetContents($sFile);
     $sPath = F::File_NormPath(Config::Get('plugin.sphinx.path') . '/');
     $sDescription = E::ModuleLang()->Get('plugin.sphinx.conf_description', array('path' => $sPath, 'prefix' => Config::Get('plugin.sphinx.prefix')));
     $sDescription = preg_replace('/\\s\\s+/', ' ', str_replace("\n", "\n## ", $sDescription));
     $sTitle = E::ModuleLang()->Get('plugin.sphinx.conf_title');
     $aData = array('{{title}}' => $sTitle, '{{description}}' => $sDescription, '{{db_type}}' => Config::Get('db.params.type') == 'postgresql' ? 'pgsql' : 'mysql', '{{db_host}}' => Config::Get('db.params.host'), '{{db_user}}' => Config::Get('db.params.user'), '{{db_pass}}' => Config::Get('db.params.pass'), '{{db_name}}' => Config::Get('db.params.dbname'), '{{db_port}}' => Config::Get('db.params.port'), '{{db_prefix}}' => Config::Get('db.table.prefix'), '{{db_socket}}' => Config::Get('plugin.sphinx.db_socket'), '{{spinx_prefix}}' => Config::Get('plugin.sphinx.prefix'), '{{spinx_path}}' => $sPath);
     $sText = str_replace(array_keys($aData), array_values($aData), $sText);
     echo '<pre>';
     echo $sText;
     echo '</pre>';
     exit;
 }
 /**
  * Инициализация
  */
 public function Init()
 {
     // Маппер
     $this->oMapper = Engine::GetMapper(__CLASS__);
     // facebook API
     $path = Plugin::GetPath('facebook') . 'classes/lib/facebook-php-sdk/src/facebook.php';
     include $path;
     $this->LoadSettings();
     $this->aCfg = Config::Get('plugin.facebook');
     // Игнорировать сертификаты
     Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
     Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;
     // API
     if ($this->aCfg['application']['id'] && $this->aCfg['application']['secret']) {
         $this->FB = new Facebook(array('appId' => $this->aCfg['application']['id'], 'secret' => $this->aCfg['application']['secret'], 'cookie' => true));
     }
 }
 protected function _ActionAdminInerits()
 {
     $sFrom = 'ActionAdmin';
     $sMask = Plugin::GetPath($this->sPlugin) . '/classes/actions/ActionAdmin_Event*.class.php';
     $aFiles = glob($sMask);
     asort($aFiles);
     foreach ($aFiles as $sFile) {
         $sTo = 'PluginAceadminpanel_' . basename($sFile, '.class.php');
         Engine::getInstance()->Plugin_Inherit($sFrom, $sTo, get_class($this));
         include_once $sFile;
     }
     include_once Plugin::GetPath($this->sPlugin) . '/classes/actions/ActionAdminPlugin.class.php';
 }
Beispiel #4
0
 /**
  * Инициализация модуля
  */
 public function Init()
 {
     F::IncludeFile(Plugin::GetPath('ls') . 'libs/external/LiveImage/Image.php');
     $this->aParamsDefault = array('watermark_use' => false, 'round_corner' => false);
 }
 /**
  * Возврашает список файлов миграций по версиям
  *
  * @param      $sPlugin
  * @param null $sVersionFrom
  *
  * @return array
  */
 public function GetUpdateNewFiles($sPlugin, $sVersionFrom = null)
 {
     $sPluginDir = Plugin::GetPath($sPlugin) . 'update/';
     /**
      * Получаем список каталогов-версий в /update/
      */
     $aVersions = array();
     $aPaths = glob($sPluginDir . '*', GLOB_ONLYDIR);
     if ($aPaths) {
         foreach ($aPaths as $sPath) {
             $aVersions[] = basename($sPath);
         }
     }
     $aVersions = $this->SortVersions($aVersions);
     /**
      * Оставляем только новые версии
      */
     if ($sVersionFrom and false !== ($iPos = array_search($sVersionFrom, $aVersions))) {
         $aVersions = array_slice($aVersions, ++$iPos);
     }
     /**
      * Получаем список файлов для каждой версии
      */
     $aResultFiles = array();
     foreach ($aVersions as $sVersion) {
         $aResultFiles[$sVersion] = array();
         $aFiles = glob($sPluginDir . "{$sVersion}/*");
         if ($aFiles) {
             foreach ($aFiles as $sFile) {
                 $aResultFiles[$sVersion][] = array('name' => basename($sFile, '.php'), 'file' => basename($sFile), 'path' => $sFile);
             }
         }
     }
     return $aResultFiles;
 }
 public function TplStatisticsPerformanceItem()
 {
     if ($this->_checkAdmin()) {
         $aMemoryStats['memory_limit'] = ini_get('memory_limit');
         $aMemoryStats['usage'] = ACE::MemSizeFormat(memory_get_usage());
         $aMemoryStats['peak_usage'] = ACE::MemSizeFormat(memory_get_peak_usage(true));
         $this->Viewer_Assign('aMemoryStats', $aMemoryStats);
         $sTpl = Plugin::GetTemplatePath(__CLASS__) . 'hook.statistics_performance_item.tpl';
         if (!ACE::FileExists($sTpl)) {
             $sTpl = Plugin::GetPath(__CLASS__) . '/templates/skin/default/hook.statistics_performance_item.tpl';
         }
         if (ACE::FileExists($sTpl)) {
             return $this->Viewer_Fetch($sTpl);
         }
     }
 }
<?php

require_once Plugin::GetPath('api') . 'src/VK/VK.php';
require_once Plugin::GetPath('api') . 'src/VK/VKException.php';
class PluginApi_ActionApi extends ActionPlugin
{
    /**
     * Инициализация экшена
     */
    protected $oUserCurrent = null;
    public function Init()
    {
        $this->SetDefaultEvent('index');
    }
    /**
     * Регистрируем евенты
     */
    protected function RegisterEvent()
    {
        $this->AddEvent('index', 'EventIndex');
        $this->AddEvent('dir', 'EventDir');
        $this->AddEvent('ban', 'EventUsersBan');
        $this->AddEvent('skill', 'EventSkill');
    }
    protected function EventUsersBan()
    {
        $this->Security_ValidateSendForm();
        $oUserCurrent = $this->ModuleUser_GetUserCurrent();
        if (!$oUserCurrent->IsGlobalModerator()) {
            return false;
        }
Beispiel #8
0
 /**
  * Установка языка интерфейса
  *
  * @return void
  */
 public function SetLang()
 {
     if (!$this->User_IsInit()) {
         $this->User_Init();
     }
     if ($this->PluginL10n_L10n_GetLangFromUrl()) {
         // берем язык интерфейса с урла
         Config::Set('lang.current', $this->PluginL10n_L10n_GetLangFromUrl());
     } elseif ($this->User_IsAuthorization()) {
         // если в урле пусто -
         // для авторизированных пользователей проверяем какой язык интерфейса
         // выбран по умолчанию и устанавливаем его в качестве текущего
         $oUser = $this->User_GetUserCurrent();
         Config::Set('lang.current', $oUser->getUserLang());
     } elseif (isset($_SERVER['REMOTE_ADDR']) && Config::Get('plugin.l10n.use_geoip')) {
         // для остальных язык будет передаваться по GeoIP
         require_once Plugin::GetPath(__CLASS__) . 'classes/lib/external/GeoIp/Wrapper.php';
         $gi = new GeoIp_Wrapper();
         // 2х значный код страны - он же код языка
         $country = $gi->getCountryCodeByAddr($_SERVER['REMOTE_ADDR']);
         $ruSpeaks = Config::Get('plugin.l10n.ru.countries');
         // @todo refact
         if ($country == 'ua') {
             Config::Set('lang.current', $this->PluginL10n_L10n_GetLangByAlias('uk'));
             setlocale(LC_ALL, "uk_UA.UTF-8");
         } else {
             Config::Set('lang.current', $this->PluginL10n_L10n_GetLangByAlias('ru'));
             setlocale(LC_ALL, "ru_RU.UTF-8");
             date_default_timezone_set('Europe/Moscow');
             // See http://php.net/manual/en/timezones.php
         }
         //            if (in_array($country, $ruSpeaks)) {
         //                Config::Set('lang.current', $this->PluginL10n_L10n_GetLangByAlias('ru'));
         //                //   setlocale(LC_ALL, "ru_RU.UTF-8");
         //                date_default_timezone_set('Europe/Moscow'); // See http://php.net/manual/en/timezones.php
         //            } else {
         //                Config::Set('lang.current', $this->PluginL10n_L10n_GetLangByAlias('en'));
         //                //   setlocale(LC_ALL, "en_EN.UTF-8");
         //            }
     } else {
         Config::Set('lang.current', Config::Get('lang.default'));
     }
     $sLang = $this->PluginL10n_L10n_GetAliasByLang(Config::Get('lang.current'));
     $sWebPath = Router::GetPathWebCurrent();
     /**
      * Проверяем, включено ли принудительно проставление языка в урле, не является ли это CLI или Аяксом
      */
     if (Config::Get('plugin.l10n.lang_in_url') && $sWebPath && !$this->isAjax()) {
         /**
          * Проверям, был ли язык в урле, и не главная ли это страница
          */
         if (!Router::getLang() && rtrim($sWebPath, '/') != Config::Get('path.root.web')) {
             $sWebPath = str_replace(Config::Get('path.root.web'), Config::Get('path.root.web') . '/' . $sLang, $sWebPath);
             Router::Location($sWebPath);
         }
         $this->PluginL10n_L10n_SetLangForUrl($sLang);
     }
     $sConfigFile = Config::Get('path.root.server') . '/config/plugins/l10n/config.' . $sLang . '.php';
     if (file_exists($sConfigFile)) {
         Config::LoadFromFile($sConfigFile);
     }
     $this->UpdateBlockRoutes();
     $this->Viewer_Assign('sLangCurrent', $this->PluginL10n_L10n_GetAliasByLang(Config::Get('lang.current')));
 }
Beispiel #9
0
 /**
  * @param   string      $sName
  * @param   string|null $sPlugin
  * @param   bool        $bReturnClassName
  *
  * @return  string|bool
  */
 protected function _fileClassExists($sName, $sPlugin = null, $bReturnClassName = false)
 {
     if (!$sPlugin) {
         $aPathSeek = Config::Get('path.root.seek');
         $sFile = '/classes/widgets/Widget' . $sName . '.class.php';
         $sClass = 'Widget' . $sName;
     } else {
         $aPathSeek = array(Plugin::GetPath($sPlugin));
         $sFile = '/classes/widgets/Widget' . $sName . '.class.php';
         $sClass = 'Plugin' . F::StrCamelize($sPlugin) . '_Widget' . $sName;
     }
     if (F::File_Exists($sFile, $aPathSeek)) {
         return $bReturnClassName ? $sClass : $sFile;
     }
     return false;
 }
 /**
  * Init plugin Tasks
  */
 public function Init()
 {
     require_once Plugin::GetPath(__CLASS__) . 'lib/external/firephp-0/FirePHPCore/FirePHP.class.php';
 }
Beispiel #11
0
 /**
  * Выполняется при откате версии
  */
 public function down()
 {
     $this->exportSQL(Plugin::GetPath(__CLASS__) . '/data/uninstall.sql');
 }
<?php

include Plugin::GetPath(__CLASS__) . "admintopic/includes/pr.php";
function sort_by_vals($a, $b)
{
    return $a < $b;
}
class PluginAdmintopic_ActionAdminPlugin extends ActionAdminPlugin
{
    private function parsePage($params)
    {
        $iPage = 1;
        if (count($params) != 0) {
            if (preg_match("/^page(\\d+)\$/i", $params[0], $match)) {
                $iPage = intval($match[1]);
            }
        }
        return $iPage;
    }
    private function parseOrder()
    {
        if (!($sort = htmlspecialchars(getRequest('sort')))) {
            $sort = Config::Get('plugin.admintopic.default_sort');
        }
        if ($rev = getRequest('rev')) {
            $rev = intval(getRequest('rev'));
        } else {
            $rev = Config::Get('plugin.admintopic.default_sort_direction');
        }
        $sRev = $rev == 0 ? 'DESC' : 'ASC';
        return array('raw' => array('sort' => $sort, 'rev' => $rev), 'sql' => ' t.' . $sort . ' ' . $sRev);