Пример #1
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $tmp = new \fpcm\model\files\tempfile(\fpcm\modules\nkorg\classicimporter\nkorgclassicimporter::mappingRolls);
     $data = $db->fetch($db->select('usrlevels', '*', 'id > 3'), true);
     $ids = array();
     foreach ($data as $lvl) {
         $roll = new \fpcm\model\users\userRoll();
         $roll->setRollName(utf8_encode($lvl->leveltitle));
         if (!$roll->save()) {
             trigger_error('Unable to import user roll: ' . $lvl->leveltitle);
             continue;
         }
         $res = \fpcm\classes\baseconfig::$fpcmDatabase->fetch(\fpcm\classes\baseconfig::$fpcmDatabase->select(\fpcm\classes\database::tableRoll, 'MAX(id) as newid'));
         $ids[$lvl->id] = $res->newid;
     }
     if (!count($ids)) {
         \fpcm\classes\logs::syslogWrite('Classic Importer: No user roll ids found, maybe no user rolls imported...');
         die('0');
     }
     $tmp->setContent(json_encode($ids));
     $tmp->save();
     die('1');
 }
Пример #2
0
 /**
  * Request-Handler
  * @return bool
  */
 public function request()
 {
     if ($this->getRequestVar('step')) {
         $this->forceStep = (int) $this->getRequestVar('step');
     }
     if ($this->getRequestVar('file')) {
         $tmpFile = new \fpcm\model\files\tempfile('forceUpdateFile', $this->getRequestVar('file'));
         $tmpFile->save();
     }
     if (!$this->forceStep) {
         \fpcm\classes\baseconfig::enableAsyncCronjobs(false);
     }
     return parent::request();
 }
Пример #3
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $data = $db->fetch($db->select('authors', '*'), true);
     $tmp = new \fpcm\model\files\tempfile(\fpcm\modules\nkorg\classicimporter\nkorgclassicimporter::mappingUser);
     $ids = array();
     $rmfile = new \fpcm\model\files\tempfile(\fpcm\modules\nkorg\classicimporter\nkorgclassicimporter::mappingRolls);
     $rollmapping = $rmfile->getContent();
     $rollmapping = json_decode($rollmapping, true);
     if ($rmfile->getFilesize() > 0 && !is_array($rollmapping)) {
         trigger_error('Unable to parse user roll mapping file');
         die('0');
     }
     foreach ($data as $user) {
         $author = new \fpcm\model\users\author();
         $author->disablePasswordSecCheck();
         $author->setUserName(utf8_encode($user->sysusr));
         $author->setDisplayName(utf8_encode($user->name));
         $author->setEmail(utf8_encode($user->email));
         $author->setRegistertime($user->registertime);
         $roll = isset($rollmapping[$user->usrlevel]) ? $rollmapping[$user->usrlevel] : 3;
         $author->setRoll($roll);
         $author->setPassword(utf8_encode($user->sysusr));
         $author->setUserMeta(array());
         $res = $author->save();
         if ($res !== true) {
             if ($res == \fpcm\model\users\author::AUTHOR_ERROR_EXISTS) {
                 trigger_error('User import failed, user already exists: ' . $author->getUsername());
             } else {
                 trigger_error('Unable to import user: '******'Classic Importer: No user ids found, maybe no users imported...');
         die('0');
     }
     $tmp->setContent(json_encode($ids));
     $tmp->save();
     die('1');
 }
Пример #4
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $res = $db->fetch($db->select('newsposts', 'id, titel, writtentime'), true);
     $res = array_map(array($this, 'utf8'), $res);
     $tempData = array();
     foreach ($res as $np) {
         $hash = md5(html_entity_decode(htmlspecialchars_decode(utf8_encode($np->titel))) . '#' . $np->writtentime);
         $tempData[$hash] = $np->id;
     }
     $articleTempData = new \fpcm\model\files\tempfile('articleimportdata', json_encode($tempData));
     $articleTempData->save();
     die(json_encode($res));
 }
Пример #5
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $data = $db->fetch($db->select('categories', '*'), true);
     $tmp = new \fpcm\model\files\tempfile(\fpcm\modules\nkorg\classicimporter\nkorgclassicimporter::mappingCategories);
     $rmfile = new \fpcm\model\files\tempfile(\fpcm\modules\nkorg\classicimporter\nkorgclassicimporter::mappingRolls);
     $rollmapping = $rmfile->getContent();
     $rollmapping = json_decode($rollmapping, true);
     if ($rmfile->getFilesize() > 0 && !is_array($rollmapping)) {
         trigger_error('Unable to parse user roll mapping file');
         die('0');
     }
     $ids = array();
     foreach ($data as $cat) {
         $category = new \fpcm\model\categories\category();
         $category->setName(utf8_encode($cat->catname));
         $category->setIconPath(utf8_encode($cat->icon_path));
         $group = isset($rollmapping[$cat->minlevel]) ? $rollmapping[$cat->minlevel] : 1;
         $category->setGroups($group);
         $res = $category->save();
         if (!$res) {
             trigger_error('Unable to import category "' . utf8_encode($cat->catname) . '", maybe it already exists. Continue...');
             continue;
         }
         $ids[$cat->id] = \fpcm\classes\baseconfig::$fpcmDatabase->getLastInsertId();
     }
     if (!count($ids)) {
         \fpcm\classes\logs::syslogWrite('Classic Importer: No category ids found, maybe no categories imported...');
         die('0');
     }
     $tmp->setContent(json_encode($ids));
     $tmp->save();
     die('1');
 }
Пример #6
0
 /**
  * Request-Handler
  * @return boolean
  */
 public function request()
 {
     if (!$this->session->exists() && !$this->permissions->check($this->checkPermission)) {
         return false;
     }
     if (is_null($this->getRequestVar('action')) || is_null($this->getRequestVar('keys'))) {
         return true;
     }
     $this->cache->cleanup();
     $this->action = $this->getRequestVar('action');
     $this->keys = $this->getRequestVar('keys', array(1, 4, 7));
     if (!is_array($this->keys)) {
         $this->keys = json_decode($this->keys, true);
     }
     if (!is_array($this->keys)) {
         return true;
     }
     $this->keys = array_map('trim', $this->keys);
     $this->keys = array_map('base64_decode', $this->keys);
     switch ($this->action) {
         case 'disable':
             if (!$this->permissions->check(array('modules' => 'enable'))) {
                 return true;
             }
             $res = $this->modulelist->disableModules($this->keys);
             break;
         case 'enable':
             if (!$this->permissions->check(array('modules' => 'enable'))) {
                 return true;
             }
             $res = $this->modulelist->enableModules($this->keys);
             break;
         case 'uninstall':
             if (!$this->permissions->check(array('modules' => 'uninstall'))) {
                 return true;
             }
             $res = $this->modulelist->uninstallModules($this->keys);
             break;
         case 'install':
             if (!$this->permissions->check(array('modules' => 'install'))) {
                 return true;
             }
             $this->keys = array_diff($this->keys, $this->modulelist->getInstalledModules());
             $tempFile = new \fpcm\model\files\tempfile('installkeys', json_encode($this->keys));
             if (!$tempFile->save()) {
                 trigger_error('Unable to save module keys to temp file');
                 return true;
             }
             break;
         case 'update':
             if (!$this->permissions->check(array('modules' => 'install'))) {
                 return true;
             }
             $updater = new \fpcm\model\updater\modules();
             $updater->getModulelist();
             $remotes = $updater->getRemoteData();
             $this->keys = array_intersect($this->keys, $this->modulelist->getInstalledModules());
             $versionKeys = array();
             foreach ($this->keys as $key) {
                 $versionKeys[] = $key . '_version' . $remotes[$key]['version'];
             }
             $tempFile = new \fpcm\model\files\tempfile('installkeys', json_encode($versionKeys));
             if (!$tempFile->save()) {
                 trigger_error('Unable to save module keys to temp file');
                 return true;
             }
             break;
     }
     if (!isset($res)) {
         return true;
     }
     if ($res) {
         $this->view->addNoticeMessage('MODULES_SUCCESS_' . strtoupper($this->action));
     } else {
         $this->view->addErrorMessage('MODULES_FAILED_' . strtoupper($this->action));
     }
     return true;
 }
Пример #7
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();
 }