} else { if (!cmtx_setting('approve_notifications')) { cmtx_notify_subscribers($cmtx_name, $cmtx_comment, $cmtx_page_id, $cmtx_comment_id, $cmtx_reply_to, $cmtx_is_admin); } } } cmtx_notify_admin_new_comment_okay($cmtx_name, $cmtx_comment, $cmtx_comment_id); //notify admin of new comment if (isset($_POST['cmtx_remember']) || !cmtx_setting('enabled_remember') && cmtx_setting('form_cookie')) { cmtx_set_form_cookie($cmtx_name, $cmtx_email, $cmtx_website, $cmtx_town, $cmtx_country); //save form inputs $cmtx_default_name = cmtx_strip_slashes(cmtx_decode($cmtx_name)); $cmtx_default_email = cmtx_strip_slashes(cmtx_decode($cmtx_email)); $cmtx_default_website = cmtx_strip_slashes(cmtx_decode($cmtx_website)); $cmtx_default_town = cmtx_strip_slashes(cmtx_decode($cmtx_town)); $cmtx_default_country = cmtx_strip_slashes(cmtx_decode($cmtx_country)); } if (cmtx_session_set()) { //if there's a session $_SESSION['cmtx_resubmit_key'] = $_POST['cmtx_resubmit_key']; //add resubmit key to session } $cmtx_reply_id = 0; //reset the reply id if (cmtx_session_set()) { //if there's a session $_SESSION['cmtx_question'] = ''; //reset session $_SESSION['cmtx_captcha'] = ''; //reset session }
</td> <?php $page_id = $comment["page_id"]; $page_reference_query = cmtx_db_query("SELECT `reference` FROM `" . $cmtx_mysql_table_prefix . "pages` WHERE `id` = '{$page_id}'"); $page_reference_result = cmtx_db_fetch_assoc($page_reference_query); ?> <td><?php echo $page_reference_result["reference"]; ?> </td> <?php $comment1 = $comment["comment"]; $comment1 = str_ireplace("<br />", " ", $comment1); $comment1 = str_ireplace("<p></p>", " ", $comment1); $comment1 = strip_tags($comment1); $comment1 = cmtx_decode($comment1); $comment1 = substr($comment1, 0, 75); $comment1 = htmlspecialchars($comment1, ENT_NOQUOTES, 'UTF-8'); ?> <td><?php echo $comment1; ?> </td> <td><?php if ($comment["is_approved"]) { echo CMTX_TABLE_YES; } else { echo CMTX_TABLE_NO; } ?> </td>
function cmtx_prepare_comment_for_email($comment, $slashes = true) { //prepares comment for email if ($slashes) { $comment = cmtx_strip_slashes($comment); } $comment = str_ireplace("<br />", "\r\n", $comment); $comment = str_ireplace("<br/>", "\r\n", $comment); $comment = str_ireplace("<br>", "\r\n", $comment); $comment = str_ireplace("<p></p>", "\r\n\r\n", $comment); $comment = str_ireplace("<p />", "\r\n\r\n", $comment); $comment = str_ireplace("<p/>", "\r\n\r\n", $comment); $comment = str_ireplace("<li>", "- ", $comment); $comment = str_ireplace("</li>", "\r\n", $comment); $comment = str_ireplace("\r\n</ul>", "", $comment); $comment = str_ireplace("\r\n</ol>", "", $comment); $comment = strip_tags($comment); $comment = cmtx_decode($comment); $comment = preg_replace("/(\r\n){3,}/", "\r\n\r\n", $comment); $comment = trim($comment); return $comment; }
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; } }
} else { $admin_new_comment_flag_email_file = $cmtx_path . 'includes/emails/' . cmtx_setting('language_frontend') . '/admin/new_flag.txt'; //build path to admin new flag email file } $body = file_get_contents($admin_new_comment_flag_email_file); //get the file's contents $comment_query = cmtx_db_query("SELECT * FROM `" . $cmtx_mysql_table_prefix . "comments` WHERE `id` = '{$id}'"); $comment_result = cmtx_db_fetch_assoc($comment_query); $page_id = $comment_result['page_id']; $page_query = cmtx_db_query("SELECT * FROM `" . $cmtx_mysql_table_prefix . "pages` WHERE `id` = '{$page_id}'"); $page_result = cmtx_db_fetch_assoc($page_query); $page_reference = cmtx_decode($page_result['reference']); $page_url = cmtx_decode($page_result['url']); $comment_url = cmtx_decode(cmtx_get_permalink($id, $page_result['url'])); //get the permalink of the comment $poster = cmtx_decode($comment_result['name']); $comment = cmtx_prepare_comment_for_email($comment_result['comment'], false); $admin_link = cmtx_url_encode_spaces(cmtx_setting('commentics_url') . cmtx_setting('admin_folder')) . '/'; //build admin panel link //convert email variables with actual variables $body = str_ireplace('[page reference]', $page_reference, $body); $body = str_ireplace('[page url]', $page_url, $body); $body = str_ireplace('[comment url]', $comment_url, $body); $body = str_ireplace('[poster]', $poster, $body); $body = str_ireplace('[comment]', $comment, $body); $body = str_ireplace('[admin link]', $admin_link, $body); $body = str_ireplace('[signature]', cmtx_setting('signature'), $body); //select administrators from database $admins = cmtx_db_query("SELECT `email` FROM `" . $cmtx_mysql_table_prefix . "admins` WHERE `receive_email_new_flag` = '1' AND `is_enabled` = '1'"); while ($admin = cmtx_db_fetch_assoc($admins)) { //while there are administrators
function cmtx_prepare_comment_for_email($comment) { //prepares comment for email $comment = str_ireplace("<br />", "\r\n", $comment); $comment = str_ireplace("<br/>", "\r\n", $comment); $comment = str_ireplace("<br>", "\r\n", $comment); $comment = str_ireplace("<p></p>", "\r\n\r\n", $comment); $comment = str_ireplace("<p />", "\r\n\r\n", $comment); $comment = str_ireplace("<p/>", "\r\n\r\n", $comment); $comment = str_ireplace("<li>", "- ", $comment); $comment = str_ireplace("</li>", "\r\n", $comment); $comment = str_ireplace("\r\n</ul>", "", $comment); $comment = str_ireplace("\r\n</ol>", "", $comment); $comment = strip_tags($comment); $comment = cmtx_decode($comment); $comment = preg_replace('/(\\r\\n){3,}/', "\r\n\r\n", $comment); $comment = trim($comment); return $comment; }