Example #1
0
 public function processCli()
 {
     $checkOptions = array();
     $updater = new \fpcm\model\updater\system();
     $updater->checkUpdates();
     $remoteVersion = $updater->getRemoteData('version');
     $versionCheckresult = version_compare($this->config->system_version, $remoteVersion, '>=');
     $checkOptions[$this->lang->translate('SYSTEM_OPTIONS_SYSCHECK_FPCMVERSION')] = array('current' => $this->config->system_version, 'recommend' => $remoteVersion ? $remoteVersion : $this->lang->translate('GLOBAL_NOTFOUND'), 'result' => $versionCheckresult, 'notice' => !$versionCheckresult ? 'You may run       : php ' . \fpcm\classes\baseconfig::$baseDir . 'fpcmcli.php pkg --upgrade system' : '');
     $checkOptions = array_merge($checkOptions, $this->getCheckOptionsSystem());
     return $this->events->runEvent('runSystemCheck', $checkOptions);
 }
Example #2
0
 /**
  * Auszuführender Cron-Code
  */
 public function run()
 {
     $updater = new \fpcm\model\updater\system();
     $res = $updater->checkUpdates();
     $this->setReturnData($res);
     /* @var $config \fpcm\model\system\config */
     $config = \fpcm\classes\baseconfig::$fpcmConfig;
     if (!$res && $this->getAsyncCurrent() && $config->system_updates_emailnotify) {
         $replacements = array('{{version}}' => $updater->getRemoteData('version'), '{{acplink}}' => \fpcm\classes\baseconfig::$rootPath);
         $language = \fpcm\classes\baseconfig::$fpcmLanguage;
         $email = new \fpcm\classes\email($config->system_email, $language->translate('CRONJOB_UPDATES_NEWVERSION'), $language->translate('CRONJOB_UPDATES_NEWVERSION_TEXT', $replacements));
         $email->submit();
     }
     $this->updateLastExecTime();
     return true;
 }
Example #3
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     if (!parent::process()) {
         return false;
     }
     if (!is_writable(\fpcm\classes\baseconfig::$versionFile)) {
         $this->view->addErrorMessage('UPDATE_WRITEERROR');
         $this->view->render();
         return false;
     }
     $this->config->setMaintenanceMode(false);
     $updater = new \fpcm\model\updater\system();
     $updater->checkUpdates();
     $remoteFilePath = $updater->getRemoteData('filepath');
     $params = $this->initPkgManagerData();
     $params['fpcmUpdaterMaxStep'] = 6;
     $params['fpcmUpdaterStartStep'] = $this->forceStep ? $this->forceStep : (\fpcm\classes\baseconfig::canConnect() ? 1 : 4);
     $params['fpcmUpdaterMessages']['1_START'] = $this->lang->translate('PACKAGES_RUN_DOWNLOAD', array('{{pkglink}}' => is_array($remoteFilePath) ? '' : $remoteFilePath));
     $params['fpcmUpdaterMessages']['EXIT_1'] = $this->lang->translate('UPDATES_SUCCESS');
     $this->view->addJsVars($params);
     $this->view->setViewJsFiles(array(\fpcm\classes\baseconfig::$jsPath . 'updater.js'));
     $this->view->render();
 }
Example #4
0
 /**
  * Paket Manager Aktionen
  * @return boolean
  */
 public function processPkg()
 {
     $updaterSys = new \fpcm\model\updater\system();
     $updaterMod = new \fpcm\model\updater\modules();
     $moduleList = new \fpcm\model\modules\modulelist();
     switch ($this->funcParams[0]) {
         case self::FPCMCLI_PARAM_UPDATE:
             $this->output('Check for system and module updates...');
             $successSys = $updaterSys->checkUpdates();
             $successMod = $updaterMod->checkUpdates();
             if ($successSys > 1 || $successMod > 1) {
                 $this->output('Unable to update package informations. Check PHP log for further information.' . PHP_EOL . 'Error Code: SYS-' . $successSys . ' | MOD-' . $successMod, true);
             }
             $this->output('Check successfull!');
             $this->output('Current system version: ' . $updaterSys->getRemoteData('version'));
             $this->output('Module updates available: ' . ($successMod ? 'yes' : 'no'));
             break;
         case self::FPCMCLI_PARAM_INSTALL:
         case self::FPCMCLI_PARAM_UPGRADE:
             if ($this->funcParams[1] !== self::FPCMCLI_PARAM_TYPE_MODULE && $this->funcParams[0] === self::FPCMCLI_PARAM_INSTALL) {
                 $this->output('Invalid params', true);
             }
             if ($this->funcParams[1] === self::FPCMCLI_PARAM_TYPE_SYSTEM) {
                 $this->output('Start system update...');
                 $successSys = $updaterSys->checkUpdates();
                 $remoteData = $updaterSys->getRemoteData();
                 $fileInfo = pathinfo($remoteData['filepath'], PATHINFO_FILENAME);
                 $pkg = new \fpcm\model\packages\update('update', $fileInfo);
             } elseif ($this->funcParams[1] === self::FPCMCLI_PARAM_TYPE_MODULE) {
                 $list = $moduleList->getModulesRemote();
                 $keyData = \fpcm\model\packages\package::explodeModuleFileName($this->funcParams[2]);
                 if (!array_key_exists($keyData[0], $list)) {
                     $this->output('The requested module was not found in package list storage. Check your module key or update package information storage.', true);
                 }
                 /* @var $module \fpcm\model\modules\listitem */
                 $module = $list[$keyData[0]];
                 $pkg = new \fpcm\model\packages\module('module', $module->getKey(), $module->getVersionRemote());
             }
             $this->output('Download package from ' . $pkg->getRemoteFile() . '...');
             $success = $pkg->download();
             if ($success !== true) {
                 $this->output('Download failed. ERROR CODE: ' . $success, true);
             }
             $this->output('Unpacking package file ' . \fpcm\model\files\ops::removeBaseDir($pkg->getLocalFile(), true) . '...');
             $success = $pkg->extract();
             if ($success !== true) {
                 $this->output('Unpacking failed. ERROR CODE: ' . $success, true);
             }
             $this->output('Copy package content...');
             $success = $pkg->copy();
             if ($success !== true) {
                 $this->output('Copy process failed. ERROR CODE: ' . $success, true);
             }
             if ($this->funcParams[1] === self::FPCMCLI_PARAM_TYPE_SYSTEM) {
                 $this->output('Run final update steps...');
                 $this->runFinalizer();
             } elseif ($this->funcParams[1] === self::FPCMCLI_PARAM_TYPE_MODULE) {
                 $this->output('Perform database changes...');
                 $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)) {
                     $this->output('Module class ' . $moduleClass . ' not found in "' . $moduleClassPath . '"!', true);
                 }
                 $modObj = new $moduleClass($pkg->getKey(), '', $module->getVersionRemote());
                 if (!is_a($modObj, '\\fpcm\\model\\abstracts\\module')) {
                     $this->output('Module class ' . $moduleClass . ' must be an instance of "\\fpcm\\model\\abstracts\\module"!', true);
                 }
                 if ($this->funcParams[0] === self::FPCMCLI_PARAM_INSTALL) {
                     if ($module->isInstalled()) {
                         $this->output('The selected module is already installed. Exiting...', true);
                     }
                     $res = $modObj->runInstall();
                 } elseif ($this->funcParams[0] === self::FPCMCLI_PARAM_UPGRADE) {
                     if (!$module->isInstalled()) {
                         $this->output('The selected module is not installed. Exiting...', true);
                     }
                     $res = $modObj->runUpdate();
                 }
             }
             $this->output('Update package manager log...');
             $pkg->loadPackageFileListFromTemp();
             \fpcm\classes\logs::pkglogWrite($pkg->getKey() . ' ' . $pkg->getVersion(), $pkg->getFiles());
             $this->output('Perform cleanup...');
             $success = $pkg->cleanup();
             if ($this->funcParams[1] === self::FPCMCLI_PARAM_TYPE_SYSTEM) {
                 $this->output('System update successfull. New version: ' . $this->config->system_version);
             }
             if ($this->funcParams[1] === self::FPCMCLI_PARAM_TYPE_MODULE) {
                 $this->output('Module installed successfull!');
             }
             break;
         case self::FPCMCLI_PARAM_UPGRADE_DB:
             if ($this->funcParams[1] === self::FPCMCLI_PARAM_TYPE_MODULE) {
                 $this->output('Invalid params', true);
             }
             if ($this->funcParams[1] === self::FPCMCLI_PARAM_TYPE_SYSTEM) {
                 $this->output('Update database and filesystem...');
                 $this->runFinalizer();
                 $this->output('Update successfull. New version: ' . $this->config->system_version);
             }
             break;
         case self::FPCMCLI_PARAM_REMOVE:
             if ($this->funcParams[1] !== self::FPCMCLI_PARAM_TYPE_MODULE) {
                 $this->output('Invalid params', true);
             }
             $list = $moduleList->getModulesRemote();
             $keyData = \fpcm\model\packages\package::explodeModuleFileName($this->funcParams[2]);
             if (!array_key_exists($keyData[0], $list)) {
                 $this->output('The requested module was not found in package list storage. Check your module key or update package information storage.', true);
             }
             /* @var $module \fpcm\model\modules\listitem */
             $module = $list[$keyData[0]];
             if (!$module->isInstalled()) {
                 $this->output('The selected module is not installed. Exiting...', true);
             }
             $module->runUninstall();
             if (!$moduleList->uninstallModules(array($keyData[0]))) {
                 $this->output('Unable to remove module ' . $keyData[0], true);
             }
             $this->output('Module ' . $keyData[0] . ' was removed successfully.');
             break;
         case self::FPCMCLI_PARAM_LIST:
             if ($this->funcParams[1] !== self::FPCMCLI_PARAM_TYPE_MODULE) {
                 $this->output('Invalid params', true);
             }
             $list = $moduleList->getModulesRemote(false);
             $out = array('', 'Available modules from package server for current FanPress CM version:', '');
             /* @var $value \fpcm\model\modules\listitem */
             foreach ($list as $value) {
                 $line = array('   == ' . $value->getName() . ' > ' . $value->getKey() . ', ' . $value->getVersionRemote(), '   ' . $value->getAuthor() . ' > ' . $value->getLink(), '   ' . $value->getDescription(), '');
                 $out[] = implode(PHP_EOL, $line);
             }
             $this->output($out);
             break;
         case self::FPCMCLI_PARAM_INFO:
             if ($this->funcParams[1] !== self::FPCMCLI_PARAM_TYPE_MODULE) {
                 $this->output('Invalid params', true);
             }
             $list = $moduleList->getModulesRemote();
             $keyData = \fpcm\model\packages\package::explodeModuleFileName($this->funcParams[2]);
             if (!array_key_exists($keyData[0], $list)) {
                 $this->output('The requested module was not found in package list storage. Check your module key or update package information storage.', true);
             }
             /* @var $module \fpcm\model\modules\listitem */
             $module = $list[$keyData[0]];
             $this->output(array('== ' . $module->getName(), '   ' . $module->getKey(), '   > ' . $module->getDescription(), '   Version: ' . $module->getVersionRemote(), '   Author: ' . $module->getAuthor(), '   Link: ' . $module->getLink(), '   Installed: ' . ($module->isInstalled() ? 'yes' : 'no'), '   Installed version: ' . $module->getVersion(), '   Status: ' . ($module->getStatus() ? 'enabled' : 'disabled'), '   Dependencies:', '   ' . implode(PHP_EOL, $module->getDependencies())));
             break;
         default:
             break;
     }
     return true;
 }
Example #5
0
 /**
  * Prüft ob neue System-Updates vorhanden sind, erzeugt ggf. Meldung mit Möglichkeit, Update zu starten
  * @return void
  */
 protected function checkUpdates()
 {
     if (!$this->updateCheckEnabled) {
         return;
     }
     $asyncMail = $this->session->exists() ? false : true;
     $res = $this->crons->registerCron('updateCheck', $asyncMail);
     if ($res === \fpcm\model\updater\system::SYSTEMUPDATER_FURLOPEN_ERROR || !\fpcm\classes\baseconfig::canConnect()) {
         $updater = new \fpcm\model\updater\system();
         $this->view->addJsVars(array('fpcmManualCheckUrl' => $updater->getManualCheckAddress(), 'fpcmManualCheckHeadline' => $this->lang->translate('HL_PACKAGEMGR_SYSUPDATES')));
         $this->view->assign('includeManualCheck', true);
         if (!\fpcm\classes\baseconfig::canConnect() && $updater->checkManual()) {
             $this->view->assign('autoDialog', is_null($res) ? false : true);
         } else {
             $this->view->assign('autoDialog', false);
         }
         return;
     } elseif ($res === \fpcm\model\updater\system::SYSTEMUPDATER_FORCE_UPDATE) {
         $this->redirect('package/sysupdate');
         return;
     } elseif ($res === false) {
         $systemUpdates = new \fpcm\model\updater\system();
         $replace = array('{{versionlink}}' => $this->getControllerLink('package/sysupdate'), '{{version}}' => $systemUpdates->getRemoteData('version'));
         $this->view->addErrorMessage('UPDATE_VERSIONCHECK_NEW', $replace);
     }
 }
Example #6
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();
 }