Ejemplo n.º 1
0
function ExportComments(tpost $post)
{
    global $wpdb;
    $comments = tcomments::i($post->id);
    $comments->lock();
    $comusers = tcomusers::i($post->id);
    $comusers->lock();
    $items = $wpdb->get_results("SELECT  * FROM {$wpdb->comments} \r\n  WHERE comment_post_ID   = {$post->id}");
    foreach ($items as $item) {
        $date = strtotime(mysql2date('Ymd\\TH:i:s', $item->comment_date));
        $status = $item->comment_approved == '1' ? 'approved' : 'hold';
        if ($item->comment_type != '') {
            addpingback($post->id, $item->comment_author, $item->comment_author_url, $item->comment_author_IP, $date, $status);
            continue;
        }
        $author = $comusers->add($item->comment_author, $item->comment_author_email, $item->comment_author_url, $item->comment_author_IP);
        $cid = $comments->add($author, $item->comment_content, $status, $item->comment_author_IP);
        if (dbversion) {
            $comments->db->setvalue($cid, 'posted', sqldate(min(time(), $date)));
        } else {
            $comments->items[$cid]['posted'] = $date;
        }
    }
    $comusers->unlock();
    $comments->unlock();
    if (dbversion) {
        $count = $comments->db->getcount("post = {$post->id} and status = 'approved'");
        $comments->getdb('posts')->setvalue($post->id, 'commentscount', $count);
        $count = $comments->getdb('pingbacks')->getcount("post = {$post->id} and status = 'approved'");
        $comments->getdb('posts')->setvalue($post->id, 'pingbackscount', $count);
    }
}
Ejemplo n.º 2
0
function migratecomments($idpost)
{
    global $data, $users;
    if (!$data->loadfile('posts' . DIRECTORY_SEPARATOR . $idpost . DIRECTORY_SEPARATOR . 'comments')) {
        return;
    }
    if (!isset($data->data['items'])) {
        var_dump($idpost, $data->data);
        exit;
    }
    if (!isset($users)) {
        $users = new tmigratedata();
        $users->loadfile('commentusers');
    }
    $comments = tcomments::instance($idpost);
    $comments->lock();
    $comusers = tcomusers::instance($idpost);
    $comusers->lock();
    foreach ($data->data['items'] as $id => $item) {
        $user = $users->data['items'][$item['uid']];
        if ($item['type'] == '') {
            $author = $comusers->add($user['name'], $user['email'], $user['url'], '');
            $cid = $comments->add($author, $item['rawcontent'], $item['status'], '');
            if (dbversion) {
                $comments->db->setvalue($cid, 'posted', sqldate(min(time(), $item['date'])));
                $comusers->db->setvalue($author, 'cookie', newmd5($user['cookie']));
            } else {
                $comments->items[$cid]['posted'] = $item['date'];
                $comusers->items[$author]['cookie'] = newmd5($user['cookie']);
            }
        } else {
            addpingback($idpost, $item, $user);
        }
    }
    $comusers->unlock();
    $comments->unlock();
    if (dbversion) {
        $count = $comments->db->getcount("post = {$idpost} and status = 'approved'");
        $comments->getdb('posts')->setvalue($idpost, 'commentscount', $count);
        $count = $comments->getdb('pingbacks')->getcount("post = {$idpost} and status = 'approved'");
        $comments->getdb('posts')->setvalue($idpost, 'pingbackscount', $count);
    }
}