diff --git a/redirect.php b/redirect.php index f8722dd..23ad901 100755 --- a/redirect.php +++ b/redirect.php @@ -75,7 +75,7 @@ if($from == 'Google Calendar ') { // If we don't know the project yet, attempt to determine it from the complete email address. if(!$project) { - $project = ParseSenderEmail($from); + $project = ParseSenderEmail($from); } // Still no project? Check the domain of the sender. if(!$project) { @@ -155,35 +155,35 @@ function SendToMailHandler($input, $params) { //See if this email address is associated with a particular project function ParseSenderEmail($from) { + $filePath = getenv('FILEPATH'); $project = $email = NULL; if(preg_match("/\b([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4})\b/i", $from, $matches)) { $email = $matches[1]; } - switch($email) { - case "ezra.berkley.nepon@gmail.com ": - $project = "astraea"; - break; - //the following emails will not go into Redmine, and will cause an NDR to go to the sender. - case "billing@linode.com": - echo "dying"; - die; + if (($handle = fopen($filePath . "/" . "data/usermap.csv", 'r')) !== FALSE) { + while (($data = fgetcsv($handle, 1000)) !== FALSE) { + $users[$data[0]] = $data[1]; + } + } + if ($users[$email]) { + $project = $users[$email]; } return $project; } function ParseSenderDomain($email) { + $filePath = getenv('FILEPATH'); $domain = $project = NULL; if(preg_match("/@(.*)\b/", $email, $matches)) { $domain = $matches[1]; } - switch($domain) { - case "legalmomentum.org": - $project = "lm-tech"; - break; - //put spam domain entries here - case "allverbia.xyz": - echo "dying"; - die; + if (($handle = fopen($filePath . "/" . "data/domainmap.csv", 'r')) !== FALSE) { + while (($data = fgetcsv($handle, 1000)) !== FALSE) { + $domains[$data[0]] = $data[1]; + } + } + if($domains[$domain]) { + $project = $domains[$domain]; } return $project; }