110 lines
2.9 KiB
PHP
110 lines
2.9 KiB
PHP
<?php
|
|
include "/m/data1/app.hotlunches.net/db.php";
|
|
|
|
$URLs = array(
|
|
"fundraiserorders.com",
|
|
"happymeals.ca",
|
|
"parentcouncil.net",
|
|
"payschoolfees.net",
|
|
"registrationnow.net",
|
|
"schoolcouncil.net",
|
|
"schoolsuppliesorder.com",
|
|
"schoolcouncil.net",
|
|
"hotlunches.net",
|
|
);
|
|
|
|
|
|
|
|
$time = date("H",time());
|
|
if ($time == '06') {
|
|
$query = "SELECT * FROM schools WHERE status IN ('Active','Linked','Special')";
|
|
}
|
|
else {
|
|
$query = "SELECT * FROM schools WHERE status IN ('Active','Linked','Special') AND (base_url = '' OR base_url IS NULL)";
|
|
}
|
|
$schools = db_query($query);
|
|
|
|
while ($row = db_fetch_assoc($schools)) {
|
|
$url = $row['url'];
|
|
$rnum = $row['record_num'];
|
|
|
|
$URLparts = explode('.',$url);
|
|
if (count($URLparts) != 3) {
|
|
$base_url = $url;
|
|
}
|
|
else {
|
|
$base_url = $URLparts[1].'.'.$URLparts[2];
|
|
}
|
|
|
|
$query = "UPDATE schools SET base_url = '$base_url' WHERE record_num = $rnum";
|
|
db_query($query);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start the aliases file
|
|
$Header = "";
|
|
$fp = fopen("/m/data1/app.hotlunches.net/default.aliases.txt","r");
|
|
while (!feof($fp)) {
|
|
$text = trim(fgets($fp,1000));
|
|
$Header .= "$text\n";
|
|
}
|
|
fclose($fp);
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($URLs); $i++) {
|
|
$currentURL = $URLs[$i];
|
|
$cHeader = str_replace("payschoolfees.net",$currentURL,$Header);
|
|
|
|
|
|
// Get school records
|
|
$query = "SELECT * FROM schools " .
|
|
"WHERE status IN ('Active','Linked','Special') " .
|
|
"AND base_url = '{$currentURL}' " .
|
|
"AND (reply_email LIKE '%@%' OR support_email LIKE '%@%') " .
|
|
"ORDER BY school_name";
|
|
$query = "SELECT * FROM schools " .
|
|
"WHERE status IN ('Active','Linked','Special') " .
|
|
"AND base_url = '{$currentURL}' " .
|
|
"AND (reply_email LIKE '%@%' OR support_email LIKE '%@%') " .
|
|
"ORDER BY school_name";
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results)) {
|
|
|
|
echo("$currentURL\n");
|
|
|
|
$fp = fopen("/etc/exim/domains/{$currentURL}.aliases","w");
|
|
fwrite($fp,$cHeader);
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
$school_name = $school_name;
|
|
|
|
$schoolID = $default_url_code;
|
|
$email = trim($support_email);
|
|
if (strlen($email) == 0) $email = trim($reply_email);
|
|
$email = str_replace(' ','',$email);
|
|
$email = str_replace(';',',',$email);
|
|
|
|
fwrite($fp,"# $school_name\n");
|
|
fwrite($fp,"$schoolID: $email\n");
|
|
|
|
if (isset($volunteer_reminder_email) && !is_null($volunteer_reminder_email) && strlen(trim($volunteer_reminder_email))) {
|
|
fwrite($fp,"volunteer.$schoolID: ".trim($volunteer_reminder_email)."\n");
|
|
}
|
|
|
|
fwrite($fp,"\n");
|
|
}
|
|
|
|
fwrite($fp,"webmaster: mfester\n");
|
|
fwrite($fp,"dmarc: dmarc\n");
|
|
fwrite($fp,"\n");
|
|
fclose($fp);
|
|
}
|
|
}
|
|
|
|
?>
|