Example #1
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $data = $db->fetch($db->select('config', 'config_value', "config_name = 'active_news_template' OR config_name = 'active_comment_template'"), true);
     $articleTemplate = $this->fpcm2Path . '/styles/' . $data[0]->config_value . '.html';
     $commentTemplate = $this->fpcm2Path . '/styles/' . $data[1]->config_value . '.html';
     if (!file_exists($articleTemplate) || !file_exists($commentTemplate)) {
         die('0');
     }
     if (file_put_contents(\fpcm\classes\baseconfig::$stylesDir . 'articles/fpcm2import.html', '') === false || file_put_contents(\fpcm\classes\baseconfig::$stylesDir . 'comments/fpcm2import.html', '') === false) {
         trigger_error('Unable to create import template dummy files...');
         die('0');
     }
     $articleReplacements = array('%news_headline%' => '{{headline}}', '%news_text%' => '{{text}}', '%author%' => '{{author}}', '%category%' => '{{categoryTexts}}', '%caticon%' => '{{categoryIcons}}', '%date%' => '{{date}}', '%edited%' => '{{changeDate}}', '%comment_count%' => '{{commentCount}}', '%commemts%' => '{{commentLink}}Comments{{/commentLink}}', '%sharebuttons%' => '{{shareButtons}}', '[newslink]' => '{{permaLink}}', '[/newslink]' => '{{/permaLink}}', '%status_pinned%' => '{{statusPinned}}');
     $articleTemplateContent = str_replace(array_keys($articleReplacements), array_values($articleReplacements), file_get_contents($articleTemplate));
     $tplArticle = new \fpcm\model\pubtemplates\article('fpcm2import');
     $tplArticle->setContent($articleTemplateContent);
     if (!$tplArticle->save()) {
         trigger_error('Unable to import active FanPress CM 2.5 article template.');
         die('0');
     }
     $commentReplacements = array('%author%' => '{{author}}', '%email%' => '{{email}}', '%comment_text%' => '{{text}}', '%url%' => '{{website}}', '%date%' => '{{date}}', '%comment_num%' => '{{number}}', '[mention]' => '{{mention}}', '[/mention]' => '{{/mention}}');
     $commentTemplateContent = str_replace(array_keys($commentReplacements), array_values($commentReplacements), file_get_contents($commentTemplate));
     $tplComment = new \fpcm\model\pubtemplates\comment('fpcm2import');
     $tplComment->setContent($commentTemplateContent);
     if (!$tplComment->save()) {
         trigger_error('Unable to import active FanPress CM 2.5 comment template.');
         die('0');
     }
     die('1');
 }
Example #2
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');
 }
Example #3
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $data = $db->fetch($db->select('smilies', '*'), true);
     foreach ($data as $value) {
         $smiley = new \fpcm\model\files\smiley();
         $smiley->setSmileycode($value->sml_code);
         $smiley->setFilename($value->sml_filename);
         if ($smiley->exists() || !$smiley->save()) {
             trigger_error('Unable to create smiley entry in database or smiley already exists.');
             continue;
         }
         $src = $this->fpcm2Path . '/img/smilies/' . $value->sml_filename;
         if (!file_exists($src)) {
             continue;
         }
         $dest = \fpcm\classes\baseconfig::$smileyDir . $value->sml_filename;
         if (!copy($src, $dest)) {
             trigger_error("Unable to copy smiley file {$src} to {$dest}...");
         }
     }
     die('1');
 }
Example #4
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $res = $db->fetch($db->select('uploads'), true);
     die(json_encode($res));
 }
Example #5
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $res = true;
     $db = \fpcm\classes\baseconfig::$fpcmDatabase;
     $res = $res && $db->delete(\fpcm\classes\database::tableAuthors, 'id != ?', array($this->session->getUserId()));
     $res = $res && $db->delete(\fpcm\classes\database::tableRoll, 'id > 3');
     $res = $res && $db->delete(\fpcm\classes\database::tablePermissions, 'rollid > 3');
     $res = $res && $db->delete(\fpcm\classes\database::tableCategories, 'id > 1');
     $res = $res && $db->delete(\fpcm\classes\database::tableArticles, 'id > 0');
     $res = $res && $db->delete(\fpcm\classes\database::tableComments, 'id > 0');
     if (!$res) {
         die('0');
     }
     die('1');
 }
Example #6
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');
 }
Example #7
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $res = is_dir($this->fpcm2Path) && is_dir($this->fpcm2Path . '/data/') && file_exists($this->fpcm2Path . '/inc/config.php') && file_exists($this->fpcm2Path . '/version.php');
     if (!$res) {
         trigger_error('FanPress CM 2.5 config file not found in "' . $this->fpcm2Path . '/inc/config.php"');
         die(0);
     }
     include_once $this->fpcm2Path . '/version.php';
     if (version_compare($fpcmVersion, '2.5.0', '<')) {
         die('2');
     }
     if (!is_object($this->initDatabase())) {
         die(0);
     }
     die('1');
 }
Example #8
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $data = $db->fetch($db->select('bannedips', '*'), true);
     foreach ($data as $value) {
         $ip = new \fpcm\model\ips\ipaddress();
         $ip->setIpaddress($value->ip);
         $ip->setIptime($value->bann_time);
         $ip->setUserid($value->bann_by);
         $ip->setNocomments(1);
     }
     die('1');
 }
 /**
  * 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));
 }
Example #10
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');
 }
Example #11
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $filename = $this->getRequestVar('file');
     $id = $this->getRequestVar('id');
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $file = $db->fetch($db->select('uploads', '*', "id = {$id} AND filename = '{$filename}'"));
     if (!$file) {
         usleep(500000);
         die('0');
     }
     $img = new \fpcm\model\files\image($file->filename);
     $img->setFiletime($file->uploadtime);
     $img->setUserid($file->uploaderid);
     if (!$img->save()) {
         usleep(500000);
         die('0');
     }
     $src = $this->fpcm2Path . '/data/upload/' . $file->filename;
     $dest = \fpcm\classes\baseconfig::$uploadDir . $file->filename;
     if (!file_exists($src)) {
         trigger_error("Unable to copy smiley file {$src} to {$dest}, source file not found...");
         die('0');
     }
     if (file_exists($dest)) {
         trigger_error("Unable to copy smiley file {$src} to {$dest}, destination file already exists...");
         die('0');
     }
     if (!copy($src, $dest)) {
         trigger_error("Unable to copy smiley file {$src} to {$dest}...");
         die('0');
     }
     usleep(750000);
     die('1');
 }
Example #12
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $data = $db->fetch($db->select('config', '*'), true);
     $combined = array();
     foreach ($data as $value) {
         $combined[$value->config_name] = $value->config_value;
     }
     $newconfig = array();
     $newconfig['system_email'] = $combined['system_mail'];
     $newconfig['system_url'] = $combined['system_url'];
     $newconfig['system_dtmask'] = $combined['timedate_mask'];
     $newconfig['system_css_path'] = $combined['useiframecss'];
     $newconfig['articles_sort'] = $combined['sort_news'];
     $newconfig['articles_sort_order'] = $combined['sort_news_order'];
     $newconfig['comments_antispam_question'] = $combined['anti_spam_question'];
     $newconfig['comments_antispam_answer'] = $combined['anti_spam_answer'];
     $newconfig['file_img_thumb_width'] = $combined['max_img_size_x'];
     $newconfig['file_img_thumb_height'] = $combined['max_img_size_y'];
     $newconfig['twitter_data']['consumer_key'] = $combined['twitter_consumer_key'];
     $newconfig['twitter_data']['consumer_secret'] = $combined['twitter_consumer_secret'];
     $newconfig['twitter_data']['user_token'] = $combined['twitter_access_token'];
     $newconfig['twitter_data']['user_secret'] = $combined['twitter_access_token_secret'];
     $newconfig['twitter_events']['create'] = 1;
     $newconfig['twitter_events']['update'] = 0;
     $newconfig['twitter_data'] = json_encode($newconfig['twitter_data']);
     $newconfig['twitter_events'] = json_encode($newconfig['twitter_events']);
     $this->config->setNewConfig($newconfig);
     if (!$this->config->update()) {
         die('0');
     }
     die('1');
 }
Example #13
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');
 }