public function commentValidate($comment) { $result = null; if (!$comment['contact_id'] && ($api_key = $this->getSettingValue('api_key')) && class_exists('Akismet')) { $url = wa()->getRouteUrl('blog', array(), true); $post_url = null; if (isset($comment['post_data'])) { $post_url = blogPost::getUrl($comment['post_data']); if (is_array($post_url)) { $post_url = array_shift($post_url); } } $akismet = new Akismet($url, $api_key); $akismet->setCommentAuthor($comment['name']); $akismet->setCommentAuthorEmail($comment['email']); //$akismet->setCommentAuthorURL($comment['site']); $akismet->setCommentContent($comment['text']); if ($post_url) { $akismet->setPermalink($post_url); } if ($akismet->isCommentSpam()) { $result = array('text' => _wp('According to Akismet.com, your comment very much looks like spam, thus will not be published. Please rewrite your comment. Sorry for the inconvenience.')); } } return $result; }
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); }
function akismet_create_topic($msg_options, $topic_options, $poster_options) { global $modSettings, $scripturl, $smcFunc, $sourcedir; require $sourcedir . '/Akismet.class.php'; // If the subject is 'akismet-test-123', then mark it as spam (this is a test) if ($msg_options['subject'] == 'akismet-test-123') { $spam = true; } else { // If the API key has been set if (isset($modSettings['akismetAPIKey']) && $modSettings['akismetAPIKey'] != "") { // Set up the Akismet class $akismet = new Akismet($scripturl, $modSettings['akismetAPIKey']); $akismet->setAuthor($poster_options['name']); $akismet->setAuthorEmail($poster_options['email']); //$akismet->setCommentAuthorURL(""); -- URL's not used in SMF. $akismet->setContent($msg_options['body']); if (!empty($topic_options['id'])) { $akismet->setPermalink($scripturl . '?topic=' . $topicOptions['id']); } $akismet->setType('smf-post'); // Now, the moment of truth... Send the post to Akismet $akismet_return = $akismet->isSpam(); // Was the server down? if ($akismet_return === 'conn_error') { // Assume it's not spam. We log an error to the error log later $spam = false; // Log it! if (empty($modSettings['akismetNoLog'])) { log_error(sprintf($txt['akismet_cant_connect2'], $_POST['guestname'], $scripturl . '?topic=' . $topic . (isset($_REQUEST['msg']) ? '.msg' . $_REQUEST['msg'] : ''))); } } elseif ($akismet_return === true) { // Oh, the horror! Someone posted spam to your forum! $spam = true; } else { $spam = false; } } else { // No API key, assume it isn't spam $spam = false; } } if ($spam) { // Mark the message as spam and unapprove the post. Post moderation is a big help here. :) $smcFunc['db_query']('', ' UPDATE {db_prefix}topics SET spam = 1, approved = 0, unapproved_posts = 1 WHERE id_topic = {int:id_topic}', array('id_topic' => $topic_options['id'])); $smcFunc['db_query']('', ' UPDATE {db_prefix}messages SET approved = 0 WHERE id_msg = {int:id_msg}', array('id_msg' => $msg_options['id'])); // Increase spam count $smcFunc['db_query']('', ' UPDATE {db_prefix}settings SET value = value + 1 WHERE variable = {string:akismetCaughtSpam}', array('akismetCaughtSpam' => 'akismetCaughtSpam')); } }
/** * 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: 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; }
public function action_comment_insert_before(Comment $comment) { $api_key = Options::get('habariakismet__api_key'); $provider = Options::get('habariakismet__provider'); if ($api_key == null || $provider == null) { return; } $endpoint = $provider == 'Akismet' ? self::SERVER_AKISMET : self::SERVER_TYPEPAD; $a = new Akismet(Site::get_url('habari'), $api_key); $a->setAkismetServer($endpoint); $a->setCommentAuthor($comment->name); $a->setCommentAuthorEmail($comment->email); $a->setCommentAuthorURL($comment->url); $a->setCommentContent($comment->content); $a->setPermalink($comment->post->permalink); try { $comment->status = $a->isCommentSpam() ? 'spam' : 'ham'; return; } catch (Exception $e) { EventLog::log($e->getMessage(), 'notice', 'comment', 'HabariAkismet'); } }
/** * 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; }
/** * 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; }
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 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; } }
public function add_comment() { $aItem = $this->prepareDataForFunction('add_comment'); $authorName = trim($aItem['authorName']); $authorName = strip_tags($authorName); $authorEmail = trim($aItem['authorEmail']); $authorEmail = strip_tags($authorEmail); $body = trim($aItem['body']); $body = strip_tags($body); $title = $aItem['title']; $itemId = $aItem['id']; $userId = $aItem['userId']; $status_num = -1; $item = $this->manager->findByPrimaryKey($itemId); $itemURL = osc_item_url(); Params::setParam('itemURL', $itemURL); if ($authorName == '' || !preg_match('|^.*?@.{2,}\\..{2,3}$|', $authorEmail)) { return 3; } if ($body == '') { return 4; } $num_moderate_comments = osc_moderate_comments(); if ($userId == null) { $num_comments = 0; } else { $num_comments = count(ItemComment::newInstance()->findByAuthorID($userId)); } if ($num_moderate_comments == -1 || $num_moderate_comments != 0 && $num_comments >= $num_moderate_comments) { $status = 'ACTIVE'; $status_num = 2; } else { $status = 'INACTIVE'; $status_num = 1; } if (osc_akismet_key()) { require_once LIB_PATH . 'Akismet.class.php'; $akismet = new Akismet(osc_base_url(), osc_akismet_key()); $akismet->setCommentAuthor($authorName); $akismet->setCommentAuthorEmail($authorEmail); $akismet->setCommentContent($body); $akismet->setPermalink($itemURL); $status = $akismet->isCommentSpam() ? 'SPAM' : $status; if ($status == 'SPAM') { $status_num = 5; } } $mComments = ItemComment::newInstance(); $aComment = array('dt_pub_date' => DB_FUNC_NOW, 'fk_i_item_id' => $itemId, 's_author_name' => $authorName, 's_author_email' => $authorEmail, 's_title' => $title, 's_body' => $body, 'e_status' => $status, 'fk_i_user_id' => $userId); if ($mComments->insert($aComment)) { $notify = osc_notify_new_comment(); $admin_email = osc_contact_email(); $prefLocale = osc_language(); //Notify admin if ($notify) { $mPages = new Page(); $aPage = $mPages->findByInternalName('email_new_comment_admin'); $locale = osc_current_user_locale(); $content = array(); if (isset($aPage['locale'][$locale]['s_title'])) { $content = $aPage['locale'][$locale]; } else { $content = current($aPage['locale']); } $words = array(); $words[] = array('{COMMENT_AUTHOR}', '{COMMENT_EMAIL}', '{COMMENT_TITLE}', '{COMMENT_TEXT}', '{ITEM_TITLE}', '{ITEM_ID}', '{ITEM_URL}'); $words[] = array($authorName, $authorEmail, $title, $body, $item['s_title'], $itemId, $itemURL); $title_email = osc_mailBeauty($content['s_title'], $words); $body_email = osc_mailBeauty($content['s_text'], $words); $from = osc_contact_email(); $from_name = osc_page_title(); if (osc_notify_contact_item()) { $add_bbc = osc_contact_email(); } $emailParams = array('from' => $admin_email, 'from_name' => __('Admin mail system'), 'subject' => $title_email, 'to' => $admin_email, 'to_name' => __('Admin mail system'), 'body' => $body_email, 'alt_body' => $body_email); osc_sendMail($emailParams); } osc_run_hook('add_comment', $item); return $status_num; } return -1; }
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'); } } } }
/** * 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; }
/** * Store a newly created resource in storage. * POST /frontend/publicmeme * * @return Response */ public function store() { $rules = array('first_line' => 'Required', 'second_line' => 'Required', 'meme_id' => 'Required'); $v = Validator::make(Input::all(), $rules); if ($v->passes()) { if (Input::get('antibot') == Session::get('antispam1') + Session::get('antispam2')) { $base = Meme::findOrFail(Input::get('meme_id')); $meme = new MemeInstance(); $meme->meme_id = strip_tags(Input::get("meme_id")); $meme->first_line = strip_tags(Input::get("first_line")); $meme->second_line = strip_tags(Input::get("second_line")); $akismet = new Akismet('http://www.puskice.org/', '5fa6e0236f7b'); if (Session::get("id") != null) { $meme->user_id = strip_tags(Session::get("id")); $user = User::find($meme->user_id); $akismet->setCommentAuthor($user->username); $akismet->setCommentAuthorEmail($user->email); } else { $meme->user_id = -1; $akismet->setCommentAuthor('anonymous'); $akismet->setCommentAuthorEmail('*****@*****.**'); } $meme->permalink = Puskice::url_slug(htmlspecialchars_decode($meme->first_line)); $meme->published = 1; $meme->trashed = 0; $meme->view_count = 0; $meme->thumbs_up = 0; $meme->thumbs_down = 0; $akismet->setCommentAuthorURL(""); $akismet->setCommentContent($meme->first_line . " " . $meme->second_line); $akismet->setPermalink('http://www.puskice.org/meme/' . $meme->id . '-' . $meme->permalink); if ($akismet->isCommentSpam()) { return Redirect::to(Request::root() . "/memes/new")->with('message', __("Систем каже да спамујете"))->with('notif', 'danger')->withInput(); } $meme->save(); Session::forget('antispam1'); Session::forget('antispam2'); return Redirect::to(Request::root() . "/meme/" . $meme->id . "-" . $meme->permalink); } else { return Redirect::to(Request::root() . "/memes/new")->with('message', __("Нисте добро сабрали бројеве"))->with('notif', 'danger')->withInput(); } } else { return Redirect::to(Request::root() . "/memes/new")->withErrors($v)->with('notif', 'danger'); } }
$j = false; } } if ($j) { $db = new SQL(0); $w = array(); $w["txt"] = $_POST["text"]; $w["question"] = $params["id"] + 0; $w["author"] = MyUser::isloggedin() ? MyUser::id() + 0 : 0 - rand(10, 999999); $w["authorIP"] = $_SERVER["REMOTE_ADDR"]; $w["date_created"] = time(); $w["date_edited"] = time(); if (!MyUser::isloggedin() && SiteConfig::val("akismet/key") . "" != "") { $akismet = new Akismet(SiteConfig::val("akismet/host"), SiteConfig::val("akismet/key")); $akismet->setCommentContent($w["txt"]); $akismet->setPermalink(Question::PermalinkByData($w["question"], "Frage")); $akismet->setUserIP($_SERVER["REMOTE_ADDR"]); try { if ($akismet->isCommentSpam()) { $w["isSPAM"] = 2; } else { $w["isSPAM"] = -2; } } catch (Exception $ex) { } } $db->CreateUpdate(0, 'answers', $w); $answerID = $db->LastInsertKey(); $db->cmd(0, 'UPDATE questions SET date_action={1},user_action="{2}", count_answers = (SELECT count(*) FROM answers WHERE question=questions.id) WHERE id={0} LIMIT 1', true, array($w["question"], time(), MyUser::id() + 0)); $_SESSION["myuser"]["lastwritten"]["answers"][$answerID] = true; Karma::RuleAction("CREATE_ANSWER", array("user" => MyUser::id(), "question" => $w["question"], "answer" => $answerID));
function rps_comments_ajax_submit() { $response = array('spam' => 'no', 'comment_sent' => 'no'); global $wpdb; if (is_user_logged_in()) { global $current_user; get_currentuserinfo(); $name = !empty($current_user->display_name) ? $wpdb->escape($current_user->display_name) : $wpdb->escape($current_user->user_login); $email = $wpdb->escape($current_user->user_email); $user_id = (int) $current_user->ID; } else { $name = $wpdb->escape(sanitize_text_field($_POST['form']['name'])); $email = $wpdb->escape(sanitize_email($_POST['form']['email'])); $user_id = 0; } $message = $wpdb->escape(sanitize_text_field($_POST['form']['message'])); $comment_approved = $user_id == 1 ? 1 : 0; $comment_type = 'comment'; $id = (int) $_POST['form']['id']; $time = current_time('mysql'); $url = ''; $user_ip = $_SERVER['REMOTE_ADDR']; $user_agent = $_SERVER['HTTP_USER_AGENT']; $akismet = new Akismet(URL, AKISMET_KEY); $akismet->setCommentAuthor($name); $akismet->setCommentAuthorEmail($email); $akismet->setCommentContent($message); $akismet->setPermalink($id); if ($akismet->isCommentSpam()) { $response['spam'] = 'yes'; } else { $comment_check = check_comment($name, $email, $url, $message, $user_ip, $user_agent, $comment_type); $check = $comment_check ? 1 : 0; $data = array('comment_post_ID' => $id, 'comment_author' => $name, 'comment_author_email' => $email, 'comment_author_url' => $url, 'comment_content' => $message, 'comment_type' => $comment_type, 'comment_parent' => 0, 'user_id' => $user_id, 'comment_author_IP' => $user_ip, 'comment_agent' => $user_agent, 'comment_date' => $time, 'comment_approved' => $check); // Insert comment wp_insert_comment($data); if (!$comment_check) { // Send myself a message $to = get_bloginfo('admin_email'); $subject = __('A new comment is awaiting moderation'); $the_message = 'Get on that Sweeney :)'; $mail_sent = wp_mail($to, $subject, $the_message); } // Create HTML to append new comment to the DOM $avatar = get_avatar($email, 80); $comment = '<li class="comment"><article>'; $comment .= $avatar; $comment .= '<p class="who-wrote">' . $name . ' wrote</p>'; $comment .= '<div class="comment-container">'; $comment .= $comment_check ? '' : '<p><em>Your comment is awaiting moderation.</em></p>'; $comment .= '<p>' . $message . '</p>'; $comment .= '<footer><p class="post-meta">' . date('F jS, Y') . '</p></footer>'; $comment .= '</div></article>'; $response['comment_sent'] = 'yes'; $response['comment'] = $comment; } $response = json_encode($response); header("Content-Type: application/json"); echo $response; die; }
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')); } }
function post_comment($ctype, $subject, $id) { $uid = $this->user['user_id']; $com_time = $this->module->time; $ip = $this->module->ip; $author = ''; $return_data = array(); if (isset($this->module->post['preview'])) { $xtpl = new XTemplate('./skins/' . $this->module->skin . '/comment_preview.xtpl'); $icon = $this->settings['site_address'] . $this->module->icon_dir . 'Anonymous.png'; if ($this->user['user_level'] > USER_GUEST && !empty($this->user['user_icon'])) { $icon = $this->settings['site_address'] . $this->module->icon_dir . $this->user['user_icon']; } $xtpl->assign('icon', $icon); $xtpl->assign('date', date($this->settings['blog_dateformat'], $this->module->time)); $xtpl->assign('subject', $subject); $text = null; $message = null; if (isset($this->module->post['comment_message'])) { $params = POST_BBCODE | POST_EMOTICONS; $text = $this->module->format($this->module->post['comment_message'], $params); $message = htmlspecialchars($this->module->post['comment_message']); } $xtpl->assign('text', $text); $xtpl->assign('message', $message); if ($this->user['user_level'] == USER_GUEST || $this->user['user_level'] == USER_MEMBER) { $xtpl->parse('Comment.SpamControl'); } if ($this->user['user_level'] == USER_GUEST) { $author = isset($this->cookie[$this->settings['cookie_prefix'] . 'comment_author']) ? htmlspecialchars($this->cookie[$this->settings['cookie_prefix'] . 'comment_author']) : 'Anonymous'; $xtpl->assign('author', $author); $xtpl->parse('Comment.GuestName'); } else { $xtpl->assign('author', htmlspecialchars($this->user['user_name'])); } if ($this->settings['friendly_urls']) { switch ($ctype) { case COMMENT_BLOG: $action_link = $this->settings['site_address'] . $this->module->clean_url($subject) . "-{$id}.html#newcomment"; break; case COMMENT_GALLERY: $action_link = $this->settings['site_address'] . 'gallery/' . $this->module->clean_url($subject) . "-{$id}.html#newcomment"; break; case COMMENT_FILE: $action_link = $this->settings['site_address'] . 'downloads/' . $this->module->clean_url($subject) . "-{$id}.html#newcomment"; } } else { switch ($ctype) { case COMMENT_BLOG: $action_link = "{$this->settings['site_address']}index.php?a=blog&p={$id}#newcomment"; break; case COMMENT_GALLERY: $action_link = "{$this->settings['site_address']}index.php?a=gallery&p={$id}#newcomment"; break; case COMMENT_FILE: $action_link = "{$this->settings['site_address']}index.php?a=downloads&p={$id}#newcomment"; break; } } $xtpl->assign('action_link', $action_link); $xtpl->assign('site_root', $this->settings['site_address']); $xtpl->assign('emoticons', $this->module->bbcode->generate_emote_links()); $xtpl->assign('bbcode_menu', $this->module->bbcode->get_bbcode_menu()); $xtpl->parse('Comment'); return $xtpl->text('Comment'); } if ($this->user['user_level'] == USER_GUEST) { if (isset($this->module->post['comment_author']) || !empty($this->module->post['comment_author'])) { $author = $this->module->post['comment_author'] . ' [Anon]'; } } else { $author = $this->user['user_name']; } if (!isset($this->module->post['comment_message']) || empty($this->module->post['comment_message'])) { return $this->module->error('You cannot post an empty comment!'); } $message = $this->module->post['comment_message']; $type = intval($ctype); // I'm not sure if the anti-spam code needs to use the escaped strings or not, so I'll feed them whatever the spammer fed me. require_once 'lib/akismet.php'; $spam_checked = false; $akismet = null; if ($this->user['user_level'] < USER_PRIVILEGED) { try { $akismet = new Akismet($this->settings['site_address'], $this->settings['wordpress_api_key'], $this->module->version); $akismet->setCommentAuthor($author); // $akismet->setCommentAuthorEmail($email); if ($this->user['user_level'] == USER_MEMBER && isset($this->user['user_url'])) { $akismet->setCommentAuthorURL($this->user['user_url']); } elseif (isset($this->module->post['url'])) { $akismet->setCommentAuthorURL($this->module->post['url']); } else { $akismet->setCommentAuthorURL(''); } $akismet->setCommentContent($this->module->post['comment_message']); $akismet->setCommentType('comment'); $link = $this->module->clean_url($subject); $plink = $this->settings['site_address'] . "{$link}-{$id}.html"; $akismet->setPermalink($plink); $spam_checked = true; } catch (Exception $e) { $this->error($e->getMessage()); } } else { $spam_checked = true; } if ($spam_checked && $akismet != null && $akismet->isCommentSpam()) { // Store the contents of the entire $_SERVER array. $svars = json_encode($_SERVER); $this->db->dbquery("\n\t\t\t INSERT INTO %pspam (spam_post, spam_user, spam_author, spam_message, spam_date, spam_type, spam_ip, spam_server)\n\t\t\t VALUES (%d, %d, '%s', '%s', %d, %d, '%s', '%s')", $id, $uid, $author, $message, $com_time, $type, $ip, $svars); $this->settings['spam_count']++; $this->module->save_settings(); $this->purge_old_spam(); return $this->module->message('Akismet Warning', 'Your comment has been flagged as potential spam and must be evaluated by the site owner.'); } if ($this->user['user_level'] == USER_GUEST) { setcookie($this->settings['cookie_prefix'] . 'comment_author', $this->module->post['comment_author'], $this->module->time + 31556926, $this->settings['cookie_path'], $this->settings['cookie_domain'], $this->settings['cookie_secure'], true); } $this->db->dbquery("\n\t\t\tINSERT INTO %pblogcomments (comment_user, comment_author, comment_post, comment_date, comment_ip, comment_message, comment_referrer, comment_agent, comment_type)\n\t\t\t VALUES ( %d, '%s', %d, %d, '{$ip}', '%s', '%s', '%s', %d)", $uid, $author, $id, $com_time, $message, $this->module->referrer, $this->module->agent, $type); $cid = $this->db->insert_id(); switch ($ctype) { case COMMENT_BLOG: $this->db->dbquery('UPDATE %pblogposts SET post_comment_count=post_comment_count+1 WHERE post_id=%d', $id); break; case COMMENT_GALLERY: $this->db->dbquery('UPDATE %pphotogallery SET photo_comment_count=photo_comment_count+1 WHERE photo_id=%d', $id); break; case COMMENT_FILE: $this->db->dbquery('UPDATE %pfilelist SET file_comment_count=file_comment_count+1 WHERE file_id=%d', $id); } if ($this->settings['blog_notifycomments'] && $this->user['user_level'] < USER_ADMIN) { $error = null; if (!$spam_checked) { $error = ' This comment has not been properly screened by Akismet due to a thrown exception.'; } if ($this->settings['friendly_urls']) { switch ($ctype) { case COMMENT_BLOG: $link = $this->settings['site_address'] . $this->module->clean_url($subject) . "-{$id}.html&c={$cid}#comment-{$cid}"; break; case COMMENT_GALLERY: $link = $this->settings['site_address'] . 'gallery/' . $this->module->clean_url($subject) . "-{$id}.html&c={$cid}#comment-{$cid}"; break; case COMMENT_FILE: $link = $this->settings['site_address'] . 'downloads/' . $this->module->clean_url($subject) . "-{$id}.html&c={$cid}#comment-{$cid}"; break; } } else { switch ($ctype) { case COMMENT_BLOG: $link = "{$this->settings['site_address']}index.php?a=blog&p={$id}&c={$cid}#comment-{$cid}"; break; case COMMENT_GALLERY: $link = "{$this->settings['site_address']}index.php?a=gallery&p={$id}&c={$cid}#comment-{$cid}"; break; case COMMENT_FILE: $link = "{$this->settings['site_address']}index.php?a=downloads&p={$id}&c={$cid}#comment-{$cid}"; break; } } $comment_author = htmlspecialchars($author); if ($this->settings['html_email']) { $message_date = date($this->settings['blog_dateformat'], $this->module->time); $params = POST_BBCODE | POST_EMOTICONS; $html_message = $this->module->format($this->module->post['comment_message'], $params); $email_link = "\n<html>\n<body bgcolor=\"#ffffff\">\n{$comment_author} has posted a comment to: \n<a href=\"{$link}\">{$subject}</a><br />\n<br />\n<h4>On {$message_date}, {$comment_author} said:</h4>\n<p>{$html_message}</p><br />\n{$error}\n</body></html>"; $headers = "From: {$this->settings['site_name']} <{$this->settings['email_adm']}>\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $boundary = uniqid("HTMLBLOGCOMMENT"); $headers .= "Content-Type: multipart/alternative" . "; boundary = {$boundary}\r\n\r\n"; $headers .= "This is a MIME encoded message.\r\n\r\n"; $headers .= "--{$boundary}\r\n" . "Content-Type: text/html; charset=UTF-8\r\n"; $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n\r\n"; mail($this->settings['email_adm'], 'Comment posted.', $email_link, $headers); } else { $headers = "From: {$this->settings['site_name']} <{$this->settings['email_adm']}>\r\n" . "X-Mailer: PHP/" . phpversion(); mail($this->settings['email_adm'], 'Comment posted.', "{$comment_author} has posted a comment to: {$subject} {$link}\n\n{$error}", $headers); } } return $cid; // Returns the comment ID so the originating page can header to it immediately. }
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; }
public function is_spam($comment) { $akismet = new Akismet($this->blogURL, $this->wordPressAPIKey); $akismet->setCommentAuthor($comment->authorName); $akismet->setCommentAuthorEmail($comment->email); $akismet->setCommentAuthorURL($comment->url); $akismet->setCommentContent($comment->content); $akismet->setPermalink(''); // print_r($akismet->comment['user_ip']);echo "§<br/>"; if ($akismet->isCommentSpam()) { $comment->spam = Comment::COMMENT_IS_SPAM; } else { $comment->spam = Comment::COMMENT_NOT_SPAM; } //let's take this opportunity ... $comment->authorIP = $akismet->comment['user_ip']; return $comment; }
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 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); } } } }
public function add_comment() { if(!osc_comments_enabled()) { return 7; } $aItem = $this->prepareDataForFunction('add_comment'); $authorName = trim(strip_tags($aItem['authorName'])); $authorEmail = trim(strip_tags($aItem['authorEmail'])); $body = trim(strip_tags($aItem['body'])); $title = trim(strip_tags($aItem['title'])); $itemId = $aItem['id']; $userId = $aItem['userId']; $status_num = -1; $banned = osc_is_banned(trim(strip_tags($aItem['authorEmail']))); if($banned==1 || $banned==2) { Session::newInstance()->_setForm('commentAuthorName', $authorName); Session::newInstance()->_setForm('commentTitle', $title); Session::newInstance()->_setForm('commentBody', $body); Session::newInstance()->_setForm('commentAuthorEmail', $authorEmail); return 5; } $item = $this->manager->findByPrimaryKey($itemId); View::newInstance()->_exportVariableToView('item', $item); $itemURL = osc_item_url(); $itemURL = '<a href="'.$itemURL.'" >'.$itemURL.'</a>'; Params::setParam('itemURL', $itemURL); if(osc_reg_user_post_comments() && !osc_is_web_user_logged_in()) { Session::newInstance()->_setForm('commentAuthorName', $authorName); Session::newInstance()->_setForm('commentTitle', $title); Session::newInstance()->_setForm('commentBody', $body); return 6; } if( !preg_match('|^.*?@.{2,}\..{2,3}$|', $authorEmail)) { Session::newInstance()->_setForm('commentAuthorName', $authorName); Session::newInstance()->_setForm('commentTitle', $title); Session::newInstance()->_setForm('commentBody', $body); return 3; } if( ($body == '') ) { Session::newInstance()->_setForm('commentAuthorName', $authorName); Session::newInstance()->_setForm('commentAuthorEmail', $authorEmail); Session::newInstance()->_setForm('commentTitle', $title); return 4; } $num_moderate_comments = osc_moderate_comments(); if($userId==null) { $num_comments = 0; } else { $user = User::newInstance()->findByPrimaryKey($userId); $num_comments = $user['i_comments']; } if ($num_moderate_comments == -1 || ($num_moderate_comments != 0 && $num_comments >= $num_moderate_comments)) { $status = 'ACTIVE'; $status_num = 2; } else { $status = 'INACTIVE'; $status_num = 1; } if (osc_akismet_key()) { require_once LIB_PATH . 'Akismet.class.php'; $akismet = new Akismet(osc_base_url(), osc_akismet_key()); $akismet->setCommentAuthor($authorName); $akismet->setCommentAuthorEmail($authorEmail); $akismet->setCommentContent($body); $akismet->setPermalink($itemURL); $status = $akismet->isCommentSpam() ? 'SPAM' : $status; if($status == 'SPAM') { $status_num = 5; } } $mComments = ItemComment::newInstance(); $aComment = array('dt_pub_date' => date('Y-m-d H:i:s') ,'fk_i_item_id' => $itemId ,'s_author_name' => $authorName ,'s_author_email' => $authorEmail ,'s_title' => $title ,'s_body' => $body ,'b_active' => ($status=='ACTIVE' ? 1 : 0) ,'b_enabled' => 1 ,'fk_i_user_id' => $userId); osc_run_hook('before_add_comment', $aComment); if( $mComments->insert($aComment) ) { $commentID = $mComments->dao->insertedId(); if($status_num == 2 && $userId != null) { // COMMENT IS ACTIVE $user = User::newInstance()->findByPrimaryKey($userId); if( $user ) { User::newInstance()->update( array( 'i_comments' => $user['i_comments'] + 1) ,array( 'pk_i_id' => $user['pk_i_id'] ) ); } } //Notify admin if ( osc_notify_new_comment() ) { osc_run_hook('hook_email_new_comment_admin', $aItem); } //Notify user if ( osc_notify_new_comment_user() ) { osc_run_hook('hook_email_new_comment_user', $aItem); } osc_run_hook( 'add_comment', $commentID ); return $status_num; } return -1; }
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; } }
public function delete_comments($marks, $deleteallspam = false) { if ($this->manage !== true) return false; if (is_array($marks)) { foreach ($marks as $k => $mark) { if (!is_numeric($mark)) { // id must be a number unset($marks[$k]); continue; } if ($where) $where .= ' OR '; $where .= "id=$mark"; } } elseif ($deleteallspam) $where = 'spam=1'; if (!$where) return; if ($_POST['unspam'] || $_POST['spam']) { $action = 'UPDATE '; $action_result = $_POST['unspam'] ? 'unmarked as spam' : 'marked as spam'; $set = ' SET spam=' . (int)(bool)$_POST['spam'] . ' '; if ($_POST['spam'] && $GLOBALS['mark_as_spam_and_delete']) { $action = 'DELETE FROM '; $action_result = 'marked for Akismet as spam and then deleted'; $set = ''; } if (!empty($this->akismet_file) && !empty($this->wpAPIkey) && @include_once($this->akismet_file)) { // submit false positive or missed spam to Akismet $res = mysqli_query($this->link, "SELECT * FROM commentator_comments WHERE $where AND page=\"{$this->page}\""); $error = mysqli_error($this->link); if (!$res) { if ($_POST['unspam']) $not = ' not'; $error = $error ? "Mysql error: $error" : "Selection is already$not spam"; $this->alert("No comments affected. $error"); return; } while ($row = mysqli_fetch_array($res, MYSQL_ASSOC)) { $akismet = new Akismet($this->domain, $this->wpAPIkey); $akismet->setCommentAuthor($row['name']); $akismet->setCommentAuthorEmail($row['email']); $akismet->setCommentAuthorURL($row['website']); $akismet->setCommentContent($row['comment']); $akismet->setPermalink('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); if ($_POST['unspam']) $akismet->submitHam(); else $akismet->submitSpam(); } } } else { $action = 'DELETE FROM '; $action_result = 'deleted'; } $res = mysqli_query($this->link, $action . "commentator_comments {$set}WHERE $where AND page=\"{$this->page}\""); $affected = mysqli_affected_rows($this->link); if ($affected !== 1) $s = 's'; $this->alert($affected . " comment$s $action_result"); }
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"); } } }