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); } }
private function importcomments(array $items, $idpost) { $comments = tcomments::i($idpost); $comments->lock(); $comusers = tcomusers::i($idpost); $comusers->lock(); foreach ($items as $item) { $status = $item['wp:comment_approved'] == '1' ? 'approved' : 'hold'; $posted = strtotime($item['wp:comment_date']); if ($item['wp:comment_type'] == 'pingback') { $pingbacks = tpingbacks::i($idpost); $pingbacks->import($item['wp:comment_author_url'], $item['wp:comment_author'], $posted, $item['wp:comment_author_IP'], $status); continue; } $idauthor = $comusers->add($item['wp:comment_author'], $item['wp:comment_author_email'], $item['wp:comment_author_url']); $comments->add($idpost, $idauthor, $item['wp:comment_content'], $item['wp:comment_author_IP'], $status, $posted); } $comusers->unlock(); $comments->unlock(); }
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); } }
public function wpeditComment($blog_id, $login, $password, $id, $struct) { $this->auth($login, $password, 'moderator'); $id = (int) $id; $comments = tcomments::i(); if (!$comments->itemexists($id)) { return $this->xerror(404, 'Invalid comment ID.'); } $comment = $comment->getcomment($id); if (isset($struct['status'])) { if (!preg_match('/^hold|approve|spam$/', $struct['status'])) { return $this->xerror(401, 'Invalid comment status.'); } $comment->status = $struct['status'] == 'approve' ? 'approved' : $struct['status']; } $comusers = tcomusers::i(); $comment->author = $comusers->add(isset($struct['author']) ? $struct['author'] : $comment->name, isset($struct['author_email']) ? $struct['author_email'] : $comment->email, isset($struct['author_url']) ? $struct['author_url'] : $comment->url); if (!empty($struct['date_created_gmt'])) { $comment->posted = $struct['date_created_gmt']->getTimestamp(); } if (isset($struct['content'])) { $comment->rawcontent = $struct['content']; } $comment->save(); return true; }
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(); }