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); } }
<?php define('litepublisher_mode', 'xmlrpc'); include 'index.php'; $db = litepublisher::$db; $db->table = 'posts'; $items = $db->res2assoc($db->query("select id, categories, tags from {$db->posts}")); $tags = ttags::instance(); $tags->lock(); $tags->itemsposts->lock(); $cats = tcategories::instance(); $cats->lock(); $cats->itemsposts->lock(); foreach ($items as $item) { $cats->itemsposts->setitems($item['id'], explode(',', $item['categories'])); $tags->itemsposts->setitems($item['id'], explode(',', $item['tags'])); } $tags->itemsposts->unlock(); $tags->unlock(); $cats->itemsposts->unlock(); $cats->unlock(); litepublisher::$urlmap->clearcache(); echo "updated<br>\n";
public function CreateFirstPost() { $html = THtmlResource::instance(); $html->section = 'installation'; $lang = tlocal::instance(); $theme = ttheme::instance(); $post = tpost::instance(0); $post->title = $lang->posttitle; $post->catnames = $lang->postcategories; $post->tagnames = $lang->posttags; $post->content = $theme->parse($lang->postcontent); $posts = tposts::instance(); $posts->add($post); $icons = ticons::instance(); $cats = tcategories::instance(); $cats->setvalue($post->categories[0], 'icon', $icons->getid('news')); $comusers = tcomusers::instance($post->id); $userid = $comusers->add($lang->author, $lang->email, $lang->homeurl); echo "new comuser id = "; var_dump($userid); echo "<br>"; litepublisher::$classes->commentmanager->addcomment($post->id, $userid, $lang->postcomment); $plugins = tplugins::instance(); $plugins->lock(); //$plugins->add('oldestposts'); //$plugins->add('adminlinks'); //$plugins->add('nicedit'); $plugins->unlock(); }