diff -Nru mantis-0.19.0.orig/bug_report_mail.php mantis-0.19.0/bug_report_mail.php
--- mantis-0.19.0.orig/bug_report_mail.php Thu Jan 1 01:00:00 1970
+++ mantis-0.19.0/bug_report_mail.php Wed Sep 15 17:29:41 2004
@@ -0,0 +1,33 @@
+
+
diff -Nru mantis-0.19.0.orig/config_defaults_inc.php mantis-0.19.0/config_defaults_inc.php
--- mantis-0.19.0.orig/config_defaults_inc.php Sun Sep 12 14:12:30 2004
+++ mantis-0.19.0/config_defaults_inc.php Wed Sep 15 17:27:55 2004
@@ -1335,4 +1335,20 @@
# Enable support for bug relationships where a bug can be a related, dependent on, or duplicate of another.
# See relationship_api.php for more details.
$g_enable_relationship = ON;
+
+ ######################
+ # Mail Reporting
+ ######################
+
+ # --- mail reporting settings -----
+ # This tells Mantis to report all the Mail with only one account
+ $g_mail_use_reporter = ON;
+
+ # The account's name for mail reporting
+ # Also used for fallback if a user is not found in database
+ $g_mail_reporter = 'Mail';
+
+ # Signup new users automatically (possible security risk!)
+ # Default is OFF, ignored if mail_use_reporter is ON
+ $g_mail_auto_signup = OFF;
?>
diff -Nru mantis-0.19.0.orig/config_inc.php mantis-0.19.0/config_inc.php
--- mantis-0.19.0.orig/config_inc.php Sun Sep 12 16:03:14 2004
+++ mantis-0.19.0/config_inc.php Wed Sep 15 17:28:04 2004
@@ -49,4 +49,17 @@
# The default value is ON but you must make sure file uploading is enabled
# in PHP as well. You may need to add "file_uploads = TRUE" to your php.ini.
$g_allow_file_upload = ON;
+
+ # --- mail reporting settings -----
+ # This tells Mantis to report all the Mail with only one account
+ $g_mail_use_reporter = OFF;
+
+ # The account's name for mail reporting
+ # Also used for fallback if a user is not found in database
+ $g_mail_reporter = 'Mail';
+
+ # Signup new users automatically (possible security risk!)
+ # Default is OFF, ignored if mail_use_reporter is ON
+ $g_mail_auto_signup = ON;
+
?>
diff -Nru mantis-0.19.0.orig/core/mail_api.php mantis-0.19.0/core/mail_api.php
--- mantis-0.19.0.orig/core/mail_api.php Thu Jan 1 01:00:00 1970
+++ mantis-0.19.0/core/mail_api.php Wed Sep 15 17:20:27 2004
@@ -0,0 +1,222 @@
+connect($t_pop3_host, 110);
+ $t_pop3->login($t_pop3_user, $t_pop3_password);
+
+ for ($i = 1; $i <= $t_pop3->numMsg(); $i++) {
+ $t_mail = $t_pop3->getParsedHeaders($i);
+ $t_mail['X-Mantis-Body'] = $t_pop3->getBody($i);
+ $t_mail['X-Mantis-Complete'] = $t_pop3->getMsg($i);
+ array_push($v_mails, $t_mail);
+ #$t_pop3->deleteMsg($i);
+ }
+
+ $t_pop3->disconnect();
+ return $v_mails;
+ }
+
+ # --------------------
+ # return the mailadress from the mail's 'From'
+ function mail_parse_address ( $p_mailaddress ) {
+ if (preg_match("/<(.*?)>/", $p_mailaddress, $matches)) {
+ $c_mailaddress = $matches[1];
+ }
+
+ return $c_mailaddress;
+ }
+
+ # --------------------
+ # return the a valid username from an email address
+ function mail_user_name_from_address ( $p_mailaddress ) {
+
+ return preg_replace("/[@\.-]/", '_', $p_mailaddress);
+ }
+
+ # --------------------
+ # return true if there is a valid mantis bug referernce in subject
+ function mail_is_a_bugnote ($p_mail_subject) {
+ return preg_match("/\[([A-Za-z0-9-_\.]*\s[0-9]{7})\]/", $p_mail_subject);
+ }
+
+ # --------------------
+ # return the bug's id from the subject
+ function mail_get_bug_id_from_subject ( $p_mail_subject) {
+ preg_match("/\[([A-Za-z0-9-_\.]*\s([0-9]{7}?))\]/", $p_mail_subject, $v_matches);
+
+ return $v_matches[2];
+ }
+
+ # --------------------
+ # return the user id for the mail reporting user
+ function mail_get_user ($p_mailaddress) {
+ $t_mail_use_reporter = config_get( 'mail_use_reporter' );
+ $t_mail_auto_signup = config_get( 'mail_auto_signup' );
+ $t_mail_reporter = config_get( 'mail_reporter' );
+
+ $c_mailaddress = mail_parse_address( $p_mailaddress );
+
+ if ( $t_mail_use_reporter ) {
+ // Always report as mail_reporter
+ $t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+ } else {
+ // Try to get the reporting users id
+ $t_reporter_id = user_get_id_by_mail ( $c_mailaddress );
+ if ( ! $t_reporter_id && $t_mail_auto_signup ) {
+ // So, we've to sign up a new user...
+ $t_user_name = mail_user_name_from_address ( $c_mailaddress );
+ user_signup($t_user_name, $c_mailaddress);
+ $t_reporter_id = user_get_id_by_name($t_user_name);
+ } elseif ( ! $t_reporter_id ) {
+ // Fall back to the default mail_reporter
+ $t_reporter_id = user_get_id_by_name( $t_mail_reporter );
+ }
+ }
+
+ return $t_reporter_id;
+ }
+
+ # --------------------
+ # Adds a bug which is reported via email
+ # Taken from bug_report.php and
+ function mail_add_bug( $p_mail, $p_project ) {
+ $t_bug_data = new BugData;
+ $t_bug_data->build = gpc_get_string( 'build', '' );
+ $t_bug_data->platform = gpc_get_string( 'platform', '' );
+ $t_bug_data->os = gpc_get_string( 'os', '' );
+ $t_bug_data->os_build = gpc_get_string( 'os_build', '' );
+ $t_bug_data->version = gpc_get_string( 'product_version', '' );
+ $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 );
+ $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 );
+ $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
+
+ $t_bug_data->category = gpc_get_string( 'category', '' );
+ $t_bug_data->reproducibility = 10;
+ $t_bug_data->severity = 50;
+ $t_bug_data->priority = gpc_get_int( 'priority', NORMAL );
+ $t_bug_data->summary = $p_mail['Subject'];
+ $t_bug_data->description = $p_mail['X-Mantis-Body'];
+ $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', '' );
+ $t_bug_data->additional_information = $p_mail['X-Mantis-Complete'];
+
+ $t_bug_data->project_id = $p_project['id'];
+
+ $t_bug_data->reporter_id = mail_get_user( $p_mail['From'] );
+
+ if (mail_is_a_bugnote($p_mail['Subject']))
+ {
+ # Add a bug note
+ $t_bug_id = mail_get_bug_id_from_subject( $p_mail['Subject'] );
+ if ( ! bug_is_readonly( $t_bug_id ) ) {
+ bugnote_add ( $t_bug_id, $p_mail['X-Mantis-Body'] );
+ email_bugnote_add ( $t_bug_id );
+ }
+ }
+ else
+ {
+ # Create the bug
+ #$t_bug_id = bug_create( $t_bug_data );
+ #email_new_bug( $t_bug_id );
+ }
+
+ }
+
+?>
diff -Nru mantis-0.19.0.orig/core/user_api.php mantis-0.19.0/core/user_api.php
--- mantis-0.19.0.orig/core/user_api.php Mon Aug 23 16:13:34 2004
+++ mantis-0.19.0/core/user_api.php Wed Sep 15 17:20:36 2004
@@ -478,6 +478,27 @@
}
# --------------------
+ # get a user id from an mail address
+ # return false if the mail address does not exist
+ function user_get_id_by_mail( $p_mailaddress ) {
+
+ $c_mailaddress = db_prepare_string( $p_mailaddress );
+
+ $t_user_table = config_get( 'mantis_user_table' );
+
+ $query = "SELECT id
+ FROM $t_user_table
+ WHERE email='$c_mailaddress'";
+ $result = db_query( $query );
+
+ if ( 0 == db_num_rows( $result ) ) {
+ return false;
+ } else {
+ return db_result( $result );
+ }
+ }
+
+ # --------------------
# return all data associated with a particular user name
# return false if the username does not exist
function user_get_row_by_name( $p_username ) {
diff -Nru mantis-0.19.0.orig/doc/README.bug_report_mail mantis-0.19.0/doc/README.bug_report_mail
--- mantis-0.19.0.orig/doc/README.bug_report_mail Thu Jan 1 01:00:00 1970
+++ mantis-0.19.0/doc/README.bug_report_mail Wed Sep 15 17:32:01 2004
@@ -0,0 +1,53 @@
+The current version of bug_report_mail only support plain text e-mails
+and POP3 Mailaccounts with PEAR's Net_POP3 packge.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter your projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+ core/user_api.php
+ manage_proj_edit_page.php
+ config_default_inc.php
+These files are new:
+ core/mail_api.php
+ sql/bug_report_mail.sql
+ bug_report_mail.php
+ manage_proj_mail_delete.php
+ manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure (and default) way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+ $g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+ $g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+ $g_mail_auto_signup = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+
+This line uses lynx to fetch bug reports from via POP3 every 5 minutes.
+
+This addon is distributed under the same condition as Mantis itself.
+
+Gerrit Beine, August 2004
diff -Nru mantis-0.19.0.orig/doc/README.bug_report_mail~ mantis-0.19.0/doc/README.bug_report_mail~
--- mantis-0.19.0.orig/doc/README.bug_report_mail~ Thu Jan 1 01:00:00 1970
+++ mantis-0.19.0/doc/README.bug_report_mail~ Mon Aug 9 23:26:21 2004
@@ -0,0 +1,54 @@
+The current version of bug_report_mail only support plain text e-mails
+and POP3 Mailaccounts with PEAR's Net_POP3 packge.
+
+bug_report_mail is able to recognize if mail is a reply to an already opened
+bug and adds the content as a bugnote.
+
+If you are alway running Mantis you have to alter you projects table
+with the sql/bug_report_mail.sql script.
+If not, you can create the database tables in the way described in
+the doc/INSTALL file.
+
+This patch changes the following files:
+ core/user_api.php
+ manage_proj_edit_page.php
+ config_inc.php.sample
+These files are new:
+ core/mail_api.php
+ sql/bug_report_mail.php
+ bug_report_mail.php
+ manage_proj_mail_delete.php
+ manage_proj_mail_update.php
+
+After installing this patch, you can add a POP3 server's hostname
+and authentication data for each of your projects with the
+project edit form.
+
+There are two ways to receive mail with bug_report_mail:
+The secure way is to use a standard reporting user:
+You have to create a reporter account, for example 'Mail'.
+The name for this reporter account you have to write in your config_inc.php file:
+ $g_mail_reporter = "Mail";
+and then, bug_report_mail must be informed to behave like this:
+ $g_mail_use_reporter = ON;
+
+The other way is to signup new user accounts automatically.
+For using this, you have to change this
+ $g_mail_auto_signup = OFF;
+from OFF to ON.
+Now, bug_report_mail will look for an user named like the mail's sender
+or an user which mail adress is identical.
+If no user is found, then a new account will be created.
+The new user's name will be the mail address.
+
+This could be used for attacks, but there is no other way in the moment.
+
+After this, bug_report_mail can be used via cron like this:
+
+*/5 * * * * lynx --dump http://mantis.homepage.com/bug_report_mail.php
+
+This line uses lynx to fetch bug reports from via POP3 every 5 minutes.
+
+This addon is distributed under the same condition as Mantis itself.
+
+Gerrit Beine, August 2004
diff -Nru mantis-0.19.0.orig/manage_proj_edit_page.php mantis-0.19.0/manage_proj_edit_page.php
--- mantis-0.19.0.orig/manage_proj_edit_page.php Thu Jul 15 00:16:34 2004
+++ mantis-0.19.0/manage_proj_edit_page.php Wed Sep 15 17:30:05 2004
@@ -18,6 +18,7 @@
require_once( $t_core_path . 'version_api.php' );
require_once( $t_core_path . 'custom_field_api.php' );
require_once( $t_core_path . 'icon_api.php' );
+ require_once( $t_core_path . 'mail_api.php' );
?>
@@ -534,4 +537,55 @@
+
+
+
+