Exemplo n.º 1
0
<?php

include 'loggedin.php';
if ($status) {
    savepost($_GET['user'], $_GET['message']);
    print chatlist();
} else {
    print "Not logged in";
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
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);
    }
}