Use __DIR__ magic constant instead of environment variable
This commit is contained in:
parent
6dff727f35
commit
1ad482978d
|
@ -6,8 +6,6 @@ KEY=''
|
||||||
# Delivery address is the original email before the "@". e.g. if delivering to "support_mt@mayfirst.org", set this to "support_mt"
|
# Delivery address is the original email before the "@". e.g. if delivering to "support_mt@mayfirst.org", set this to "support_mt"
|
||||||
DELIVERY_ADDRESS='support_mt'
|
DELIVERY_ADDRESS='support_mt'
|
||||||
CATCHALL_PROJECT_NAME='catch'
|
CATCHALL_PROJECT_NAME='catch'
|
||||||
# The path to the root directory containing this file.
|
|
||||||
FILEPATH='/usr/local/bin/redirect_test'
|
|
||||||
# Leave these three blank for false.
|
# Leave these three blank for false.
|
||||||
DEBUG_MODE=
|
DEBUG_MODE=
|
||||||
DRY_RUN=
|
DRY_RUN=
|
||||||
|
|
|
@ -20,7 +20,7 @@ $membershipMapping = getUserMemberships($userList, $client);
|
||||||
writeUsers($projectsById, $membershipMapping);
|
writeUsers($projectsById, $membershipMapping);
|
||||||
|
|
||||||
function writeDomains($projectsByDomain) {
|
function writeDomains($projectsByDomain) {
|
||||||
$domainHandle = fopen('./data/domainmap.csv', 'w');
|
$domainHandle = fopen(__DIR__ . '/data/domainmap.csv', 'w');
|
||||||
foreach ($projectsByDomain as $domain => $identifier) {
|
foreach ($projectsByDomain as $domain => $identifier) {
|
||||||
fwrite ($domainHandle, "$domain,$identifier\n");
|
fwrite ($domainHandle, "$domain,$identifier\n");
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ function writeDomains($projectsByDomain) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeUsers($projectsById, $membershipMapping) {
|
function writeUsers($projectsById, $membershipMapping) {
|
||||||
$userHandle = fopen('./data/usermap.csv', 'w');
|
$userHandle = fopen(__DIR__ . '/data/usermap.csv', 'w');
|
||||||
foreach ($membershipMapping as $email => $projectId) {
|
foreach ($membershipMapping as $email => $projectId) {
|
||||||
fwrite ($userHandle, "$email,{$projectsById[$projectId]}\n");
|
fwrite ($userHandle, "$email,{$projectsById[$projectId]}\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,12 +155,11 @@ function SendToMailHandler($input, $params) {
|
||||||
|
|
||||||
//See if this email address is associated with a particular project
|
//See if this email address is associated with a particular project
|
||||||
function ParseSenderEmail($from) {
|
function ParseSenderEmail($from) {
|
||||||
$filePath = getenv('FILEPATH');
|
|
||||||
$project = $email = NULL;
|
$project = $email = NULL;
|
||||||
if(preg_match("/\b([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4})\b/i", $from, $matches)) {
|
if(preg_match("/\b([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4})\b/i", $from, $matches)) {
|
||||||
$email = $matches[1];
|
$email = $matches[1];
|
||||||
}
|
}
|
||||||
if (($handle = fopen($filePath . "/" . "data/usermap.csv", 'r')) !== FALSE) {
|
if (($handle = fopen(__DIR__ . "/" . "data/usermap.csv", 'r')) !== FALSE) {
|
||||||
while (($data = fgetcsv($handle, 1000)) !== FALSE) {
|
while (($data = fgetcsv($handle, 1000)) !== FALSE) {
|
||||||
$users[$data[0]] = $data[1];
|
$users[$data[0]] = $data[1];
|
||||||
}
|
}
|
||||||
|
@ -172,12 +171,11 @@ function ParseSenderEmail($from) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ParseSenderDomain($email) {
|
function ParseSenderDomain($email) {
|
||||||
$filePath = getenv('FILEPATH');
|
|
||||||
$domain = $project = NULL;
|
$domain = $project = NULL;
|
||||||
if(preg_match("/@(.*)\b/", $email, $matches)) {
|
if(preg_match("/@(.*)\b/", $email, $matches)) {
|
||||||
$domain = $matches[1];
|
$domain = $matches[1];
|
||||||
}
|
}
|
||||||
if (($handle = fopen($filePath . "/" . "data/domainmap.csv", 'r')) !== FALSE) {
|
if (($handle = fopen(__DIR__ . "/" . "data/domainmap.csv", 'r')) !== FALSE) {
|
||||||
while (($data = fgetcsv($handle, 1000)) !== FALSE) {
|
while (($data = fgetcsv($handle, 1000)) !== FALSE) {
|
||||||
$domains[$data[0]] = $data[1];
|
$domains[$data[0]] = $data[1];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue