diff --git a/includes/general.php b/includes/general.php index 735f3578..91844ffe 100644 --- a/includes/general.php +++ b/includes/general.php @@ -554,10 +554,27 @@ function signmail($to, $subject, $message, $from, $replyto = "") function checkEmail($email) { + if ( is_devmode() ) { + return "OK" ; + } + $myemail = mysql_real_escape_string($email); if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\+\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $email)) { list($username,$domain)=explode('@',$email,2); + + /* + * Check if the MX_WHITELIST environment variable is set, + * and, if so, see if it contains the domain name for + * this e-mail address. + */ + if ( strlen( getenv( "MX_WHITELIST" )) > 0 ) { + $whitelist_arr = explode( ",", getenv( "MX_WHITELIST" )) ; + if ( in_array( $domain, $whitelist_arr ) ) { + return "OK" ; + } + } + $mxhostrr = array(); $mxweight = array(); if( !getmxrr($domain, $mxhostrr, $mxweight) ) { @@ -592,10 +609,10 @@ function checkEmail($email) { $fp_opt = array( 'ssl' => array( - 'verify_peer' => false, // Opportunistic Encryption - 'verify_peer_name' => false, // Opportunistic Encryption - ) - ); + 'verify_peer' => false, // Opportunistic Encryption + 'verify_peer_name' => false, // Opportunistic Encryption + ) + ); $fp_ctx = stream_context_create($fp_opt); $fp = @stream_socket_client("tcp://$domain:25",$errno,$errstr,5,STREAM_CLIENT_CONNECT,$fp_ctx); if($fp) @@ -678,7 +695,7 @@ function checkEmail($email) } } $query = "insert into `pinglog` set `when`=NOW(), `uid`='".intval($_SESSION['profile']['id'])."', - `email`='$myemail', `result`='Failed to make a connection to the mail server'"; + `email`='$myemail', `result`='Failed to make a connection to the mail server'"; mysql_query($query); return _("Failed to make a connection to the mail server"); } @@ -819,6 +836,40 @@ function sanitizeFilename($text) return($text); } + /** + * Test whether the MODE environment variable + * is set to DEV. + */ + function is_devmode() { + return( getenv( "MODE" ) == "DEV" ) ; + } + + /** + * Test whether the MODE environment variable + * is set to PROD. + * + * If it is not set at all, assume PROD. + */ + function is_prodmode() { + $prod_mode == false ; + + $is_prod = getenv( "MODE" ) == "PROD" ; + if ( ! $is_prod && ! ( getenv( "MODE" ) == "DEV" ) ) { + $prod_mode = true ; + } + + return $prod_mode ; + } + + /** + * Test whether the MODE environment variable + * is set to TEST. + */ + function is_testmode() { + return ( getenv( "MODE" ) == "TEST" ) ; + } + + // returns text message to be shown to the user given the result of is_no_assurer function no_assurer_text($Status)