function __wps__notification_do_jobs($mode) { global $wpdb; $summary_email = __("Website Title", WPS_TEXT_DOMAIN).": ".get_bloginfo('name')."<br />"; $summary_email .= __("Website URL", WPS_TEXT_DOMAIN).": ".get_bloginfo('wpurl')."<br />"; $summary_email .= __("Admin Email", WPS_TEXT_DOMAIN).": ".get_bloginfo('admin_email')."<br />"; $summary_email .= __("WordPress version", WPS_TEXT_DOMAIN).": ".get_bloginfo('version')."<br />"; $summary_email .= sprintf(__("%s version", WPS_TEXT_DOMAIN), WPS_WL).": ".WPS_VER."<br />"; $summary_email .= __("Daily Digest mode", WPS_TEXT_DOMAIN).": ".$mode."<br /><br />"; $topics_count = 0; $user_count = 0; $success = "INCOMPLETE. "; $users_sent_to_success = ''; $users_sent_to_failed = ''; // ******************************************* Daily Digest ****************************************** $send_summary = get_option(WPS_OPTIONS_PREFIX.'_send_summary'); if ($send_summary == "on" || $mode == 'cron' || $mode == 'symposium_dailydigest_admin' || $mode == 'send_admin_summary_and_to_users') { // Calculate yesterday $startTime = mktime(0, 0, 0, date('m'), date('d')-1, date('Y')); $endTime = mktime(23, 59, 59, date('m'), date('d')-1, date('Y')); // Get all new topics from previous period $topics_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM ".$wpdb->prefix.'symposium_topics'." WHERE topic_parent = %d AND UNIX_TIMESTAMP(topic_date) >= ".$startTime." AND UNIX_TIMESTAMP(topic_date) <= ".$endTime, 0)); if ($topics_count > 0 || $mode == 'symposium_dailydigest_admin') { // Get Forum URL $forum_url = __wps__get_url('forum'); // Decide on query suffix on whether a permalink or not if (strpos($forum_url, '?') !== FALSE) { $q = "&"; } else { $q = "?"; } $body = ""; $categories = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix.'symposium_cats'." ORDER BY listorder"); if ($categories) { foreach ($categories as $category) { $shown_category = false; $topics = $wpdb->get_results(" SELECT tid, topic_subject, topic_parent, topic_post, topic_date, display_name, topic_category FROM ".$wpdb->prefix.'symposium_topics'." INNER JOIN ".$wpdb->base_prefix.'users'." ON ".$wpdb->prefix.'symposium_topics'.".topic_owner = ".$wpdb->base_prefix.'users'.".ID WHERE topic_parent = 0 AND topic_category = ".$category->cid." AND UNIX_TIMESTAMP(topic_date) >= ".$startTime." AND UNIX_TIMESTAMP(topic_date) <= ".$endTime." ORDER BY tid"); if ($topics) { if (!$shown_category) { $shown_category = true; $body .= "<h1>".stripslashes($category->title)."</h1>"; } $body .= "<h2>".__('New Topics', WPS_TEXT_DOMAIN)."</h2>"; $body .= "<ol>"; foreach ($topics as $topic) { $body .= "<li><strong><a href='".$forum_url.$q."cid=".$category->cid."&show=".$topic->tid."'>".stripslashes($topic->topic_subject)."</a></strong>"; $body .= " started by ".$topic->display_name.":<br />"; $body .= stripslashes($topic->topic_post); $body .= "</li>"; } $body .= "</ol>"; } $replies = $wpdb->get_results(" SELECT tid, topic_subject, topic_parent, topic_post, topic_date, display_name, topic_category FROM ".$wpdb->prefix.'symposium_topics'." INNER JOIN ".$wpdb->base_prefix.'users'." ON ".$wpdb->prefix.'symposium_topics'.".topic_owner = ".$wpdb->base_prefix.'users'.".ID WHERE topic_parent > 0 AND topic_category = ".$category->cid." AND UNIX_TIMESTAMP(topic_date) >= ".$startTime." AND UNIX_TIMESTAMP(topic_date) <= ".$endTime." ORDER BY topic_parent, tid"); if ($replies) { if (!$shown_category) { $shown_category = true; $body .= "<h1>".$category->title."</h1>"; } $body .= "<h2>".__('Replies in', WPS_TEXT_DOMAIN)." ".$category->title."</h2>"; $current_parent = ''; foreach ($replies as $reply) { $parent = $wpdb->get_var($wpdb->prepare("SELECT topic_subject FROM ".$wpdb->prefix.'symposium_topics'." WHERE tid = %d", $reply->topic_parent)); if ($parent != $current_parent) { $body .= "<h3>".$parent."</h3>"; $current_parent = $parent; } $body .= "<em>".$reply->display_name." wrote:</em> "; $post = __wps__clean_html(stripslashes($reply->topic_post)); if (strlen($post) > 100) { $post = substr($post, 0, 100)."..."; } if (strpos($reply->topic_post, '<iframe src=\"http://www.youtube.com') !== FALSE) $post .= " (".__('video', WPS_TEXT_DOMAIN).")"; $body .= $post; $body .= " <a href='".$forum_url.$q."cid=".$category->cid."&show=".$topic->tid."'>".__('View topic', WPS_TEXT_DOMAIN)."...</a>"; $body .= "<br />"; $body .= "<br />"; } } } } $body .= "<p>".__("You can stop receiving these emails at", WPS_TEXT_DOMAIN)." <a href='".$forum_url."'>".$forum_url."</a>.</p>"; // Send the mail if (($mode == 'cron' && get_option(WPS_OPTIONS_PREFIX.'_send_summary') == "on") || $mode == 'send_admin_summary_and_to_users') { // send to all users $users = $wpdb->get_results("SELECT DISTINCT user_email FROM ".$wpdb->base_prefix.'users'." u INNER JOIN ".$wpdb->base_prefix."usermeta m ON u.ID = m.user_id WHERE meta_key = 'symposium_forum_digest' and m.meta_value = 'on'"); if ($users) { foreach ($users as $user) { $user_count++; $email = $user->user_email; if(__wps__sendmail($email, __('Daily Forum Digest', WPS_TEXT_DOMAIN), $body)) { $users_sent_to_success .= $user->user_email.'<br />'; update_option(WPS_OPTIONS_PREFIX."_notification_triggercount",get_option(WPS_OPTIONS_PREFIX."_notification_triggercount")+1); } else { $users_sent_to_failed .= $user->user_email.'<br />'; } } } else { $users_sent_to_success = __('No users have selected to receive the digest.', WPS_TEXT_DOMAIN).'<br />'; } } if ($mode == 'symposium_dailydigest_admin') { // send to admin only if(__wps__sendmail(get_bloginfo('admin_email'), __('Daily Forum Digest (admin only)', WPS_TEXT_DOMAIN), $body)) { $users_sent_to_success .= get_bloginfo('admin_email').'<br />'; } else { $users_sent_to_failed .= get_bloginfo('admin_email').'<br />'; } } } } // Send admin summary $summary_email .= __("Forum topic count for previous day (midnight to midnight)", WPS_TEXT_DOMAIN).": ".$topics_count."<br />"; $summary_email .= __("Daily Digest sent count", WPS_TEXT_DOMAIN).": ".$user_count."<br /><br />"; $summary_email .= "<b>".__("List of recipients sent to:", WPS_TEXT_DOMAIN)."</b><br />"; if ($users_sent_to_success != '') { $summary_email .= $users_sent_to_success; } else { $summary_email .= 'None.'; } $summary_email .= "<br /><br /><b>List of sent failures:</b><br />"; if ($users_sent_to_failed != '') { $summary_email .= $users_sent_to_failed; } else { $summary_email .= 'None.'; } $email = get_bloginfo('admin_email'); if (__wps__sendmail($email, __('Daily Digest Summary Report', WPS_TEXT_DOMAIN), $summary_email)) { $success = "OK<br />(summary sent to ".get_bloginfo('admin_email').")<br />"; } else { $success = "FAILED sending to ".get_bloginfo('admin_email').". "; } return $success; }
$event_live = $_POST['event_live']; $enable_places = $_POST['enable_places']; $max_places = $_POST['max_places']; $show_max = $_POST['show_max']; $confirmation = $_POST['confirmation']; $tickets_per_booking = $_POST['tickets_per_booking']; $send_email = $_POST['send_email']; $email = $_POST['email']; $pay_link = $_POST['pay_link']; $cost = $_POST['cost']; $more = $_POST['more']; $desc = strip_tags($desc); $more = __wps__clean_html($more); $email = __wps__clean_html($email); $allowedtags = array( 'a' => array('href' => array(), 'title' => array(), 'target' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'blockquote' => array(), 'caption' => array(), 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), 'div' => array(), 'p' => array('style' => array()), 'ul' => array(), 'ol' => array(), 'li' => array(),