/** * Adds a new subscription */ public function add_subscription($_post_id = 0, $_email = '', $_status = 'Y') { global $wpdb; # break if email tries illegal stuff lhg_email_filter($_email); // Does the post exist? $target_post = get_post($post_id); if ($post_id > 0 && !is_object($target_post)) { return; } // Filter unwanted statuses if (!in_array($_status, array('Y', 'YC', 'R', 'RC', 'C', '-C')) || empty($_status)) { return; } // No double check if logged in // R.Z. if (is_user_logged_in()) { $_status = 'Y'; } // Using Wordpress local time $dt = date_i18n('Y-m-d H:i:s'); //$dt = date_i18n('Y-m-d'); $clean_email = $this->clean_email($_email); $wpdb->query($wpdb->prepare("\r\n\t\t\tINSERT IGNORE INTO {$wpdb->postmeta} (post_id, meta_key, meta_value)\r\n\t\t\t\tSELECT %d, %s, %s\r\n\t\t\t\tFROM DUAL\r\n\t\t\t\tWHERE NOT EXISTS (\r\n\t\t\t\t\tSELECT post_id\r\n\t\t\t\t\tFROM {$wpdb->postmeta}\r\n\t\t\t\t\tWHERE post_id = %d\r\n\t\t\t\t\t\tAND meta_key = %s\r\n\t\t\t\t\tLIMIT 0,1\r\n\t\t\t\t)", $_post_id, "_stcr@_{$clean_email}", "{$dt}|{$_status}", $_post_id, "_stcr@_{$clean_email}")); }
<?php // Avoid direct access to this piece of code if (!function_exists('add_action')) { header('Location: /'); exit; } ob_start(); if (!empty($email)) { global $wp_subscribe_reloaded; lhg_email_filter($email); # manager link should only be requested seldomly lhg_email_filter_time($email); // Send management link $from_name = stripslashes(get_option('subscribe_reloaded_from_name', 'admin')); $from_email = get_option('subscribe_reloaded_from_email', get_bloginfo('admin_email')); $subject = html_entity_decode(stripslashes(get_option('subscribe_reloaded_management_subject', 'Manage your subscriptions on [blog_name]')), ENT_COMPAT, 'UTF-8'); $message = html_entity_decode(stripslashes(get_option('subscribe_reloaded_management_content', '')), ENT_COMPAT, 'UTF-8'); $manager_link = get_bloginfo('url') . get_option('subscribe_reloaded_manager_page', '/comment-subscriptions'); if (function_exists('qtrans_convertURL')) { $manager_link = qtrans_convertURL($manager_link); } $clean_email = $wp_subscribe_reloaded->clean_email($email); $subscriber_salt = $wp_subscribe_reloaded->generate_key($clean_email); $post_permalink = get_permalink($post_ID); $headers = "MIME-Version: 1.0\n"; $headers .= "From: {$from_name} <{$from_email}>\n"; $content_type = get_option('subscribe_reloaded_enable_html_emails', 'no') == 'yes' ? 'text/html' : 'text/plain'; $headers .= "Content-Type: {$content_type}; charset=" . get_bloginfo('charset'); $manager_link .= strpos($manager_link, '?') !== false ? '&' : '?'; $manager_link .= "sre=" . urlencode($clean_email) . "&srk={$subscriber_salt}";