function __construct($comment) { $ini = eZINI::instance('akismet.ini'); $blogURL = $ini->variable('SiteSettings', 'BlogURL'); $apiKey = $ini->variable('AccountSettings', 'APIKey'); parent::__construct($blogURL, $apiKey); if (isset($comment['permalink'])) { parent::setPermalink($comment['permalink']); } if ($comment['type']) { parent::setCommentType($comment['type']); } if (isset($comment['author'])) { parent::setCommentAuthor($comment['author']); } else { parent::setCommentAuthor(''); } if (isset($comment['email'])) { parent::setCommentAuthorEmail($comment['email']); } if ($comment['website']) { parent::setCommentAuthorURL($comment['website']); } if ($comment['body']) { parent::setCommentContent($comment['body']); } }
function HandleGuestStore($pagename, $auth) { global $wpcom_api_key, $wpcom_home; $akismet = new Akismet($wpcom_home, $wpcom_api_key); $akismet->setCommentAuthor($_POST['name']); $akismet->setCommentAuthorEmail($_POST['email']); $akismet->setCommentAuthorURL($_POST['url']); $akismet->setCommentContent($_POST['comment']); $itemurl = $pagename . date("Ymd") . "-" . uniqid(); $akismet->setPermalink($itemurl); $page['name'] = $itemurl; $page['text'] = "----\n"; $page['text'] .= strlen($_POST['name']) > 0 ? $_POST['name'] : "Unbekannt"; if (strlen($_POST['email']) > 0) { $page['text'] .= " [[✉->mailto:"; $page['text'] .= $_POST['email']; $page['text'] .= "]]"; } if (strlen($_POST['url']) > 0) { $page['text'] .= " [[➚->"; $page['text'] .= substr($_POST['url'], 0, 4) == "http" ? $_POST['url'] : "http://" . $_POST['url']; $page['text'] .= "]]"; } $page['text'] .= " schrieb am "; $page['text'] .= date("d.m.Y"); $page['text'] .= ":\n\n"; $page['text'] .= $_POST['comment']; $page['text'] .= $akismet->isCommentSpam() ? "(:spam: true:)" : "(:spam: false:)"; $page['time'] = $Now; $page['host'] = $_SERVER['REMOTE_ADDR']; $page['agent'] = @$_SERVER['HTTP_USER_AGENT']; UpdatePage($page['name'], $page, $page); HandleBrowse($pagename); }
/** * check if a comment is spam through Akismet * * @param mixed $data Data passed to this action * @return bool TRUE if comment is spam else FALSE */ public function perform($data = FALSE) { include_once JAPA_BASE_DIR . 'modules/common/includes/Akismet.class.php'; $akismet = new Akismet($data['url'], $data['key']); $akismet->setCommentAuthor($data['user']['name']); $akismet->setCommentAuthorEmail($data['user']['email']); $akismet->setCommentAuthorURL($data['user']['url']); $akismet->setCommentContent($data['user']['comment']); $akismet->setPermalink($data['permaLink']); return $akismet->isCommentSpam(); }
function checkSpam($api, $blogUrl, $name, $email, $url, $comment, &$msgA) { require_once JPATH_COMPONENT . DS . 'assets' . DS . 'akismet' . DS . 'Akismet.class.php'; $akismet = new Akismet($blogUrl, $api); $akismet->setCommentAuthor($name); $akismet->setCommentAuthorEmail($email); $akismet->setCommentAuthorURL($url); $akismet->setCommentContent($comment); if ($akismet->isKeyValid()) { } else { $msgA = 'Akismet: Key is invalid'; } //trigger_error("Akismet: ".$akismet->isCommentSpam(),E_USER_WARNING); return $akismet->isCommentSpam(); }
function q_isspam($q) { if (get_option('q_filter_spam') == 'TRUE') { global $current_user; get_currentuserinfo(); $akismet = new Akismet(get_bloginfo('wpurl'), get_option('q_wpcomAPIkey')); $akismet->setCommentAuthor($current_user->user_login); $akismet->setCommentAuthorEmail($current_user->user_email); $akismet->setCommentAuthorURL($current_user->user_url); $akismet->setCommentContent($q); if ($akismet->isCommentSpam()) { return true; } else { return false; } } }
/** * Function: create * Attempts to create a comment using the passed information. If the Akismet API key is present, it will check it. * * Parameters: * $body - The comment. * $author - The name of the commenter. * $url - The commenter's website. * $email - The commenter's email. * $post - The <Post> they're commenting on. * $parent - The <Comment> they're replying to. * $notify - Notification on follow-up comments. * $type - The type of comment. Optional, used for trackbacks/pingbacks. */ static function create($body, $author, $url, $email, $post, $parent, $notify, $type = null) { if (!self::user_can($post->id) and !in_array($type, array("trackback", "pingback"))) { return; } $config = Config::current(); $route = Route::current(); $visitor = Visitor::current(); if (!$type) { $status = $post->user_id == $visitor->id ? "approved" : $config->default_comment_status; $type = "comment"; } else { $status = $type; } if (!empty($config->akismet_api_key)) { $akismet = new Akismet($config->url, $config->akismet_api_key); $akismet->setCommentContent($body); $akismet->setCommentAuthor($author); $akismet->setCommentAuthorURL($url); $akismet->setCommentAuthorEmail($email); $akismet->setPermalink($post->url()); $akismet->setCommentType($type); $akismet->setReferrer($_SERVER['HTTP_REFERER']); $akismet->setUserIP($_SERVER['REMOTE_ADDR']); if ($akismet->isCommentSpam()) { self::add($body, $author, $url, $email, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], "spam", $post->id, $visitor->id, $parent, $notify); error(__("Spam Comment"), __("Your comment has been marked as spam. It has to be reviewed and/or approved by an admin.", "comments")); } else { $comment = self::add($body, $author, $url, $email, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $status, $post->id, $visitor->id, $parent, $notify); fallback($_SESSION['comments'], array()); $_SESSION['comments'][] = $comment->id; if (isset($_POST['ajax'])) { exit("{ \"comment_id\": \"" . $comment->id . "\", \"comment_timestamp\": \"" . $comment->created_at . "\" }"); } Flash::notice(__("Comment added."), $post->url() . "#comments"); } } else { $comment = self::add($body, $author, $url, $email, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $status, $post->id, $visitor->id, $parent, $notify); fallback($_SESSION['comments'], array()); $_SESSION['comments'][] = $comment->id; if (isset($_POST['ajax'])) { exit("{ \"comment_id\": \"" . $comment->id . "\", \"comment_timestamp\": \"" . $comment->created_at . "\" }"); } Flash::notice(__("Comment added."), $post->url() . "#comment"); } }
public function queryAkismet($author, $textDiff, $permalink) { global $wgMWAkismetKey; global $wgMWAkismetURL; // First check to see if the config settings are set if ($wgMWAkismetKey == '' || $wgMWAkismetURL == '') { echo "Akismet key and url must be set. Instructions for getting a key are here: <a href=\"http://faq.wordpress.com/2005/10/19/api-key/\">API key FAQ on Wordpress.com</a>"; die; } $akismet = new Akismet($wgMWAkismetURL, $wgMWAkismetKey); $akismet->setCommentAuthor($author); $akismet->setCommentAuthorEmail(""); $akismet->setCommentAuthorURL(""); $akismet->setCommentContent($textDiff); $akismet->setPermalink($permalink); $isSpam = $akismet->isCommentSpam(); return $isSpam; }
/** * This event check spam in comments, posts and other contents for modules * * @param array All params to check (blogurl, name, email, url, text, permalink) * @return bool */ public function eventRmcommonCheckPostSpam($params) { $config = RMFunctions::get()->plugin_settings('akismet', true); if ($config['key'] == '') { return; } extract($params); $akismet = new Akismet($blogurl, $config['key']); $akismet->setCommentAuthor($name); $akismet->setCommentAuthorEmail($email); $akismet->setCommentAuthorURL($url); $akismet->setCommentContent($text); $akismet->setPermalink($permalink); $akismet->setUserIP($_SERVER['REMOTE_ADDR']); if ($akismet->isCommentSpam()) { return false; } return true; }
function akismet_scan($Data, $Setup, $Config) { if (empty($Setup['_APIKey'])) { return false; } include_once WP_PLUGIN_DIR . '/db-toolkit/data_form/processors/akismet/Akismet.class.php'; $WordPressAPIKey = $Setup['_APIKey']; $MyBlogURL = get_bloginfo('url'); $akismet = new Akismet($MyBlogURL, $WordPressAPIKey); $akismet->setCommentAuthor($Data[$Setup['_Name']]); $akismet->setCommentAuthorEmail($Data[$Setup['_Email']]); $akismet->setCommentAuthorURL($Data[$Setup['_URL']]); $akismet->setCommentContent($Data[$Setup['_Text']]); $akismet->setUserIP($_SERVER['REMOTE_ADDR']); if ($akismet->isCommentSpam()) { return true; } else { return false; } return false; }
/** * Use Akismet to check comment data for spam * * @param array $data * @return bool */ function isSpam(&$data) { $apiKey = Configure::read('Wildflower.settings.wordpress_api_key'); if (empty($apiKey)) { return false; } try { App::import('Vendor', 'akismet'); $siteUrl = Configure::read('Wildflower.fullSiteUrl'); $akismet = new Akismet($siteUrl, $apiKey); $akismet->setCommentAuthor($data[$this->name]['name']); $akismet->setCommentAuthorEmail($data[$this->name]['email']); $akismet->setCommentAuthorURL($data[$this->name]['url']); $akismet->setCommentContent($data[$this->name]['content']); $akismet->setPermalink($data['Post']['permalink']); if ($akismet->isCommentSpam()) { return true; } } catch (Exception $e) { trigger_error('Akismet not reachable: ' . $e->message); } return false; }
/** * Use Akismet to check comment data for spam * * @param array $data * @return array Data with spam field set */ function isSpam(&$data) { $apiKey = Configure::read('AppSettings.wordpress_api_key'); if (empty($apiKey)) { return false; } try { App::import('Vendor', 'akismet'); $siteUrl = 'http://' . getenv('SERVER_NAME'); $akismet = new Akismet($siteUrl, $apiKey); $akismet->setCommentAuthor($data[$this->name]['name']); $akismet->setCommentAuthorEmail($data[$this->name]['email']); $akismet->setCommentAuthorURL($data[$this->name]['url']); $akismet->setCommentContent($data[$this->name]['content']); $akismet->setPermalink($data['Post']['permalink']); if ($akismet->isCommentSpam()) { return true; } } catch (Exception $e) { $this->log('Akismet not reachable!'); } return false; }
protected function getAkismet($invoker) { $request = sfContext::getInstance()->getRequest(); $api_key = sfConfig::get('app_akismet_api_key'); if (empty($api_key)) { return false; } $akismet = new Akismet($request->getUriPrefix() . $request->getRelativeUrlRoot(), $api_key); $data = $invoker->getAkismetData(); // Set values if (!empty($data['author_name'])) { $akismet->setCommentAuthor($data['author_name']); } else { return true; } if (!empty($data['author_email'])) { $akismet->setCommentAuthorEmail($data['author_email']); } if (!empty($data['author_url'])) { $akismet->setCommentAuthorURL($data['author_url']); } if (!empty($data['content'])) { $akismet->setCommentContent($data['content']); } else { return true; } if (!empty($data['permalink'])) { $akismet->setPermalink($data['permalink']); } if (!empty($data['referrer'])) { $akismet->setReferer($data['referrer']); } if (!empty($data['user_ip'])) { $akismet->setUserIp($data['user_ip']); } return $akismet; }
function delete_comment() { // Lock this shit down!!! if ($this->user['user_level'] < USER_PRIVILEGED) { return $this->module->error('Access Denied: You do not have permission to perform that action.'); } if (!isset($this->module->get['c'])) { return $this->module->message('Delete Comment', 'No comment was specified for editing.'); } $c = intval($this->module->get['c']); $comment = $this->db->quick_query('SELECT c.*, u.* FROM %pblogcomments c LEFT JOIN %pusers u ON u.user_id=c.comment_user WHERE comment_id=%d', $c); if (!$comment) { return $this->module->message('Delete Comment', 'No such comment was found for deletion.'); } if ($this->user['user_id'] != $comment['comment_user'] && $this->user['user_level'] < USER_CONTRIBUTOR) { return $this->module->error('Access Denied: You do not own the comment you are attempting to delete.'); } // After 3 hours, you're stuck with it if you're a regular member. if ($this->user['user_level'] == USER_PRIVILEGED && $this->module->time - $comment['comment_date'] > 10800) { return $this->module->error('Access Denied: You cannot delete your comments after 3 hours have gone by.'); } $user = null; if ($comment['comment_type'] == COMMENT_BLOG) { $user = $this->db->quick_query('SELECT post_user FROM %pblogposts WHERE post_id=%d', $comment['comment_post']); } elseif ($comment['comment_type'] == COMMENT_GALLERY) { $user = $this->db->quick_query('SELECT photo_user FROM %pphotogallery WHERE photo_id=%d', $comment['comment_post']); } elseif ($comment['comment_type'] == COMMENT_FILE) { $user = $this->db->quick_query('SELECT file_user FROM %pfilelist WHERE file_id=%d', $comment['comment_post']); } if (!$user) { return $this->module->error('Access Denied: You do not own the entry you are trying to edit.'); } if ($this->user['user_level'] == USER_CONTRIBUTOR) { switch ($comment['comment_type']) { case COMMENT_BLOG: if ($this->user['user_id'] != $user['post_user'] && $this->user['user_id'] != $comment['comment_user']) { return $this->module->error('Access Denied: You do not own the blog entry you are trying to edit.'); } break; case COMMENT_GALLERY: if ($this->user['user_id'] != $user['photo_user'] && $this->user['user_id'] != $comment['comment_user']) { return $this->module->error('Access Denied: You do not own the image entry you are trying to edit.'); } break; case COMMENT_FILE: if ($this->user['user_id'] != $user['file_user'] && $this->user['user_id'] != $comment['comment_user']) { return $this->module->error('Access Denied: You do not own the download entry you are trying to edit.'); } break; default: return $this->module->error('Unknown comment type selected for editing.'); } } if (isset($this->module->get['t']) && $this->module->get['t'] == 'spam') { if ($this->user['user_level'] < USER_CONTRIBUTOR) { return $this->module->error('Access Denied: You are not authorized to report spam.'); } } $page = ''; if ($comment['comment_type'] == COMMENT_BLOG) { $page = 'blog'; } elseif ($comment['comment_type'] == COMMENT_GALLERY) { $page = 'gallery'; } elseif ($comment['comment_type'] == COMMENT_FILE) { $page = 'downloads'; } if (!isset($this->module->get['confirm'])) { $author = htmlspecialchars($comment['user_name']); $params = POST_BBCODE | POST_EMOTICONS; $text = $this->module->format($comment['comment_message'], $params); $date = date($this->settings['blog_dateformat'], $comment['comment_date']); $msg = "<div class=\"title\">Comment by {$author} Posted on: {$date}</div><div class=\"article\">{$text}</div>"; $link = "index.php?a={$page}&s=del_comment&c={$c}&confirm=1"; $sp = null; if (isset($this->module->get['t']) && $this->module->get['t'] == 'spam') { $link .= '&t=spam'; $sp = '<br />This comment will be reported as spam.'; } $msg .= "<div class=\"title\" style=\"text-align:center\">Are you sure you want to delete this comment?{$sp}</div>"; return $this->module->message('DELETE COMMENT', $msg, 'Delete', $link, 0); } $out = null; if (isset($this->module->get['t']) && $this->module->get['t'] == 'spam') { // Time to report the spammer before we delete the comment. Hopefully this is enough info to strike back with. require_once 'lib/akismet.php'; $akismet = new Akismet($this->settings['site_address'], $this->settings['wordpress_api_key'], $this->module->version); $akismet->setCommentAuthor($comment['user_name']); $akismet->setCommentAuthorURL($comment['user_url']); $akismet->setCommentContent($comment['comment_message']); $akismet->setUserIP($comment['comment_ip']); $akismet->setReferrer($comment['comment_referrer']); $akismet->setCommentUserAgent($comment['comment_agent']); $akismet->setCommentType('comment'); $akismet->submitSpam(); $this->settings['spam_count']++; $this->settings['spam_uncaught']++; $this->module->save_settings(); $out .= 'Comment tagged as spam and reported.<br />'; } $this->db->dbquery('DELETE FROM %pblogcomments WHERE comment_id=%d', $c); if ($comment['comment_type'] == COMMENT_BLOG) { $this->db->dbquery('UPDATE %pblogposts SET post_comment_count=post_comment_count-1 WHERE post_id=%d', $comment['comment_post']); } elseif ($comment['comment_type'] == COMMENT_GALLERY) { $this->db->dbquery('UPDATE %pphotogallery SET photo_comment_count=photo_comment_count-1 WHERE photo_id=%d', $comment['comment_post']); } elseif ($comment['comment_type'] == COMMENT_FILE) { $this->db->dbquery('UPDATE %pfilelist SET file_comment_count=file_comment_count-1 WHERE file_id=%d', $comment['comment_post']); } $out .= 'Comment has been deleted.'; return $this->module->message('Delete Comment', $out, 'Continue', "index.php?a={$page}&p={$comment['comment_post']}"); }
if (isset($_POST['spam']) and !empty($_POST['pilihan'])) { # Panggil classAkismet require_once $this->direktori_kiss . '/classAkismet.php'; foreach ($_POST['pilihan'] as $id_komentar) { $id_komen = $this->filter($id_komentar); # Jangan tampilkan komentar dari konten yang bersangkutan $proses = $this->db->perbarui('komentar', "aktif = 0", "id = '{$id_komentar}'"); if ($proses) { # Ambil data komentar $komen_spam = $this->db->ambil('komentar', 'komentar, nama, email, situs', "id = '{$id_komentar}'"); # Proses dengan Akismet (submit ke server Akismet sebagai SPAM) $akismet = new Akismet($this->alamat, $this->data_utama['wordpress_key']); $akismet->setCommentAuthor($komen_spam['nama']); $akismet->setCommentAuthorEmail($komen_spam['email']); if (!empty($komen_spam['situs'])) { $akismet->setCommentAuthorURL($komen_spam['situs']); } $akismet->setCommentContent($komen_spam['komentar']); $akismet->submitSpam(); } } $komen .= 'Komentar telah ditandai sebagai SPAM'; } elseif (isset($_POST['hapus']) and !empty($_POST['pilihan'])) { $num = 0; foreach ($_POST['pilihan'] as $id_komentar) { $id_komentar = $this->filter($id_komentar); $proses = $this->db->hapus('komentar', "id = '{$id_komentar}'"); $num++; } $konten .= $proses ? 'Menghapus ' . $num . ' komentar' : 'Gagal menghapus komentar'; }
function addMonial() { jimport('joomla.filesystem.file'); jimport('joomla.utilities.utility'); JRequest::checkToken() or jexit('Invalid Token'); $app = JFactory::getApplication(); $db =& JFactory::getDBO(); $document =& JFactory::getDocument(); require_once JPATH_COMPONENT . DS . 'assets' . DS . '3rdparty' . DS . 'SimpleImage.php'; $myparams =& JComponentHelper::getParams('com_eztestimonial'); $imageSubFolder = $myparams->getValue('data.params.imagefolder'); $autoApprove = $myparams->getValue('data.params.autoapprove', 0); $uploadSize = $myparams->getValue('data.params.imagesize', 400); $spamfilter = $myparams->getValue('data.params.spamfilter'); $sendemailtouser = $myparams->getValue('data.params.sendemailtouser', 0); $sendemailtoadmin = $myparams->getValue('data.params.sendemailtoadmin', 0); $summerytxtlength = $myparams->getValue('data.params.summerytxtlength', 100); $ImgUrl = JRoute::_(JURI::base() . 'images/' . $imageSubFolder . '/'); $returnUrl = JRoute::_("index.php?option=com_eztestimonial&view=testimonials"); $valid = true; $fullname = strip_tags(JRequest::getVar('iname')); $useremail = strip_tags(JRequest::getVar('iemail')); $location = strip_tags(JRequest::getVar('iaddress')); $website = strip_tags(JRequest::getVar('iwebsite')); $message = strip_tags(JRequest::getVar('imessage')); $aboutme = strip_tags(JRequest::getVar('iboutme')); $rating = JRequest::getVar('rating'); $file = JRequest::getVar('iimage', null, 'files', 'array'); $filename = JFile::makeSafe($file['name']); $src = $file['tmp_name']; $extension_of_image = testimonialController::get_extension(strtolower($filename)); //get the extension of image $FileSize = filesize($file['tmp_name']); $AllowedSize = $uploadSize * 1048576; if ($spamfilter == 1) { $privatekey = $myparams->getValue('data.params.reprivatekey'); require_once JPATH_COMPONENT . DS . 'assets' . DS . '3rdparty' . DS . 'recaptchalib.php'; $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $app->enqueueMessage(JText::_('COM_TESTIMONIALS_WRONGRECAPTCHA'), 'error'); $valid = false; } } elseif ($spamfilter == 2) { $akismetKey = $myparams->getValue('data.params.akismetKey'); require_once JPATH_COMPONENT . DS . 'assets' . DS . '3rdparty' . DS . 'Akismet.class.php'; $MyURL = JURI::base(); $akismet = new Akismet($MyURL, $akismetKey); $akismet->setCommentAuthor($fullname); $akismet->setCommentAuthorEmail($email); $akismet->setCommentAuthorURL($website); $akismet->setCommentContent($message); $akismet->setPermalink(JURI::current()); if ($akismet->isCommentSpam()) { die("spam alert!"); $valid = false; } } if ($FileSize > $AllowedSize) { $exceededtxt = JText::sprintf(JText::_('COM_TESTIMONIALS_IMAGESIZETOOBIG'), testimonialController::format_bytes($AllowedSize), testimonialController::format_bytes($FileSize)); $app->enqueueMessage($exceededtxt, 'error'); $valid = false; } if (strlen($FileSize) <= 1 && strlen($filename) > 1) { $app->enqueueMessage(JText::_('COM_TESTIMONIALS_ERRUPLOADING'), 'error'); $valid = false; } if ($FileSize > 1 && $valid == true) { // Import image switch ($extension_of_image) { case 'jpg': case 'jpeg': case 'png': case 'gif': break; default: // Unsupported format $app->enqueueMessage(JText::_('COM_TESTIMONIALS_FILENOTSUPPORTED'), 'error'); $valid = false; break; } } if ($FileSize > 1 && $valid == true) { $random_str = testimonialController::random_str(); $photo_name = strtolower(str_replace(" ", "-", htmlspecialchars($fullname))) . "-" . $random_str . "."; // cleaned photo name with random charactor $newPhotoname = $photo_name . $extension_of_image; $newPhotoPath = JPATH_BASE . DS . "images" . DS . $imageSubFolder . DS; $thumb_dest = $newPhotoPath . 'thumb_' . $newPhotoname; $thumb_dest50 = $newPhotoPath . 'thumb50_' . $newPhotoname; $dest = $newPhotoPath . $newPhotoname; $image = new SimpleImage(); $image->square_crop($file['tmp_name'], $thumb_dest, $thumb_size = 200, $jpg_quality = 90); $image->square_crop($file['tmp_name'], $thumb_dest50, $thumb_size = 50, $jpg_quality = 90); $image->load($file['tmp_name']); //$image->resizeToWidth(600); $image->save($dest); } else { $newPhotoname = ''; } if (strlen($fullname) < 2) { $app->enqueueMessage(JText::_('COM_TESTIMONIALS_EMPTYNAME'), 'error'); $valid = false; } if (strlen($useremail) < 2) { $app->enqueueMessage(JText::_('COM_TESTIMONIALS_EMPTYEMAIL'), 'error'); $valid = false; } if (strlen($location) < 2) { $app->enqueueMessage(JText::_('COM_TESTIMONIALS_EMPTYLOCATION'), 'error'); $valid = false; } if (strlen($message) < 2) { $app->enqueueMessage(JText::_('COM_TESTIMONIALS_EMPTYMSSG'), 'error'); $valid = false; } if ($valid) { $approved = $autoApprove == 1 ? 1 : 0; $postdata = array('fullName' => $fullname, 'email' => $useremail, 'location' => $location, 'aboutauthor' => $aboutme, 'website' => $website, 'message_summary' => testimonialController::truncate($message, $summerytxtlength), 'message_long' => $message, 'image_name' => $newPhotoname, 'added_date' => date("Y-m-d H:i:s"), 'rating' => $rating, 'approved' => $approved); $row =& $this->getTable(); if (!$row->bind($postdata)) { $app->enqueueMessage($row->getError(), 'error'); } if (!$row->store()) { $app->enqueueMessage($row->getError(), 'error'); } else { //send email to user $sitename = $app->getCfg('sitename'); if ($sendemailtouser == 1) { $useremailfromnametxt = $myparams->getValue('data.params.useremailfromnametxt', 'From A Company'); $useremailaddress = $myparams->getValue('data.params.useremailfromtxt', '*****@*****.**'); $useremailsubject = $myparams->getValue('data.params.useremailsubjecttxt', 'Email Subject'); $useremailbody = $myparams->getValue('data.params.useremailtxt', 'Email Body'); $useremailbody = JText::sprintf($useremailbody, $fullname); $prasearray = array('{b}' => '<b>', '{/b}' => '</b>', '{br}' => '<br />', '{sitename}' => $sitename, '{siteurl}' => JURI::base(), '{name}' => $fullname); $useremailbody = testimonialController::mail_body_phraser($useremailbody, $prasearray); $SendUserEmail = JUtility::sendMail($useremailaddress, $useremailfromnametxt, $useremail, $useremailsubject, $useremailbody, true); if (!$SendUserEmail) { $app->enqueueMessage(JText::_('COM_TESTIMONIALS_EMAILFAILDUSER'), 'error'); } } $adminemails = explode(",", $myparams->getValue('data.params.adminemails', '*****@*****.**')); $adminmailtxt = $myparams->getValue('data.params.adminmailtxt'); $prasearray = array('{b}' => '<b>', '{/b}' => '</b>', '{br}' => '<br />', '{sitename}' => $sitename, '{siteurl}' => JURI::base()); $adminmailtxt = testimonialController::mail_body_phraser($adminmailtxt, $prasearray); // send mail to all administrators foreach ($adminemails as $adminemail) { $adminmailtxt = JText::sprintf($adminmailtxt, $row->iname); $SendAdminEmail = JUtility::sendMail($mailfrom, $fromname, $adminemail, $adminmailsubjecttxt, $adminmailtxt, true); $app->enqueueMessage($adminemailstosend, 'error'); if (!$SendAdminEmail) { $app->enqueueMessage(JText::_('COM_TESTIMONIALS_EMAILFAILDADMIN'), 'error'); } } //display message accordingly if ($autoApprove == 0) { $app->enqueueMessage(JText::_('COM_TESTIMONIALS_WAITINGAPPROVAL'), 'message'); $app->redirect($returnUrl); } else { $app->enqueueMessage(JText::_('COM_TESTIMONIALS_PUBLISHEDMSG'), 'message'); $app->redirect($returnUrl); } } } }
function comment() { $mainframe = JFactory::getApplication(); jimport('joomla.mail.helper'); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables'); $params = K2HelperUtilities::getParams('com_k2'); $user = JFactory::getUser(); $config = JFactory::getConfig(); JLoader::register('Services_JSON', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'lib' . DS . 'JSON.php'); $json = new Services_JSON(); $response = new JObject(); //Get item $item = JTable::getInstance('K2Item', 'Table'); $item->load(JRequest::getInt('itemID')); //Get category $category = JTable::getInstance('K2Category', 'Table'); $category->load($item->catid); //Access check if (K2_JVERSION != '15') { if (!in_array($item->access, $user->getAuthorisedViewLevels()) || !in_array($category->access, $user->getAuthorisedViewLevels())) { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); } } else { if ($item->access > $user->get('aid', 0) || $category->access > $user->get('aid', 0)) { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); } } //Published check if (!$item->published || $item->trash) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } if (!$category->published || $category->trash) { JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND')); } //Check permissions if ($params->get('comments') == '2' && $user->id > 0 && K2HelperPermissions::canAddComment($item->catid) || $params->get('comments') == '1') { // If new antispam settings are not saved, show a message to the comments form and stop the comment submission $antispamProtection = $params->get('antispam', null); if ($antispamProtection === null || ($antispamProtection == 'recaptcha' || $antispamProtection == 'both') && !$params->get('recaptcha_private_key') || ($antispamProtection == 'akismet' || $antispamProtection == 'both') && !$params->get('akismetApiKey')) { $response->message = JText::_('K2_ANTISPAM_SETTINGS_ERROR'); echo $json->encode($response); $mainframe->close(); } $row = JTable::getInstance('K2Comment', 'Table'); if (!$row->bind(JRequest::get('post'))) { $response->message = $row->getError(); echo $json->encode($response); $mainframe->close(); } $row->commentText = JRequest::getString('commentText', '', 'default'); $row->commentText = strip_tags($row->commentText); //Strip a tags since all urls will be converted to links automatically on runtime. //Additionaly strip tables to avoid layout issues. //Also strip all attributes except src, alt and title. //$filter = new JFilterInput(array('a', 'table'), array('src', 'alt', 'title'), 1); //$row->commentText = $filter->clean( $row->commentText ); //Clean vars $filter = JFilterInput::getInstance(); $row->userName = $filter->clean($row->userName, 'username'); if ($row->commentURL && preg_match('/^((http|https|ftp):\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,6}((:[0-9]{1,5})?\\/.*)?$/i', $row->commentURL)) { $url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $row->commentURL); $url = str_replace(';//', '://', $url); if ($url != '') { $url = !strstr($url, '://') ? 'http://' . $url : $url; $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); $row->commentURL = $url; } } else { $row->commentURL = ''; } $datenow = JFactory::getDate(); $row->commentDate = K2_JVERSION == '15' ? $datenow->toMySQL() : $datenow->toSql(); if (!$user->guest) { $row->userID = $user->id; $row->commentEmail = $user->email; $row->userName = $user->name; } $userName = trim($row->userName); $commentEmail = trim($row->commentEmail); $commentText = trim($row->commentText); $commentURL = trim($row->commentURL); if (empty($userName) || $userName == JText::_('K2_ENTER_YOUR_NAME') || empty($commentText) || $commentText == JText::_('K2_ENTER_YOUR_MESSAGE_HERE') || empty($commentEmail) || $commentEmail == JText::_('K2_ENTER_YOUR_EMAIL_ADDRESS')) { $response->message = JText::_('K2_YOU_NEED_TO_FILL_IN_ALL_REQUIRED_FIELDS'); echo $json->encode($response); $mainframe->close(); } if (!JMailHelper::isEmailAddress($commentEmail)) { $response->message = JText::_('K2_INVALID_EMAIL_ADDRESS'); echo $json->encode($response); $mainframe->close(); } if ($user->guest) { $db = JFactory::getDBO(); $query = "SELECT COUNT(*) FROM #__users WHERE name=" . $db->Quote($userName) . " OR email=" . $db->Quote($commentEmail); $db->setQuery($query); $result = $db->loadresult(); if ($result > 0) { $response->message = JText::_('K2_THE_NAME_OR_EMAIL_ADDRESS_YOU_TYPED_IS_ALREADY_IN_USE'); echo $json->encode($response); $mainframe->close(); } } // Google reCAPTCHA if ($params->get('antispam') == 'recaptcha' || $params->get('antispam') == 'both') { if ($user->guest || $params->get('recaptchaForRegistered', 1)) { if (!function_exists('_recaptcha_qsencode')) { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'lib' . DS . 'recaptchalib.php'; } $privatekey = $params->get('recaptcha_private_key'); $recaptcha_challenge_field = isset($_POST["recaptcha_challenge_field"]) ? $_POST["recaptcha_challenge_field"] : ''; $recaptcha_response_field = isset($_POST["recaptcha_response_field"]) ? $_POST["recaptcha_response_field"] : ''; $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field, $recaptcha_response_field); if (!$resp->is_valid) { $response->message = JText::_('K2_THE_WORDS_YOU_TYPED_DID_NOT_MATCH_THE_ONES_DISPLAYED_PLEASE_TRY_AGAIN'); echo $json->encode($response); $mainframe->close(); } } } // Akismet if ($params->get('antispam') == 'akismet' || $params->get('antispam') == 'both') { if ($user->guest || $params->get('akismetForRegistered', 1)) { if ($params->get('akismetApiKey')) { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'lib' . DS . 'akismet.class.php'; $akismetApiKey = $params->get('akismetApiKey'); $akismet = new Akismet(JURI::root(false), $akismetApiKey); $akismet->setCommentAuthor($userName); $akismet->setCommentAuthorEmail($commentEmail); $akismet->setCommentAuthorURL($commentURL); $akismet->setCommentContent($commentText); $akismet->setPermalink(JURI::root(false) . 'index.php?option=com_k2&view=item&id=' . JRequest::getInt('itemID')); try { if ($akismet->isCommentSpam()) { $response->message = JText::_('K2_SPAM_ATTEMPT_HAS_BEEN_DETECTED_THE_COMMENT_HAS_BEEN_REJECTED'); echo $json->encode($response); $mainframe->close(); } } catch (Exception $e) { $response->message = $e->getMessage(); echo $json->encode($response); $mainframe->close(); } } } } if ($commentURL == JText::_('K2_ENTER_YOUR_SITE_URL') || $commentURL == "") { $row->commentURL = NULL; } else { if (substr($commentURL, 0, 7) != 'http://') { $row->commentURL = 'http://' . $commentURL; } } if ($params->get('commentsPublishing')) { $row->published = 1; } else { $row->published = 0; // Auto publish comments for users with administrative permissions if (K2_JVERSION != '15') { if ($user->authorise('core.admin')) { $row->published = 1; } } else { if ($user->gid > 23) { $row->published = 1; } } } if (!$row->store()) { $response->message = $row->getError(); echo $json->encode($response); $mainframe->close(); } if ($row->published) { $caching = K2_JVERSION == '30' ? $config->get('caching') : $config->getValue('config.caching'); if ($caching && $user->guest) { $response->message = JText::_('K2_THANK_YOU_YOUR_COMMENT_WILL_BE_PUBLISHED_SHORTLY'); echo $json->encode($response); } else { $response->message = JText::_('K2_COMMENT_ADDED_REFRESHING_PAGE'); $response->refresh = 1; echo $json->encode($response); } } else { $response->message = JText::_('K2_COMMENT_ADDED_AND_WAITING_FOR_APPROVAL'); echo $json->encode($response); } } $mainframe->close(); }
public static function check($input, &$model) { $application = JFactory::getApplication(); $params = JComponentHelper::getParams('com_k2'); $user = JFactory::getUser(); // Google reCAPTCHA if ($params->get('antispam') == 'recaptcha' || $params->get('antispam') == 'both') { if ($user->guest || $params->get('recaptchaForRegistered')) { $data = array(); $data['secret'] = $params->get('recaptcha_private_key'); $data['remoteip'] = $_SERVER["REMOTE_ADDR"]; $data['response'] = $application->input->post->get('g-recaptcha-response', '', 'raw'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify?' . http_build_query($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); $error = curl_error($ch); curl_close($ch); if ($response === false) { $model->setError($error); return false; } $json = json_decode($response); if (!$json->success) { $model->setError(JText::_('K2_WE_COULD_NOT_VERIFY_THAT_YOU_ARE_HUMAN')); return false; } } } // Akismet if ($params->get('antispam') == 'akismet' || $params->get('antispam') == 'both') { if ($user->guest || $params->get('akismetForRegistered')) { if ($params->get('akismetApiKey')) { require_once JPATH_ADMINISTRATOR . 'components/com_k2/classes/akismet.class.php'; $akismetApiKey = $params->get('akismetApiKey'); $akismet = new Akismet(JURI::root(false), $akismetApiKey); $akismet->setCommentAuthor($input['name']); $akismet->setCommentAuthorEmail($input['email']); $akismet->setCommentAuthorURL($input['url']); $akismet->setCommentContent($input['text']); $akismet->setPermalink(JURI::root(false) . 'index.php?option=com_k2&view=item&id=' . $input['itemId']); try { if ($akismet->isCommentSpam()) { $model->setError(JText::_('K2_SPAM_ATTEMPT_HAS_BEEN_DETECTED_THE_COMMENT_HAS_BEEN_REJECTED')); return false; } } catch (Exception $e) { $model->setError($e->getMessage()); return false; } } } } return true; }
static function reportSpam($comments) { $config = Config::current(); foreach ($comments as $comment) { $akismet = new Akismet($config->url, $config->akismet_api_key); $akismet->setCommentAuthor($comment->author); $akismet->setCommentAuthorEmail($comment->author_email); $akismet->setCommentAuthorURL($comment->author_url); $akismet->setCommentContent($comment->body); $akismet->setPermalink($comment->post_id); $akismet->setReferrer($comment->author_agent); $akismet->setUserIP($comment->author_ip); $akismet->submitSpam(); } }
function report_ham($c) { $spam = $this->db->quick_query('SELECT * FROM %pspam WHERE spam_id=%d', $c); if (!$spam) { return $this->message('Spam Control', 'There is no such spam comment.', 'Continue', '/index.php?a=spam_control'); } if ($this->user['user_level'] == USER_CONTRIBUTOR) { $user = null; if ($spam['spam_type'] == COMMENT_BLOG) { $user = $this->db->quick_query('SELECT post_user FROM %blogposts WHERE post_id=%d', $spam['spam_post']); } else { if ($spam['spam_type'] == COMMENT_GALLERY) { $user = $this->db->quick_query('SELECT photo_user FROM %pphotogallery WHERE photo_id=%d', $spam['spam_post']); } else { if ($spam['spam_type'] == COMMENT_FILE) { $user = $this->db->quick_query('SELECT file_user FROM %pfilelist WHERE file_id=%d', $spam['spam_post']); } } } if (!$user) { return $this->error('Access Denied: You do not own the entry you are trying to report.'); } } $svars = json_decode($spam['spam_server'], true); // Setup and deliver the information to flag this comment as legit with Akismet. require_once 'lib/akismet.php'; $akismet = new Akismet($this->settings['site_address'], $this->settings['wordpress_api_key'], $this->version); $akismet->setCommentAuthor($spam['spam_author']); $akismet->setCommentAuthorURL($spam['spam_url']); $akismet->setCommentContent($spam['spam_message']); $akismet->setUserIP($spam['spam_ip']); $akismet->setReferrer($svars['HTTP_REFERER']); $akismet->setUserAgent($svars['HTTP_USER_AGENT']); $akismet->setCommentType('comment'); $akismet->submitHam(); $q = $spam['spam_post']; $author = $spam['spam_user']; $author_name = $spam['spam_author']; $message = $spam['spam_message']; $url = $spam['spam_url']; $time = $spam['spam_date']; $ip = $spam['spam_ip']; $type = $spam['spam_type']; $this->settings['spam_count']--; $this->settings['ham_count']++; $this->save_settings(); $this->db->dbquery("INSERT INTO %pblogcomments\n\t\t (comment_post, comment_user, comment_author, comment_message, comment_date, comment_ip, comment_type)\n\t\t VALUES ( %d, %d, '%s', '%s', %d, '%s', %d)", $q, $author, $author_name, $message, $time, $ip, $type); if ($type == COMMENT_BLOG) { $this->db->dbquery('UPDATE %pblogposts SET post_comment_count=post_comment_count+1 WHERE post_id=%d', $q); } elseif ($type == COMMENT_GALLERY) { $this->db->dbquery('UPDATE %pphotogallery SET photo_comment_count=photo_comment_count+1 WHERE photo_id=%d', $q); } elseif ($type == COMMENT_FILE) { $this->db->dbquery('UPDATE %pfilelist SET file_comment_count=file_comment_count+1 WHERE file_id=%d', $q); } $this->db->dbquery('DELETE FROM %pspam WHERE spam_id=%d', $c); return $this->message('Spam Control', 'Comment has been posted and Akismet notified of a false positive.', 'Continue', $this->settings['site_address'] . 'index.php?a=spam_control'); }
/** * Check to see if the content being passed is considered as SPAM. * * @return bool TRUE is spam, FALSE if it isn't. */ private function _isSpam() { if (Phpfox::getUserParam('core.is_spam_free')) { return false; } if (!Phpfox::getParam('core.enable_spam_check')) { return false; } if (Phpfox::isUser() && Phpfox::getUserBy('total_spam') > Phpfox::getParam('core.auto_deny_items')) { $this->_aParams['is_spam'] = true; return true; } $sUrl = Phpfox::getParam('core.akismet_url'); $sPassword = Phpfox::getParam('core.akismet_password'); if (empty($sUrl) || empty($sPassword)) { return false; } $sAkismet = PHPFOX_DIR_LIB . 'akismet' . PHPFOX_DS . 'Akismet.class.php'; if (file_exists($sAkismet)) { require_once $sAkismet; $oAkismet = new Akismet($sUrl, $sPassword); if (Phpfox::isUser()) { $oAkismet->setCommentAuthor(Phpfox::getUserBy('full_name')); $oAkismet->setCommentAuthorEmail(Phpfox::getUserBy('email')); } else { if (isset($this->_aParams['user'])) { $oAkismet->setCommentAuthor($this->_aParams['user']); } if (isset($this->_aParams['email'])) { $oAkismet->setCommentAuthorEmail($this->_aParams['email']); } } if (isset($this->_aParams['url'])) { $oAkismet->setCommentAuthorURL($this->_aParams['url']); } if (isset($this->_aParams['link'])) { $oAkismet->setPermalink($this->_aParams['link']); } if (isset($this->_aParams['content'])) { $oAkismet->setCommentContent($this->_aParams['content']); } if (($this->_aParams['is_spam'] = $oAkismet->isCommentSpam()) === true) { Phpfox_Database::instance()->updateCounter('user', 'total_spam', 'user_id', Phpfox::getUserId()); } return $this->_aParams['is_spam']; } return false; }
function akismet_showpage() { global $main_smarty, $the_template, $current_user, $db; force_authentication(); $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('god'); if ($canIhaveAccess == 1) { if (phpnum() >= 5) { include_once akismet_lib_path . 'Akismet.class_5.php'; } else { include_once akismet_lib_path . 'Akismet.class_4.php'; } $navwhere['text1'] = 'Akismet'; $navwhere['link1'] = URL_akismet; define('pagename', 'akismet'); $main_smarty->assign('pagename', pagename); define('modulename', 'akismet'); $main_smarty->assign('modulename', modulename); if (isset($_REQUEST['view'])) { $view = sanitize($_REQUEST['view'], 3); } else { $view = ''; } if ($view == '') { $wordpress_key = get_misc_data('wordpress_key'); if ($wordpress_key == '') { header('Location: ' . URL_akismet . '&view=manageKey'); } $spam_links = get_misc_data('spam_links'); if ($spam_links != '') { $spam_links = unserialize(get_misc_data('spam_links')); } else { $spam_links = array(); } $main_smarty->assign('spam_links', $spam_links); $main_smarty->assign('spam_links_count', count($spam_links)); $spam_comments = get_misc_data('spam_comments'); if ($spam_comments != '') { $spam_comments = unserialize(get_misc_data('spam_comments')); } else { $spam_comments = array(); } $main_smarty->assign('spam_comments', $spam_comments); $main_smarty->assign('spam_comments_count', count($spam_comments)); $main_smarty = do_sidebar($main_smarty, $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); $main_smarty->assign('tpl_center', akismet_tpl_path . 'main'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } if ($view == 'manageKey') { $wordpress_key = get_misc_data('wordpress_key'); $main_smarty->assign('wordpress_key', $wordpress_key); $main_smarty = do_sidebar($main_smarty, $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageKey'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } if ($view == 'updateKey') { if (isset($_REQUEST['key'])) { $wordpress_key = sanitize($_REQUEST['key'], 3); } else { $wordpress_key = ''; } misc_data_update('wordpress_key', $wordpress_key); header('Location: ' . URL_akismet); } if ($view == 'manageSpam') { $spam_links = get_misc_data('spam_links'); if ($spam_links != '') { $spam_links = unserialize(get_misc_data('spam_links')); } else { $spam_links = array(); } if (count($spam_links) > 0) { $sql = "SELECT " . table_links . ".* FROM " . table_links . " WHERE "; $sql .= 'link_id IN (' . implode(',', $spam_links) . ')'; $link_data = $db->get_results($sql); $main_smarty->assign('link_data', object_2_array($link_data)); } else { header('Location: ' . URL_akismet); } $main_smarty = do_sidebar($main_smarty, $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSpam'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } if ($view == 'manageSettings') { $main_smarty = do_sidebar($main_smarty, $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSettings'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } /* if($view == 'isSpam'){ if(isset($_REQUEST['link_id'])){$link_id = sanitize($_REQUEST['link_id'], 3);}else{$link_id='';} $spam_links = get_misc_data('spam_links'); $spam_links = unserialize(get_misc_data('spam_links')); unset($spam_links[$link_id]); misc_data_update('spam_links', serialize($spam_links)); $link = new Link; $link->id = $link_id; $link->read(FALSE); $link->status = 'discard'; $link->store(); header('Location: ' . URL_akismet . '&view=manageSpam'); } if($view == 'isNotSpam'){ if(isset($_REQUEST['link_id'])){$link_id = sanitize($_REQUEST['link_id'], 3);}else{$link_id='';} $spam_links = get_misc_data('spam_links'); $spam_links = unserialize(get_misc_data('spam_links')); unset($spam_links[$link_id]); misc_data_update('spam_links', serialize($spam_links)); $link = new Link; $link->id = $link_id; $link->read(FALSE); $link->status = 'queued'; $link->store(); header('Location: ' . URL_akismet . '&view=manageSpam'); } if($view == 'addSpam'){ $spam_links[1] = 1; misc_data_update('spam_links', serialize($spam_links)); header('Location: ' . URL_akismet . '&view=manageSpam'); } */ if ($view == 'manageSpamcomments') { $spam_comments = get_misc_data('spam_comments'); if ($spam_comments != '') { $spam_comments = unserialize(get_misc_data('spam_comments')); } else { $spam_comments = array(); } if (count($spam_comments) > 0) { $sql = "SELECT * FROM " . table_prefix . "spam_comments WHERE "; $sql .= 'linkid IN (' . implode(',', $spam_comments) . ')'; $link_data = $db->get_results($sql); $user_cmt = new User(); $user_cmt_link = new Link(); $spam_output .= ' <form name="bulk_moderate" action="' . URL_akismet_isSpamcomment . '&action=bulkmod" method="post">'; $spam_output .= "<table>"; $spam_output .= "<tr><th>Author</th><th>Body</th><th>this is spam</th><th>this is NOT spam</th></tr>"; if ($link_data) { foreach ($link_data as $spam_cmts) { $user_cmt->id = $spam_cmts->userid; $user_cmt->read(); $user_name = $user_cmt->username; $user_cmt_link->id = $spam_cmts->linkid; $user_cmt_link->read(); $spam_output .= "<tr>"; $spam_output .= "<td>" . $user_name . "</td>"; $spam_output .= "<td>" . save_text_to_html($spam_cmts->cmt_content) . "</td>"; $spam_output .= '<td><center><input type="radio" name="spamcomment[' . $spam_cmts->auto_id . ']" id="spamcomment-' . $spam_cmts->auto_id . '" value="spamcomment"></center></td>'; $spam_output .= '<td><center><input type="radio" name="spamcomment[' . $spam_cmts->auto_id . ']" id="spamcomment-' . $spam_cmts->auto_id . '" value="notspamcomment"></center></td>'; $spam_output .= "</tr>"; } } $spam_output .= "</table>"; $spam_output .= '<p align="right"><input type="submit" name="submit" value="Change Status" class="log2" /></p>'; $spam_output .= "</form>"; $main_smarty->assign('spam_output', $spam_output); $main_smarty->assign('link_data', object_2_array($link_data)); } else { header('Location: ' . URL_akismet); } $main_smarty = do_sidebar($main_smarty, $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSpamcomments'); $main_smarty->display($the_template . '/pligg.tpl'); } if ($view == 'isSpam') { if ($_GET['action'] == "bulkmod") { if (isset($_POST['submit'])) { $spam = array(); foreach ($_POST["spam"] as $k => $v) { $spam[intval($k)] = $v; } foreach ($spam as $key => $value) { if ($value == "spam") { if (isset($key)) { $link_id = sanitize($key, 3); } else { $link_id = ''; } $spam_links = get_misc_data('spam_links'); $spam_links = unserialize(get_misc_data('spam_links')); $key = array_search($link_id, $spam_links); unset($spam_links[$key]); misc_data_update('spam_links', serialize($spam_links)); $link = new Link(); $link->id = $link_id; $link->read(); $link->status = 'discard'; $link->store(); $user = new User(); $user->id = $link->author; $user->read(); $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key')); $akismet->setCommentAuthor($user->username); $akismet->setCommentAuthorEmail($user->email); $akismet->setCommentAuthorURL($link->url); $akismet->setCommentContent($link->content); $akismet->setPermalink(getmyurl('story', $link->id)); $akismet->submitSpam(); } elseif ($value == "notspam") { if (isset($key)) { $link_id = sanitize($key, 3); } else { $link_id = ''; } $spam_links = get_misc_data('spam_links'); $spam_links = unserialize(get_misc_data('spam_links')); $key = array_search($link_id, $spam_links); unset($spam_links[$key]); misc_data_update('spam_links', serialize($spam_links)); $link = new Link(); $link->id = $link_id; $link->read(FALSE); $link->status = 'queued'; $link->store(); $user = new User(); $user->id = $link->author; $user->read(); $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key')); $akismet->setCommentAuthor($user->username); $akismet->setCommentAuthorEmail($user->email); $akismet->setCommentAuthorURL($link->url); $akismet->setCommentContent($link->content); $akismet->setPermalink(getmyurl('story', $link->id)); $akismet->submitHam(); } } } } header('Location: ' . URL_akismet . '&view=manageSpam'); } if ($view == 'isSpamcomment') { if ($_GET['action'] == "bulkmod") { if (isset($_POST['submit'])) { $spamcomment = array(); foreach ($_POST["spamcomment"] as $k => $v) { $spamcomment[intval($k)] = $v; } foreach ($spamcomment as $key => $value) { if ($value == "spamcomment") { if (isset($key)) { $link_id = sanitize($key, 3); } else { $link_id = ''; } global $db; $spam_comments = get_misc_data('spam_comments'); $spam_comments = unserialize(get_misc_data('spam_comments')); $key = array_search($link_id, $spam_comments); unset($spam_comments[$key]); $sql_result = "Select * from " . table_prefix . "spam_comments where auto_id=" . $link_id; $result_arr = $db->get_results($sql_result); if ($result_arr) { foreach ($result_arr as $result_arr_comments) { $link = new Link(); $link->id = $result_arr_comments->linkid; $link->read(); $user = new User(); $user->id = $result_arr_comments->userid; $user->read(); $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key')); $akismet->setCommentAuthor($user->username); $akismet->setCommentAuthorEmail($user->email); $akismet->setCommentAuthorURL($link->url); $akismet->setCommentContent($result_arr_comments->cmt_content); $akismet->setPermalink(getmyurl('story', $link->id)); $akismet->submitSpam(); } } misc_data_update('spam_comments', serialize($spam_comments)); $db->query(' Delete from ' . table_prefix . 'spam_comments where auto_id=' . $link_id); } elseif ($value == "notspamcomment") { if (isset($key)) { $link_id = sanitize($key, 3); } else { $link_id = ''; } global $db; $spam_comments = get_misc_data('spam_comments'); $spam_comments = unserialize(get_misc_data('spam_comments')); $key = array_search($link_id, $spam_comments); unset($spam_comments[$key]); $sql_result = " Select * from " . table_prefix . "spam_comments where auto_id={$link_id}"; $result_arr = $db->get_results($sql_result); if ($result_arr) { foreach ($result_arr as $result_arr_comments) { $link = new Link(); $link->id = $result_arr_comments->linkid; $link->read(); $user = new User(); $user->id = $result_arr_comments->userid; $user->read(); $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key')); $akismet->setCommentAuthor($user->username); $akismet->setCommentAuthorEmail($user->email); $akismet->setCommentAuthorURL($link->url); $akismet->setCommentContent($result_arr_comments->cmt_content); $akismet->setPermalink(getmyurl('story', $link->id)); $akismet->submitHam(); $sql = "INSERT INTO " . table_comments . " (comment_parent, comment_user_id, comment_link_id , comment_date, comment_randkey, comment_content) VALUES ({$result_arr_comments->cmt_parent}, {$result_arr_comments->userid}, {$result_arr_comments->linkid}, now(), '{$result_arr_comments->cmt_rand}', '{$result_arr_comments->cmt_content}')"; $db->query($sql); } } misc_data_update('spam_comments', serialize($spam_comments)); $sql_delete = ' Delete from ' . table_prefix . 'spam_comments where auto_id=' . $link_id; $db->query($sql_delete); $link->adjust_comment(1); $link->store(); } } } header('Location: ' . URL_akismet . '&view=manageSpamcomments'); } } } }
/** * Calculates comment's status using akismet. * * @param array $data Comment's data to be validated by Akismet * @return string Filtered comment's status */ protected function _akismetStatus($data) { require_once Plugin::classPath('Comment') . 'Lib/Akismet.php'; try { $akismet = new \Akismet(Router::url('/'), $this->config('settings.akismet_key')); if (!empty($data['author_name'])) { $akismet->setCommentAuthor($data['author_name']); } if (!empty($data['author_email'])) { $akismet->setCommentAuthorEmail($data['author_email']); } if (!empty($data['author_web'])) { $akismet->setCommentAuthorURL($data['author_web']); } if (!empty($data['body'])) { $akismet->setCommentContent($data['body']); } if ($akismet->isCommentSpam()) { return 'spam'; } } catch (\Exception $ex) { return 'pending'; } return $data['status']; }
protected function proses_komentar($id_konten, $komentar, $nama, $email, $situs) { # Filtering input $id_konten = $this->filter($id_konten); $komentar = $this->filter($komentar); $nama = $this->filter($nama); $email = $this->filter($email); $tanggal = date("j M Y"); # Cek variabel situs $situs = !empty($situs) ? 'http://' . str_replace('http://', '', $this->filter($situs)) : ''; # Cek apakah komentar sudah dimasukkan sebelumnya $cekdobel = $this->db->queri("SELECT id_konten, komentar, nama, email FROM komentar WHERE id_konten = '{$id_konten}' AND nama = '{$nama}' AND email = '{$email}' AND komentar = '{$komentar}'", 1); if ($cekdobel > 0) { echo 'Komentar sudah dimasukkan'; } else { if ($_SERVER['HTTP_HOST'] != 'localhost' and !empty($this->data_utama['wordpress_key'])) { $konten = $this->db->ambil('konten', 'id_kategori, slug', "id = '{$id_konten}'"); $kategori = $this->db->ambil('kategori', 'slug', "id = '" . $konten['id_kategori'] . "'"); $alamat_konten = $this->alamat . '/' . $kategori['slug'] . '/' . $konten['slug']; $aktif = 1; # Panggil classAkismet require_once $this->direktori_kiss . '/classAkismet.php'; $akismet = new Akismet($this->alamat, $this->data_utama['wordpress_key']); $akismet->setCommentAuthor($nama); $akismet->setCommentAuthorEmail($email); $akismet->setCommentAuthorURL($situs); $akismet->setCommentContent($komentar); $akismet->setPermalink($alamat_konten); if ($akismet->isCommentSpam()) { echo 'Komentar dikenali sebagai SPAM!'; $aktif = 0; } else { $proses = $this->db->tambah('komentar', 'tanggal, id_konten, komentar, nama, email, situs, aktif', "'{$tanggal}', {$id_konten}, '{$komentar}', '{$nama}', '{$email}', '{$situs}', {$aktif}"); echo 'Terimakasih atas komentarnya ' . $nama; } } else { $proses = $this->db->tambah('komentar', 'tanggal, id_konten, komentar, nama, email, situs, aktif', "'{$tanggal}', {$id_konten}, '{$komentar}', '{$nama}', '{$email}', '{$situs}', 1"); } } }
private function performChecks() { $request = JRequest::get(); // Calc check if ($this->params->get('type_calc')) { if ($this->_session->get('rot13', null, 'easycalccheck') == 1) { $spamcheckresult = base64_decode(str_rot13($this->_session->get('spamcheckresult', null, 'easycalccheck'))); } else { $spamcheckresult = base64_decode($this->_session->get('spamcheckresult', null, 'easycalccheck')); } $spamcheck = JRequest::getInt($this->_session->get('spamcheck', null, 'easycalccheck'), '', 'post'); $this->_session->clear('rot13', 'easycalccheck'); $this->_session->clear('spamcheck', 'easycalccheck'); $this->_session->clear('spamcheckresult', 'easycalccheck'); if (!is_numeric($spamcheckresult) || $spamcheckresult != $spamcheck) { return false; // Failed } } // Hidden field if ($this->params->get('type_hidden')) { $hidden_field = $this->_session->get('hidden_field', null, 'easycalccheck'); $this->_session->clear('hidden_field', 'easycalccheck'); if (JRequest::getVar($hidden_field, '', 'post')) { return false; // Hidden field was filled out - failed } } // Time lock if ($this->params->get('type_time')) { $time = $this->_session->get('time', null, 'easycalccheck'); $this->_session->clear('time', 'easycalccheck'); if (time() - $this->params->get('type_time_sec') <= $time) { return false; // Submitted too fast - failed } } // Own Question // Conversion to lower case if ($this->params->get('question')) { $answer = strtolower(JRequest::getString($this->_session->get('question', null, 'easycalccheck'), '', 'post')); $this->_session->clear('question', 'easycalccheck'); if ($answer != strtolower($this->params->get('question_a'))) { return false; // Question wasn't answered - failed } } // StopForumSpam - Check the IP Address // Further informations: http://www.stopforumspam.com if ($this->params->get('stopforumspam')) { $url = 'http://www.stopforumspam.com/api?ip=' . $this->_session->get('ip', null, 'easycalccheck'); // Function test - Comment out to test - Important: Enter a active Spam-IP // $ip = '88.180.52.46'; // $url = 'http://www.stopforumspam.com/api?ip='.$ip; $response = false; $is_spam = false; if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); } if ($response) { preg_match('#<appears>(.*)</appears>#', $response, $out); $is_spam = $out[1]; } else { $response = @fopen($url, 'r'); if ($response) { while (!feof($response)) { $line = fgets($response, 1024); if (preg_match('#<appears>(.*)</appears>#', $line, $out)) { $is_spam = $out[1]; break; } } fclose($response); } } if ($is_spam == 'yes' and $response == true) { return false; // Spam-IP - failed } } // Honeypot Project // Further informations: http://www.projecthoneypot.org/home.php // BL ACCESS KEY - http://www.projecthoneypot.org/httpbl_configure.php if ($this->params->get('honeypot')) { require_once dirname(__FILE__) . DS . 'easycalccheckplus' . DS . 'honeypot.php'; $http_blKey = $this->params->get('honeypot_key'); if ($http_blKey) { $http_bl = new http_bl($http_blKey); $result = $http_bl->query($this->_session->get('ip', null, 'easycalccheck')); // Function test - Comment out to test - Important: Enter a active Spam-IP // $ip = '117.21.224.251'; // $result = $http_bl->query($ip); if ($result == 2) { return false; } } } // Akismet // Further informations: http://akismet.com/ if ($this->params->get('akismet')) { require_once dirname(__FILE__) . DS . 'easycalccheckplus' . DS . 'akismet.php'; $akismet_key = $this->params->get('akismet_key'); if ($akismet_key) { $akismet_url = JURI::getInstance()->toString(); $name = ''; $email = ''; $url = ''; $comment = ''; if ($request['option'] == 'com_contact') { $name = $request['jform']['contact_name']; $email = $request['jform']['contact_email']; $comment = $request['jform']['contact_message']; } elseif ($request['option'] == 'com_users') { $name = $request['jform']['name']; $email = $request['jform']['email1']; if (isset($request['jform']['email'])) { $email = $request['jform']['email']; } } elseif ($request['option'] == 'com_comprofiler') { $name = $request['name']; $email = $request['email']; if (isset($request['checkusername'])) { $name = $request['checkusername']; } if (isset($request['checkemail'])) { $email = $request['checkemail']; } } elseif ($request['option'] == 'com_easybookreloaded') { $name = $request['gbname']; $email = $request['gbmail']; $comment = $request['gbtext']; if (isset($request['gbpage'])) { $url = $request['gbpage']; } } elseif ($request['option'] == 'com_phocaguestbook') { $name = $request['pgusername']; $email = $request['email']; $comment = $request['pgbcontent']; } elseif ($request['option'] == 'com_dfcontact') { $name = $request['name']; $email = $request['email']; $comment = $request['message']; } elseif ($request['option'] == 'com_flexicontact') { $name = $request['from_name']; $email = $request['from_email']; $comment = $request['area_data']; } elseif ($request['option'] == 'com_alfcontact') { $name = $request['name']; $email = $request['email']; $comment = $request['message']; } elseif ($request['option'] == 'com_community') { $name = $request['usernamepass']; $email = $request['emailpass']; } elseif ($request['option'] == 'com_virtuemart') { $name = $request['name']; $email = $request['email']; $comment = $request['comment']; } elseif ($request['option'] == 'com_jshopping') { $name = $request['f_name']; $email = $request['email']; } $akismet = new Akismet($akismet_url, $akismet_key); $akismet->setCommentAuthor($name); $akismet->setCommentAuthorEmail($email); $akismet->setCommentAuthorURL($url); $akismet->setCommentContent($comment); if ($akismet->isCommentSpam()) { return false; } } } // ReCaptcha // Further informations: http://www.google.com/recaptcha if ($this->params->get('recaptcha') and $this->params->get('recaptcha_publickey') and $this->params->get('recaptcha_privatekey')) { require_once dirname(__FILE__) . DS . 'easycalccheckplus' . DS . 'recaptchalib.php'; $privatekey = $this->params->get('recaptcha_privatekey'); $resp = recaptcha_check_answer($privatekey, $this->_session->get('ip', null, 'easycalccheck'), $request['recaptcha_challenge_field'], $request['recaptcha_response_field']); if (!$resp->is_valid) { return false; } } // Botscout - Check the IP Address // Further informations: http://botscout.com/ if ($this->params->get('botscout') and $this->params->get('botscout_key')) { $url = 'http://botscout.com/test/?ip=' . $this->_session->get('ip', null, 'easycalccheck') . '&key=' . $this->params->get('botscout_key'); // Function test - Comment out to test - Important: Enter a active Spam-IP // $ip = '87.103.128.199'; // $url = 'http://botscout.com/test/?ip='.$ip.'&key='.$this->params->get('botscout_key'); $response = false; $is_spam = false; if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); } if ($response) { $is_spam = substr($response, 0, 1); } else { $response = @fopen($url, 'r'); if ($response) { while (!feof($response)) { $line = fgets($response, 1024); $is_spam = substr($line, 0, 1); } fclose($response); } } if ($is_spam == 'Y' and $response == true) { // Spam-IP - failed return false; } } // Mollom // Further informations: http://mollom.com/ if ($this->params->get('mollom') and $this->params->get('mollom_publickey') and $this->params->get('mollom_privatekey')) { require_once dirname(__FILE__) . DS . 'easycalccheckplus' . DS . 'mollom.php'; Mollom::setPublicKey($this->params->get('mollom_publickey')); Mollom::setPrivateKey($this->params->get('mollom_privatekey')); $servers = Mollom::getServerList(); $name = ''; $email = ''; $url = ''; $comment = ''; if ($request['option'] == 'com_contact') { $name = $request['jform']['contact_name']; $email = $request['jform']['contact_email']; $comment = $request['jform']['contact_message']; } elseif ($request['option'] == 'com_users') { $name = $request['jform']['name']; $email = $request['jform']['email1']; if (isset($request['jform']['email'])) { $email = $request['jform']['email']; } } elseif ($request['option'] == 'com_comprofiler') { $name = $request['name']; $email = $request['email']; if (isset($request['checkusername'])) { $name = $request['checkusername']; } if (isset($request['checkemail'])) { $email = $request['checkemail']; } } elseif ($request['option'] == 'com_easybookreloaded') { $name = $request['gbname']; $email = $request['gbmail']; $comment = $request['gbtext']; if (isset($request['gbpage'])) { $url = $request['gbpage']; } } elseif ($request['option'] == 'com_phocaguestbook') { $name = $request['pgusername']; $email = $request['email']; $comment = $request['pgbcontent']; } elseif ($request['option'] == 'com_dfcontact') { $name = $request['name']; $email = $request['email']; $comment = $request['message']; } elseif ($request['option'] == 'com_flexicontact') { $name = $request['from_name']; $email = $request['from_email']; $comment = $request['area_data']; } elseif ($request['option'] == 'com_alfcontact') { $name = $request['name']; $email = $request['email']; $comment = $request['message']; } elseif ($request['option'] == 'com_community') { $name = $request['usernamepass']; $email = $request['emailpass']; } elseif ($request['option'] == 'com_virtuemart') { $name = $request['name']; $email = $request['email']; $comment = $request['comment']; } elseif ($request['option'] == 'com_jshopping') { $name = $request['f_name']; $email = $request['email']; } $feedback = Mollom::checkContent(null, null, $comment, $name, $url, $email); if ($feedback['spam'] == 'spam') { return false; } } $this->_session->clear('ip', 'easycalccheck'); $this->_session->clear('saved_data', 'easycalccheck'); return true; }
/** * If we have Akismet configured, check if this comment should be marked as spam. * Or ham. Or bacon. Or steak! Steak would be good! * @param SiteConfig $siteConfig */ private function checkAkismet(SiteConfig $siteConfig) { try { $akismet = new Akismet(Director::absoluteBaseURL(), $siteConfig->AkismetKey); $akismet->setCommentAuthor($this->Name); $akismet->setCommentContent($this->Comment); $akismet->setCommentAuthorEmail($this->Email); $akismet->setCommentAuthorURL($this->URL); $result = (int) $akismet->isCommentSpam(); if ($result) { $this->AkismetMarked = true; $this->Visible = false; } } catch (Exception $e) { /** * Akismet didn't work, most likely the service is down. * Just to be on the safe side, we hide this comment. */ $this->Visible = false; } }
function cmtx_akismet($name, $email, $website, $comment) { //check Akismet test for spam global $cmtx_path; //globalise variables $name = cmtx_strip_slashes(cmtx_decode($name)); $email = cmtx_strip_slashes(cmtx_decode($email)); $website = cmtx_strip_slashes(cmtx_decode($website)); if ($website == 'http://') { $website = ''; } $comment = cmtx_strip_slashes(cmtx_decode($comment)); if (!class_exists('Akismet')) { require_once $cmtx_path . 'includes/external/akismet/akismet.php'; //load Akismet script } $WordPressAPIKey = cmtx_setting('akismet_key'); //set API key $MyBlogURL = cmtx_setting('site_url'); $akismet = new Akismet($MyBlogURL, $WordPressAPIKey); $akismet->setCommentAuthor($name); $akismet->setCommentAuthorEmail($email); $akismet->setCommentAuthorURL($website); $akismet->setCommentContent($comment); $akismet->setCommentType('comment'); $akismet->setPermalink(cmtx_current_page()); if ($akismet->isCommentSpam()) { return true; } else { return false; } }
/** * Check if comment is spam using Akismet. * * @param Comment $comment The Comment object * @param string $api_key The Akismet API key * * @return void * * @since 2.0 */ public function akismet($comment, $api_key = '') { // load akismet class $this->app->loader->register('Akismet', 'libraries:akismet/akismet.php'); // check comment $akismet = new Akismet(JURI::root(), $api_key); $akismet->setCommentAuthor($comment->author); $akismet->setCommentAuthorEmail($comment->email); $akismet->setCommentAuthorURL($comment->url); $akismet->setCommentContent($comment->content); // set state if ($akismet->isCommentSpam()) { $comment->state = Comment::STATE_SPAM; } }
function akismet_showpage() { global $main_smarty, $the_template, $current_user, $db; force_authentication(); $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('admin'); if ($canIhaveAccess == 1) { $navwhere['text1'] = 'Akismet'; $navwhere['link1'] = URL_akismet; define('pagename', 'akismet'); $main_smarty->assign('pagename', pagename); define('modulename', 'akismet'); $main_smarty->assign('modulename', modulename); if (isset($_REQUEST['view'])) { $view = sanitize($_REQUEST['view'], 3); } else { $view = ''; } if ($view == '') { $wordpress_key = get_misc_data('wordpress_key'); if ($wordpress_key == '') { header('Location: ' . URL_akismet . '&view=manageKey'); die; } $main_smarty->assign('spam_links_count', akismet_get_link_count()); $main_smarty->assign('spam_comments_count', akismet_get_comment_count()); $main_smarty = do_sidebar($main_smarty, $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); $main_smarty->assign('tpl_center', akismet_tpl_path . 'main'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } if ($view == 'updateKey') { if ($_REQUEST['key']) { $wordpress_key = sanitize($_REQUEST['key'], 3); // Verify key before save if (phpnum() >= 5) { include akismet_lib_path . 'Akismet.class_5.php'; $akismet = new Akismet(my_base_url . my_pligg_base, $wordpress_key); if (!$akismet->isKeyValid()) { $main_smarty->assign('error', 1); } else { misc_data_update('wordpress_key', $wordpress_key); } } else { include akismet_lib_path . 'Akismet.class_4.php'; $akismet = new Akismet(my_base_url . my_pligg_base, $wordpress_key); if (!$akismet->_isValidApiKey($wordpress_key)) { $main_smarty->assign('error', 1); } else { misc_data_update('wordpress_key', $wordpress_key); } } } else { $wordpress_key = ''; misc_data_update('wordpress_key', $wordpress_key); } $view = 'manageKey'; } if ($view == 'manageKey') { $wordpress_key = get_misc_data('wordpress_key'); $main_smarty->assign('wordpress_key', $wordpress_key); $main_smarty = do_sidebar($main_smarty, $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageKey'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } if ($view == 'manageSpam') { $sql = "SELECT " . table_links . ".*, " . table_users . ".user_login FROM " . table_links . " \r\n\t\t\t\t\tLEFT JOIN " . table_users . " ON link_author=user_id \r\n\t\t\t\t\tLEFT JOIN " . table_prefix . "spam_links ON linkid=link_id\r\n\t\t\t\t\tWHERE !ISNULL(linkid)"; $link_data = $db->get_results($sql); if (sizeof($link_data)) { $main_smarty->assign('link_data', object_2_array($link_data)); } else { header("Location: " . my_pligg_base . "/admin/admin_index.php"); // header('Location: ' . URL_akismet); die; } $main_smarty = do_sidebar($main_smarty, $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSpam'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } if ($view == 'manageSettings') { $main_smarty = do_sidebar($main_smarty, $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSettings'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } if ($view == 'manageSpamcomments') { $sql = "SELECT * FROM " . table_prefix . "spam_comments "; $link_data = $db->get_results($sql); if (sizeof($link_data)) { $user_cmt = new User(); $user_cmt_link = new Link(); $spam_output .= ' <form name="bulk_moderate" action="' . URL_akismet_isSpamcomment . '&action=bulkmod" method="post">'; $spam_output .= '<table class="table table-bordered table-striped">'; $spam_output .= "<thead>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<th>Author</th>\r\n\t\t\t\t\t\t\t\t\t\t<th>Content</th>\r\n\t\t\t\t\t\t\t\t\t\t<th style='width:65px;text-align:center;'><input type='checkbox' name='all1' onclick='mark_all_spam();' style='display:none;'><a onclick='mark_all_spam();' style='cursor:pointer;text-decoration:none;'>Spam</a></th>\r\n\t\t\t\t\t\t\t\t\t\t<th style='width:80px;text-align:center;'><input type='checkbox' name='all2' onclick='mark_all_notspam();' style='display:none;'><a onclick='mark_all_notspam();' style='cursor:pointer;text-decoration:none;'>Not Spam</a></th>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t<tbody>"; foreach ($link_data as $spam_cmts) { $user_cmt->id = $spam_cmts->userid; $user_cmt->read(); $user_name = $user_cmt->username; $user_cmt_link->id = $spam_cmts->linkid; $user_cmt_link->read(); $spam_output .= "<tr>"; $spam_output .= "\t<td>" . $user_name . "</td>"; $spam_output .= "\t<td><a href='story.php?id=" . ($user_cmt_link->id = $spam_cmts->linkid . "'>" . save_text_to_html($spam_cmts->cmt_content) . "</a></td>"); $spam_output .= ' <td style="text-align:center;"><input type="radio" name="spamcomment[' . $spam_cmts->auto_id . ']" id="spamcomment-' . $spam_cmts->auto_id . '" value="spamcomment"></td>'; $spam_output .= ' <td style="text-align:center;"><input type="radio" name="spamcomment[' . $spam_cmts->auto_id . ']" id="spamcomment-' . $spam_cmts->auto_id . '" value="notspamcomment"></td>'; $spam_output .= "</tr>"; } $spam_output .= "</tbody></table>"; $spam_output .= '<p align="right" style="margin-top:10px;"><input type="submit" name="submit" value="Apply Changes" class="btn btn-default" /></p>'; $spam_output .= "</form>"; $main_smarty->assign('spam_output', $spam_output); $main_smarty->assign('link_data', object_2_array($link_data)); } else { header("Location: " . my_pligg_base . "/admin/admin_index.php"); // header('Location: ' . URL_akismet); die; } $main_smarty = do_sidebar($main_smarty, $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSpamcomments'); $main_smarty->display($template_dir . '/admin/admin.tpl'); } if (phpnum() >= 5) { include_once akismet_lib_path . 'Akismet.class_5.php'; } else { include_once akismet_lib_path . 'Akismet.class_4.php'; } if ($view == 'isSpam') { if ($_GET['action'] == "bulkmod") { if (isset($_POST['submit'])) { $spam = array(); foreach ($_POST["spam"] as $k => $v) { $spam[intval($k)] = $v; } foreach ($spam as $key => $value) { if (isset($key)) { $link_id = sanitize($key, 3); } else { continue; } $link = new Link(); $link->id = $link_id; $link->read(); $user = new User(); $user->id = $link->author; $user->read(); if (phpnum() < 5) { $comment = array('author' => $user->username, 'email' => $user->email, 'website' => $link->url, 'body' => $link->content, 'permalink' => my_base_url . getmyurl('story', $link->id)); $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'), $comment); } else { $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key')); $akismet->setCommentAuthor($user->username); $akismet->setCommentAuthorEmail($user->email); $akismet->setCommentAuthorURL($link->url); $akismet->setCommentContent($link->content); $akismet->setPermalink(my_base_url . getmyurl('story', $link->id)); } if ($value == "spam") { $link->status = 'spam'; $link->store(); killspam($user->id); $akismet->submitSpam(); } elseif ($value == "notspam") { $link->status = 'new'; $link->store(); $akismet->submitHam(); } $db->query("DELETE FROM " . table_prefix . "spam_links WHERE linkid={$link_id}"); } } } header('Location: ' . URL_akismet . '&view=manageSpam'); die; } if ($view == 'isSpamcomment') { if ($_GET['action'] == "bulkmod") { if (isset($_POST['submit'])) { $spamcomment = array(); foreach ($_POST["spamcomment"] as $k => $v) { $spamcomment[intval($k)] = $v; } foreach ($spamcomment as $key => $value) { if (isset($key)) { $link_id = sanitize($key, 3); } else { continue; } $sql_result = "Select * from " . table_prefix . "spam_comments where auto_id=" . $link_id; $result = $db->get_row($sql_result); #print_r($result); $link = new Link(); $link->id = $result->linkid; $link->read(); $user = new User(); $user->id = $result->userid; $user->read(); #print_r($user); if (phpnum() < 5) { $comment = array('author' => $user->username, 'email' => $user->email, 'website' => $link->url, 'body' => $result->cmt_content, 'permalink' => my_base_url . getmyurl('story', $link->id)); $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'), $comment); } else { $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key')); $akismet->setCommentAuthor($user->username); $akismet->setCommentAuthorEmail($user->email); $akismet->setCommentAuthorURL($link->url); $akismet->setCommentContent($result->cmt_content); $akismet->setPermalink(my_base_url . getmyurl('story', $link->id)); } if ($value == "spamcomment") { $akismet->submitSpam(); } elseif ($value == "notspamcomment") { $akismet->submitHam(); $sql = "INSERT INTO " . table_comments . " (comment_parent, comment_user_id, comment_link_id , comment_date, comment_randkey, comment_content) VALUES ('{$result->cmt_parent}', '{$result->userid}', '{$result->linkid}', now(), '{$result->cmt_rand}', '{$result->cmt_content}')"; $db->query($sql); #print $sql; } $link->adjust_comment(1); $link->store(); $db->query(' Delete from ' . table_prefix . 'spam_comments where auto_id=' . $link_id); } } header('Location: ' . URL_akismet . '&view=manageSpamcomments'); die; } } } else { header("Location: " . getmyurl('login', $_SERVER['REQUEST_URI'])); die; } }
function delete_comment() { if (!isset($this->get['c'])) { return $this->message('Delete Comment', 'No comment was specified for editing.'); } $c = intval($this->get['c']); $comment = $this->db->quick_query('SELECT c.*, u.* FROM %pblogcomments c LEFT JOIN %pusers u ON u.user_id=c.comment_user WHERE comment_id=%d', $c); if (!$comment) { return $this->message('Delete Comment', 'No such comment was found for deletion.'); } if (!isset($this->get['confirm'])) { $xtpl = new XTemplate('./skins/' . $this->skin . '/AdminCP/post_comment_edit.xtpl'); $xtpl->assign('token', $this->generate_token()); $xtpl->assign('author', htmlspecialchars($comment['user_name'])); $params = POST_BBCODE | POST_EMOTICONS; $xtpl->assign('text', $this->format($comment['comment_message'], $params)); $xtpl->assign('date', date($this->settings['blog_dateformat'], $comment['comment_date'])); $link = 'admin.php?a=posts&s=del_comment&c=' . $c; $sp = null; if (isset($this->get['t']) && $this->get['t'] == 'spam') { $link .= '&t=spam'; $sp = '<br />This comment will be reported as spam.'; } $xtpl->assign('action_link', $link); $xtpl->assign('sp', $sp); $xtpl->parse('Comment.Delete'); return $xtpl->text('Comment.Delete'); } if (!$this->is_valid_token()) { return $this->error('Invalid or expired security token. Please go back, reload the form, and try again.'); } $out = null; if (isset($this->get['t']) && $this->get['t'] == 'spam') { // Time to report the spammer before we delete the comment. Hopefully this is enough info to strike back with. require_once 'lib/akismet.php'; $akismet = new Akismet($this->settings['site_address'], $this->settings['wordpress_api_key']); $akismet->setCommentAuthor($comment['user_name']); $akismet->setCommentAuthorURL($comment['user_url']); $akismet->setCommentContent($comment['comment_message']); $akismet->setUserIP($comment['comment_ip']); $akismet->setReferrer($comment['comment_referrer']); $akismet->setCommentUserAgent($comment['comment_agent']); $akismet->setCommentType('comment'); $akismet->submitSpam(); $this->settings['spam_count']++; $this->settings['spam_uncaught']++; $this->save_settings(); $out .= 'Comment tagged as spam and reported.<br />'; } $this->db->dbquery('DELETE FROM %pblogcomments WHERE comment_id=%d', $c); if ($comment['comment_type'] == COMMENT_BLOG) { $this->db->dbquery('UPDATE %pblogposts SET post_comment_count=post_comment_count-1 WHERE post_id=%d', $comment['comment_post']); } elseif ($comment['comment_type'] == COMMENT_GALLERY) { $this->db->dbquery('UPDATE %pphotogallery SET photo_comment_count=photo_comment_count-1 WHERE photo_id=%d', $comment['comment_post']); } elseif ($comment['comment_type'] == COMMENT_FILE) { $this->db->dbquery('UPDATE %pfilelist SET file_comment_count=file_comment_count-1 WHERE file_id=%d', $comment['comment_post']); } $out .= 'Comment has been deleted.'; return $this->message('Delete Comment', $out, 'Continue', "admin.php?a=posts&s=edit&p={$comment['comment_post']}"); }
public function postCreateMemeComment($id) { try { $comment = new MemeComment(); $news = MemeInstance::findOrFail($id); if (Input::get('createdAt')) { $comment->created_at = date("Y-m-d H:i:s", strtotime(Input::get('createdAt'))); } else { $comment->created_at = date("Y-m-d H:i:s", strtotime('now')); } $comment->comment_content = Input::get('commentContent'); $akismet = new Akismet('http://www.puskice.org/', '5fa6e0236f7b'); $akismet->setCommentAuthor($comment->username); $akismet->setCommentAuthorEmail($comment->email); $akismet->setCommentAuthorURL(""); $akismet->setCommentContent($comment->comment_content); $akismet->setPermalink('http://www.puskice.org/meme/' . $news->id . '-' . $news->permalink); if ($akismet->isCommentSpam()) { $comment->deleted_at = date('Y-m-d H:i:s', strtotime('now')); } if (Input::get('user_id')) { $comment->published = 1; } else { $comment->published = 0; } if (Input::get('user_id')) { $user = User::find(Input::get('user_id')); $comment->username = $user->username; $comment->email = $user->email; } else { $comment->username = Input::get('username'); $comment->email = Input::get('email'); } if (Input::get('user_id')) { $comment->user_id = Input::get('user_id'); } else { $comment->user_id = 0; } $comment->news_id = $id; $comment->ip_address = Puskice::getIP(); $comment->save(); if ($comment->deleted_at == null) { $user = array('email' => '*****@*****.**', 'name' => 'Info tim'); // the data that will be passed into the mail view blade template $data = array('url' => "http://www.puskice.org//" . Config::get('settings.admin_url') . "/meme-comments/edit/" . $comment->id, 'approve_url' => "http://www.puskice.org//" . Config::get('settings.admin_url') . "/meme-comments/publish/" . $comment->id, 'delete_url' => "http://www.puskice.org//" . Config::get('settings.admin_url') . "/meme-comments/trash/" . $comment->id, 'username' => $comment->username, 'email' => $comment->email, 'title' => $news->title, 'news' => 1, 'news_id' => $news->id, 'content' => $comment->comment_content); // use Mail::send function to send email passing the data and using the $user variable in the closure Mail::send('emails.new_comment', $data, function ($message) use($user) { $message->from('*****@*****.**', "Puškice cenzura"); $message->to('*****@*****.**', 'Info tim Puškice')->subject('Novi meme komentar čeka moderaciju'); }); } return Response::json(array('status' => 'success', 'message' => __("Ваш коментар је успешно прослеђен"))); } catch (Exception $e) { return Response::json(array('status' => 'fail')); } }