function wp_new_user_notification($user_id, $plaintext_pass = '') { //pyboxlog('called wp_n_u_n', 1); $user = new WP_User($user_id); $body = __t('An account has been created for you on the Computer Science Circles website, with a randomly generated password. User name: %username% Current random password: %password% Please visit %loginurl% and change your password to something you will remember. Press "%upprof%" once you are done. Thanks from the Computer Science Circles team! %siteurl%'); //pyboxlog('locale:' . pll_current_language('locale'), 1); if (class_exists('PLL_Base')) { update_user_meta($user_id, 'user_lang', pll_current_language('locale')); } $subject = __t('Computer Science Circles: New account'); $user_login = stripslashes($user->user_login); $user_email = stripslashes($user->user_email); $find = array('/%username%/i', '/%password%/i', '/%blogname%/i', '/%siteurl%/i', '/%loginurl%/i', '/%useremail%/i', '/%upprof%/i'); $replace = array($user_login, $plaintext_pass, get_option('blogname'), get_option('siteurl'), get_option('siteurl') . '/wp-login.php', $user_email, __t('Update Profile')); $body = preg_replace($find, $replace, $body); $body = preg_replace("/%.*%/", "", $body); pb_mail('"' . get_option('blogname') . '" <' . CSCIRCLES_BOUNCE_EMAIL . '>', '<' . $user_email . '>', $subject, $body); }
function send($problem_info, $from, $to, $student, $slug, $body, $noreply) { global $wpdb, $current_user, $lang; $unanswered = getUserID() == $student ? 1 : 0; if (getUserID() != $student) { $wpdb->update($wpdb->prefix . 'pb_mail', array('unanswered' => 0), array('unanswered' => 1, 'ustudent' => $student, 'problem' => $slug)); } if ($noreply != 'false') { // don't redirect return "#"; } $insert_to = $to; if ($to == 0 && $lang != 'en') { $insert_to = getSoft(unserialize(CSCIRCLES_ASST_ID_MAP), $lang, $insert_to); } $wpdb->insert($wpdb->prefix . 'pb_mail', array('ufrom' => $from, 'uto' => $insert_to, 'ustudent' => $student, 'problem' => $slug, 'body' => $body, 'unanswered' => $unanswered), array('%d', '%d', '%d', '%s', '%s', '%d')); $mailref = $wpdb->insert_id; if (userIsAdmin() || userIsAssistant()) { $mFrom = '"' . __t("CS Circles Assistant") . '" <' . CSCIRCLES_BOUNCE_EMAIL . '>'; } else { $mFrom = '"' . $current_user->user_login . '" <' . $current_user->user_email . '>'; } $subject = __t('CS Circles') . ' - ' . __t('message about') . ' ' . $problem_info['publicname']; $contents = $body . "\n===\n"; $contents .= __t("To send a reply message, please visit") . "\n"; $contents .= cscurl('mail') . "?who={$student}&what={$slug}&which={$mailref}#m\n"; $contents .= __t("Problem URL:") . " " . $problem_info['url'] . "\n"; $contents .= "[" . __t("Sent by CS Circles") . " " . cscurl("homepage") . "]"; if ($to == 0) { // same fallback as admin-options.php $to_emailaddr = get_option('cscircles_asst_email', get_userdata(1)->user_email); $tmp = getSoft(unserialize(CSCIRCLES_ASST_ID_MAP), $lang, -1); if ($lang != 'en' && $tmp != -1) { $to_emailaddr = get_user_by('id', $tmp)->user_email; } } else { $to_emailaddr = get_user_by('id', $to)->user_email; } //pyboxlog($mFrom . " " . $to_emailaddr . " " . $subject . " " . $contents); pb_mail($mFrom, $to_emailaddr, $subject, $contents); if (get_the_author_meta('pbnocc', getUserID()) != 'true') { $to_desc = $to == 0 ? "the CS Circles Assistant" : get_user_by('id', $to)->user_login; pb_mail($mFrom, $current_user->user_email, __t("SENT:") . " " . $subject, sprintf(__t("THIS IS A COPY of a message you sent to %s."), $to_desc) . "\n\n" . $contents); } return $mailref; }
function resendEmails() { global $wpdb; $return; foreach ($wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "pb_mail WHERE ID >= 3818 and ID <= 3835 and uto != 0", ARRAY_A) as $r) { $problem = $r['problem']; $pname = $wpdb->get_var("SELECT publicname FROM " . $wpdb->prefix . "pb_problems WHERE slug like '{$problem}'"); $purl = $wpdb->get_var("SELECT url FROM " . $wpdb->prefix . "pb_problems WHERE slug like '{$problem}'"); $subject = "CS Circles - Message about {$pname}"; $to = get_user_by('id', $r['uto'])->user_email; if ($r['ufrom'] == 0) { $mFrom = '"' . __t("CS Circles Assistant") . '" <' . CSCIRCLES_BOUNCE_EMAIL . '>'; } else { $user = get_user_by('id', $r['ufrom']); $mFrom = '"' . $user->user_login . '" <' . $user->user_email . '>'; } $student = $r['ustudent']; $slug = $problem; $mailref = $r['ID']; $contents = "[Please accept our apologies for the delay in this message, which was caused by a mail daemon problem.]\n\n"; $contents .= $r['body'] . "\n===\n"; $contents .= __t("To send a reply message, please visit") . "\n"; $contents .= cscurl('mail') . "?who={$student}&what={$slug}&which={$mailref}#m"; $contents .= __t("Problem URL:") . " " . $purl . "\n"; $contents .= "[" . __t("Sent by CS Circles") . " " . cscurl("homepage") . "]"; // $contents .= "\n\n" . $to; pyboxlog("Trying to resend message {$mailref}:{$mFrom}|{$to}|{$subject}|{$contents}", TRUE); pb_mail($mFrom, $to, $subject, $contents); pyboxlog("Resent message {$mailref}", TRUE); } }