public function auth($id, $action) { if (!litepublisher::$options->user) { return false; } $comments = tcomments::i(); if (!$comments->itemexists($id)) { return false; } if (litepublisher::$options->ingroup('moderator')) { return true; } $cm = tcommentmanager::i(); switch ($action) { case 'edit': if (!$cm->canedit) { return false; } if ('closed' == litepublisher::$db->getval('posts', $comments->getvalue($id, 'post'), 'comstatus')) { return false; } return $comments->getvalue($id, 'author') == litepublisher::$options->user; case 'delete': if (!$cm->candelete) { return false; } if ('closed' == litepublisher::$db->getval('posts', $comments->getvalue($id, 'post'), 'comstatus')) { return false; } return $comments->getvalue($id, 'author') == litepublisher::$options->user; } return false; }
public function getcontent() { $result = ''; $comments = tcomments::i(); $cm = tcommentmanager::i(); $lang = $this->lang; $html = $this->html; if ($action = $this->action) { $id = $this->idget(); if (!$comments->itemexists($id)) { return $this->notfound; } switch ($action) { case 'delete': if (!$this->can($id, 'delete')) { return $html->h4->forbidden; } if (!$this->confirmed) { return $this->confirmdelete($id); } $comments->delete($id); $result .= $html->h4->successmoderated; break; case 'hold': if (!$this->moder) { return $html->h4->forbidden; } $comments->setstatus($id, 'hold'); $result .= $this->moderated($id); break; case 'approve': if (!$this->moder) { return $html->h4->forbidden; } $comments->setstatus($id, 'approved'); $result .= $this->moderated($id); break; case 'edit': if (!$this->can($id, 'edit')) { return $html->h4->forbidden; } $result .= $this->editcomment($id); break; case 'reply': if (!$this->can($id, 'edit')) { return $html->h4->forbidden; } $result .= $this->reply($id); break; } } $result .= $this->getlist($this->name); return $result; }
public function wpnewComment($blog_id, $login, $password, $idpost, $struct) { $this->auth($login, $password, 'moderator'); if (is_numeric($idpost)) { $idpost = absint($idpost); } else { $urlmap = turlmap::i(); if (!($item = $urlmap->finditem($url))) { return $this->xerror(404, 'Invalid post ID.'); } if ($item['class'] != litepublisher::$classes->classes['post']) { return $this->xerror(404, 'Invalid post ID.'); } $idpost = $item['arg']; } $post = tpost::i($idpost); if (!$post->commentenabled || $post->status != 'published') { return $this->xerror(403, 'The specified post cannot be used to commenting'); } $manager = tcommentmanager::i(); return $manager->add($idpost, isset($struct['author']) ? $struct['author'] : '', isset($struct['author_email']) ? $struct['author_email'] : '', isset($struct['author_url']) ? $struct['author_url'] : '', $struct['content']); }
public function getjs($confirmcomment, $logstatus) { $cm = tcommentmanager::i(); $result = sprintf('<script type="text/javascript"> ltoptions.theme.comments = $.extend(true, ltoptions.theme.comments, %s%s); </script>', json_encode(array('confirmcomment' => $confirmcomment, 'comuser' => 'comuser' == $logstatus, 'canedit' => $cm->canedit, 'candelete' => $cm->candelete)), $logstatus == 'logged' ? ', {ismoder: <?php echo ($ismoder ? \'true\' : \'false\'); ?>}' : ''); $template = ttemplate::I(); $result .= $template->getjavascript($template->jsmerger_comments); return $result; /* $result .= $template->getjavascript('/js/litepublisher/confirmcomment.js'); $result .= $template->getjavascript($template->jsmerger_moderate); $result .= $template->getjavascript('/js/litepublisher/moderate.js'); return $result; */ }
public function getauthorlink() { $name = $this->data['name']; $website = $this->data['website']; if ($website == '') { return $name; } $manager = tcommentmanager::i(); if ($manager->hidelink || $this->trust <= $manager->trustlevel) { return $name; } $rel = $manager->nofollow ? 'rel="nofollow"' : ''; if ($manager->redir) { return sprintf('<a %s href="%s/comusers.htm%sid=%d">%s</a>', $rel, litepublisher::$site->url, litepublisher::$site->q, $this->author, $name); } else { if (!strbegin($website, 'http://')) { $website = 'http://' . $website; } return sprintf('<a class="url fn" %s href="%s" itemprop="url">%s</a>', $rel, $website, $name); } }
public function processform(array $values, $confirmed) { $lang = tlocal::i('comment'); if (trim($values['content']) == '') { return $this->geterrorcontent($lang->emptycontent); } if (!$this->checkspam(isset($values['antispam']) ? $values['antispam'] : '')) { return $this->geterrorcontent($lang->spamdetected); } $shortpost = $this->getshortpost(isset($values['postid']) ? (int) $values['postid'] : 0); if ($err = $this->invalidate($shortpost)) { return $err; } if ((int) $shortpost['idperm']) { $post = tpost::i((int) $shortpost['id']); $perm = tperm::i($post->idperm); if (!$perm->hasperm($post)) { return 403; } } $cm = tcommentmanager::i(); if ($cm->checkduplicate && $cm->is_duplicate($shortpost['id'], $values['content'])) { return $this->geterrorcontent($lang->duplicate); } unset($values['submitbutton']); if (!$confirmed) { $values['ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']); } if (litepublisher::$options->ingroups($cm->idgroups)) { if (!$confirmed && $cm->confirmlogged) { return $this->request_confirm($values, $shortpost); } $iduser = litepublisher::$options->user; } else { switch ($shortpost['comstatus']) { case 'reg': return $this->geterrorcontent($lang->reg); case 'guest': if (!$confirmed && $cm->confirmguest) { return $this->request_confirm($values, $shortpost); } $iduser = $cm->idguest; break; case 'comuser': //hook in regservices social plugin if ($r = $this->oncomuser($values, $confirmed)) { return $r; } if (!$confirmed && $cm->confirmcomuser) { return $this->request_confirm($values, $shortpost); } if ($err = $this->processcomuser($values)) { return $err; } $users = tusers::i(); if ($iduser = $users->emailexists($values['email'])) { if ('comuser' != $users->getvalue($iduser, 'status')) { return $this->geterrorcontent($lang->emailregistered); } } else { $iduser = $cm->addcomuser($values['name'], $values['email'], $values['url'], $values['ip']); } $cookies = array(); foreach (array('name', 'email', 'url') as $field) { $cookies["comuser_{$field}"] = $values[$field]; } break; } } $user = tusers::i()->getitem($iduser); if ('hold' == $user['status']) { return $this->geterrorcontent($lang->holduser); } if (!$cm->canadd($iduser)) { return $this->geterrorcontent($lang->toomany); } if (!$cm->add($shortpost['id'], $iduser, $values['content'], $values['ip'])) { return $this->geterrorcontent($lang->spamdetected); } //subscribe by email switch ($user['status']) { case 'approved': if ($user['email'] != '') { // subscribe if its first comment if (1 == tcomments::i()->db->getcount("post = {$shortpost['id']} and author = {$iduser}")) { if ('enabled' == tuseroptions::i()->getvalue($iduser, 'subscribe')) { tsubscribers::i()->update($shortpost['id'], $iduser, true); } } } break; case 'comuser': if ('comuser' == $shortpost['comstatus'] && $cm->comuser_subscribe) { tsubscribers::i()->update($shortpost['id'], $iduser, $values['subscribe']); } break; } //$post->lastcommenturl; $shortpost['commentscount']++; if (!litepublisher::$options->commentpages || $shortpost['commentscount'] <= litepublisher::$options->commentsperpage) { $c = 1; } else { $c = ceil($shortpost['commentscount'] / litepublisher::$options->commentsperpage); } $url = litepublisher::$urlmap->getvalue($shortpost['idurl'], 'url'); if ($c > 1 && !litepublisher::$options->comments_invert_order) { $url = rtrim($url, '/') . "/page/{$c}/"; } litepublisher::$urlmap->setexpired($shortpost['idurl']); return $this->sendresult(litepublisher::$site->url . $url, isset($cookies) ? $cookies : array()); }
public function CreateFirstPost() { $html = tadminhtml::i(); $html->section = 'installation'; $lang = tlocal::i(); $theme = ttheme::i(); $post = tpost::i(0); $post->title = $lang->posttitle; $post->catnames = $lang->postcategories; $post->tagnames = $lang->posttags; $post->content = $theme->parse($lang->postcontent); $posts = tposts::i(); $posts->add($post); $icons = ticons::i(); $cats = tcategories::i(); $cats->setvalue($post->categories[0], 'icon', $icons->getid('news')); $cm = tcommentmanager::i(); $users = tusers::i(); $cm->idguest = $users->add(array('email' => '', 'name' => tlocal::get('default', 'guest'), 'status' => 'hold', 'idgroups' => 'commentator')); $cm->save(); $users->setvalue($cm->idguest, 'status', 'approved'); tcomments::i()->add($post->id, $cm->idguest, $lang->postcomment, 'approved', '127.0.0.1'); $plugins = tplugins::i(); $plugins->lock(); $plugins->add('oldestposts'); //$plugins->add('adminlinks'); //$plugins->add('nicedit'); $plugins->unlock(); }
protected function getstat() { $posts = tposts::i(); $manager = tcommentmanager::i(); $lang = tlocal::i('foaf'); return sprintf($lang->statistic, $posts->archivescount, $manager->count); }
private function dogetholdcomments($url, $count) { $this->domrss->CreateRoot(litepublisher::$site->url . $url, tlocal::get('comment', 'onrecent') . ' ' . litepublisher::$site->name); $manager = tcommentmanager::i(); $recent = $manager->getrecent($count, 'hold'); $title = tlocal::get('comment', 'onpost') . ' '; $comment = new tarray2prop(); foreach ($recent as $item) { $comment->array = $item; $this->AddRSSComment($comment, $title . $comment->title); } }
function tblackipUninstall($self) { tcommentmanager::i()->unbind($self); }
public function delete($id) { parent::delete($id); $manager = tcommentmanager::instance(); $manager->authordeleted($id); }
public function processform() { extract($_POST, EXTR_SKIP); $options = litepublisher::$options; $cm = tcommentmanager::i(); $cm->lock(); $options->comstatus = $comstatus; $cm->filterstatus = isset($filterstatus); $cm->defstatus = isset($commentsapproved) ? 'approved' : 'hold'; $cm->checkduplicate = isset($checkduplicate); $useroptions = tuseroptions::i(); $useroptions->defvalues['subscribe'] = isset($defaultsubscribe) ? 'enabled' : 'disabled'; $useroptions->defvalues['authorpost_subscribe'] = isset($authorpost_subscribe) ? 'enabled' : 'disabled'; $useroptions->save(); $options->commentsdisabled = isset($commentsdisabled); $options->pingenabled = isset($pingenabled); $options->commentpages = isset($commentpages); $options->commentsperpage = (int) trim($commentsperpage); $options->comments_invert_order = isset($comments_invert_order); $cm->sendnotification = isset($sendnotification); $cm->hidelink = isset($hidelink); $cm->redir = isset($redir); $cm->nofollow = isset($nofollow); $cm->comuser_subscribe = isset($comuser_subscribe); $cm->unlock(); $tc = ttemplatecomments::i(); foreach (array('logged', 'reqlogin', 'regaccount', 'guest', 'comuser', 'loadhold') as $name) { $tc->{$name} = $_POST[$name]; } $tc->save(); $subscr = tsubscribers::i(); $subscr->lock(); $subscr->locklist = $locklist; $subscr->enabled = isset($subscribe_enabled); $subscr->unlock(); $rss = trssholdcomments::i(); $rss->count = $rsscount; $rss->template = $rsstemplate; $rss->save(); }