Exemplo n.º 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');
 }
Exemplo n.º 2
0
 /**
  * Controller-Processing
  * @return boolean
  */
 public function process()
 {
     if (!parent::process()) {
         return false;
     }
     $this->view->setViewJsFiles(array(\fpcm\classes\baseconfig::$jsPath . 'moduleinstaller.js'));
     $tempFile = new \fpcm\model\files\tempfile('installkeys');
     if (!$tempFile->getContent()) {
         trigger_error('No module key data found!');
         $this->view->addErrorMessage('MODULES_FAILED_TEMPKEYS');
         $this->view->assign('nokeys', true);
         $this->view->render();
         return false;
     }
     $startStep = $this->forceStep ? $this->forceStep : (\fpcm\classes\baseconfig::canConnect() ? 1 : 4);
     $keys = json_decode($tempFile->getContent(), true);
     $params = $this->initPkgManagerData();
     $params['fpcmModuleKeys'] = $keys;
     $params['fpcmModuleUrl'] = \fpcm\classes\baseconfig::$moduleServer . 'packages/{{pkgkey}}.zip';
     $params['fpcmUpdaterStartStep'] = $this->forceStep ? $this->forceStep : (\fpcm\classes\baseconfig::canConnect() ? 1 : 4);
     $params['fpcmProgressbarMax'] = count($keys);
     $params['fpcmUpdaterMessages']['EXIT_1'] = $this->lang->translate('MODULES_SUCCESS_INSTALL');
     $params['fpcmUpdaterMessages']['4_0'] = $this->lang->translate('MODULES_FAILED_INSTALL');
     $this->view->addJsVars($params);
     $this->view->render();
     $tempFile->delete();
 }
Exemplo n.º 3
0
 public function run($params = null)
 {
     $tmpArticleData = new \fpcm\model\files\tempfile('articleimportdata');
     $data = json_decode($tmpArticleData->getContent(), true);
     if (!$tmpArticleData->exists() || !is_array($data)) {
         return $params;
     }
     $hash = md5($params['title'] . '#' . $params['createtime']);
     if (!array_key_exists($hash, $data)) {
         return $params;
     }
     $params['id'] = (int) $data[$hash];
     return $params;
 }
Exemplo n.º 4
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();
 }
Exemplo n.º 5
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');
 }
Exemplo n.º 6
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));
 }
Exemplo n.º 7
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');
 }
Exemplo n.º 8
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;
 }
Exemplo n.º 9
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $id = (int) $this->getRequestVar('id');
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $tmp1 = new \fpcm\model\files\tempfile(\fpcm\modules\nkorg\classicimporter\nkorgclassicimporter::mappingUser);
     $usermapping = $tmp1->getContent();
     $usermapping = json_decode($tmp1->getContent(), true);
     $tmp2 = new \fpcm\model\files\tempfile(\fpcm\modules\nkorg\classicimporter\nkorgclassicimporter::mappingCategories);
     $categorymapping = $tmp2->getContent();
     $categorymapping = json_decode($tmp2->getContent(), true);
     if ($tmp2->getFilesize() > 0 && !is_array($categorymapping) || $tmp1->getFilesize() > 0 && !is_array($usermapping)) {
         trigger_error('Unable to parse user or category mapping files');
         die('0');
     }
     $newspost = $db->fetch($db->select('newsposts', '*', "id = {$id}"));
     $article = new \fpcm\model\articles\article();
     $content = html_entity_decode(htmlspecialchars_decode(utf8_encode($newspost->content)));
     $search = array('/data/upload/', '/thumb_');
     $replace = array('/data/uploads/', '/thumbs/');
     $titel = html_entity_decode(htmlspecialchars_decode(utf8_encode($newspost->titel)));
     $article->setContent(str_replace($search, $replace, $content));
     $article->setTitle($titel);
     $article->setCreatetime($newspost->writtentime);
     $article->setChangetime($newspost->editedtime ? $newspost->editedtime : $newspost->writtentime);
     $article->setComments($newspost->comments_active);
     $article->setDeleted($newspost->is_deleted);
     $article->setDraft($newspost->ispreview);
     $article->setArchived($newspost->is_archived);
     $article->setPinned($newspost->is_pinned);
     if ($newspost->writtentime > time()) {
         $article->setPostponed(true);
     }
     $article->setCategories(array(1));
     $newcategories = array();
     $oldcategories = explode(';', $newspost->category);
     if (is_array($categorymapping)) {
         if (count($oldcategories)) {
             foreach ($oldcategories as $categorie) {
                 if (!isset($categorymapping[$categorie])) {
                     continue;
                 }
                 $newcategories[] = (int) $categorymapping[$categorie];
             }
         }
     } else {
         $categoryList = new \fpcm\model\categories\categoryList();
         $categories = $categoryList->getCategoriesAll();
         foreach ($oldcategories as $categorie) {
             if (!isset($categories[$categorie])) {
                 continue;
             }
             $newcategories[] = $categories[$categorie]->getId();
         }
     }
     if (count($newcategories)) {
         $article->setCategories($newcategories);
     }
     if (is_array($usermapping) && isset($usermapping[$newspost->author])) {
         $article->setCreateuser($usermapping[$newspost->author]);
         $article->setChangeuser($usermapping[$newspost->author]);
     } else {
         $article->setCreateuser($newspost->author);
         $article->setChangeuser($newspost->author);
     }
     $article->prepareDataSave(true);
     $newid = $article->save();
     if (!$newid) {
         trigger_error('Unable to import article with ID ' . $id . '! Skipping comments...');
         usleep(500000);
         die('0');
     }
     $id = $newid != $id ? $newid : $id;
     $comments = $db->fetch($db->select('comments', '*', "newsid = {$id}"), true);
     if (!count($comments)) {
         usleep(750000);
         die('1');
     }
     foreach ($comments as $comment) {
         $newcomment = new \fpcm\model\comments\comment();
         $newcomment->setName(utf8_encode(htmlspecialchars_decode($comment->author_name)));
         $newcomment->setEmail(utf8_encode(htmlspecialchars_decode($comment->author_email)));
         $newcomment->setWebsite(utf8_encode(htmlspecialchars_decode($comment->author_url)));
         $newcomment->setText(htmlspecialchars_decode(utf8_encode($comment->comment_text)));
         $newcomment->setCreatetime($comment->comment_time);
         $newcomment->setIpaddress($comment->ip);
         $newcomment->setChangeuser($this->session->getUserId());
         $newcomment->setChangetime(time());
         if ($comment->status == 2) {
             $newcomment->setApproved(0);
         } elseif ($comment->status == 1) {
             $newcomment->setPrivate(1);
         } else {
             $newcomment->setApproved(1);
         }
         $newcomment->setArticleid($id);
         $newcomment->save();
     }
     usleep(750000);
     die('1');
 }
Exemplo n.º 10
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();
 }