/**
  * Builds notification emails for the selected customers about changes made in bugs reports they are linked to
  *
  * @param array $customer_ids the ids of the customer to notify
  * @param string $from the start of the interval
  * @param string $to the end of the interval
  *
  * @return array notified customers
  */
 static function buildNotificationEmails($customer_ids, $from, $to)
 {
     $emails = array();
     lang_push(plugin_config_get('email_notification_language'));
     $fromDate = self::startOfDay(strtotime($from));
     $toDate = self::endOfDay(strtotime($to));
     $changedBugIds = CustomerManagementDao::findAllChangedBugIds($customer_ids, $fromDate, $toDate);
     $dateFormat = config_get('short_date_format');
     foreach ($customer_ids as $customer_id) {
         $changesForCustomer = array();
         foreach ($changedBugIds as $changedBugId) {
             if ($changedBugId['customer_id'] == $customer_id) {
                 $changesForCustomer[] = array('bug' => bug_get($changedBugId['bug_id']));
             }
         }
         if (count($changesForCustomer) > 0) {
             $counter = 0;
             $text = '';
             foreach ($changesForCustomer as $changeForCustomer) {
                 $counter++;
                 $bugId = $changeForCustomer['bug']->id;
                 $text .= $counter . '. ';
                 $text .= sprintf(plugin_lang_get('email_notification_bug_header'), $changeForCustomer['bug']->id, $changeForCustomer['bug']->summary, date($dateFormat, $changeForCustomer['bug']->date_submitted), get_enum_element('status', $changeForCustomer['bug']->status));
                 $text .= "\n";
                 $reporterName = user_get_name($changeForCustomer['bug']->reporter_id);
                 $reporterEmail = user_get_email($changeForCustomer['bug']->reporter_id);
                 $text .= sprintf(plugin_lang_get('email_notification_bug_reported_by'), $reporterName, $reporterEmail);
                 $text .= "\n";
                 $text .= sprintf(plugin_lang_get('email_notification_bug_description'), $changeForCustomer['bug']->description);
                 $text .= "\n\n";
             }
             $customer = CustomerManagementDao::getCustomer($customer_id);
             $email = new EmailData();
             $email->email = $customer['email'];
             $email->subject = sprintf(plugin_lang_get('email_notification_title'), $customer['name'], $from, $to);
             $email->body = $text;
             $email->metadata['priority'] = config_get('mail_priority');
             $email->metadata['charset'] = 'utf-8';
             array_push($emails, $email);
         }
     }
     lang_pop();
     return $emails;
 }
Example #2
0
/**
 * JSON error handler
 * 
 * <p>Ensures that all necessary headers are set and terminates processing after being invoked.</p>
 */
function json_error_handler($p_type, $p_error, $p_file, $p_line, $p_context)
{
    # flush any language overrides to return to user's natural default
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            lang_push(lang_get_default());
        }
    }
    $t_error_code = ERROR_GENERIC;
    // default
    # build an appropriate error string
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            $t_error_description = $p_error;
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            $t_error_description = $p_error;
            break;
        case E_USER_ERROR:
            $t_error_type = "APPLICATION ERROR #{$p_error}";
            $t_error_code = $p_error;
            $t_error_description = error_string($p_error);
            break;
        case E_USER_WARNING:
            $t_error_type = "APPLICATION WARNING #{$p_error}";
            $t_error_code = $p_error;
            $t_error_description = error_string($p_error);
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            $t_error_description = $p_error;
            break;
        default:
            #shouldn't happen, just display the error just in case
            $t_error_type = '';
            $t_error_description = $p_error;
    }
    json_output_raw(array('status' => 'ERROR', 'error' => array('code' => $t_error_code, 'type' => $t_error_type, 'message' => $t_error_description), 'contents' => $t_error_description));
}
Example #3
0
/**
 * Default error handler
 *
 * This handler will not receive E_ERROR, E_PARSE, E_CORE_*, or E_COMPILE_* errors.
 *
 * E_USER_* are triggered by us and will contain an error constant in $p_error
 * The others, being system errors, will come with a string in $p_error
 * @param integer $p_type    Contains the level of the error raised, as an integer.
 * @param string  $p_error   Contains the error message, as a string.
 * @param string  $p_file    Contains the filename that the error was raised in, as a string.
 * @param integer $p_line    Contains the line number the error was raised at, as an integer.
 * @param array   $p_context To the active symbol table at the point the error occurred (optional).
 * @return void
 */
function mc_error_handler($p_type, $p_error, $p_file, $p_line, array $p_context)
{
    # check if errors were disabled with @ somewhere in this call chain
    # also suppress php 5 strict warnings
    if (0 == error_reporting() || 2048 == $p_type) {
        return;
    }
    # flush any language overrides to return to user's natural default
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            lang_push(lang_get_default());
        }
    }
    # build an appropriate error string
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            $t_error_description = $p_error;
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            $t_error_description = $p_error;
            break;
        case E_USER_ERROR:
            $t_error_type = 'APPLICATION ERROR #' . $p_error;
            $t_error_description = error_string($p_error);
            break;
        case E_USER_WARNING:
            $t_error_type = 'APPLICATION WARNING #' . $p_error;
            $t_error_description = error_string($p_error);
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            $t_error_description = $p_error;
            break;
        default:
            #shouldn't happen, just display the error just in case
            $t_error_type = '';
            $t_error_description = $p_error;
    }
    $t_error_stack = error_get_stack_trace();
    error_log('[mantisconnect.php] Error Type: ' . $t_error_type . ',' . "\n" . 'Error Description: ' . $t_error_description . "\n" . 'Stack Trace:' . "\n" . $t_error_stack);
    throw new SoapFault('Server', 'Error Type: ' . $t_error_type . ',' . "\n" . 'Error Description: ' . $t_error_description);
}
Example #4
0
}
# if the user is already protected and the admin is not removing the
#  protected flag then don't update the access level and enabled flag.
#  If the user was unprotected or the protected flag is being turned off
#  then proceed with a full update.
$query_params = array();
if ($f_protected && $t_old_protected) {
    $query = "UPDATE {$t_user_table}\n\t\t\tSET username="******", email=" . db_param() . ",\n\t\t\t\tprotected=" . db_param() . ", realname=" . db_param() . "\n\t\t\tWHERE id=" . db_param();
    $query_params = array($c_username, $c_email, $c_protected, $c_realname, $c_user_id);
} else {
    $query = "UPDATE {$t_user_table}\n\t\t\tSET username="******", email=" . db_param() . ",\n\t\t\t\taccess_level=" . db_param() . ", enabled=" . db_param() . ",\n\t\t\t\tprotected=" . db_param() . ", realname=" . db_param() . "\n\t\t\tWHERE id=" . db_param();
    $query_params = array($c_username, $c_email, $c_access_level, $c_enabled, $c_protected, $c_realname, $c_user_id);
}
$result = db_query_bound($query, $query_params);
if ($f_send_email_notification) {
    lang_push(user_pref_get_language($f_user_id));
    $t_changes = "";
    if (strcmp($f_username, $t_old_username)) {
        $t_changes .= lang_get('username_label') . lang_get('word_separator') . $t_old_username . ' => ' . $f_username . "\n";
    }
    if (strcmp($t_realname, $t_old_realname)) {
        $t_changes .= lang_get('realname_label') . lang_get('word_separator') . $t_old_realname . ' => ' . $t_realname . "\n";
    }
    if (strcmp($t_email, $t_old_email)) {
        $t_changes .= lang_get('email_label') . lang_get('word_separator') . $t_old_email . ' => ' . $t_email . "\n";
    }
    if (strcmp($f_access_level, $t_old_access_level)) {
        $t_old_access_string = get_enum_element('access_levels', $t_old_access_level);
        $t_new_access_string = get_enum_element('access_levels', $f_access_level);
        $t_changes .= lang_get('access_level_label') . lang_get('word_separator') . $t_old_access_string . ' => ' . $t_new_access_string . "\n\n";
    }
Example #5
0
<br />


<!-- Email testing -->
<a name="email" id="email" />
<table width="100%" bgcolor="#222222" border="0" cellpadding="20" cellspacing="1">
<tr>
	<td bgcolor="#f4f4f4">
		<span class="title">Testing Email</span>
		<p>You can test the ability for Mantis to send email notifications with this form.  Just click "Send Mail".  If the page takes a very long time to reappear or results in an error then you will need to investigate your php/mail server settings (see PHPMailer related settings in your config_inc.php, if they don't exist, copy from config_defaults_inc.php).  Note that errors can also appear in the server error log.  More help can be found at the <a href="http://www.php.net/manual/en/ref.mail.php">PHP website</a> if you are using the mail() PHPMailer sending mode.</p>
		<?php 
if ($f_mail_test) {
    echo '<b><font color="#ff0000">Testing Mail</font></b> - ';
    # @@@ thraxisp - workaround to ensure a language is set without authenticating
    #  will disappear when this is properly localized
    lang_push('english');
    $t_email_data = new EmailData();
    $t_email_data->email = config_get_global('administrator_email');
    $t_email_data->subject = 'Testing PHP mail() function';
    $t_email_data->body = 'Your PHP mail settings appear to be correctly set.';
    $t_email_data->metadata['priority'] = config_get('mail_priority');
    $t_email_data->metadata['charset'] = lang_get('charset', lang_get_current());
    $result = email_send($t_email_data);
    #$result = email_send( config_get_global( 'administrator_email' ), 'Testing PHP mail() function',	'Your PHP mail settings appear to be correctly set.');
    if (!$result) {
        echo ' PROBLEMS SENDING MAIL TO: ' . config_get_global('administrator_email') . '. Please check your php/mail server settings.<br />';
    } else {
        echo ' mail() send successful.<br />';
    }
}
?>
Example #6
0
/**
 * Default error handler
 *
 * This handler will not receive E_ERROR, E_PARSE, E_CORE_*, or E_COMPILE_*
 *  errors.
 *
 * E_USER_* are triggered by us and will contain an error constant in $p_error
 * The others, being system errors, will come with a string in $p_error
 *
 * @access private
 * @param integer $p_type    Contains the level of the error raised, as an integer.
 * @param string  $p_error   Contains the error message, as a string.
 * @param string  $p_file    Contains the filename that the error was raised in, as a string.
 * @param integer $p_line    Contains the line number the error was raised at, as an integer.
 * @param array   $p_context To the active symbol table at the point the error occurred (optional).
 * @return void
 * @uses lang_api.php
 * @uses config_api.php
 * @uses compress_api.php
 * @uses database_api.php (optional)
 * @uses html_api.php (optional)
 */
function error_handler($p_type, $p_error, $p_file, $p_line, array $p_context)
{
    global $g_error_parameters, $g_error_handled, $g_error_proceed_url;
    global $g_error_send_page_header;
    # check if errors were disabled with @ somewhere in this call chain
    if (0 == error_reporting()) {
        return;
    }
    $t_lang_pushed = false;
    $t_db_connected = false;
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            $t_db_connected = true;
        }
    }
    $t_html_api = false;
    if (function_exists('html_end')) {
        $t_html_api = true;
    }
    # flush any language overrides to return to user's natural default
    if ($t_db_connected) {
        lang_push(lang_get_default());
        $t_lang_pushed = true;
    }
    $t_method_array = config_get_global('display_errors');
    if (isset($t_method_array[$p_type])) {
        $t_method = $t_method_array[$p_type];
    } else {
        if (isset($t_method_array[E_ALL])) {
            $t_method = $t_method_array[E_ALL];
        } else {
            $t_method = 'none';
        }
    }
    # build an appropriate error string
    $t_error_location = 'in \'' . $p_file . '\' line ' . $p_line;
    $t_error_description = '\'' . $p_error . '\' ' . $t_error_location;
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            break;
        case E_STRICT:
            $t_error_type = 'STRICT NOTICE';
            break;
        case E_RECOVERABLE_ERROR:
            # This should generally be considered fatal (like E_ERROR)
            $t_error_type = 'SYSTEM ERROR';
            break;
        case E_DEPRECATED:
            $t_error_type = 'DEPRECATED';
            break;
        case E_USER_ERROR:
            $t_error_type = 'APPLICATION ERROR #' . $p_error;
            $t_error_description = error_string($p_error);
            if ($t_method == DISPLAY_ERROR_INLINE) {
                $t_error_description .= ' (' . $t_error_location . ")\n" . error_string(ERROR_DISPLAY_USER_ERROR_INLINE);
            }
            break;
        case E_USER_WARNING:
            $t_error_type = 'APPLICATION WARNING #' . $p_error;
            $t_error_description = error_string($p_error) . ' (' . $t_error_location . ')';
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            break;
        case E_USER_DEPRECATED:
            # Get the parent of the call that triggered the error to facilitate
            # debugging with a more useful filename and line number
            $t_stack = debug_backtrace();
            $t_caller = $t_stack[2];
            $t_error_type = 'WARNING';
            $t_error_description = error_string($p_error) . ' (in ' . $t_caller['file'] . ' line ' . $t_caller['line'] . ')';
            if ($t_method == DISPLAY_ERROR_INLINE && php_sapi_name() != 'cli') {
                # Enqueue messages for later display with error_print_delayed()
                global $g_errors_delayed;
                $g_errors_delayed[] = $t_error_description;
                $g_error_handled = true;
                return;
            }
            break;
        default:
            # shouldn't happen, just display the error just in case
            $t_error_type = 'UNHANDLED ERROR TYPE (' . '<a href="http://php.net/errorfunc.constants">' . $p_type . '</a>)';
            $t_error_description = $p_error . ' (' . $t_error_location . ')';
    }
    $t_error_description = nl2br($t_error_description);
    if (php_sapi_name() == 'cli') {
        if (DISPLAY_ERROR_NONE != $t_method) {
            echo $t_error_type . ': ' . $t_error_description . "\n";
            if (ON == config_get_global('show_detailed_errors')) {
                echo "\n";
                debug_print_backtrace();
            }
        }
        if (DISPLAY_ERROR_HALT == $t_method) {
            exit(1);
        }
    } else {
        switch ($t_method) {
            case DISPLAY_ERROR_HALT:
                # disable any further event callbacks
                if (function_exists('event_clear_callbacks')) {
                    event_clear_callbacks();
                }
                $t_oblen = ob_get_length();
                if ($t_oblen > 0) {
                    $t_old_contents = ob_get_contents();
                    if (!error_handled()) {
                        # Retrieve the previously output header
                        if (false !== preg_match_all('|^(.*)(</head>.*$)|is', $t_old_contents, $t_result) && isset($t_result[1]) && isset($t_result[1][0])) {
                            $t_old_headers = $t_result[1][0];
                            unset($t_old_contents);
                        }
                    }
                }
                # We need to ensure compression is off - otherwise the compression headers are output.
                compress_disable();
                # then clean the buffer, leaving output buffering on.
                if ($t_oblen > 0) {
                    ob_clean();
                }
                # If HTML error output was disabled, set an error header and stop
                if (defined('DISABLE_INLINE_ERROR_REPORTING')) {
                    # @TODO Have a mapping for mantis error codes to appropiate HTTP error codes
                    header(' ', true, 400);
                    exit(1);
                }
                # don't send the page header information if it has already been sent
                if ($g_error_send_page_header) {
                    if ($t_html_api) {
                        html_page_top1();
                        if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                            html_page_top2();
                        } else {
                            html_page_top2a();
                        }
                    } else {
                        echo '<html><head><title>', $t_error_type, '</title></head><body>';
                    }
                } else {
                    # Output the previously sent headers, if defined
                    if (isset($t_old_headers)) {
                        echo $t_old_headers, "\n";
                        html_page_top2();
                    }
                }
                echo '<div id="error-msg">';
                echo '<div class="error-type">' . $t_error_type . '</div>';
                echo '<div class="error-description">', $t_error_description, '</div>';
                echo '<div class="error-info">';
                if (null === $g_error_proceed_url) {
                    echo lang_get('error_no_proceed');
                } else {
                    echo '<a href="', $g_error_proceed_url, '">', lang_get('proceed'), '</a>';
                }
                echo '</div>';
                if (ON == config_get_global('show_detailed_errors')) {
                    echo '<div class="error-details">';
                    error_print_details($p_file, $p_line, $p_context);
                    echo '</div>';
                    echo '<div class="error-trace">';
                    error_print_stack_trace();
                    echo '</div>';
                }
                echo '</div>';
                if (isset($t_old_contents)) {
                    echo '<div class="warning">Previous non-fatal errors occurred.  Page contents follow.</div>';
                    echo '<div id="old-contents">';
                    echo $t_old_contents;
                    echo '</div>';
                }
                if ($t_html_api) {
                    if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                        html_page_bottom();
                    } else {
                        html_body_end();
                        html_end();
                    }
                } else {
                    echo '</body></html>', "\n";
                }
                exit(1);
            case DISPLAY_ERROR_INLINE:
                if (!defined('DISABLE_INLINE_ERROR_REPORTING')) {
                    echo '<div class="error-inline">', $t_error_type, ': ', $t_error_description, '</div>';
                }
                $g_error_handled = true;
                break;
            default:
                # do nothing - note we treat this as we've not handled an error, so any redirects go through.
        }
    }
    if ($t_lang_pushed) {
        lang_pop();
    }
    $g_error_parameters = array();
    $g_error_proceed_url = null;
}
Example #7
0
/**
 * 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;
}
Example #8
0
/**
 * Send a notification to user or set of users that were mentioned in an issue
 * or an issue note.
 *
 * @param integer       $p_bug_id     Issue for which the reminder is sent.
 * @param array         $p_mention_user_ids User id or list of user ids array.
 * @param string        $p_message    Optional message to add to the e-mail.
 * @param array         $p_removed_mention_user_ids  The users that were removed due to lack of access.
 * @return array List of users ids to whom the reminder e-mail was actually sent
 */
function email_user_mention($p_bug_id, $p_mention_user_ids, $p_message, $p_removed_mention_user_ids = array())
{
    if (OFF == config_get('enable_email_notification')) {
        log_event(LOG_EMAIL_VERBOSE, 'email notifications disabled.');
        return array();
    }
    $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'));
    $t_user_id = auth_get_current_user_id();
    $t_users_processed = array();
    foreach ($p_removed_mention_user_ids as $t_removed_mention_user_id) {
        log_event(LOG_EMAIL_VERBOSE, 'skipped mention email for U' . $t_removed_mention_user_id . ' (no access to issue or note).');
    }
    $t_result = array();
    foreach ($p_mention_user_ids as $t_mention_user_id) {
        # Don't trigger mention emails for self mentions
        if ($t_mention_user_id == $t_user_id) {
            log_event(LOG_EMAIL_VERBOSE, 'skipped mention email for U' . $t_mention_user_id . ' (self-mention).');
            continue;
        }
        # Don't process a user more than once
        if (isset($t_users_processed[$t_mention_user_id])) {
            continue;
        }
        $t_users_processed[$t_mention_user_id] = true;
        # Don't email mention notifications to disabled users.
        if (!user_is_enabled($t_mention_user_id)) {
            continue;
        }
        lang_push(user_pref_get_language($t_mention_user_id, $t_project_id));
        $t_email = user_get_email($t_mention_user_id);
        if (access_has_project_level(config_get('show_user_email_threshold'), $t_project_id, $t_mention_user_id)) {
            $t_sender_email = ' <' . user_get_email($t_sender_id) . '> ';
        } else {
            $t_sender_email = '';
        }
        $t_complete_subject = sprintf(lang_get('mentioned_in'), $t_subject);
        $t_header = "\n" . lang_get('on_date') . ' ' . $t_date . ', ' . $t_sender . ' ' . $t_sender_email . lang_get('mentioned_you') . "\n\n";
        $t_contents = $t_header . string_get_bug_view_url_with_fqdn($p_bug_id) . " \n\n" . $p_message;
        $t_id = email_store($t_email, $t_complete_subject, $t_contents);
        if ($t_id !== null) {
            $t_result[] = $t_mention_user_id;
        }
        log_event(LOG_EMAIL_VERBOSE, 'queued mention email ' . $t_id . ' for U' . $t_mention_user_id);
        lang_pop();
    }
    return $t_result;
}
Example #9
0
function mc_error_handler($p_type, $p_error, $p_file, $p_line, $p_context)
{
    global $g_error_parameters, $g_error_handled, $g_error_proceed_url;
    global $g_lang_overrides;
    global $g_error_send_page_header;
    global $l_oServer;
    # check if errors were disabled with @ somewhere in this call chain
    # also suppress php 5 strict warnings
    if (0 == error_reporting() || 2048 == $p_type) {
        return;
    }
    $t_lang_pushed = false;
    # flush any language overrides to return to user's natural default
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            lang_push(lang_get_default());
            $t_lang_pushed = true;
        }
    }
    $t_short_file = basename($p_file);
    $t_method_array = config_get('display_errors');
    if (isset($t_method_array[$p_type])) {
        $t_method = $t_method_array[$p_type];
    } else {
        $t_method = 'none';
    }
    # build an appropriate error string
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            $t_error_description = $p_error;
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            $t_error_description = $p_error;
            break;
        case E_USER_ERROR:
            $t_error_type = "APPLICATION ERROR #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_WARNING:
            $t_error_type = "APPLICATION WARNING #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            $t_error_description = $p_error;
            break;
        default:
            #shouldn't happen, just display the error just in case
            $t_error_type = '';
            $t_error_description = $p_error;
    }
    $t_error_description = $t_error_description;
    $t_error_stack = error_get_stack_trace();
    $l_oServer->fault('Server', "Error Type: {$t_error_type},\nError Description:\n{$t_error_description},\nStack Trace:\n{$t_error_stack}");
    $l_oServer->send_response();
    exit;
}
/**
 * Default error handler
 *
 * This handler will not receive E_ERROR, E_PARSE, E_CORE_*, or E_COMPILE_*
 *  errors.
 *
 * E_USER_* are triggered by us and will contain an error constant in $p_error
 * The others, being system errors, will come with a string in $p_error
 *
 * @access private
 * @param int p_type contains the level of the error raised, as an integer.
 * @param string p_error contains the error message, as a string.
 * @param string p_file contains the filename that the error was raised in, as a string.
 * @param int p_line contains the line number the error was raised at, as an integer.
 * @param array p_context to the active symbol table at the point the error occurred (optional)
 * @uses lang_api.php
 * @uses config_api.php
 * @uses compress_api.php
 * @uses database_api.php (optional)
 * @uses html_api.php (optional)
 */
function error_handler($p_type, $p_error, $p_file, $p_line, $p_context)
{
    global $g_error_parameters, $g_error_handled, $g_error_proceed_url;
    global $g_lang_overrides;
    global $g_error_send_page_header;
    # check if errors were disabled with @ somewhere in this call chain
    if (0 == error_reporting()) {
        return;
    }
    $t_lang_pushed = false;
    $t_db_connected = false;
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            $t_db_connected = true;
        }
    }
    $t_html_api = false;
    if (function_exists('html_end')) {
        $t_html_api = true;
    }
    # flush any language overrides to return to user's natural default
    if ($t_db_connected) {
        lang_push(lang_get_default());
        $t_lang_pushed = true;
    }
    $t_short_file = basename($p_file);
    $t_method_array = config_get_global('display_errors');
    if (isset($t_method_array[$p_type])) {
        $t_method = $t_method_array[$p_type];
    } else {
        if (isset($t_method_array[E_ALL])) {
            $t_method = $t_method_array[E_ALL];
        } else {
            $t_method = 'none';
        }
    }
    # build an appropriate error string
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            $t_error_description = "'{$p_error}' in '{$p_file}' line {$p_line}";
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            $t_error_description = "'{$p_error}' in '{$p_file}' line {$p_line}";
            break;
        case E_USER_ERROR:
            $t_error_type = "APPLICATION ERROR #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_WARNING:
            $t_error_type = "APPLICATION WARNING #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            $t_error_description = $p_error;
            break;
        default:
            # shouldn't happen, just display the error just in case
            $t_error_type = '';
            $t_error_description = $p_error;
    }
    $t_error_description = nl2br($t_error_description);
    switch ($t_method) {
        case 'halt':
            # disable any further event callbacks
            if (function_exists('event_clear_callbacks')) {
                event_clear_callbacks();
            }
            $t_oblen = ob_get_length();
            if (error_handled() && $t_oblen > 0) {
                $t_old_contents = ob_get_contents();
            }
            # We need to ensure compression is off - otherwise the compression headers are output.
            compress_disable();
            # then clean the buffer, leaving output buffering on.
            if ($t_oblen > 0) {
                ob_clean();
            }
            # don't send the page header information if it has already been sent
            if ($g_error_send_page_header) {
                if ($t_html_api) {
                    html_page_top1();
                    if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                        html_page_top2();
                    } else {
                        html_page_top2a();
                    }
                } else {
                    echo '<html><head><title>', $t_error_type, '</title></head><body>';
                }
            }
            echo '<br /><div align="center"><table class="width50" cellspacing="1">';
            echo '<tr><td class="form-title">', $t_error_type, '</td></tr>';
            echo '<tr><td><p class="center" style="color:red">', $t_error_description, '</p></td></tr>';
            echo '<tr><td><p class="center">';
            if (null === $g_error_proceed_url) {
                echo lang_get('error_no_proceed');
            } else {
                echo '<a href="', $g_error_proceed_url, '">', lang_get('proceed'), '</a>';
            }
            echo '</p></td></tr>';
            if (ON == config_get_global('show_detailed_errors')) {
                echo '<tr><td>';
                error_print_details($p_file, $p_line, $p_context);
                echo '</td></tr>';
                echo '<tr><td>';
                error_print_stack_trace();
                echo '</td></tr>';
            }
            echo '</table></div>';
            if (isset($t_old_contents)) {
                echo '<p>Previous non-fatal errors occurred.  Page contents follow.</p>';
                echo '<div style="border: solid 1px black;padding: 4px">';
                echo $t_old_contents;
                echo '</div>';
            }
            if ($t_html_api) {
                if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                    html_page_bottom();
                } else {
                    html_body_end();
                    html_end();
                }
            } else {
                echo '</body></html>', "\n";
            }
            exit;
        case 'inline':
            echo '<p style="color:red">', $t_error_type, ': ', $t_error_description, '</p>';
            $g_error_handled = true;
            break;
        default:
            # do nothing - note we treat this as we've not handled an error, so any redirects go through.
    }
    if ($t_lang_pushed) {
        lang_pop();
    }
    $g_error_parameters = array();
    $g_error_proceed_url = null;
}
Example #11
0
function mc_error_handler($p_type, $p_error, $p_file, $p_line, $p_context)
{
    global $l_oServer;
    # check if errors were disabled with @ somewhere in this call chain
    # also suppress php 5 strict warnings
    if (0 == error_reporting() || 2048 == $p_type) {
        return;
    }
    # flush any language overrides to return to user's natural default
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            lang_push(lang_get_default());
        }
    }
    # build an appropriate error string
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            $t_error_description = $p_error;
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            $t_error_description = $p_error;
            break;
        case E_USER_ERROR:
            $t_error_type = "APPLICATION ERROR #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_WARNING:
            $t_error_type = "APPLICATION WARNING #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            $t_error_description = $p_error;
            break;
        default:
            #shouldn't happen, just display the error just in case
            $t_error_type = '';
            $t_error_description = $p_error;
    }
    $t_error_stack = error_get_stack_trace();
    error_log("[mantisconnect.php] Error Type: {$t_error_type},\nError Description: {$t_error_description}\nStack Trace:\n{$t_error_stack}");
    $l_oServer->fault('Server', "Error Type: {$t_error_type},\nError Description: {$t_error_description}");
    $l_oServer->send_response();
    exit;
}
function formatBugEntry($data)
{
    lang_push(user_pref_get_language($data['handler_id']));
    $p_visible_bug_data = $data;
    $p_visible_bug_data['email_project'] = project_get_name($data['project_id']);
    $p_visible_bug_data['email_category'] = category_get_name($data['category_id']);
    $t_email_separator1 = config_get('email_separator1');
    $t_email_separator2 = config_get('email_separator2');
    $p_visible_bug_data['email_bug'] = $data['id'];
    $p_visible_bug_data['email_status'] = get_enum_element('status', $p_visible_bug_data['status'], $data['handler_id'], $data['project_id']);
    $p_visible_bug_data['email_severity'] = get_enum_element('severity', $p_visible_bug_data['severity']);
    $p_visible_bug_data['email_priority'] = get_enum_element('priority', $p_visible_bug_data['priority']);
    $p_visible_bug_data['email_reproducibility'] = get_enum_element('reproducibility', $p_visible_bug_data['reproducibility']);
    $p_visible_bug_data['email_summary'] = $data['summary'];
    $t_message = $t_email_separator1 . " \n";
    $t_message .= string_get_bug_view_url_with_fqdn($data['id'], $data['handler_id']) . " \n";
    $t_message .= $t_email_separator1 . " \n";
    $t_message .= email_format_attribute($p_visible_bug_data, 'email_project');
    $t_message .= email_format_attribute($p_visible_bug_data, 'email_bug');
    $t_message .= email_format_attribute($p_visible_bug_data, 'email_category');
    $t_message .= email_format_attribute($p_visible_bug_data, 'email_priority');
    $t_message .= email_format_attribute($p_visible_bug_data, 'email_status');
    $t_message .= $t_email_separator1 . " \n";
    $t_message .= email_format_attribute($p_visible_bug_data, 'email_summary');
    $t_message .= $t_email_separator1 . " \n\n\n";
    return $t_message;
}
Example #13
0
/**
 * Default error handler
 *
 * This handler will not receive E_ERROR, E_PARSE, E_CORE_*, or E_COMPILE_*
 *  errors.
 *
 * E_USER_* are triggered by us and will contain an error constant in $p_error
 * The others, being system errors, will come with a string in $p_error
 *
 * @access private
 * @param int p_type contains the level of the error raised, as an integer.
 * @param string p_error contains the error message, as a string.
 * @param string p_file contains the filename that the error was raised in, as a string.
 * @param int p_line contains the line number the error was raised at, as an integer.
 * @param array p_context to the active symbol table at the point the error occurred (optional)
 * @uses lang_api.php
 * @uses config_api.php
 * @uses compress_api.php
 * @uses database_api.php (optional)
 * @uses html_api.php (optional)
 */
function error_handler($p_type, $p_error, $p_file, $p_line, $p_context)
{
    global $g_error_parameters, $g_error_handled, $g_error_proceed_url;
    global $g_lang_overrides;
    global $g_error_send_page_header;
    # check if errors were disabled with @ somewhere in this call chain
    if (0 == error_reporting()) {
        return;
    }
    $t_lang_pushed = false;
    $t_db_connected = false;
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            $t_db_connected = true;
        }
    }
    $t_html_api = false;
    if (function_exists('html_end')) {
        $t_html_api = true;
    }
    # flush any language overrides to return to user's natural default
    if ($t_db_connected) {
        lang_push(lang_get_default());
        $t_lang_pushed = true;
    }
    $t_short_file = basename($p_file);
    $t_method_array = config_get_global('display_errors');
    if (isset($t_method_array[$p_type])) {
        $t_method = $t_method_array[$p_type];
    } else {
        if (isset($t_method_array[E_ALL])) {
            $t_method = $t_method_array[E_ALL];
        } else {
            $t_method = 'none';
        }
    }
    # build an appropriate error string
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            $t_error_description = "'{$p_error}' in '{$p_file}' line {$p_line}";
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            $t_error_description = "'{$p_error}' in '{$p_file}' line {$p_line}";
            break;
        case E_USER_ERROR:
            $t_error_type = "APPLICATION ERROR #{$p_error}";
            $t_error_description = error_string($p_error);
            if ($t_method == DISPLAY_ERROR_INLINE) {
                $t_error_description .= "\n" . error_string(ERROR_DISPLAY_USER_ERROR_INLINE);
            }
            break;
        case E_USER_WARNING:
            $t_error_type = "APPLICATION WARNING #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            $t_error_description = $p_error;
            break;
        default:
            # shouldn't happen, just display the error just in case
            $t_error_type = '';
            $t_error_description = $p_error;
    }
    $t_error_description = nl2br($t_error_description);
    switch ($t_method) {
        case DISPLAY_ERROR_HALT:
            # disable any further event callbacks
            if (function_exists('event_clear_callbacks')) {
                event_clear_callbacks();
            }
            $t_oblen = ob_get_length();
            if ($t_oblen > 0) {
                $t_old_contents = ob_get_contents();
                if (!error_handled()) {
                    # Retrieve the previously output header
                    if (false !== preg_match_all('|^(.*)(</head>.*$)|is', $t_old_contents, $result)) {
                        $t_old_headers = $result[1][0];
                        unset($t_old_contents);
                    }
                }
            }
            # We need to ensure compression is off - otherwise the compression headers are output.
            compress_disable();
            # then clean the buffer, leaving output buffering on.
            if ($t_oblen > 0) {
                ob_clean();
            }
            # don't send the page header information if it has already been sent
            if ($g_error_send_page_header) {
                if ($t_html_api) {
                    html_page_top1();
                    if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                        html_page_top2();
                    } else {
                        html_page_top2a();
                    }
                } else {
                    echo '<html><head><title>', $t_error_type, '</title></head><body>';
                }
            } else {
                # Output the previously sent headers, if defined
                if (isset($t_old_headers)) {
                    echo $t_old_headers, "\n";
                    html_page_top2();
                }
            }
            echo '<div id="error-msg">';
            echo '<div class="error-type">' . $t_error_type . '</div>';
            echo '<div class="error-description">', $t_error_description, '</div>';
            echo '<div class="error-info">';
            if (null === $g_error_proceed_url) {
                echo lang_get('error_no_proceed');
            } else {
                echo '<a href="', $g_error_proceed_url, '">', lang_get('proceed'), '</a>';
            }
            echo '</div>';
            if (ON == config_get_global('show_detailed_errors')) {
                echo '<div class="error-details">';
                error_print_details($p_file, $p_line, $p_context);
                echo '</div>';
                echo '<div class="error-trace">';
                error_print_stack_trace();
                echo '</div>';
            }
            echo '</div>';
            if (isset($t_old_contents)) {
                echo '<div class="warning">Previous non-fatal errors occurred.  Page contents follow.</div>';
                echo '<div id="old-contents">';
                echo $t_old_contents;
                echo '</div>';
            }
            if ($t_html_api) {
                if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                    html_page_bottom();
                } else {
                    html_body_end();
                    html_end();
                }
            } else {
                echo '</body></html>', "\n";
            }
            exit;
        case DISPLAY_ERROR_INLINE:
            echo '<div class="error-inline">', $t_error_type, ': ', $t_error_description, '</div>';
            $g_error_handled = true;
            break;
        default:
            # do nothing - note we treat this as we've not handled an error, so any redirects go through.
    }
    if ($t_lang_pushed) {
        lang_pop();
    }
    $g_error_parameters = array();
    $g_error_proceed_url = null;
}
Example #14
0
    require_api('authentication_api.php');
    if (auth_is_user_authenticated()) {
        require_api('user_pref_api.php');
        $t_user_timezone = user_pref_get_pref(auth_get_current_user_id(), 'timezone');
        if (!is_blank($t_user_timezone)) {
            date_default_timezone_set($t_user_timezone);
        }
    }
}
if (!defined('MANTIS_MAINTENANCE_MODE')) {
    require_api('collapse_api.php');
    collapse_cache_token();
}
# Load custom functions
require_api('custom_function_api.php');
if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'custom_functions_inc.php')) {
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'custom_functions_inc.php';
}
# Set HTTP response headers
require_api('http_api.php');
http_all_headers();
# Push default language to speed calls to lang_get
if (!defined('LANG_LOAD_DISABLED')) {
    require_api('lang_api.php');
    lang_push(lang_get_default());
}
# Signal plugins that the core system is loaded
if (!defined('PLUGINS_DISABLED') && !defined('MANTIS_MAINTENANCE_MODE')) {
    require_api('event_api.php');
    event_signal('EVENT_CORE_READY');
}
    # Create random password
    $t_seed = $f_email . $f_username;
    $f_password = auth_generate_random_password($t_seed);
} else {
    # Password won't to be sent by email. It entered by the admin
    # Now, if the password is empty, confirm that that is what we wanted
    if (is_blank($f_password)) {
        helper_ensure_confirmed(lang_get('empty_password_sure_msg'), lang_get('empty_password_button'));
    }
}
# Don't allow the creation of accounts with access levels higher than that of
# the user creating the account.
access_ensure_global_level($f_access_level);
# Need to send the user creation mail in the tracker language, not in the creating admin's language
# Park the current language name until the user has been created
lang_push(config_get('default_language'));
# create the user
$t_admin_name = user_get_name(auth_get_current_user_id());
$t_cookie = user_create($f_username, $f_password, $f_email, $f_access_level, $f_protected, $f_enabled, $t_realname, $t_admin_name);
# set language back to user language
lang_pop();
form_security_purge('manage_user_create');
if ($t_cookie === false) {
    $t_redirect_url = 'manage_user_page.php';
} else {
    # ok, we created the user, get the row again
    $t_user_id = user_get_id_by_name($f_username);
    $t_redirect_url = 'manage_user_edit_page.php?user_id=' . $t_user_id;
}
html_page_top(null, $t_redirect_url);
?>
Example #16
0
function error_handler($p_type, $p_error, $p_file, $p_line, $p_context)
{
    global $g_error_parameters, $g_error_handled, $g_error_proceed_url;
    global $g_lang_overrides;
    global $g_error_send_page_header;
    # check if errors were disabled with @ somewhere in this call chain
    # also suppress php 5 strict warnings
    if (0 == error_reporting() || 2048 == $p_type) {
        return;
    }
    $t_lang_pushed = false;
    # flush any language overrides to return to user's natural default
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            lang_push(lang_get_default());
            $t_lang_pushed = true;
        }
    }
    $t_short_file = basename($p_file);
    $t_method_array = config_get('display_errors');
    if (isset($t_method_array[$p_type])) {
        $t_method = $t_method_array[$p_type];
    } else {
        $t_method = 'none';
    }
    # build an appropriate error string
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            $t_error_description = $p_error;
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            $t_error_description = $p_error;
            break;
        case E_USER_ERROR:
            $t_error_type = "APPLICATION ERROR #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_WARNING:
            $t_error_type = "APPLICATION WARNING #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            $t_error_description = $p_error;
            break;
        default:
            #shouldn't happen, just display the error just in case
            $t_error_type = '';
            $t_error_description = $p_error;
    }
    $t_error_description = nl2br($t_error_description);
    if ('halt' == $t_method) {
        $t_old_contents = ob_get_contents();
        # ob_end_clean() still seems to call the output handler which
        #  outputs the headers indicating compression. If we had
        #  PHP > 4.2.0 we could use ob_clean() instead but as it is
        #  we need to disable compression.
        compress_disable();
        if (ob_get_length()) {
            ob_end_clean();
        }
        # don't send the page header information if it has already been sent
        if ($g_error_send_page_header) {
            html_page_top1();
            if ($p_error != ERROR_DB_QUERY_FAILED) {
                html_page_top2();
            } else {
                html_page_top2a();
            }
        }
        print '<br /><div align="center"><table class="width50" cellspacing="1">';
        print "<tr><td class=\"form-title\">{$t_error_type}</td></tr>";
        print "<tr><td><p class=\"center\" style=\"color:red\">{$t_error_description}</p></td></tr>";
        print '<tr><td><p class="center">';
        if (null === $g_error_proceed_url) {
            print lang_get('error_no_proceed');
        } else {
            print "<a href=\"{$g_error_proceed_url}\">" . lang_get('proceed') . '</a>';
        }
        print '</p></td></tr>';
        if (ON == config_get('show_detailed_errors')) {
            print '<tr><td>';
            error_print_details($p_file, $p_line, $p_context);
            print '</td></tr>';
            print '<tr><td>';
            error_print_stack_trace();
            print '</td></tr>';
        }
        print '</table></div>';
        if ($g_error_handled && !is_blank($t_old_contents)) {
            print '<p>Previous non-fatal errors occurred.  Page contents follow.</p>';
            print '<div style="border: solid 1px black;padding: 4px">';
            print $t_old_contents;
            print '</div>';
        }
        if ($p_error != ERROR_DB_QUERY_FAILED) {
            html_page_bottom1();
        } else {
            html_body_end();
            html_end();
        }
        exit;
    } else {
        if ('inline' == $t_method) {
            print "<p style=\"color:red\">{$t_error_type}: {$t_error_description}</p>";
        } else {
            # do nothing
        }
    }
    if ($t_lang_pushed) {
        lang_pop();
    }
    $g_error_parameters = array();
    $g_error_handled = true;
    $g_error_proceed_url = null;
}
// Zugriff auf die Mantis Funktionen
//require_once ($mantisPath . 'core.php');
// Lade die Konfigurationsdatei und stelle die Datenbankverbindung her
// Zugriff auf die agileMantis Funktionen
if ($_POST['timezone']) {
    date_default_timezone_set($_POST['timezone']);
}
ob_end_clean();
if ($_POST['user']) {
    $sitekey = $agilemantis_tasks->getConfigValue('plugin_agileMantis_gadiv_sitekey');
    $heute = mktime(0, 0, 0, date('m'), date('d'), date('y'));
    $generatedKey = md5($sitekey . $heute);
    $user_id = $_POST['user'];
    $language = user_pref_get_language($user_id);
    lang_load($language, $mantisBtPath . 'plugins' . DIRECTORY_SEPARATOR . 'agileMantis' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR);
    lang_push($language);
    // Load language stuff
    if ($language == 'german') {
        require_once $mantisBtPath . 'lang' . DIRECTORY_SEPARATOR . 'strings_german.txt';
        require_once $mantisBtPath . 'plugins' . DIRECTORY_SEPARATOR . 'agileMantis' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'strings_german.txt';
    } else {
        require_once $mantisBtPath . 'lang' . DIRECTORY_SEPARATOR . 'strings_english.txt';
        require_once $mantisBtPath . 'plugins' . DIRECTORY_SEPARATOR . 'agileMantis' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'strings_english.txt';
    }
    if ($_POST['event'] == 'checkIdentity') {
        if ($generatedKey == $_POST['appletkey']) {
            echo true;
        } else {
            echo false;
        }
    }