Exemple #1
0
 /**
  * Auszuführender Cron-Code
  */
 public function run()
 {
     if (!\fpcm\classes\baseconfig::asyncCronjobsEnabled()) {
         return false;
     }
     if (!is_writable(\fpcm\classes\baseconfig::$tempDir)) {
         trigger_error('Unable to cleanup ' . \fpcm\classes\baseconfig::$tempDir . '! Access denied!');
         return false;
     }
     $tempFiles = glob(\fpcm\classes\baseconfig::$tempDir . '*');
     if (!is_array($tempFiles) || !count($tempFiles)) {
         return true;
     }
     foreach ($tempFiles as $tempFile) {
         if ($tempFile == \fpcm\classes\baseconfig::$tempDir . 'index.html') {
             continue;
         }
         if (filectime($tempFile) + 3600 * 24 > time()) {
             continue;
         }
         if (is_dir($tempFile)) {
             \fpcm\model\files\ops::deleteRecursive($tempFile);
             continue;
         }
         unlink($tempFile);
     }
     \fpcm\classes\logs::syslogWrite('Temp files cleanup in ' . \fpcm\classes\baseconfig::$tempDir);
     return true;
 }
 /**
  * wird ausgeführt, wenn Cache über "Cache leeren" Button geleert wird
  * @param array $data
  * @return mixed
  */
 public function run($data = null)
 {
     $functionData = explode('_', $data['name'], 3);
     if (!isset($functionData[0]) || !isset($functionData[1]) || !isset($functionData[2])) {
         trigger_error('Malformed function name data given: "' . $data['name'] . '"');
         return false;
     }
     $vendorKey = $functionData[0];
     $moduleKey = $functionData[1];
     $functionName = $functionData[2];
     $classFile = \fpcm\classes\baseconfig::$moduleDir . $vendorKey . '/' . $moduleKey . '/events/apiCallFunction.php';
     if (!file_exists($classFile)) {
         trigger_error('Event class "apiCallFunction" not found in ' . \fpcm\model\files\ops::removeBaseDir($classFile, true));
         return false;
     }
     $classkey = $vendorKey . '/' . $moduleKey;
     $eventClass = \fpcm\model\abstracts\module::getModuleEventNamespace($classkey, 'apiCallFunction');
     /**
      * @var \fpcm\model\abstracts\event
      */
     $module = new $eventClass();
     if (!$this->is_a($module)) {
         return false;
     }
     $data['name'] = $functionName;
     return $module->run($data);
 }
 public function runInstall()
 {
     if (!is_dir($this->dataPath) && !mkdir($this->dataPath, 0777)) {
         trigger_error('Unable to create module datapath in ' . \fpcm\model\files\ops::removeBaseDir($this->dataPath, true));
         return false;
     }
     if (!file_exists($this->dataPath) || !is_writable($this->dataPath)) {
         trigger_error('Module datapath ' . \fpcm\model\files\ops::removeBaseDir($this->dataPath, true) . ' was not found or is not writable!');
         return false;
     }
     return true;
 }
Exemple #4
0
 /**
  * Check ausführen
  */
 protected function runCheck()
 {
     $checkFolders = array($this->language->translate('SYSCHECK_FOLDER_DATA') => \fpcm\classes\baseconfig::$dataDir, $this->language->translate('SYSCHECK_FOLDER_CACHE') => \fpcm\classes\baseconfig::$cacheDir, $this->language->translate('SYSCHECK_FOLDER_CONFIG') => \fpcm\classes\baseconfig::$configDir, $this->language->translate('SYSCHECK_FOLDER_FILEMANAGER') => \fpcm\classes\baseconfig::$filemanagerTempDir, $this->language->translate('SYSCHECK_FOLDER_LOGS') => \fpcm\classes\baseconfig::$logDir, $this->language->translate('SYSCHECK_FOLDER_MODULES') => \fpcm\classes\baseconfig::$moduleDir, $this->language->translate('SYSCHECK_FOLDER_SHARE') => \fpcm\classes\baseconfig::$shareDir, $this->language->translate('SYSCHECK_FOLDER_SMILEYS') => \fpcm\classes\baseconfig::$smileyDir, $this->language->translate('SYSCHECK_FOLDER_STYLES') => \fpcm\classes\baseconfig::$stylesDir, $this->language->translate('SYSCHECK_FOLDER_TEMP') => \fpcm\classes\baseconfig::$tempDir, $this->language->translate('SYSCHECK_FOLDER_UPLOADS') => \fpcm\classes\baseconfig::$uploadDir, $this->language->translate('SYSCHECK_FOLDER_DBDUMPS') => \fpcm\classes\baseconfig::$dbdumpDir, $this->language->translate('SYSCHECK_FOLDER_DRAFTS') => \fpcm\classes\baseconfig::$articleTemplatesDir);
     natcasesort($checkFolders);
     $this->tableContent[] = '<tr colspan="2"><td class="fpcm-ui-center"><a class="fpcm-ui-button fpcm-ui-margin-icon fpcm-syscheck-btn" href="index.php?module=system/options&syscheck=1">' . $this->language->translate('SYSCHECK_COMPLETE') . '</a></td></tr>';
     $this->tableContent[] = '<tr><td colspan="2" class="fpcm-td-spacer" style="padding-bottom:0.5em;"></td></tr>';
     foreach ($checkFolders as $description => $folderPath) {
         $checkres = $this->boolToText(is_writable($folderPath));
         $linePath = \fpcm\model\files\ops::removeBaseDir($folderPath, true);
         $this->tableContent[] = "<tr><td title=\"{$linePath}\"><strong>{$description}:</strong></td><td class=\"fpcm-ui-center\">{$checkres}</td></tr>";
     }
     $this->tableContent[] = '<tr><td><strong>' . $this->language->translate('SYSTEM_CHECK_CONNECT') . ':</strong></td><td class="fpcm-ui-center">' . $this->boolToText2(\fpcm\classes\baseconfig::canConnect()) . '</td></tr>';
 }
Exemple #5
0
 /**
  * System-Check ausführen
  * @return array
  */
 protected function getCheckOptionsSystem()
 {
     $checkOptions = array();
     $loadedExtensions = array_map('strtolower', get_loaded_extensions());
     $phpVer = '5.4.0';
     $checkOptions[$this->lang->translate('SYSTEM_OPTIONS_SYSCHECK_PHPVERSION')] = array('current' => phpversion(), 'recommend' => $phpVer, 'result' => version_compare(phpversion(), $phpVer, '>='), 'helplink' => 'http://php.net/', 'optional' => 0);
     $recomVal = 64;
     $curVal = \fpcm\classes\baseconfig::memoryLimit();
     $checkOptions[$this->lang->translate('SYSTEM_OPTIONS_SYSCHECK_PHPMEMLIMIT')] = array('current' => $curVal . ' MiB', 'recommend' => $recomVal . ' MiB', 'result' => $curVal >= $recomVal ? true : false, 'helplink' => 'http://php.net/manual/de/info.configuration.php', 'optional' => 1);
     $recomVal = 10;
     $curVal = ini_get('max_execution_time');
     $checkOptions[$this->lang->translate('SYSTEM_OPTIONS_SYSCHECK_PHPMAXEXECTIME')] = array('current' => $curVal . ' sec', 'recommend' => $recomVal . ' sec', 'result' => $curVal >= $recomVal ? true : false, 'helplink' => 'http://php.net/manual/de/info.configuration.php', 'optional' => 1);
     $dbDrivers = \PDO::getAvailableDrivers();
     $resultMySql = in_array('mysql', $dbDrivers);
     $resultPgSql = in_array('pgsql', $dbDrivers);
     $sqlhelp = 'http://php.net/manual/de/pdo.getavailabledrivers.php';
     $current = $resultMySql || $resultPgSql ? true : false;
     $checkOptions[$this->lang->translate('SYSTEM_OPTIONS_SYSCHECK_DBDRV_MYSQL')] = array('current' => $current ? 'true' : 'false', 'recommend' => 'true', 'result' => $resultMySql, 'helplink' => $sqlhelp, 'optional' => !$resultMySql && $resultPgSql ? 1 : 0);
     $checkOptions[$this->lang->translate('SYSTEM_OPTIONS_SYSCHECK_DBDRV_PGSQL')] = array('current' => $current ? 'true' : 'false', 'recommend' => 'true', 'result' => $resultPgSql, 'helplink' => $sqlhelp, 'optional' => $resultMySql ? 1 : 0);
     if (is_object(\fpcm\classes\baseconfig::$fpcmDatabase)) {
         $checkOptions[$this->lang->translate('SYSTEM_OPTIONS_SYSCHECK_DBDRV_ACTIVE')] = array('current' => \fpcm\classes\baseconfig::$fpcmDatabase->getDbtype(), 'recommend' => implode(', ', array_intersect($dbDrivers, array_keys(\fpcm\classes\database::$supportedDBMS))), 'result' => true, 'helplink' => 'http://php.net/manual/de/pdo.getavailabledrivers.php', 'optional' => 0);
         $checkOptions[$this->lang->translate('SYSTEM_OPTIONS_SYSCHECK_DBVERSION')] = array('current' => \fpcm\classes\baseconfig::$fpcmDatabase->getDbVersion(), 'recommend' => \fpcm\classes\baseconfig::$fpcmDatabase->getRecommendVersion(), 'result' => \fpcm\classes\baseconfig::$fpcmDatabase->checkDbVersion(), 'helplink' => 'http://php.net/manual/de/pdo.getattribute.php', 'optional' => 0);
     }
     $current = in_array('pdo', $loadedExtensions) && in_array('pdo_mysql', $loadedExtensions);
     $checkOptions['PHP Data Objects (PDO)'] = array('current' => $current ? 'true' : 'false', 'recommend' => 'true', 'result' => true && $current, 'helplink' => 'http://php.net/manual/en/class.pdo.php', 'optional' => 0);
     $current = CRYPT_SHA256 == 1 ? true : false;
     $current = $current && in_array(\fpcm\classes\security::defaultHashAlgo, hash_algos());
     $checkOptions['SHA256 Hash Algorithm'] = array('current' => $current ? 'true' : 'false', 'recommend' => 'true', 'result' => true && $current, 'helplink' => 'http://php.net/manual/en/function.hash-algos.php', 'optional' => 0);
     $current = in_array('gd', $loadedExtensions);
     $checkOptions['GD Lib'] = array('current' => $current ? 'true' : 'false', 'recommend' => 'true', 'result' => true && $current, 'helplink' => 'http://php.net/manual/en/book.image.php', 'optional' => 0);
     $current = in_array('json', $loadedExtensions);
     $checkOptions['JSON'] = array('current' => $current ? 'true' : 'false', 'recommend' => 'true', 'result' => true && $current, 'helplink' => 'http://php.net/manual/en/book.json.php', 'optional' => 0);
     $current = in_array('xml', $loadedExtensions) && in_array('simplexml', $loadedExtensions) && class_exists('DOMDocument');
     $checkOptions['XML, SimpleXML, DOMDocument'] = array('current' => $current ? 'true' : 'false', 'recommend' => 'true', 'result' => true && $current, 'helplink' => 'http://php.net/manual/en/class.simplexmlelement.php', 'optional' => 0);
     $current = in_array('zip', $loadedExtensions);
     $checkOptions['ZipArchive'] = array('current' => $current ? 'true' : 'false', 'recommend' => 'true', 'result' => true && $current, 'helplink' => 'http://php.net/manual/en/class.ziparchive.php', 'optional' => 0);
     $externalCon = \fpcm\classes\baseconfig::canConnect();
     $checkOptions['allow_url_fopen = 1 (' . $this->lang->translate('GLOBAL_OPTIONAL') . ')'] = array('current' => $externalCon ? 'true' : false, 'recommend' => 'true', 'result' => true && $externalCon, 'helplink' => 'http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen', 'optional' => 1);
     $current = in_array('curl', $loadedExtensions);
     $checkOptions['cURL (' . $this->lang->translate('GLOBAL_OPTIONAL') . ')'] = array('current' => $current ? 'true' : 'false', 'recommend' => 'true', 'result' => false || $current, 'helplink' => 'http://php.net/manual/en/book.curl.php', 'optional' => 1);
     $current = in_array('phar', $loadedExtensions);
     $checkOptions['Phar (' . $this->lang->translate('GLOBAL_OPTIONAL') . ')'] = array('current' => $current ? 'true' : 'false', 'recommend' => 'true', 'result' => false || $current, 'helplink' => 'http://php.net/manual/en/class.phar.php', 'optional' => 1);
     $checkFolders = $this->getCheckFolders();
     foreach ($checkFolders as $description => $folderPath) {
         $current = is_writable($folderPath);
         $pathOutput = \fpcm\model\files\ops::removeBaseDir($folderPath, true);
         $checkOptions['<i>' . $description . ' ' . $pathOutput . '</i> ' . $this->lang->translate('GLOBAL_WRITABLE')] = array('current' => $current ? 'true' : 'false', 'recommend' => 'true', 'result' => true && $current, 'optional' => 0);
     }
     return $checkOptions;
 }
Exemple #6
0
 /**
  * Kopiert Inhalt von Paket von Quelle nach Ziel
  * @return boolean
  */
 public function copy()
 {
     if (!file_exists($this->tempListFile)) {
         \fpcm\classes\baseconfig::enableAsyncCronjobs(true);
         return false;
     }
     $this->loadPackageFileListFromTemp();
     if (!count($this->files)) {
         \fpcm\classes\baseconfig::enableAsyncCronjobs(true);
         return false;
     }
     $vendorFolder = \fpcm\classes\baseconfig::$baseDir . $this->copyDestination . dirname($this->key);
     if (!is_dir($vendorFolder) && !mkdir($vendorFolder)) {
         trigger_error('Unable to create module vendor folder ' . \fpcm\model\files\ops::removeBaseDir($vendorFolder, true));
         \fpcm\classes\baseconfig::enableAsyncCronjobs(true);
         return false;
     }
     $res = true;
     foreach ($this->files as $zipFile) {
         $source = $this->extractPath . $zipFile;
         $dest = \fpcm\classes\baseconfig::$baseDir . $this->copyDestination . str_replace(basename($this->key) . '/', $this->key . '/', $zipFile);
         $dest = $this->replaceFanpressDirString($dest);
         if (is_dir($source)) {
             if (!file_exists($dest) && !mkdir($dest, 0777)) {
                 if (!is_array($res)) {
                     $res = array();
                 }
                 $res[] = $dest;
             }
             continue;
         }
         if (file_exists($dest)) {
             if (sha1_file($source) == sha1_file($dest)) {
                 continue;
             }
             $backFile = $dest . '.back';
             if (file_exists($backFile)) {
                 unlink($backFile);
             }
             rename($dest, $backFile);
         }
         if (!copy($source, $dest)) {
             if (!is_array($res)) {
                 $res = array();
             }
             $res[] = $dest;
         }
     }
     return is_array($res) ? self::FPCMPACKAGE_FILESCOPY_ERROR : $res;
 }
Exemple #7
0
 /**
  * Auszuführender Cron-Code
  */
 public function run()
 {
     if (\fpcm\classes\baseconfig::$fpcmDatabase->getDbtype() == 'pgsql') {
         $this->updateLastExecTime();
         return true;
     }
     include_once \fpcm\classes\loader::libGetFilePath('Ifsnop/Mysqldump', 'Mysqldump.php');
     $dbconfig = \fpcm\classes\baseconfig::getDatabaseConfig();
     $dumpSettings = array();
     $this->dumpfile = \fpcm\classes\baseconfig::$dbdumpDir . '/' . $dbconfig['DBNAME'] . '_' . date('Y-m-d_H-i-s') . '.sql';
     if (function_exists('gzopen')) {
         $dumpSettings['compress'] = \Ifsnop\Mysqldump\Mysqldump::GZIP;
         $this->dumpfile .= '.gz';
     }
     $dumpSettings['single-transaction'] = false;
     $dumpSettings['lock-tables'] = false;
     $dumpSettings['add-locks'] = false;
     $dumpSettings['extended-insert'] = false;
     $dumpSettings['no-autocommit'] = false;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableArticles;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableAuthors;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableCategories;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableComments;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableConfig;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableCronjobs;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableFiles;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableIpAdresses;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableModules;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tablePermissions;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableRoll;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableSessions;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableSmileys;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableTexts;
     $dumpSettings['include-tables'][] = $dbconfig['DBPREF'] . '_' . \fpcm\classes\database::tableRevisions;
     $dumpSettings['include-tables'] = $this->events->runEvent('cronjobDbDumpIncludeTables', $dumpSettings['include-tables']);
     \fpcm\classes\logs::syslogWrite('Create new database dump in "' . \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true) . '"...');
     $mysqlDump = new \Ifsnop\Mysqldump\Mysqldump($dbconfig['DBNAME'], $dbconfig['DBUSER'], $dbconfig['DBPASS'], $dbconfig['DBHOST'], $dbconfig['DBTYPE'], $dumpSettings);
     $mysqlDump->start($this->dumpfile);
     $this->updateLastExecTime();
     if (!file_exists($this->dumpfile)) {
         \fpcm\classes\logs::syslogWrite('Unable to create database dump in "' . \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true) . '", file not found. See system check and error log!');
         return false;
     }
     \fpcm\classes\logs::syslogWrite('New database dump created in "' . \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true) . '".');
     $text = \fpcm\classes\baseconfig::$fpcmLanguage->translate('CRONJOB_DBBACKUPS_TEXT', array('{{filetime}}' => date(\fpcm\classes\baseconfig::$fpcmConfig->system_dtmask, $this->getLastExecTime()), '{{dumpfile}}' => \fpcm\model\files\ops::removeBaseDir($this->dumpfile, true)));
     $email = new \fpcm\classes\email(\fpcm\classes\baseconfig::$fpcmConfig->system_email, \fpcm\classes\baseconfig::$fpcmLanguage->translate('CRONJOB_DBBACKUPS_SUBJECT'), $text);
     $email->submit();
     return true;
 }
Exemple #8
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']);
 /**
  * Controller-Processing
  */
 public function process()
 {
     if (!parent::process()) {
         return false;
     }
     if ($this->canConnect) {
         $keyData = \fpcm\model\packages\package::explodeModuleFileName($this->key);
         $pkg = new \fpcm\model\packages\module('module', $keyData[0], $keyData[1]);
     }
     if (!isset($keyData[0]) || !isset($keyData[1])) {
         $this->returnCode = $this->step . '_0';
         $this->getResponse();
     }
     $this->returnData['current'] = $this->step;
     switch ($this->step) {
         case 1:
             $res = $pkg->download();
             $from = $pkg->getRemoteFile();
             if ($res === true) {
                 \fpcm\classes\logs::syslogWrite('Downloaded module package successfully from ' . $from);
                 $this->returnData['nextstep'] = 2;
             } else {
                 \fpcm\classes\logs::syslogWrite('Error while downloading module package from' . $from);
                 $this->returnData['nextstep'] = 5;
             }
             break;
         case 2:
             $res = $pkg->extract();
             $from = \fpcm\model\files\ops::removeBaseDir($pkg->getLocalFile());
             if ($res === true) {
                 \fpcm\classes\logs::syslogWrite('Extracted module package successfully from ' . $from);
                 $this->returnData['nextstep'] = 3;
             } else {
                 \fpcm\classes\logs::syslogWrite('Error while extracting module package from ' . $from);
                 $this->returnData['nextstep'] = 5;
             }
             break;
         case 3:
             $res = $pkg->copy();
             $dest = \fpcm\model\files\ops::removeBaseDir(\fpcm\classes\baseconfig::$baseDir) . $pkg->getCopyDestination() . $pkg->getKey();
             $from = \fpcm\model\files\ops::removeBaseDir($pkg->getExtractPath() . basename($pkg->getKey()));
             if ($res === true) {
                 \fpcm\classes\logs::syslogWrite('Moved module package content successfully from ' . $from . ' to ' . $dest);
                 $this->returnData['nextstep'] = 4;
             } else {
                 \fpcm\classes\logs::syslogWrite('Error while moving module package content from ' . $from . ' to ' . $dest);
                 \fpcm\classes\logs::syslogWrite(implode('<br>', $pkg->getCopyErrorPaths()));
                 $this->returnData['nextstep'] = 5;
             }
             break;
         case 4:
             $moduleClass = \fpcm\model\abstracts\module::getModuleClassName($keyData[0]);
             $res = class_exists($moduleClass);
             $moduleClassPath = \fpcm\classes\baseconfig::$moduleDir . $keyData[0] . '/' . str_replace(array('\\', '/'), '', $keyData[0]) . '.php';
             if (!file_exists($moduleClassPath)) {
                 $res = false;
                 trigger_error('Module class ' . $moduleClass . ' not found in "' . $moduleClassPath . '"!');
                 $this->returnData['nextstep'] = 5;
                 break;
             }
             if ($res) {
                 $modObj = new $moduleClass($keyData[0], '', $keyData[1]);
                 if (!is_a($modObj, '\\fpcm\\model\\abstracts\\module')) {
                     $res = false;
                     trigger_error('Module class ' . $moduleClass . ' must be an instance of "\\fpcm\\model\\abstracts\\module"!');
                     break;
                 }
                 $res = $modObj->runInstall();
             }
             $this->returnData['nextstep'] = 5;
             if ($res === true) {
                 \fpcm\classes\logs::syslogWrite('Run final module install steps successfully for ' . $pkg->getKey());
             } else {
                 \fpcm\classes\logs::syslogWrite('Error while running final module install steps for ' . $pkg->getKey());
             }
             break;
         case 5:
             if ($this->canConnect) {
                 $pkg->loadPackageFileListFromTemp();
                 \fpcm\classes\logs::pkglogWrite($pkg->getKey() . ' ' . $pkg->getVersion(), $pkg->getFiles());
                 $pkg->cleanup();
             }
             \fpcm\classes\baseconfig::enableAsyncCronjobs(true);
             $this->cache->cleanup();
             $res = true;
             break;
         default:
             $res = false;
             break;
     }
     $this->returnCode = $this->step . '_' . (int) $res;
     $this->getResponse();
 }
Exemple #10
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();
 }
Exemple #11
0
 /**
  * Prüfung von Dateisystem-Strukturen
  * @return bool
  */
 private function checkFilesystem()
 {
     if (file_exists(\fpcm\classes\baseconfig::$viewsDir . 'logs/cronjobs.php')) {
         unlink(\fpcm\classes\baseconfig::$viewsDir . 'logs/cronjobs.php');
     }
     if ($this->checkVersion('3.2.0', '>=')) {
         return true;
     }
     if (is_dir(\fpcm\classes\baseconfig::$dataDir . 'dbstruct')) {
         \fpcm\model\files\ops::deleteRecursive(\fpcm\classes\baseconfig::$dataDir . 'dbstruct');
     }
     if (is_dir(\fpcm\classes\baseconfig::$dataDir . 'dbstruct')) {
         \fpcm\model\files\ops::deleteRecursive(\fpcm\classes\baseconfig::$dataDir . 'dbstruct');
     }
     if (file_exists(\fpcm\classes\baseconfig::$jsPath . 'backupmgr.js')) {
         unlink(\fpcm\classes\baseconfig::$jsPath . 'backupmgr.js');
     }
     $libPath = \fpcm\classes\loader::libGetFilePath('jquery', 'jquery-2.1.4.min.js');
     if ($libPath) {
         unlink($libPath);
     }
     return true;
 }
Exemple #12
0
 /**
  * Module deinstallieren, nur wenn deaktiviert
  * @param array $keys
  * @return boolean
  */
 public function uninstallModules(array $keys)
 {
     $this->cache->cleanup();
     $keys = array_intersect($keys, $this->getDisabledInstalledModules());
     if (!count($keys)) {
         return false;
     }
     $res = true;
     foreach ($keys as $key) {
         $moduleClass = \fpcm\model\abstracts\module::getModuleClassName($key);
         if (!class_exists($moduleClass)) {
             continue;
         }
         $modObj = new $moduleClass($key, '', '');
         if (!is_a($modObj, '\\fpcm\\model\\abstracts\\module')) {
             continue;
         }
         $res = $res && $modObj->runUninstall();
     }
     $res = $res && $this->dbcon->delete($this->table, "(modkey = '" . implode("' OR modkey = '", $keys) . "') AND status = 0");
     $lastKey = false;
     foreach ($keys as $key) {
         $res = $res && \fpcm\model\files\ops::deleteRecursive(\fpcm\classes\baseconfig::$moduleDir . $key);
         $lastKey = $key;
     }
     if (!$lastKey) {
         return $res;
     }
     $folders = glob(\fpcm\classes\baseconfig::$moduleDir . dirname($lastKey) . '/*', GLOB_ONLYDIR);
     if (!count($folders)) {
         $res = $res && \fpcm\model\files\ops::deleteRecursive(\fpcm\classes\baseconfig::$moduleDir . dirname($lastKey));
     }
     return $res;
 }
 /**
  * Arary mit Informationen u. a. für template-Plugin von TinyMCE
  * @see \fpcm\model\abstracts\articleEditor::getTemplateDrafts()
  * @return array
  * @since FPCM 3.3
  */
 public function getTemplateDrafts()
 {
     $templatefilelist = new \fpcm\model\files\templatefilelist();
     $ret = array();
     foreach ($templatefilelist->getFolderList() as $file) {
         $basename = basename($file);
         if ($basename === 'index.html') {
             continue;
         }
         $ret[] = array("title" => $basename, "url" => \fpcm\model\files\ops::removeBaseDir($file, true));
     }
     return $ret;
 }
Exemple #14
0
 /**
  * Request-Handler
  * @return boolean
  */
 public function request()
 {
     if ($this->buttonClicked('uploadFile') && !is_null(\fpcm\classes\http::getFiles())) {
         $uploader = new \fpcm\model\files\fileuploader(\fpcm\classes\http::getFiles());
         $res = $uploader->processArticleTemplateUpload();
         if ($res == true) {
             $this->view->addNoticeMessage('SAVE_SUCCESS_UPLOADTPLFILE');
         } else {
             $this->view->addErrorMessage('SAVE_FAILED_UPLOADTPLFILE');
         }
         return true;
     }
     $delFiles = $this->getRequestVar('deltplfiles');
     if ($this->buttonClicked('fileDelete') && is_array($delFiles) && count($delFiles)) {
         $delFiles = array_map('base64_decode', $delFiles);
         $deletedOk = array();
         $deletedFailed = array();
         foreach ($delFiles as $delFile) {
             $articleTplFile = new \fpcm\model\files\templatefile($delFile);
             if (!$articleTplFile->delete()) {
                 $deletedFailed[] = \fpcm\model\files\ops::removeBaseDir($delFile);
                 continue;
             }
             $deletedOk[] = \fpcm\model\files\ops::removeBaseDir($delFile);
         }
         if (count($deletedOk)) {
             $this->view->addNoticeMessage('DELETE_SUCCESS_FILES', array('{{filenames}}' => implode(', ', $deletedOk)));
         }
         if (count($deletedFailed)) {
             $this->view->addErrorMessage('DELETE_FAILED_FILES', array('{{filenames}}' => implode(', ', $deletedFailed)));
         }
         return true;
     }
     if ($this->buttonClicked('saveTemplates') && !is_null($this->getRequestVar('template'))) {
         $this->cache->cleanup();
         $templateContents = $this->getRequestVar('template');
         $tplSaveError = array();
         $tplSaveOk = array();
         foreach ($templateContents as $templateName => $newContent) {
             $tplObj = $this->{$templateName . 'Template'};
             $tplObj->setContent($newContent);
             $res = $tplObj->save();
             if (is_null($res) && $templateName == 'commentForm') {
                 $this->view->addErrorMessage('SAVE_FAILED_TEMPLATE_CF_URLMISSING');
             } elseif (!$res) {
                 $tplSaveError[] = $tplObj->getFilename();
             } else {
                 $tplSaveOk[] = $tplObj->getFilename();
             }
         }
         if (count($tplSaveError)) {
             $this->view->addErrorMessage('SAVE_FAILED_TEMPLATE', array('{{filenames}}' => implode(', ', $tplSaveError)));
         }
         if (count($tplSaveOk)) {
             $this->view->addNoticeMessage('SAVE_SUCCESS_TEMPLATE', array('{{filenames}}' => implode(', ', $tplSaveOk)));
         }
     }
     return true;
 }
Exemple #15
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     if (!parent::process()) {
         return false;
     }
     $this->canConnect = \fpcm\classes\baseconfig::canConnect();
     if ($this->canConnect) {
         $versionDataFile = new \fpcm\model\files\tempfile('newversion');
         if ($versionDataFile->exists() && $versionDataFile->getContent()) {
             $remoteData = json_decode($versionDataFile->getContent(), true);
         } else {
             $updater = new \fpcm\model\updater\system();
             $updater->checkUpdates();
             $remoteData = $updater->getRemoteData();
             $versionDataFile->setContent(json_encode($remoteData));
             $versionDataFile->save();
         }
         $fileInfo = pathinfo($remoteData['filepath'], PATHINFO_FILENAME);
         $tmpFile = new \fpcm\model\files\tempfile('forceUpdateFile');
         if ($tmpFile->exists()) {
             $fileInfo = $tmpFile->getContent();
         }
         $signature = isset($remoteData['signature']) ? $remoteData['signature'] : '';
         $pkg = new \fpcm\model\packages\update('update', $fileInfo, '', $signature);
     }
     $this->returnData['current'] = $this->step;
     switch ($this->step) {
         case 1:
             $res = $pkg->download();
             if ($res === \fpcm\model\packages\package::FPCMPACKAGE_REMOTEFILE_ERROR) {
                 $versionDataFile->delete();
             }
             if ($res === true) {
                 \fpcm\classes\logs::syslogWrite('Downloaded update package successfully from ' . $pkg->getRemoteFile());
                 $this->returnData['nextstep'] = 2;
             } else {
                 \fpcm\classes\logs::syslogWrite('Error while downloading update package from ' . $pkg->getRemoteFile());
                 $this->returnData['nextstep'] = 5;
             }
             break;
         case 2:
             $res = $pkg->extract();
             $from = \fpcm\model\files\ops::removeBaseDir($pkg->getLocalFile());
             if ($res === true) {
                 \fpcm\classes\logs::syslogWrite('Extracted update package successfully from ' . $from);
                 $this->returnData['nextstep'] = 3;
             } else {
                 \fpcm\classes\logs::syslogWrite('Error while extracting update package from ' . $from);
                 $this->returnData['nextstep'] = 5;
             }
             break;
         case 3:
             $res = $pkg->copy();
             $dest = \fpcm\model\files\ops::removeBaseDir(\fpcm\classes\baseconfig::$baseDir);
             $from = \fpcm\model\files\ops::removeBaseDir($pkg->getExtractPath());
             if ($res === true) {
                 \fpcm\classes\logs::syslogWrite('Moved update package content successfully from ' . $from . ' to ' . $dest);
                 $this->returnData['nextstep'] = 4;
             } else {
                 \fpcm\classes\logs::syslogWrite('Error while moving update package content from ' . $from . ' to ' . $dest);
                 \fpcm\classes\logs::syslogWrite(implode('<br>', $pkg->getCopyErrorPaths()));
                 $this->returnData['nextstep'] = 5;
             }
             break;
         case 4:
             $finalizer = new \fpcm\model\updater\finalizer();
             $res = $finalizer->runUpdate();
             $this->returnData['nextstep'] = $this->forceStep ? 6 : 5;
             if ($res === true) {
                 \fpcm\classes\logs::syslogWrite('Run final update steps successfully!');
             } else {
                 \fpcm\classes\logs::syslogWrite('Error while running final update steps!');
             }
             break;
         case 5:
             if ($this->canConnect) {
                 $pkg->loadPackageFileListFromTemp();
                 \fpcm\classes\logs::pkglogWrite($pkg->getKey() . ' ' . $pkg->getVersion(), $pkg->getFiles());
                 $pkg->cleanup();
             }
             \fpcm\classes\baseconfig::enableAsyncCronjobs(true);
             $this->cache->cleanup();
             $res = true;
             $this->returnData['nextstep'] = 6;
             break;
         case 6:
             $this->returnData['newver'] = $this->config->system_version;
             $res = true;
             if ($versionDataFile->exists()) {
                 $versionDataFile->delete();
             }
             break;
         default:
             $res = false;
             break;
     }
     $this->returnCode = $this->step . '_' . (int) $res;
     $this->getResponse();
 }
Exemple #16
0
$FPCM_LANG->write('NKORG_LANGEDITOR_HEADLINE');
?>
            <?php 
fpcm\model\view\helper::helpButton('NKORG_LANGEDITOR_HEADLINE');
?>
        </h1>

        <div class="fpcm-tabs-general">

            <ul>
                <li><a href="#langvars"><?php 
$FPCM_LANG->write('NKORG_LANGEDITOR_HEADLINE');
if ($selectedFile) {
    ?>
: <?php 
    print \fpcm\model\files\ops::removeBaseDir($selectedFile);
}
?>
</a></li>
            </ul>

            <div id="langvars">
    
            <?php 
if (count($lines)) {
    ?>
                <table class="fpcm-ui-table fpcm-ui-middle">
                    <tr>
                        <th><?php 
    $FPCM_LANG->write('NKORG_LANGEDITOR_LANGVAR');
    ?>
Exemple #17
0
 public function run($params = null)
 {
     $datapath = \fpcm\model\files\ops::removeBaseDir(\fpcm\classes\baseconfig::$dataDir . 'langeditback/');
     $params['NKORG_LANGEDITOR_HEADLINE'] = $this->lang->translate('NKORG_LANGEDITOR_MANAGER_HELP', array('{{datapath}}' => $datapath));
     return $params;
 }
Exemple #18
0
 /**
  * Cache-Inhalt schreiben
  * @param mixed $data
  * @param int $expires
  */
 public function write($data, $expires = 0)
 {
     if (defined('FPCM_INSTALLER_NOCACHE') && FPCM_INSTALLER_NOCACHE) {
         return false;
     }
     $parent = dirname($this->fileName);
     if ($this->hasModule && !is_dir($parent) && !mkdir($parent)) {
         trigger_error('Unable to create cache subdirectory in ' . \fpcm\model\files\ops::removeBaseDir($parent, true));
         return false;
     }
     if (!is_null($this->fileName)) {
         file_put_contents($this->fileName, base64_encode(serialize(array('data' => $data, 'expires' => time() + $expires))));
     }
 }
Exemple #19
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();
 }
Exemple #20
0
 /**
  * Logfiles auswerten
  * @return boolean
  */
 public function processLogs()
 {
     if (!isset($this->funcParams[1]) || !trim($this->funcParams[1])) {
         $this->output('Invalid params', true);
     }
     $path = \fpcm\classes\baseconfig::$logDir . $this->funcParams[1] . '.txt';
     $this->output('--- Logfile: ' . \fpcm\model\files\ops::removeBaseDir($path, true) . ' ---');
     if (!file_exists($path) || !in_array($path, \fpcm\classes\baseconfig::$logFiles)) {
         $this->output('Logfile ' . \fpcm\model\files\ops::removeBaseDir($path, true) . ' not found!', true);
     }
     if ($this->funcParams[0] === self::FPCMCLI_PARAM_CLEAR && !file_put_contents($path, '') === false) {
         $this->output('Unable to clear logfile ' . \fpcm\model\files\ops::removeBaseDir($path, true) . '!', true);
     }
     $rows = file($path, FILE_SKIP_EMPTY_LINES);
     if (!is_array($rows)) {
         $this->output('Unable to load logfile ' . \fpcm\model\files\ops::removeBaseDir($path, true) . '!', true);
     }
     if (!count($rows)) {
         $this->output('     >> No data available...');
         return true;
     }
     $rows = array_map('json_decode', $rows);
     $is_pkg_log = $path === \fpcm\classes\baseconfig::$logFiles['pkglog'] ? true : false;
     if ($this->funcParams[0] === self::FPCMCLI_PARAM_LIST) {
         foreach ($rows as $row) {
             if (!is_object($row)) {
                 continue;
             }
             $this->output('Entry added on: ' . $row->time);
             if ($is_pkg_log) {
                 $this->output('Package name: ' . $row->pkgname);
             }
             $this->output($row->text);
             $this->output('-----');
         }
     }
     return true;
 }