if (file_exists(PUN_ROOT . 'lang/' . $pun_config['o_default_lang'] . '/mail_templates/rename.tpl')) { $mail_tpl = trim(file_get_contents(PUN_ROOT . 'lang/' . $pun_config['o_default_lang'] . '/mail_templates/rename.tpl')); } else { $mail_tpl = trim(file_get_contents(PUN_ROOT . 'lang/English/mail_templates/rename.tpl')); } } // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_subject = str_replace('<board_title>', $pun_config['o_board_title'], $mail_subject); $mail_message = str_replace('<base_url>', get_base_url() . '/', $mail_message); $mail_message = str_replace('<old_username>', $old_username, $mail_message); $mail_message = str_replace('<new_username>', $username, $mail_message); $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message); pun_mail($cur_user['email'], $mail_subject, $mail_message); unset($_SESSION['dupe_users'][$id]); } } } if (!empty($_SESSION['dupe_users'])) { $query_str = ''; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $lang_common['lang_identifier']; ?> " lang="<?php echo $lang_common['lang_identifier']; ?>
} // Must the user verify the registration or do we log him/her in right now? if ($pun_config['o_regs_verify'] == '1') { // Load the "welcome" template $mail_tpl = trim(file_get_contents(PUN_ROOT . 'lang/' . $pun_user['language'] . '/mail_templates/welcome.tpl')); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_subject = str_replace('<board_title>', $pun_config['o_board_title'], $mail_subject); $mail_message = str_replace('<base_url>', get_base_url() . '/', $mail_message); $mail_message = str_replace('<username>', $username, $mail_message); $mail_message = str_replace('<password>', $password1, $mail_message); $mail_message = str_replace('<login_url>', get_base_url() . '/login.php', $mail_message); $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message); pun_mail($email1, $mail_subject, $mail_message); message($lang->t('Reg email') . ' <a href="mailto:' . $pun_config['o_admin_email'] . '">' . $pun_config['o_admin_email'] . '</a>.', true); } // Regenerate the users info cache $cache->delete('boardstats'); pun_setcookie($new_uid, $password_hash, time() + $pun_config['o_timeout_visit']); redirect('index.php', $lang->t('Reg complete')); } } $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang->t('Register')); $required_fields = array('req_user' => $lang->t('Username'), 'req_password1' => $lang->t('Password'), 'req_password2' => $lang->t('Confirm pass'), 'req_email1' => $lang->t('Email'), 'req_email2' => $lang->t('Email') . ' 2'); $focus_element = array('register', 'req_user'); define('PUN_ACTIVE_PAGE', 'register'); require PUN_ROOT . 'header.php'; $timezone = isset($timezone) ? $timezone : $pun_config['o_default_timezone']; $dst = isset($dst) ? $dst : $pun_config['o_default_dst'];
$mail_message_full = str_replace('<message>', $message, $mail_message_full); $mail_message_full = str_replace('<post_url>', $pun_config['o_base_url'] . '/viewtopic.php?pid=' . $new_pid . '#p' . $new_pid, $mail_message_full); $mail_message_full = str_replace('<unsubscribe_url>', $pun_config['o_base_url'] . '/misc.php?unsubscribe=' . $tid, $mail_message_full); $mail_message_full = str_replace('<board_mailer>', $pun_config['o_board_title'] . ' ' . $lang_common['Mailer'], $mail_message_full); $notification_emails[$cur_subscriber['language']][0] = $mail_subject; $notification_emails[$cur_subscriber['language']][1] = $mail_message; $notification_emails[$cur_subscriber['language']][2] = $mail_subject_full; $notification_emails[$cur_subscriber['language']][3] = $mail_message_full; $mail_subject = $mail_message = $mail_subject_full = $mail_message_full = null; } // We have to double check here because the templates could be missing if ($notification_emails[$cur_subscriber['language']]) { if (!$cur_subscriber['notify_with_post']) { pun_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][0], $notification_emails[$cur_subscriber['language']][1]); } else { pun_mail($cur_subscriber['email'], $notification_emails[$cur_subscriber['language']][2], $notification_emails[$cur_subscriber['language']][3]); } } } } } } else { if ($fid) { // Create the topic $db->query('INSERT INTO ' . $db->prefix . 'topics (poster, subject, posted, last_post, last_poster, forum_id) VALUES(\'' . $db->escape($username) . '\', \'' . $db->escape($subject) . '\', ' . $_SERVER['REQUEST_TIME'] . ', ' . $_SERVER['REQUEST_TIME'] . ', \'' . $db->escape($username) . '\', ' . $fid . ')') or error('Unable to create topic', __FILE__, __LINE__, $db->error()); $new_tid = $db->insert_id(); // hcs AJAX POLL MOD BEGIN if ($pun_config['poll_enabled'] == 1) { if ($_POST['has_poll'] == 1 && !$pun_user['is_guest']) { include_once PUN_ROOT . 'include/poll/poll.inc.php'; $poll_id = $Poll->create($pun_user['id']);
$mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); // Do the generic replacements first (they apply to all e-mails sent out here) $mail_message = str_replace('<base_url>', $pun_config['o_base_url'] . '/', $mail_message); $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'] . ' ' . $lang_common['Mailer'], $mail_message); // Loop through users we found while ($cur_hit = $db->fetch_assoc($result)) { // Generate a new password and a new password activation code $new_password = random_pass(8); $new_password_key = random_pass(8); $db->query('UPDATE ' . $db->prefix . 'users SET activate_string=\'' . pun_hash($new_password) . '\', activate_key=\'' . $new_password_key . '\' WHERE id=' . $cur_hit['id']) or error('Unable to update activation data', __FILE__, __LINE__, $db->error()); // Do the user specific replacements to the template $cur_mail_message = str_replace('<username>', $cur_hit['username'], $mail_message); $cur_mail_message = str_replace('<activation_url>', $pun_config['o_base_url'] . '/profile.php?id=' . $cur_hit['id'] . '&action=change_pass&key=' . $new_password_key, $cur_mail_message); $cur_mail_message = str_replace('<new_password>', $new_password, $cur_mail_message); pun_mail($email, $mail_subject, $cur_mail_message); } message($lang_login['Forget mail'] . ' <a href="mailto:' . $pun_config['o_admin_email'] . '">' . $pun_config['o_admin_email'] . '</a>.'); } else { message($lang_login['No e-mail match'] . ' ' . $email . '.'); } } $page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / ' . $lang_login['Request pass']; $required_fields = array('req_email' => $lang_common['E-mail']); $focus_element = array('request_pass', 'req_email'); require PUN_ROOT . 'header.php'; ?> <div class="blockform"> <h2><span><?php echo $lang_login['Request pass']; ?>
if (!$db->num_rows($result)) { message($lang_common['Bad request']); } list($subject, $forum_id) = $db->fetch_row($result); // Should we use the internal report handling? if ($pun_config['o_report_method'] == 0 || $pun_config['o_report_method'] == 2) { $db->query('INSERT INTO ' . $db->prefix . 'reports (post_id, topic_id, forum_id, reported_by, created, message) VALUES(' . $post_id . ', ' . $topic_id . ', ' . $forum_id . ', ' . $pun_user['id'] . ', ' . time() . ', \'' . $db->escape($reason) . '\')') or error('Unable to create report', __FILE__, __LINE__, $db->error()); } // Should we e-mail the report? if ($pun_config['o_report_method'] == 1 || $pun_config['o_report_method'] == 2) { // We send it to the complete mailing-list in one swoop if ($pun_config['o_mailing_list'] != '') { $mail_subject = 'Report(' . $forum_id . ') - \'' . $subject . '\''; $mail_message = 'User \'' . $pun_user['username'] . '\' has reported the following message:' . "\n" . $pun_config['o_base_url'] . '/viewtopic.php?pid=' . $post_id . '#p' . $post_id . "\n\n" . 'Reason:' . "\n" . $reason; require PUN_ROOT . 'include/email.php'; pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message); } } redirect('viewtopic.php?pid=' . $post_id . '#p' . $post_id, $lang_misc['Report redirect']); } $page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / ' . $lang_misc['Report post']; $required_fields = array('req_reason' => $lang_misc['Reason']); $focus_element = array('report', 'req_reason'); require PUN_ROOT . 'header.php'; ?> <div class="blockform"> <h2><span><?php echo $lang_misc['Report post']; ?> </span></h2> <div class="box">
} } } $new_email_key = random_pass(8); $db->query('UPDATE ' . $db->prefix . 'users SET activate_string=\'' . $db->escape($new_email) . '\', activate_key=\'' . $new_email_key . '\' WHERE id=' . $id) or error('Unable to update activation data', __FILE__, __LINE__, $db->error()); // Load the "activate email" template $mail_tpl = trim(file_get_contents(PUN_ROOT . 'lang/' . $pun_user['language'] . '/mail_templates/activate_email.tpl')); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<username>', $pun_user['username'], $mail_message); $mail_message = str_replace('<base_url>', get_base_url(), $mail_message); $mail_message = str_replace('<activation_url>', get_base_url() . '/profile.php?action=change_email&id=' . $id . '&key=' . $new_email_key, $mail_message); $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'] . ' ' . $lang_common['Mailer'], $mail_message); pun_mail($new_email, $mail_subject, $mail_message); message($lang_profile['Activate email sent'] . ' <a href="mailto:' . $pun_config['o_admin_email'] . '">' . $pun_config['o_admin_email'] . '</a>.', true); } } $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Profile'], $lang_profile['Change email']); $required_fields = array('req_new_email' => $lang_profile['New email'], 'req_password' => $lang_common['Password']); $focus_element = array('change_email', 'req_new_email'); define('PUN_ACTIVE_PAGE', 'profile'); require PUN_ROOT . 'header.php'; ?> <div class="blockform"> <h2><span><?php echo $lang_profile['Change email']; ?> </span></h2> <div class="box">
$first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<replier>', $username, $mail_message); $protocol = isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ? 'https://' : 'http://'; $mail_message = str_replace('<post_url>', $proto . $_SERVER['SERVER_NAME'] . "/documents/comment/{$doc_param['0']}/{$doc_param['1']}", $mail_message); // TODO get module directly instead of 'documents' $mail_message = str_replace('<unsubscribe_url>', $pun_config['o_base_url'] . '/misc.php?unsubscribe=' . $new_tid, $mail_message); $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'] . ' ' . $lang_common['Mailer'], $mail_message); $notification_emails[$languages[$user]][0] = $mail_subject; $notification_emails[$languages[$user]][1] = $mail_message; $mail_subject = $mail_message = null; } } if (isset($notification_emails[$languages[$user]])) { pun_mail($emails[$user], $notification_emails[$languages[$user]][0], $notification_emails[$languages[$user]][1]); } } } } redirect($doc_param[2] . '#p' . $new_pid, $lang_post['Post redirect']); } else { if ($_POST['submit_forum']) { redirect('viewforum.php?id=' . $forum_id, $lang_post['Post redirect']); } else { redirect('viewtopic.php?pid=' . $new_pid . '#p' . $new_pid, $lang_post['Post redirect']); } } } } // If a topic id was specified in the url (it's a reply).
$mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_subject = str_replace('<board_title>', $pun_config['o_board_title'], $mail_subject); $mail_message = str_replace('<sender>', $pun_user['username'], $mail_message); $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'] . ' ' . $lang_common['Mailer'], $mail_message); } foreach ($destinataires as $dest) { $db->query('INSERT INTO ' . $db->prefix . 'messages (owner, subject, message, sender, sender_id, sender_ip, smileys, showed, status, posted) VALUES(\'' . $dest['id'] . '\', \'' . $db->escape($p_subject) . '\', \'' . $db->escape($p_message) . '\', \'' . $db->escape($pun_user['username']) . '\', \'' . $pun_user['id'] . '\', \'' . get_remote_address() . '\', \'' . $smilies . '\', \'0\', \'0\', \'' . time() . '\' )') or error('Impossible d\'envoyer le message.', __FILE__, __LINE__, $db->error()); $new_mp = $db->insert_id(); // Save an own copy of the message if ($save == 1) { $db->query('INSERT INTO ' . $db->prefix . 'messages (owner, subject, message, sender, sender_id, sender_ip, smileys, showed, status, posted) VALUES(\'' . $pun_user['id'] . '\', \'' . $db->escape($p_subject) . '\', \'' . $db->escape($p_message) . '\', \'' . $db->escape($dest['username']) . '\', \'' . $dest['id'] . '\', \'' . get_remote_address() . '\', \'' . $smilies . '\', \'1\', \'1\', \'' . time() . '\' )') or error('Impossible de sauvegarder le message dans le dossier des messages envoyés', __FILE__, __LINE__, $db->error()); } // E-mail notification if ($pun_config['o_pms_notification'] == '1' && $dest['notify_mp'] == 1) { $mail_message = str_replace('<pm_url>', $pun_config['o_base_url'] . '/pms_list.php?mid=' . $new_mp, $mail_message); pun_mail($dest['email'], $mail_subject, $mail_message); } } if ($from_profile != '') { redirect('profile.php?id=' . $from_profile, $lang_pms['Sent redirect']); } elseif ($tid != '') { redirect('viewtopic.php?id=' . $tid, $lang_pms['Sent redirect']); } else { redirect('pms_list.php', $lang_pms['Sent redirect']); } } } else { // To user(s) if (isset($_GET['uid'])) { $users_id = explode('-', $_GET['uid']); $users_id = array_map('intval', $users_id);
public function insert_user($user) { global $lang_register; // Insert the new user into the database. We do this now to get the last inserted ID for later use $now = time(); $intial_group_id = $this->config['o_regs_verify'] == '0' ? $this->config['o_default_user_group'] : FEATHER_UNVERIFIED; $password_hash = feather_hash($user['password1']); // Add the user $insert_user = array('username' => $user['username'], 'group_id' => $intial_group_id, 'password' => $password_hash, 'email' => $user['email1'], 'email_setting' => $this->config['o_default_email_setting'], 'timezone' => $this->config['o_default_timezone'], 'dst' => 0, 'language' => $user['language'], 'style' => $this->config['o_default_style'], 'registered' => $now, 'registration_ip' => get_remote_address(), 'last_visit' => $now); DB::for_table('users')->create()->set($insert_user)->save(); $new_uid = DB::get_db()->lastInsertId($this->feather->prefix . 'users'); if ($this->config['o_regs_verify'] == '0') { // Regenerate the users info cache if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) { require FEATHER_ROOT . 'include/cache.php'; } generate_users_info_cache(); } // If the mailing list isn't empty, we may need to send out some alerts if ($this->config['o_mailing_list'] != '') { // If we previously found out that the email was banned if (isset($user['banned_email'])) { // Load the "banned email register" template $mail_tpl = trim(file_get_contents(FEATHER_ROOT . 'lang/' . $this->user->language . '/mail_templates/banned_email_register.tpl')); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<username>', $user['username'], $mail_message); $mail_message = str_replace('<email>', $user['email1'], $mail_message); $mail_message = str_replace('<profile_url>', get_link('user/' . $new_uid . '/'), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); pun_mail($this->config['o_mailing_list'], $mail_subject, $mail_message); } // If we previously found out that the email was a dupe if (!empty($dupe_list)) { // Load the "dupe email register" template $mail_tpl = trim(file_get_contents(FEATHER_ROOT . 'lang/' . $this->user->language . '/mail_templates/dupe_email_register.tpl')); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<username>', $user['username'], $mail_message); $mail_message = str_replace('<dupe_list>', implode(', ', $dupe_list), $mail_message); $mail_message = str_replace('<profile_url>', get_link('user/' . $new_uid . '/'), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); pun_mail($this->config['o_mailing_list'], $mail_subject, $mail_message); } // Should we alert people on the admin mailing list that a new user has registered? if ($this->config['o_regs_report'] == '1') { // Load the "new user" template $mail_tpl = trim(file_get_contents(FEATHER_ROOT . 'lang/' . $this->user->language . '/mail_templates/new_user.tpl')); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<username>', $user['username'], $mail_message); $mail_message = str_replace('<base_url>', get_base_url() . '/', $mail_message); $mail_message = str_replace('<profile_url>', get_link('user/' . $new_uid . '/'), $mail_message); $mail_message = str_replace('<admin_url>', get_link('user/' . $new_uid . '/section/admin/'), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); pun_mail($this->config['o_mailing_list'], $mail_subject, $mail_message); } } // Must the user verify the registration or do we log him/her in right now? if ($this->config['o_regs_verify'] == '1') { // Load the "welcome" template $mail_tpl = trim(file_get_contents(FEATHER_ROOT . 'lang/' . $this->user->language . '/mail_templates/welcome.tpl')); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_subject = str_replace('<board_title>', $this->config['o_board_title'], $mail_subject); $mail_message = str_replace('<base_url>', get_base_url() . '/', $mail_message); $mail_message = str_replace('<username>', $user['username'], $mail_message); $mail_message = str_replace('<password>', $user['password1'], $mail_message); $mail_message = str_replace('<login_url>', get_link('login/'), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); pun_mail($user['email1'], $mail_subject, $mail_message); message($lang_register['Reg email'] . ' <a href="mailto:' . feather_escape($this->config['o_admin_email']) . '">' . feather_escape($this->config['o_admin_email']) . '</a>.', true); } feather_setcookie($new_uid, $password_hash, time() + $this->config['o_timeout_visit']); redirect(get_base_url(), $lang_register['Reg complete']); }
} elseif ($_POST['group_id'] == '1') { $sql = "SELECT username, email\r\n\t\t\t\tFROM " . $db->prefix . "users\r\n\t\t\t\tWHERE group_id = '1'" . " ORDER BY username"; } else { // envoi a un groupe en particulier + groupe administrateur $sql = "SELECT username, email\r\n\t\t\t\tFROM " . $db->prefix . "users\r\n\t\t\t\tWHERE group_id = '" . $_POST['group_id'] . "' or group_id = '1'" . " ORDER BY username"; } $result = $db->query($sql) or error($lang_globalemail["nousers"], __FILE__, __LINE__, $db->error()); while ($row = $db->fetch_assoc($result)) { $addresses[$row['username']] = $row['email']; } $usercount = count($addresses); foreach ($addresses as $recipientname => $recipientemail) { $mail_to = $recipientname . " <" . $recipientemail . ">"; $mail_subject = pun_htmlspecialchars($_POST['message_subject']); $mail_message = pun_htmlspecialchars($_POST['message_body']); pun_mail($mail_to, $mail_subject, $mail_message); } ?> <div class="block"> <h2><span><?php echo $lang_globalemail["globalmail"] . " - " . $lang_globalemail["mailsent"]; ?> </span></h2> <div class="box"> <div class="inbox"> <p><?php echo $lang_globalemail["msentto"]; ?> [ <strong><?php echo $usercount; ?>
public function warn_banned_user($post, $new_pid) { // Load the "banned email post" template $mail_tpl = trim(file_get_contents(FEATHER_ROOT . 'lang/' . $this->user->language . '/mail_templates/banned_email_post.tpl')); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<username>', $post['username'], $mail_message); $mail_message = str_replace('<email>', $post['email'], $mail_message); $mail_message = str_replace('<post_url>', get_link('post/' . $new_pid . '/#p' . $new_pid), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); pun_mail($this->config['o_mailing_list'], $mail_subject, $mail_message); }
public function password_forgotten() { global $lang_common, $lang_login; if (!$this->user->is_guest) { header('Location: ' . get_base_url()); exit; } // Start with a clean slate $errors = array(); if ($this->feather->request()->isPost()) { require FEATHER_ROOT . 'include/email.php'; // Validate the email address $email = strtolower(feather_trim($this->request->post('req_email'))); if (!is_valid_email($email)) { $errors[] = $lang_common['Invalid email']; } // Did everything go according to plan? if (empty($errors)) { $select_password_forgotten = array('id', 'username', 'last_email_sent'); $result = DB::for_table('users')->select_many($select_password_forgotten)->where('email', $email)->find_many(); if ($result) { // Load the "activate password" template $mail_tpl = trim(file_get_contents(FEATHER_ROOT . 'lang/' . $this->user->language . '/mail_templates/activate_password.tpl')); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); // Do the generic replacements first (they apply to all emails sent out here) $mail_message = str_replace('<base_url>', get_base_url() . '/', $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); // Loop through users we found foreach ($result as $cur_hit) { if ($cur_hit->last_email_sent != '' && time() - $cur_hit->last_email_sent < 3600 && time() - $cur_hit->last_email_sent >= 0) { message(sprintf($lang_login['Email flood'], intval((3600 - (time() - $cur_hit->last_email_sent)) / 60)), true); } // Generate a new password and a new password activation code $new_password = random_pass(12); $new_password_key = random_pass(8); $update_password = array('activate_string' => feather_hash($new_password), 'activate_key' => $new_password_key, 'last_email_sent' => time()); DB::for_table('users')->where('id', $cur_hit->id)->find_one()->set($update_password)->save(); // Do the user specific replacements to the template $cur_mail_message = str_replace('<username>', $cur_hit->username, $mail_message); $cur_mail_message = str_replace('<activation_url>', get_link('user/' . $cur_hit->id . '/action/change_pass/?key=' . $new_password_key), $cur_mail_message); $cur_mail_message = str_replace('<new_password>', $new_password, $cur_mail_message); pun_mail($email, $mail_subject, $cur_mail_message); } message($lang_login['Forget mail'] . ' <a href="mailto:' . feather_escape($this->config['o_admin_email']) . '">' . feather_escape($this->config['o_admin_email']) . '</a>.', true); } else { $errors[] = $lang_login['No email match'] . ' ' . htmlspecialchars($email) . '.'; } } } return $errors; }
/** * Send an e-mail to the users when we change their usernames */ function alert_dupe_users() { global $pun_config, $session; require PUN_ROOT . 'include/email.php'; foreach ($session['dupe_users'] as $cur_user) { if (empty($cur_user['language'])) { $cur_user['language'] = 'English'; } // Email the user alerting them of the change if (file_exists(PUN_ROOT . 'lang/' . $cur_user['language'] . '/mail_templates/rename.tpl')) { $mail_tpl = trim(file_get_contents(PUN_ROOT . 'lang/' . $cur_user['language'] . '/mail_templates/rename.tpl')); } else { if (file_exists(PUN_ROOT . 'lang/' . $pun_config['o_default_lang'] . '/mail_templates/rename.tpl')) { $mail_tpl = trim(file_get_contents(PUN_ROOT . 'lang/' . $pun_config['o_default_lang'] . '/mail_templates/rename.tpl')); } else { $mail_tpl = trim(file_get_contents(PUN_ROOT . 'lang/English/mail_templates/rename.tpl')); } } // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_subject = str_replace('<board_title>', $pun_config['o_board_title'], $mail_subject); $mail_message = str_replace('<base_url>', get_base_url() . '/', $mail_message); $mail_message = str_replace('<old_username>', $cur_user['old_username'], $mail_message); $mail_message = str_replace('<new_username>', $cur_user['username'], $mail_message); $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'], $mail_message); pun_mail($cur_user['email'], $mail_subject, $mail_message); } }
@set_time_limit(0); require PUN_ROOT . 'include/email.php'; // Tell admin_loader.php that this is indeed a plugin and that it is loaded define('PUN_PLUGIN_LOADED', 1); if (isset($_GET['e_per_page']) && isset($_GET['e_start_at']) && isset($_GET['e_subject']) && isset($_GET['e_message'])) { $subject = urldecode($_GET['e_subject']); $message = urldecode($_GET['e_message']) . "\n\n" . '----------------------------------' . "\n" . 'Don\'t want to receive emails from ' . $pun_config['o_board_title'] . '? They can be disabled in your profile.'; $per_page = intval($_GET['e_per_page']); $start_at = intval($_GET['e_start_at']); $end_at = $start_at + $per_page; $result = $db->query('SELECT u.email, b.id AS b_id FROM ' . $db->prefix . 'users AS u LEFT JOIN ' . $db->prefix . 'bans AS b ON b.username=u.username WHERE u.id>1 AND u.allow_email=1 LIMIT ' . $start_at . ',' . $per_page) or error('Unable to retrieve users emails', __FILE__, __LINE__, $db->error()); while ($user = $db->fetch_assoc($result)) { if (isset($user['b_id'])) { continue; } pun_mail($user['email'], $pun_config['o_board_title'] . ': ' . $subject, $message, $pun_config['o_webmaster_email']); echo 'Mail sent to ' . $user['email'] . '<br />' . "\n"; usleep(250); } // Check if there is more work to do $result = $db->query('SELECT id FROM ' . $db->prefix . 'users WHERE id>' . $end_at) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); $query_str = $db->num_rows($result) ? '&e_per_page=' . $per_page . '&e_start_at=' . $end_at . '&e_subject=' . urlencode($subject) . '&e_message=' . urlencode($message) : ''; $db->end_transaction(); $db->close(); exit('<script type="text/javascript">window.location="admin_loader.php?plugin=' . basename(__FILE__) . $query_str . '"</script><br />JavaScript redirect unsuccessful. Click <a href="admin_loader.php?plugin=' . basename(__FILE__) . $query_str . '">here</a> to continue.'); } // Display the admin navigation menu generate_admin_menu($plugin); ?> <div id="exampleplugin" class="blockform"> <h2><span>Mailer Plugin</span></h2>
public function change_email($id) { global $lang_profile, $lang_common, $lang_prof_reg; // Make sure we are allowed to change this user's email if ($this->user->id != $id) { if (!$this->user->is_admmod) { // A regular user trying to change another user's email? message($lang_common['No permission'], '403'); } elseif ($this->user->g_moderator == '1') { // A moderator trying to change a user's email? $select_change_mail = array('u.group_id', 'g.g_moderator'); $user = DB::for_table('users')->table_alias('u')->select_many($select_change_mail)->inner_join('groups', array('g.g_id', '=', 'u.group_id'), 'g')->where('u.id', $id)->find_one(); if (!$user) { message($lang_common['Bad request'], '404'); } if ($this->user->g_mod_edit_users == '0' || $this->user->g_mod_change_passwords == '0' || $user['group_id'] == FEATHER_ADMIN || $user['g_moderator'] == '1') { message($lang_common['No permission'], '403'); } } } if ($this->request->get('key')) { $key = $this->request->get('key'); $new_email_key = DB::for_table('users')->where('id', $id)->find_one_col('activate_key'); if ($key == '' || $key != $new_email_key) { message($lang_profile['Email key bad'] . ' <a href="mailto:' . feather_escape($this->config['o_admin_email']) . '">' . feather_escape($this->config['o_admin_email']) . '</a>.'); } else { DB::for_table('users')->where('id', $id)->find_one()->set_expr('email', 'activate_string')->set_expr('activate_string', 'NULL')->set_expr('activate_key', 'NULL')->save(); message($lang_profile['Email updated'], true); } } elseif ($this->request->isPost()) { if (feather_hash($this->request->post('req_password')) !== $this->user->password) { message($lang_profile['Wrong pass']); } require FEATHER_ROOT . 'include/email.php'; // Validate the email address $new_email = strtolower(feather_trim($this->request->post('req_new_email'))); if (!is_valid_email($new_email)) { message($lang_common['Invalid email']); } // Check if it's a banned email address if (is_banned_email($new_email)) { if ($this->config['p_allow_banned_email'] == '0') { message($lang_prof_reg['Banned email']); } elseif ($this->config['o_mailing_list'] != '') { // Load the "banned email change" template $mail_tpl = trim(file_get_contents(FEATHER_ROOT . 'lang/' . $this->user->language . '/mail_templates/banned_email_change.tpl')); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<username>', $this->user->username, $mail_message); $mail_message = str_replace('<email>', $new_email, $mail_message); $mail_message = str_replace('<profile_url>', get_link('user/' . $id . '/'), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); pun_mail($this->config['o_mailing_list'], $mail_subject, $mail_message); } } // Check if someone else already has registered with that email address $select_change_mail = array('id', 'username'); $result = DB::for_table('users')->select_many($select_change_mail)->where('email', $new_email)->find_many(); if ($result) { if ($this->config['p_allow_dupe_email'] == '0') { message($lang_prof_reg['Dupe email']); } elseif ($this->config['o_mailing_list'] != '') { foreach ($result as $cur_dupe) { $dupe_list[] = $cur_dupe['username']; } // Load the "dupe email change" template $mail_tpl = trim(file_get_contents(FEATHER_ROOT . 'lang/' . $this->user->language . '/mail_templates/dupe_email_change.tpl')); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<username>', $this->user->username, $mail_message); $mail_message = str_replace('<dupe_list>', implode(', ', $dupe_list), $mail_message); $mail_message = str_replace('<profile_url>', get_link('user/' . $id . '/'), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); pun_mail($this->config['o_mailing_list'], $mail_subject, $mail_message); } } $new_email_key = random_pass(8); // Update the user $update_user = array('activate_string' => $new_email, 'activate_key' => $new_email_key); DB::for_table('users')->where('id', tid)->find_one()->set($update_user)->save(); // Load the "activate email" template $mail_tpl = trim(file_get_contents(FEATHER_ROOT . 'lang/' . $this->user->language . '/mail_templates/activate_email.tpl')); // The first row contains the subject $first_crlf = strpos($mail_tpl, "\n"); $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8)); $mail_message = trim(substr($mail_tpl, $first_crlf)); $mail_message = str_replace('<username>', $this->user->username, $mail_message); $mail_message = str_replace('<base_url>', get_base_url(), $mail_message); $mail_message = str_replace('<activation_url>', get_link('user/' . $id . '/action/change_email/?key=' . $new_email_key), $mail_message); $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message); pun_mail($new_email, $mail_subject, $mail_message); message($lang_profile['Activate email sent'] . ' <a href="mailto:' . feather_escape($this->config['o_admin_email']) . '">' . feather_escape($this->config['o_admin_email']) . '</a>.', true); } }