function addpingback($idpost, $title, $url, $ip, $date, $status) { $pingbacks = tpingbacks::i($idpost); if (dbversion) { $item = array('url' => $url, 'title' => $title, 'post' => $idpost, 'posted' => sqldate($date), 'status' => $status, 'ip' => $ip); $id = $pingbacks->db->add($item); } else { $pingbacks->items[++$pingbacks->autoid] = array('url' => $url, 'title' => $title, 'post' => $idpost, 'posted' => $date, 'approved' => $status == 'approved', 'ip' => $ip); $pingbacks->save(); } }
public function getpingbacks($id) { return tpingbacks::i($id); }
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(); }
public function getcomments($idpost) { $result = ''; $idpost = (int) $idpost; $post = tpost::i($idpost); $comments = tcomments::i($idpost); $lang = tlocal::i('comment'); $list = $comments->getcontent(); $theme = $post->theme; $args = new targs(); $args->count = $post->cmtcount; $result .= $theme->parsearg($theme->templates['content.post.templatecomments.comments.count'], $args); $result .= $list; if (litepublisher::$urlmap->page == 1 && $post->pingbackscount > 0) { $pingbacks = tpingbacks::i($post->id); $result .= $pingbacks->getcontent(); } if (!litepublisher::$options->commentsdisabled && $post->comstatus != 'closed') { $args->postid = $post->id; $args->antispam = base64_encode('superspamer' . strtotime("+1 hour")); $cm = tcommentmanager::i(); $result .= sprintf('<?php if (litepublisher::$options->ingroups(array(%s))) {', implode(',', $cm->idgroups)); //add hold list because we need container when comment will be hold $result .= 'if ($ismoder = litepublisher::$options->ingroup(\'moderator\')) { ?>'; $args->comment = ''; $result .= $theme->parsearg($theme->templates['content.post.templatecomments.holdcomments'], $args); $result .= $this->loadhold; $result .= '<?php } ?>'; $mesg = $this->logged; if ($cm->canedit || $cm->candelete) { $mesg .= "\n" . $this->adminpanel; } $args->mesg = $this->fixmesg($mesg, $theme); $result .= $theme->parsearg($theme->templates['content.post.templatecomments.regform'], $args); $result .= $this->getjs($post->idperm == 0 && $cm->confirmlogged, 'logged'); $result .= '<?php } else { ?>'; switch ($post->comstatus) { case 'reg': $mesg = $this->reqlogin; if (litepublisher::$options->reguser) { $mesg .= "\n" . $this->regaccount; } $args->mesg = $this->fixmesg($mesg, $theme); $result .= $theme->parsearg($theme->templates['content.post.templatecomments.regform'], $args); break; case 'guest': $result .= $this->getjs($post->idperm == 0 && $cm->confirmguest, 'guest'); $mesg = $this->guest; if (litepublisher::$options->reguser) { $mesg .= "\n" . $this->regaccount; } $args->mesg = $this->fixmesg($mesg, $theme); $result .= $theme->parsearg($theme->templates['content.post.templatecomments.regform'], $args); break; case 'comuser': $result .= $this->getjs($post->idperm == 0 && $cm->confirmcomuser, 'comuser'); $mesg = $this->comuser; if (litepublisher::$options->reguser) { $mesg .= "\n" . $this->regaccount; } $args->mesg = $this->fixmesg($mesg, $theme); foreach (array('name', 'email', 'url') as $field) { $args->{$field} = "<?php echo (isset(\$_COOKIE['comuser_{$field}']) ? \$_COOKIE['comuser_{$field}'] : ''); ?>"; } $args->subscribe = false; $args->content = ''; $result .= $theme->parsearg($theme->templates['content.post.templatecomments.form'], $args); break; } $result .= '<?php } ?>'; } else { $result .= $theme->parse($theme->templates['content.post.templatecomments.closed']); } return $result; }
public function processform() { $pingbacks = tpingbacks::i(); if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') { extract($_POST, EXTR_SKIP); $pingbacks->edit($this->idget(), $title, $url); } else { $status = isset($_POST['approve']) ? 'approve' : (isset($_POST['hold']) ? 'hold' : 'delete'); foreach ($_POST as $k => $id) { if (!strbegin($k, 'id-') || !is_numeric($id)) { continue; } $id = (int) $id; if ($status == 'delete') { $pingbacks->delete($id); } else { $pingbacks->setstatus($id, $status == 'approve'); } } } return $this->html->h4->successmoderated; }
function addpingback($idpost, $ping, $user) { $pingbacks = tpingbacks::instance($idpost); if (dbversion) { $item = array('url' => $user['url'], 'title' => $user['name'], 'post' => $idpost, 'posted' => sqldate($ping['date']), 'status' => $ping['status'], 'ip' => ''); $id = $pingbacks->db->add($item); } else { $pingbacks->items[++$pingbacks->autoid] = array('url' => $user['url'], 'title' => $user['name'], 'posted' => $ping['date'], 'ip' => '', 'approved' => $ping['status'] == 'approved'); $pingbacks->save(); } }
public function getTrackbackPings($id) { $id = (int) $id; $posts = tposts::i(); if (!$posts->itemexists($id)) { return $this->xerror(404, "Invalid post id."); } $post = tpost::i($id); if ($post->status != 'published') { return $this->xerror(403, 'Target post not published'); } $result = array(); $pingbacks = tpingbacks::i($id); if (dbversion) { $items = $tpingbacks->db->getitems("post = {$id} and status = 'approved' order by posted"); foreach ($items as $item) { $result[] = array('pingIP' => $item['ip'], 'pingURL' => $item['url'], 'pingTitle' => $item['title']); } } else { foreach ($pingbacks->items as $url => $item) { if (!$item['approved']) { continue; } $result[] = array('pingIP' => $item['ip'], 'pingURL' => $item['url'], 'pingTitle' => $item['title']); } } return $result; }