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); } }