Пример #1
0
 /**
  * Array von Javascript-Variablen, welche in Editor-Template genutzt werden
  * @return array
  */
 public function getJsVars()
 {
     $editorStyles = array(array('title' => $this->language->translate('GLOBAL_SELECT'), 'value' => ''));
     $cache = new \fpcm\classes\cache('tinymce_plugins');
     if ($cache->isExpired()) {
         $path = dirname(\fpcm\classes\loader::libGetFilePath('tinymce4', 'tinymce.min.js'));
         $path .= '/plugins/*';
         $pluginFolders = implode(' ', array_map('basename', glob($path, GLOB_ONLYDIR)));
         $cache->write($pluginFolders, $this->config->system_cache_timeout);
     } else {
         $pluginFolders = $cache->read();
     }
     $params = array('fpcmTinyMceLang' => $this->config->system_lang, 'fpcmTinyMceElements' => '~readmore', 'fpcmTinyMcePlugins' => $pluginFolders, 'fpcmTinyMceToolbar' => 'formatselect fontsizeselect | bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify outdent indent | subscript superscript table toc | bullist numlist | fpcm_readmore hr blockquote | link unlink anchor image media | emoticons charmap insertdatetime template | undo redo removeformat searchreplace fullscreen code restoredraft', 'fpcmTinyMceCssClasses' => array_merge($editorStyles, $this->getEditorStyles()), 'fpcmTinyMceLinkList' => $this->getEditorLinks(), 'fpcmTinyMceImageList' => $this->getFileList(), 'fpcmTinyMceTextpattern' => $this->getTextPatterns(), 'fpcmTinyMceDefaultFontsize' => $this->config->system_editor_fontsize, 'fpcmTinyMceReadmoreBlockHL' => $this->language->translate('EDITOR_HTML_BUTTONS_READMORE'), 'fpcmTinyMceTemplatesList' => $this->getTemplateDrafts(), 'fpcmTinyMceAutosavePrefix' => 'fpcm-editor-as-' . $this->session->getUserId());
     return $this->events->runEvent('editorInitTinymce', $params);
 }
Пример #2
0
 /**
  * Ersetzt gefundene Wörter/ Zeichenketten durch Ersetzungstext
  * @param string $text
  */
 public function replaceItems($text)
 {
     $itemsCache = new \fpcm\classes\cache('wordbanItems');
     $data = array('search' => array(), 'replace' => array());
     if ($itemsCache->isExpired() || !is_array($itemsCache->read())) {
         $items = $this->dbcon->fetch($this->dbcon->select($this->table), true);
         if (!is_array($items) || !count($items)) {
             return $text;
         }
         foreach ($items as $value) {
             $data['search'] = $value->searchtext;
             $data['replace'] = $value->replacementtext;
         }
         $itemsCache->write($data);
     } else {
         $data = $itemsCache->read();
     }
     return str_replace($data['search'], $data['replace'], $text);
 }
Пример #3
0
 /**
  * Installer Step 7
  */
 protected function runStep7()
 {
     $res = true;
     if ($this->afterStepResult) {
         $res = \fpcm\classes\baseconfig::enableInstaller(false);
         $res = $res && \fpcm\model\files\ops::deleteRecursive(\fpcm\classes\baseconfig::$dbStructPath);
     }
     $this->view->assign('disableInstallerMsg', !$res);
     $this->view->assign('showNextButton', false);
     $cache = new \fpcm\classes\cache();
     $cache->cleanup();
 }
Пример #4
0
 /**
  * Gibt installierte Module zurück
  * @return array
  */
 public function getInstalledModules()
 {
     $cache = new \fpcm\classes\cache(__FUNCTION__, 'modules');
     if (!$cache->isExpired()) {
         return $cache->read();
     }
     $modules = $this->dbcon->fetch($this->dbcon->select($this->table, 'modkey'), true);
     $keys = array();
     foreach ($modules as $module) {
         $keys[] = $module->modkey;
     }
     $cache->write($keys, $this->config->system_cache_timeout);
     return $keys;
 }
Пример #5
0
<?php

/**
 * Combined JavaScript Files
 * @author Stefan Seehafer <*****@*****.**>
 * @copyright (c) 2011-2016, Stefan Seehafer
 * @license http://www.gnu.org/licenses/gpl.txt GPLv3
 */
require_once dirname(dirname(__DIR__)) . '/inc/common.php';
$data = array('content' => '', 'filesize' => 0);
$cache = new \fpcm\classes\cache('cssfiles', 'theme');
if ($cache->isExpired() || \fpcm\classes\baseconfig::installerEnabled() || FPCM_DEBUG) {
    $cssFiles = array(__DIR__ . '/style.css', __DIR__ . '/responsive.css', __DIR__ . '/icons.css');
    foreach ($cssFiles as $cssFile) {
        $fileContent = '/* ' . \fpcm\model\files\ops::removeBaseDir($cssFile) . ' */' . PHP_EOL . file_get_contents($cssFile) . PHP_EOL . PHP_EOL;
        if (!$fileContent) {
            continue;
        }
        $data['content'] .= $fileContent;
        $data['filesize'] += filesize($cssFile);
    }
    $cache->write($data, FPCM_LANGCACHE_TIMEOUT);
} else {
    $data = $cache->read();
}
header("Content-Type: text/css");
if (!FPCM_NOJSCSSPHP_FILESIZE_HEADER) {
    header("Content-Length: " . $data['filesize']);
}
die($data['content']);
Пример #6
0
 /**
  * Überschreibt systemweite Einstellungen mit Benutzer-Einstellungen
  * @return void
  */
 public function setUserSettings()
 {
     if (!defined('FPCM_USERID') || !FPCM_USERID) {
         return false;
     }
     $cache2 = new \fpcm\classes\cache($this->cacheName . '_user' . FPCM_USERID, 'system');
     $userData = $cache2->read();
     if ($cache2->isExpired() || !$this->useCache || !is_array($userData)) {
         $userData = $this->dbcon->fetch($this->dbcon->select(\fpcm\classes\database::tableAuthors, 'id, usrmeta', 'id = ?', array(FPCM_USERID)));
         $userData = json_decode($userData->usrmeta, true);
         if (!is_array($userData)) {
             return false;
         }
         $cache2->write($userData, $this->system_cache_timeout);
     }
     foreach ($userData as $key => $value) {
         $this->data[$key] = $value;
     }
     if ($this->system_lang != \fpcm\classes\baseconfig::$fpcmLanguage->getLangCode()) {
         \fpcm\classes\baseconfig::$fpcmLanguage = new \fpcm\classes\language($this->system_lang);
     }
 }
Пример #7
0
 public function run($params = null)
 {
     $this->dataPath = \fpcm\classes\baseconfig::$dataDir . 'langeditback/';
     $view = new \fpcm\model\view\module(\fpcm\model\abstracts\module::getModuleKeyByFolder(__DIR__), 'acp', 'main');
     $systemFiles = glob(\fpcm\classes\baseconfig::$langDir . '*/*.php');
     $moduleFiles = glob(\fpcm\classes\baseconfig::$moduleDir . '*/*/lang/*/*.php');
     if (!is_array($systemFiles) || !is_array($moduleFiles)) {
         $view->addErrorMessage('NKORG_LANGEDITOR_LOADERROR');
         $view->render();
         return true;
     }
     $langfiles = array_merge($systemFiles, $moduleFiles);
     $selectedFile = '';
     $lines = array();
     if (!is_null(\fpcm\classes\http::postOnly('btnLangfileSelect')) && \fpcm\classes\http::postOnly('langfile')) {
         $selectedFile = base64_decode(\fpcm\classes\http::postOnly('langfile'));
         if (!in_array($selectedFile, $langfiles) || !file_exists($selectedFile)) {
             $view->addErrorMessage('NKORG_LANGEDITOR_SELECTERROR');
             $selectedFile = '';
         } else {
             require $selectedFile;
             if (!isset($lang)) {
                 $view->addErrorMessage('NKORG_LANGEDITOR_FILEERROR');
             } else {
                 $lines = $lang;
             }
         }
     }
     if (!is_null(\fpcm\classes\http::postOnly('btnEditLangfile')) && \fpcm\classes\http::postOnly('langitems') && \fpcm\classes\http::postOnly('langfile')) {
         $selectedFile = base64_decode(\fpcm\classes\http::postOnly('langfile'));
         if (!is_writable(\fpcm\classes\baseconfig::$langDir)) {
             $view->addErrorMessage('NKORG_LANGEDITOR_NOTWRITABLE', array('{{syslangapth}}' => \fpcm\model\files\ops::removeBaseDir(\fpcm\classes\baseconfig::$langDir)));
         } else {
             $langItems = \fpcm\classes\http::postOnly('langitems', array(4, 7));
             $deletedItems = \fpcm\classes\http::postOnly('deleteitems');
             if (!is_array($deletedItems)) {
                 $deletedItems = array();
             }
             $fileLines = array();
             foreach ($langItems as $item) {
                 $name = $item['name'];
                 $value = $item['value'];
                 $hash = md5($name . $value);
                 if (!$name || !$value || in_array($hash, $deletedItems)) {
                     continue;
                 }
                 $fileLines[strtoupper($name)] = str_replace('\\n', PHP_EOL, $value);
             }
             $lines = $fileLines;
             $selectedFileBack = str_replace(DIRECTORY_SEPARATOR, '_', ltrim(\fpcm\model\files\ops::removeBaseDir($selectedFile), DIRECTORY_SEPARATOR));
             $dest = $this->dataPath . $selectedFileBack . '.' . date('YmdHis');
             if (!copy($selectedFile, $dest)) {
                 $dest = \fpcm\model\files\ops::removeBaseDir($dest, true);
                 $view->addErrorMessage('NKORG_LANGEDITOR_BACKUPERROR', array('{{path}}' => $dest));
                 trigger_error('Unable to create backup of ' . \fpcm\model\files\ops::removeBaseDir($selectedFile) . ' in ' . \fpcm\model\files\ops::removeBaseDir($this->dataPath, true));
             } else {
                 $fileContent = file_get_contents($selectedFile);
                 $langVarPos = strpos($fileContent, '$lang');
                 $fileContent = trim(substr($fileContent, 0, $langVarPos));
                 $fileContent .= PHP_EOL . PHP_EOL . '$lang = ' . var_export($fileLines, true) . ';' . PHP_EOL . '?>';
                 if (!file_put_contents($selectedFile, $fileContent)) {
                     trigger_error('Unable to save changes to language file ' . $selectedFile);
                     $view->addErrorMessage('NKORG_LANGEDITOR_SAVEERROR');
                 } else {
                     $view->addNoticeMessage('NKORG_LANGEDITOR_SAVEOK');
                 }
                 $cache = new \fpcm\classes\cache();
                 $cache->cleanup();
             }
         }
     }
     $files = array($this->lang->translate('NKORG_LANGEDITOR_FILE') => '');
     $excludeArray = array('help.php', 'tz.php');
     foreach ($langfiles as $langfile) {
         $basename = basename($langfile);
         if (in_array($basename, $excludeArray)) {
             continue;
         }
         $files[\fpcm\model\files\ops::removeBaseDir($langfile)] = base64_encode($langfile);
     }
     $view->assign('lines', $lines);
     $view->assign('langfiles', $files);
     $view->assign('selectedFile', $selectedFile);
     $view->render();
 }
Пример #8
0
 /**
  * CLI: Cache Aktionen durchführen
  * @return bool
  */
 public function processCache()
 {
     if (!isset($this->funcParams[1])) {
         $this->output('Invalid params detected, missing cache name or param "all"!');
         return true;
     }
     $cacheName = $this->funcParams[1] === 'all' ? null : $this->funcParams[1];
     $cacheModule = !isset($this->funcParams[2]) || $this->funcParams[2] === 'all' ? '' : $this->funcParams[2];
     $cache = new \fpcm\classes\cache($cacheName, $cacheModule);
     if ($this->funcParams[0] === self::FPCMCLI_PARAM_CLEAN) {
         $cache->cleanup($cacheName === null ? false : $cacheName, $cacheModule);
         $this->output('Cache was cleared!');
         return true;
     }
     if ($this->funcParams[0] === self::FPCMCLI_PARAM_INFO) {
         $this->output('Cache expiration interval: ' . date('Y-m-d H:i:s', $cache->getExpirationTime()));
         $this->output('Cache is expired: ' . (int) $cache->isExpired());
         return true;
     }
     if ($this->funcParams[0] === self::FPCMCLI_PARAM_SIZE) {
         $this->output('Cache total size: ' . \fpcm\classes\tools::calcSize($cache->getSize()));
         return true;
     }
     if ($this->funcParams[0] === self::FPCMCLI_PARAM_LIST) {
         $this->output('Cache structur: ');
         $this->output($cache->getCacheComplete());
         return true;
     }
 }
Пример #9
0
 /**
  * Page-Token prüfen
  * @return boolean
  */
 protected function checkPageToken()
 {
     if (isset($_SERVER['HTTP_REFERER']) && !is_null($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], \fpcm\classes\baseconfig::$rootPath) === false) {
         return false;
     }
     $fieldname = \fpcm\classes\security::getPageTokenFieldName();
     $cache = new \fpcm\classes\cache($fieldname, \fpcm\classes\security::pageTokenCacheModule);
     $tokenData = $cache->read();
     $cache->cleanup($fieldname, \fpcm\classes\security::pageTokenCacheModule);
     if (\fpcm\classes\http::getPageToken() == $tokenData) {
         return true;
     }
     return false;
 }