public function processform() { litepublisher::$options->dateformat = $_POST['dateformat']; litepublisher::$options->language = $_POST['language']; if (litepublisher::$options->timezone != $_POST['timezone']) { litepublisher::$options->timezone = $_POST['timezone']; $archives = tarchives::i(); turlmap::unsub($archives); $archives->PostsChanged(); } $merger = tlocalmerger::i(); $merger->lock(); //$merger->items = array(); //$merger->install(); foreach (array_keys($merger->items) as $name) { $keys = array_keys($merger->items[$name]['texts']); $merger->setfiles($name, $_POST[$name . '_files']); foreach ($keys as $key) { $merger->addtext($name, $key, $_POST[$name . '_text_' . $key]); } } $merger->html = explode("\n", trim($_POST['adminhtml_files'])); foreach ($merger->html as $i => $filename) { $merger->html[$i] = trim($filename); } $merger->unlock(); }
function ExportPosts() { global $wpdb, $from; $urlmap = turlmap::i(); $urlmap->lock(); $posts = tposts::i(); $posts->lock(); if (dbversion) { $r = $wpdb->get_results("SELECT max(ID) as autoid FROM {$wpdb->posts} "); $autoid = (int) $r[0]->autoid; echo "{$autoid} = auto id posts\n"; $posts->db->exec(sprintf('ALTER TABLE %s AUTO_INCREMENT = %d', $posts->thistable, $autoid)); } $categories = tcategories::i(); $categories->loadall(); $categories->lock(); $tags = ttags::i(); $tags->loadall(); $tags->lock(); if ($from == 0) { echo "import categories\n"; ExportCategories(); echo "import pages\n"; ExportPages(); } $cron = tcron::i(); $cron->disableadd = true; //$list = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post'"); $list = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} \r\nWHERE post_type = 'post'\r\nand ID > {$from}\r\nlimit 500\r\n"); echo count($list), " = countposts\n"; foreach ($list as $index => $idresult) { //$itemres= $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID = $idresult"); $itemres = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE ID = {$idresult->ID}"); $item =& $itemres[0]; $post = new tpost(); $post->id = (int) $item->ID; echo $post->id, " = id post\n"; $post->posted = strtotime(mysql2date('Ymd\\TH:i:s', $item->post_date)); $post->title = $item->post_title; $post->categories = wp_get_post_categories($item->ID); $taglist = array(); $wptags = wp_get_post_tags($item->ID); foreach ($wptags as $wptag) { AddTag($tags, (int) $wptag->term_id, 0, $wptag->name, get_tag_link($wptag->term_id)); $taglist[] = (int) $wptag->term_id; } $post->tags = $taglist; $UrlArray = parse_url(@get_permalink($item->ID)); $url = $UrlArray['path']; if (!empty($UrlArray['query'])) { $url .= '?' . $UrlArray['query']; } $post->url = $url; $post->idurl = litepublisher::$urlmap->add($post->url, get_class($post), $post->id); $post->content = $item->post_content; $post->commentsenabled = 'open' == $item->comment_status; $post->pingenabled = 'open' == $item->ping_status; $post->password = $item->post_password; $post->status = $item->post_status == 'publish' ? 'published' : 'draft'; savepost($post); $categories->itemsposts->setitems($post->id, $post->categories); $tags->itemsposts->setitems($post->id, $post->tags); ExportComments($post); $post->free(); } $cron->unlock(); //$CommentManager->SubscribtionEnabled = true; //$CommentManager->NotifyModerator = true; $tags->unlock(); $categories->unlock(); $posts->UpdateArchives(); $posts->addrevision(); $posts->unlock(); $urlmap->clearcache(); $arch = tarchives::i(); $arch->postschanged(); $urlmap->unlock(); if (count($list) < 500) { return false; } return $item->ID; }
function migrateposts() { global $data, $man; $data->loadfile('posts' . DIRECTORY_SEPARATOR . 'index'); $posts = tposts::instance(); $posts->lock(); if (dbversion) { $man = tdbmanager::instance(); $man->setautoincrement('posts', $data->lastid); } else { $posts->autoid = $data->lastid; } $tags = ttags::instance(); $tags->lock(); $tags->itemsposts->lock(); $cats = tcategories::instance(); $cats->lock(); $cats->itemsposts->lock(); $items = $data->data['items']; foreach ($items as $id => $item) { $post = migratepost($id); savepost($post); $cats->itemsposts->setitems($post->id, $post->categories); $tags->itemsposts->setitems($post->id, $post->tags); migratecomments($id); if (!dbversion) { $posts->items[$post->id] = array('posted' => $post->posted); if ($post->status != 'published') { $posts->items[$post->id]['status'] = $post->status; } if ($post->author > 1) { $posts->items[$post->id]['author'] = $post->author; } } } $posts->UpdateArchives(); $posts->addrevision(); $posts->unlock(); $tags->itemsposts->unlock(); $tags->unlock(); $cats->itemsposts->unlock(); $cats->unlock(); $arch = tarchives::instance(); $arch->postschanged(); //update trust values if (dbversion) { $db = litepublisher::$db; $trusts = $db->res2assoc($db->query("SELECT author as 'author', count(author) as 'count' FROM {$db->comments} \r\nwhere status = 'approved' GROUP BY author")); $db->table = 'comusers'; foreach ($trusts as $r) { $db->setvalue($r['author'], 'trust', $r['count']); } unset($trust); } }
public function CreateDefaultItems($password) { if ($this->mode != 'remote') { $this->congratulation($password); } $arch = tarchives::instance(); $arch->lite = $this->lite; if (!$this->lite) { $this->CreateFirstPost(); } $this->SendEmail($password); return $password; }
<?php define('litepublisher_mode', 'xmlrpc'); include 'index.php'; $linkgen = tlinkgenerator::instance(); $linkgen->archive = '/[year]/[month]/'; $linkgen->save(); $arch = tarchives::instance(); $arch->postschanged(); litepublisher::$urlmap->clearcache();
public function getcontent($id, $sidebar) { $arch = tarchives::i(); if (count($arch->items) == 0) { return ''; } $result = ''; $theme = ttheme::i(); $tml = $theme->getwidgetitem('archives', $sidebar); if ($this->showcount) { $counttml = $theme->getwidgettml($sidebar, 'archives', 'subcount'); } $args = targs::i(); $args->icon = ''; $args->subcount = ''; $args->subitems = ''; $args->rel = 'archives'; foreach ($arch->items as $date => $item) { $args->add($item); $args->text = $item['title']; if ($this->showcount) { $args->subcount = str_replace($counttml, '$itemscount', $item['count']); } $result .= $theme->parsearg($tml, $args); } return $theme->getwidgetcontent($result, 'archives', $sidebar); }