Пример #1
0
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);
    }
}
Пример #2
0
<?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";