コード例 #1
0
ファイル: Skin.class.php プロジェクト: Azany/altocms
 /**
  * Load skin manifest from XML
  *
  * @param string $sSkin
  * @param string $sSkinDir
  *
  * @return string|bool
  */
 public function GetSkinManifest($sSkin, $sSkinDir = null)
 {
     if (!$sSkinDir) {
         $sSkinDir = Config::Get('path.skins.dir') . $sSkin . '/';
     }
     if (F::File_Exists($sSkinDir . '/' . self::SKIN_XML_FILE)) {
         $sXmlFile = $sSkinDir . '/' . self::SKIN_XML_FILE;
     } else {
         $sXmlFile = $sSkinDir . '/settings/' . self::SKIN_XML_FILE;
     }
     if ($sXml = F::File_GetContents($sXmlFile)) {
         return $sXml;
     }
     return null;
 }
コード例 #2
0
ファイル: ActionSphinx.class.php プロジェクト: AntiqS/altocms
 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;
 }
コード例 #3
0
 public function PrepareFile($sFile, $sDestination)
 {
     $sContents = F::File_GetContents($sFile);
     if ($sContents !== false) {
         $sContents = $this->PrepareContents($sContents, $sFile, $sDestination);
         if (F::File_PutContents($sDestination, $sContents) !== false) {
             return $sDestination;
         }
     }
     F::SysWarning('Can not prepare asset file "' . $sFile . '"');
     return null;
 }
コード例 #4
0
ファイル: Func.php プロジェクト: AntiqS/altocms
 /**
  * Получить список плагинов
  *
  * @param bool $bAll     - все плагины (иначе - только активные)
  * @param bool $bIdOnly  - только Id плагинов (иначе - вся строка с информацией о плагине)
  *
  * @return array
  */
 public static function GetPluginsList($bAll = false, $bIdOnly = true)
 {
     $sPluginsDatFile = static::GetPluginsDatFile();
     if (isset(self::$_aPluginList[$sPluginsDatFile][$bAll])) {
         $aPlugins = self::$_aPluginList[$sPluginsDatFile][$bAll];
     } else {
         $sCommonPluginsDir = static::GetPluginsDir();
         $aPlugins = array();
         $aPluginsRaw = array();
         if ($bAll) {
             $aFiles = glob($sCommonPluginsDir . '{*,*/*}/plugin.xml', GLOB_BRACE);
             if ($aFiles) {
                 foreach ($aFiles as $sXmlFile) {
                     $aPluginInfo = array();
                     $sXmlText = F::File_GetContents($sXmlFile);
                     $sDirName = dirname(F::File_LocalPath($sXmlFile, $sCommonPluginsDir));
                     if (preg_match('/\\<id\\>([\\w\\.\\/]+)\\<\\/id\\>/', $sXmlText, $aMatches)) {
                         $aPluginInfo['id'] = $aMatches[1];
                     } else {
                         $aPluginInfo['id'] = $sDirName;
                     }
                     $aPluginInfo['dirname'] = $sDirName;
                     $aPluginInfo['path'] = dirname($sXmlFile) . '/';
                     $aPluginInfo['manifest'] = $sXmlFile;
                     $aPlugins[$aPluginInfo['id']] = $aPluginInfo;
                 }
             }
         } else {
             if (is_file($sPluginsDatFile) && ($aPluginsRaw = @file($sPluginsDatFile))) {
                 $aPluginsRaw = array_map('trim', $aPluginsRaw);
                 $aPluginsRaw = array_unique($aPluginsRaw);
             }
             if ($aPluginsRaw) {
                 foreach ($aPluginsRaw as $sPluginStr) {
                     if (($n = strpos($sPluginStr, ';')) !== false) {
                         if ($n === 0) {
                             continue;
                         }
                         $sPluginStr = trim(substr($sPluginStr, 0, $n));
                     }
                     if ($sPluginStr) {
                         $aPluginInfo = str_word_count($sPluginStr, 1, '0..9/_');
                         $aPluginInfo['id'] = $aPluginInfo[0];
                         if (empty($aPluginInfo[1])) {
                             $aPluginInfo['dirname'] = $aPluginInfo[0];
                         } else {
                             $aPluginInfo['dirname'] = $aPluginInfo[1];
                         }
                         $sXmlFile = $sCommonPluginsDir . '/' . $aPluginInfo['dirname'] . '/plugin.xml';
                         if (is_file($sXmlFile)) {
                             $aPluginInfo['path'] = dirname($sXmlFile) . '/';
                             $aPluginInfo['manifest'] = $sXmlFile;
                             $aPlugins[$aPluginInfo['id']] = $aPluginInfo;
                         }
                     }
                 }
             }
         }
         $aPlugins = self::ExcludeByEnabledMask($aPlugins);
         self::$_aPluginList[$sPluginsDatFile][$bAll] = $aPlugins;
     }
     if ($bIdOnly) {
         $aPlugins = array_keys($aPlugins);
     }
     return $aPlugins;
 }
コード例 #5
0
ファイル: ViewerAsset.class.php プロジェクト: AntiqS/altocms
 /**
  * Prepare current asset pack
  */
 public function Prepare()
 {
     if ($this->_isEmpty()) {
         return;
     }
     $bForcePreparation = Config::Get('compress.css.force') || Config::Get('compress.js.force');
     $xData = $this->_checkAssets();
     if ($xData) {
         if (is_array($xData)) {
             if (F::File_GetContents($this->GetAssetsCheckName())) {
                 // loads assets from cache
                 $this->aAssets = $xData;
                 if (!$bForcePreparation) {
                     return;
                 }
             }
         } else {
             // assets are making right now
             // may be need to wait?
             for ($i = 0; $i < self::SLEEP_COUNT; $i++) {
                 sleep(self::SLEEP_TIME);
                 $xData = $this->_checkAssets();
                 if (is_array($xData)) {
                     $this->aAssets = $xData;
                     return;
                 }
             }
             // something wrong
             return;
         }
     }
     // May be assets are not complete
     if (!$this->aAssets && $this->aFiles && !$bForcePreparation) {
         $bForcePreparation = true;
     }
     if (!F::File_GetContents($this->GetAssetsCheckName()) || $bForcePreparation) {
         // reset assets here
         $this->_resetAssets();
         $this->aAssets = array();
         // Add files & links to assets
         foreach ($this->aFiles as $sType => $aData) {
             if (isset($aData['files'])) {
                 $this->AddFilesToAssets($sType, $aData['files']);
             }
             if (isset($aData['links'])) {
                 $this->AddLinksToAssets($sType, $aData['links']);
             }
         }
         $nStage = 0;
         $bDone = true;
         // PreProcess
         foreach ($this->aAssets as $oAssetPackage) {
             if ($oAssetPackage->PreProcessBegin()) {
                 $bDone = $bDone && $oAssetPackage->PreProcess();
                 $oAssetPackage->PreProcessEnd();
             }
         }
         if ($bDone) {
             $nStage += 1;
         }
         // Process
         foreach ($this->aAssets as $oAssetPackage) {
             if ($oAssetPackage->ProcessBegin()) {
                 $bDone = $bDone && $oAssetPackage->Process();
                 $oAssetPackage->ProcessEnd();
             }
         }
         if ($bDone) {
             $nStage += 1;
         }
         // PostProcess
         foreach ($this->aAssets as $oAssetPackage) {
             if ($oAssetPackage->PostProcessBegin()) {
                 $bDone = $bDone && $oAssetPackage->PostProcess();
                 $oAssetPackage->PostProcessEnd();
             }
         }
         if ($bDone) {
             $nStage += 1;
         }
     } else {
         $nStage = 3;
     }
     if ($nStage == 3) {
         $this->_saveAssets();
     }
 }
コード例 #6
0
ファイル: ActionAdmin.class.php プロジェクト: ZeoNish/altocms
 /**
  * View logs
  */
 protected function EventLogs()
 {
     $this->sMainMenuItem = 'logs';
     if ($this->sCurrentEvent == 'logs-sqlerror') {
         $sLogFile = Config::Get('sys.logs.dir') . Config::Get('sys.logs.sql_error_file');
     } elseif ($this->sCurrentEvent == 'logs-sqllog') {
         $sLogFile = Config::Get('sys.logs.dir') . Config::Get('sys.logs.sql_query_file');
     } else {
         $sLogFile = Config::Get('sys.logs.dir') . F::ERROR_LOGFILE;
     }
     if (!is_null($this->GetPost('submit_logs_del'))) {
         $this->_eventLogsErrorDelete($sLogFile);
     }
     $sLogTxt = F::File_GetContents($sLogFile);
     if ($this->sCurrentEvent == 'logs-sqlerror') {
         $this->_setTitle(E::ModuleLang()->Get('action.admin.logs_sql_errors_title'));
         $this->SetTemplateAction('logs/sql_errors');
         $this->_eventLogsSqlErrors($sLogTxt);
     } elseif ($this->sCurrentEvent == 'logs-sqllog') {
         $this->_setTitle(E::ModuleLang()->Get('action.admin.logs_sql_title'));
         $this->SetTemplateAction('logs/sql_log');
         $this->_eventLogsSql($sLogTxt);
     } else {
         $this->_setTitle(E::ModuleLang()->Get('action.admin.logs_errors_title'));
         $this->SetTemplateAction('logs/errors');
         $this->_eventLogsErrors($sLogTxt);
     }
     E::ModuleViewer()->Assign('sLogTxt', $sLogTxt);
 }
コード例 #7
0
ファイル: Plugin.class.php プロジェクト: ZeoNish/altocms
 /**
  * @param string $sPluginXmlFile
  *
  * @return string|bool
  */
 public function GetPluginManifestFrom($sPluginXmlFile)
 {
     if ($sPluginXmlFile && ($sXml = F::File_GetContents($sPluginXmlFile))) {
         return $sXml;
     }
     return false;
 }
コード例 #8
0
ファイル: Config.class.php プロジェクト: ZeoNish/altocms
 /**
  * Читает из файлового кеша кастомную конфигурацию
  *
  * @param string $sKeyPrefix
  *
  * @return  array
  */
 protected static function _getCustomCfg($sKeyPrefix = null)
 {
     if (($sFile = self::_checkCustomCfg()) && ($sData = F::File_GetContents($sFile))) {
         $aConfig = F::Unserialize($sData);
         if (is_array($aConfig)) {
             return $aConfig;
         }
     }
     $aConfig = array();
     return $aConfig;
 }
コード例 #9
0
 /**
  * @return bool
  */
 public function Process()
 {
     $bResult = true;
     foreach ($this->aLinks as $nIdx => $aLinkData) {
         if (empty($aLinkData['throw']) && !empty($aLinkData['compress'])) {
             $sAssetFile = $aLinkData['asset_file'];
             $sExtension = 'min.' . F::File_GetExtension($sAssetFile);
             $sCompressedFile = F::File_SetExtension($sAssetFile, $sExtension);
             if (!$this->CheckDestination($sCompressedFile)) {
                 if ($sContents = F::File_GetContents($sAssetFile)) {
                     $sContents = $this->Compress($sContents);
                     if (F::File_PutContents($sCompressedFile, $sContents, LOCK_EX, true)) {
                         F::File_Delete($sAssetFile);
                         $this->aLinks[$nIdx]['link'] = F::File_SetExtension($this->aLinks[$nIdx]['link'], $sExtension);
                     }
                     if (C::Get('compress.js.gzip') && C::Get('compress.js.merge') && C::Get('compress.js.use')) {
                         // Сохраним gzip
                         $sCompressedContent = gzencode($sContents, 9);
                         F::File_PutContents($sCompressedFile . '.gz.js', $sCompressedContent, LOCK_EX, true);
                     }
                 }
             } else {
                 $this->aLinks[$nIdx]['link'] = F::File_SetExtension($this->aLinks[$nIdx]['link'], $sExtension);
             }
         }
     }
     return $bResult;
 }
コード例 #10
0
 /**
  * @param int $nStage
  *
  * @return bool
  */
 protected function _stageBegin($nStage)
 {
     $sFile = F::File_GetAssetDir() . '_check/' . $this->GetHash();
     if ($aCheckFiles = glob($sFile . '.{1,2,3}.begin.tmp', GLOB_BRACE)) {
         $sCheckFile = reset($aCheckFiles);
         // check time of tmp file
         $nTime = filectime($sCheckFile);
         if (!$nTime) {
             $nTime = F::File_GetContents($sCheckFile);
         }
         if (time() < $nTime + ModuleViewerAsset::TMP_TIME) {
             return false;
         }
     }
     if ($nStage == 2 && ($aCheckFiles = glob($sFile . '.{2,3}.end.tmp', GLOB_BRACE))) {
         return false;
     } elseif ($nStage == 3 && F::File_Exists($sFile . '.3.end.tmp')) {
         return false;
     }
     return F::File_PutContents($sFile . '.' . $nStage . '.begin.tmp', time());
 }
コード例 #11
0
ファイル: Viewer.class.php プロジェクト: AntiqS/altocms
 /**
  * @param string $sTplName
  *
  * @return string|bool
  */
 protected function _autocreateOldTemplate($sTplName)
 {
     $sOldTemplatesDir = $this->_getAutocreateOldTemplatesDir();
     if ($sFile = F::File_Exists($sTplName, $sOldTemplatesDir)) {
         return $sFile;
     }
     $aSourceTemplatesDir = array(Config::Get('path.skin.dir') . '/themes/default/layouts');
     if ($sTplName == 'header.tpl' || $sTplName == 'footer.tpl') {
         if ($sSourceFile = F::File_Exists('default.tpl', $aSourceTemplatesDir)) {
             $sSource = F::File_GetContents($sSourceFile);
             $sStr1 = "{hook run='content_begin'}";
             $sStr2 = "{hook run='content_end'}";
             if (stripos($sSource, '<!DOCTYPE') !== false) {
                 $iPos1 = stripos($sSource, $sStr1);
                 $iPos2 = stripos($sSource, $sStr2);
                 $sHeaderSrc = $this->_clearUnclosedBlocks(substr($sSource, 0, $iPos1 + strlen($sStr1)));
                 $sFooterSrc = $this->_clearUnclosedBlocks(substr($sSource, $iPos2));
                 F::File_PutContents($sOldTemplatesDir . 'header.tpl', $sHeaderSrc);
                 F::File_PutContents($sOldTemplatesDir . 'footer.tpl', $sFooterSrc);
             }
         }
     }
     if ($sFile = F::File_Exists($sTplName, $sOldTemplatesDir)) {
         return $sFile;
     }
     return false;
 }
コード例 #12
0
ファイル: Config.class.php プロジェクト: anp135/altocms
 /**
  * Читает из файлового кеша кастомную конфигурацию
  *
  * @return array
  */
 protected static function _getFileCfg()
 {
     if (($sFile = self::_checkFileCfg()) && ($sData = F::File_GetContents($sFile))) {
         $aConfig = F::Unserialize($sData);
         if (is_array($aConfig)) {
             if (isset($aConfig['_alto_hash_']) && $aConfig['_alto_hash_'] == self::_getHash()) {
                 return $aConfig;
             }
         }
     }
     return array();
 }