/** * Mantis Core API's */ require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'core.php'; access_ensure_global_level(config_get_global('admin_site_threshold')); html_page_top(); $f_to = gpc_get('send', null); if ($f_to !== null) { if ($f_to == 'all') { echo "Sending emails...<br />"; email_send_all(); echo "Done"; } else { if ($f_to == 'sendordelall') { echo "Sending or deleting emails...<br />"; email_send_all(true); echo "Done"; } else { $t_email_data = email_queue_get((int) $f_to); // check if email was found. This can fail if another request picks up the email first and sends it. echo 'Sending email...<br />'; if ($t_email_data !== false) { if (!email_send($t_email_data)) { echo 'Email Not Sent - Deleting from queue<br />'; email_queue_delete($t_email_data->email_id); } else { echo 'Email Sent<br />'; } } else { echo 'Email not found in queue<br />'; }
#!/usr/bin/php -q <?php # MantisBT - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org # Copyright (C) 2002 - 2014 MantisBT Team - mantisbt-dev@lists.sourceforge.net # MantisBT is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # MantisBT is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with MantisBT. If not, see <http://www.gnu.org/licenses/>. # See the README and LICENSE files for details global $g_bypass_headers; $g_bypass_headers = 1; require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'core.php'; require_once 'email_api.php'; # Make sure this script doesn't run via the webserver if (php_sapi_name() != 'cli') { echo "send_emails.php is not allowed to run through the webserver.\n"; exit(1); } echo "Sending emails...\n"; email_send_all(); echo "Done.\n"; exit(0);
/** * Print logging api output to bottom of html page * @return void */ function log_print_to_page() { if (config_get_global('log_destination') === 'page' && auth_is_user_authenticated() && access_has_global_level(config_get('show_log_threshold'))) { global $g_log_events, $g_log_levels, $g_email_shutdown_processing; if ($g_email_shutdown_processing) { email_send_all(); } $t_unique_queries_count = 0; $t_total_query_execution_time = 0; $t_unique_queries = array(); $t_total_queries_count = 0; $t_total_event_count = count($g_log_events); echo "\t<hr />\n"; echo "\n\n<!--Mantis Debug Log Output-->"; if ($t_total_event_count == 0) { echo "<!--END Mantis Debug Log Output-->\n\n"; return; } echo "<hr />\n"; echo "<table id=\"log-event-list\">\n"; echo "\t<thead>\n"; echo "\t\t<tr>\n"; echo "\t\t\t<th>" . lang_get('log_page_number') . "</th>\n"; echo "\t\t\t<th>" . lang_get('log_page_time') . "</th>\n"; echo "\t\t\t<th>" . lang_get('log_page_caller') . "</th>\n"; echo "\t\t\t<th>" . lang_get('log_page_event') . "</th>\n"; echo "\t\t</tr>\n"; echo "\t</thead>\n"; echo "\t<tbody>\n"; for ($i = 0; $i < $t_total_event_count; $i++) { if ($g_log_events[$i][1] == LOG_DATABASE) { if (!in_array($g_log_events[$i][2][0], $t_unique_queries)) { $t_unique_queries_count++; $g_log_events[$i][2][2] = false; array_push($t_unique_queries, $g_log_events[$i][2][0]); } else { $g_log_events[$i][2][2] = true; } $t_total_query_execution_time += $g_log_events[$i][2][1]; } } $t_count = array(); foreach ($g_log_events as $t_log_event) { $t_level = $g_log_levels[$t_log_event[1]]; if (isset($t_count[$t_log_event[1]])) { $t_count[$t_log_event[1]]++; } else { $t_count[$t_log_event[1]] = 1; } switch ($t_log_event[1]) { case LOG_DATABASE: $t_total_queries_count++; $t_query_duplicate_class = ''; if ($t_log_event[2][2]) { $t_query_duplicate_class = ' class="duplicate-query"'; } echo "\t\t<tr " . $t_query_duplicate_class . '><td>' . $t_level . '-' . $t_count[$t_log_event[1]] . '</td><td>' . $t_log_event[2][1] . '</td><td>' . string_html_specialchars($t_log_event[3]) . '</td><td>' . string_html_specialchars($t_log_event[2][0]) . "</td></tr>\n"; break; default: echo "\t\t<tr><td>" . $t_level . '-' . $t_count[$t_log_event[1]] . '</td><td>' . $t_log_event[2][1] . '</td><td>' . string_html_specialchars($t_log_event[3]) . '</td><td>' . string_html_specialchars($t_log_event[2][0]) . "</td></tr>\n"; } } # output any summary data if ($t_unique_queries_count != 0) { $t_unique_queries_executed = sprintf(lang_get('unique_queries_executed'), $t_unique_queries_count); echo "\t\t<tr><td>" . $g_log_levels[LOG_DATABASE] . '</td><td colspan="3">' . $t_unique_queries_executed . "</td></tr>\n"; } if ($t_total_queries_count != 0) { $t_total_queries_executed = sprintf(lang_get('total_queries_executed'), $t_total_queries_count); echo "\t\t<tr><td>" . $g_log_levels[LOG_DATABASE] . '</td><td colspan="3">' . $t_total_queries_executed . "</td></tr>\n"; } if ($t_total_query_execution_time != 0) { $t_total_query_time = sprintf(lang_get('total_query_execution_time'), $t_total_query_execution_time); echo "\t\t<tr><td>" . $g_log_levels[LOG_DATABASE] . '</td><td colspan="3">' . $t_total_query_time . "</td></tr>\n"; } echo "\t</tbody>\n\t</table>\n"; echo "<!--END Mantis Debug Log Output-->\n\n"; } }
/** * Send a bug reminder to the given user(s), or to each user if the first parameter is an array * * @param int|array $p_recipients user id or list of user ids array to send reminder to * @param int $p_bug_id Issue for which the reminder is sent * @param string $p_message Optional message to add to the e-mail * @return array List of users ids to whom the reminder e-mail was actually sent */ function email_bug_reminder($p_recipients, $p_bug_id, $p_message) { if (!is_array($p_recipients)) { $p_recipients = array($p_recipients); } $t_project_id = bug_get_field($p_bug_id, 'project_id'); $t_sender_id = auth_get_current_user_id(); $t_sender = user_get_name($t_sender_id); $t_subject = email_build_subject($p_bug_id); $t_date = date(config_get('normal_date_format')); $result = array(); foreach ($p_recipients as $t_recipient) { lang_push(user_pref_get_language($t_recipient, $t_project_id)); $t_email = user_get_email($t_recipient); if (access_has_project_level(config_get('show_user_email_threshold'), $t_project_id, $t_recipient)) { $t_sender_email = ' <' . user_get_email($t_sender_id) . '>'; } else { $t_sender_email = ''; } $t_header = "\n" . lang_get('on_date') . " {$t_date}, {$t_sender} {$t_sender_email} " . lang_get('sent_you_this_reminder_about') . ": \n\n"; $t_contents = $t_header . string_get_bug_view_url_with_fqdn($p_bug_id, $t_recipient) . " \n\n{$p_message}"; if (ON == config_get('enable_email_notification')) { $t_id = email_store($t_email, $t_subject, $t_contents); if ($t_id !== null) { $result[] = $t_recipient; } log_event(LOG_EMAIL, "queued reminder email #{$t_id} for U{$t_recipient}"); } lang_pop(); } if (OFF == config_get('email_send_using_cronjob')) { email_send_all(); } return $result; }
/** * (15) Print the closing <html> tag * @return void */ function html_end() { global $g_email_stored; echo '</html>', "\n"; if ($g_email_stored == true) { if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } email_send_all(); } }
/** * The email sending shutdown function * Will send any queued emails, except when $g_email_send_using_cronjob = ON. * If $g_email_shutdown_processing EMAIL_SHUTDOWN_FORCE flag is set, emails * will be sent regardless of cronjob setting. * @return void */ function email_shutdown_function() { global $g_email_shutdown_processing; # Nothing to do if # - no emails have been generated in the current request # - system is configured to use cron job (unless processing is forced) if ($g_email_shutdown_processing == EMAIL_SHUTDOWN_SKIP || !($g_email_shutdown_processing & EMAIL_SHUTDOWN_FORCE) && config_get('email_send_using_cronjob')) { return; } $t_msg = 'Shutdown function called for ' . $_SERVER['SCRIPT_NAME']; if ($g_email_shutdown_processing & EMAIL_SHUTDOWN_FORCE) { $t_msg .= ' (email processing forced)'; } log_event(LOG_EMAIL_VERBOSE, $t_msg); if ($g_email_shutdown_processing) { email_send_all(); } }
function email_group_reminder($p_user_id, $issues) { $t_username = user_get_field($p_user_id, 'username'); $t_email = user_get_email($p_user_id); $t_subject = config_get('plugin_Reminder_reminder_group_subject'); $t_message = $issues; if (!is_blank($t_email)) { email_store($t_email, $t_subject, $t_message); if (OFF == config_get('email_send_using_cronjob')) { email_send_all(); } } }