Skip to content

Commit

Permalink
added better email checking
Browse files Browse the repository at this point in the history
git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@200 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Kenzaburo Ito committed Feb 14, 2001
1 parent 522fea2 commit efa07c8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
9 changes: 6 additions & 3 deletions config_inc.php
Expand Up @@ -79,10 +79,13 @@

# Allow email
$g_enable_email_notification = 1;

# set to 0 to disable email check
$g_validate_email = 1;
#--------------------

#--------------------
# time for coookie to live in seconds
# time for 'permanent' cookie to live in seconds
$g_cookie_time_length = 30000000; # 1 year
# time to delay between page redirects
$g_wait_time = 2; # in seconds
Expand Down Expand Up @@ -344,6 +347,6 @@

#--------------------
#version
$g_mantis_version = "0.14.0";
$g_mantis_version = "0.14.0";
#--------------------
?>
?>
39 changes: 29 additions & 10 deletions core_API.php
Expand Up @@ -571,7 +571,7 @@ function print_category_option_list( $p_category="" ) {
$row = db_fetch_array( $result );
$t_category = $row["category"];
if ( $t_category==$p_category ) {
PRINT "<option value=\"$t_category\">$t_category";
PRINT "<option value=\"$t_category\" SELECTED>$t_category";
} else {
PRINT "<option value=\"$t_category\">$t_category";
}
Expand Down Expand Up @@ -1018,8 +1018,7 @@ function index_login_cookie_check( $p_redirect_url="" ) {

### go to redirect
if ( !empty( $p_redirect_url ) ) {
#header( "Location: $p_redirect_url" );
header( "Location: $g_logout_page" );
header( "Location: $p_redirect_url" );
exit;
}
### continue with current page
Expand Down Expand Up @@ -1483,22 +1482,29 @@ function email_build_bugnote_message( $p_bug_id ) {
$t_message = $t_message."-----------------------------------------------------------------------\n";
$t_message = $t_message.$t_note."\n\n";
}
$t_message = $t_message."-----------------------------------------------------------------------\n";

$t_message = stripslashes( $t_message );
return $t_message;
}
### --------------------
### Send bug info to reporter and handler
function email_bug_info( $p_bug_id, $p_message ) {
global $g_mantis_user_table, $g_mantis_bug_table;
global $g_mantis_user_table, $g_mantis_bug_table, $g_mantis_project_table;

### Get Subject
$query = "SELECT summary
$query = "SELECT project_id, summary
FROM $g_mantis_bug_table
WHERE id='$p_bug_id'";
$result = db_query( $query );
$p_subject = db_result( $result, 0, 0 );
$row = db_fetch_array( $result );
$p_subject = $row["summary"];
$t_project_id = $row["project_id"];

$query = "SELECT name
FROM $g_mantis_project_table
WHERE id='$t_project_id'";
$result = db_query( $query );
$t_project_name = db_result( $result, 0, 0 );

### Get Reporter and Handler IDs
$query = "SELECT reporter_id, handler_id
Expand All @@ -1524,6 +1530,9 @@ function email_bug_info( $p_bug_id, $p_message ) {
$t_handler_email = db_result( $result, 0, 0 );
}

### Build subject
$p_subject = "[".$t_project_name." ".$p_bug_id."]: ".$p_subject;

### build message
$t_message = $p_message."\n";
$t_message .= email_build_bug_message( $p_bug_id );
Expand Down Expand Up @@ -1585,15 +1594,25 @@ function email_send( $p_recipient, $p_subject, $p_message ) {
### --------------------
# check to see that the format is valid and that the mx record exists
function is_valid_email( $p_email ) {
global $g_validate_email;

### if we don't validate then just accept
if ( $g_validate_email==0 ) {
return true;
}

if (eregi("^[_\.0-9a-z-]+@([0-9a-z][-0-9a-z\.]+)\.([a-z]{2,3}$)", $p_email, $check)) {
if (getmxrr($check[1].".".$check[2], $temp)) {
return true;
} else {
return false;
$host = substr(strstr($check[0], '@'), 1).".";
#### for no mx record... try dns
if (checkdnsrr ( $host, "ANY" ))
return true;
}
} else {
return false;
}
### Everything failed. Bad email.
return false;
}
### --------------------
###########################################################################
Expand Down

0 comments on commit efa07c8

Please sign in to comment.