Files
2026-10-19 15:22:52 -07:00

337 lines
13 KiB
PHP

<?php
//
// Set the current Database Mode
//
// Override DB mode based on SESSION variable
if (isset($_SESSION) && array_key_exists('db_mode', $_SESSION) && strlen($_SESSION['db_mode'])) {
$currentDBMode = $_SESSION['db_mode'];
// writeLog("config.php: currentDBMode: $currentDBMode");
}
if (!isset($currentDBMode) || $currentDBMode == '') $currentDBMode = "Current";
if ($currentDBMode == 'Standard') $currentDBMode = "Current";
//
// Determine the current URL
//
if (isset($_SERVER['HTTP_HOST']) && strlen($_SERVER['HTTP_HOST'])) {
$prefix = "http://";
if (array_key_exists('HTTPS', $_SERVER)) $prefix = "https://";
$currentHOST = $prefix . strtolower($_SERVER['HTTP_HOST']);
$currentURL = strtolower($_SERVER['HTTP_HOST']);
$http_host = preg_replace("/^www\./","",$currentURL);
if (preg_match("/^backup-/",$http_host)) {
$currentDBMode = "Backup";
$currentURL = preg_replace("/^backup-/","",$currentURL);
}
if (preg_match("/^prev-/",$http_host)) {
$currentDBMode = "Previous";
$currentURL = preg_replace("/^prev-/","",$currentURL);
}
if (preg_match("/^prev2-/",$http_host)) {
$currentDBMode = "Previous2";
$currentURL = preg_replace("/^prev2-/","",$currentURL);
}
if (preg_match("/^prev3-/",$http_host)) {
$currentDBMode = "Previous3";
$currentURL = preg_replace("/^prev3-/","",$currentURL);
}
if (preg_match("/^prev4-/",$http_host)) {
$currentDBMode = "Previous4";
$currentURL = preg_replace("/^prev4-/","",$currentURL);
}
if (preg_match("/^prev5-/",$http_host)) {
$currentDBMode = "Previous5";
$currentURL = preg_replace("/^prev5-/","",$currentURL);
}
if (preg_match("/^demo-/",$http_host)) {
$currentDBMode = "Demo";
$currentURL = preg_replace("/^demo-/","",$currentURL);
}
}
// Argument override of DB mode
if (array_key_exists('db_mode', $_GET) && strlen($_GET['db_mode'])) {
$currentDBMode = $_GET['db_mode'];
$_SESSION['db_mode'] = $currentDBMode;
}
//
// Get set of current databases on server
//
if (isset($_SESSION['UserInfo']['userid']) && $_SESSION['UserInfo']['userid'] == 'superuser') {
$DBS = array();
$fp = fopen("/m/data1/app.hotlunches.net/current-dbs.txt","r");
while (! feof($fp)) {
$entry = trim(fgets($fp, 1000));
$DBS[$entry] = $entry;
}
fclose($fp);
}
//
// MySQL Database Settings
//
$log_agent = false;
$currentDBTitle = $currentDBMode;
switch ($currentDBMode) {
case 'Current':
$db_host = 'localhost';
$db_uname = 'ezssoftwaredb';
$db_pass = 'EZsoftware7785422700@@';
$db_dbname = 'hotlunch';
$log_agent = true;
if (isset($DBS) && is_array($DBS)) {
if ($currentDBMode != 'hotlunch' && $currentDBMode != 'Current') {
if ($DBS[$currentDBMode] == $currentDBMode) {
$db_dbname = $currentDBMode;
$log_agent = false;
}
}
}
break;
case 'Development':
$db_host = 'localhost';
$db_dbname = 'hotlunch';
$db_uname = 'ezssoftwaredb';
$db_pass = 'EZsoftware7785422700@@';
break;
case 'Backup':
$db_host = 'localhost';
$db_dbname = 'hotlunch_backup';
$db_uname = 'ezssoftwaredb';
$db_pass = 'EZsoftware7785422700@@';
break;
case 'Demo':
$db_host = 'localhost';
$db_dbname = 'hotlunch_demo';
$db_uname = 'ezssoftwaredb';
$db_pass = 'EZsoftware7785422700@@';
break;
case 'Previous':
$PrevTime = time() - 60 * 60 * 25;
$currentDBTitle = date("F j, Y",$PrevTime);
$db_host = 'localhost';
$db_dbname = "hotlunch_" . date("Ymd",$PrevTime);
$db_uname = 'ezssoftwaredb';
$db_pass = 'EZsoftware7785422700@@';
$log_agent = true;
break;
case 'Previous2':
$PrevTime = time() - 60 * 60 * (24 * 2 + 1);
$currentDBTitle = date("F j, Y",$PrevTime);
$db_host = 'localhost';
$db_dbname = "hotlunch_" . date("Ymd",$PrevTime);
$db_uname = 'ezssoftwaredb';
$db_pass = 'EZsoftware7785422700@@';
$log_agent = true;
break;
case 'Previous3':
$PrevTime = time() - 60 * 60 * (24 * 3 + 1);
$currentDBTitle = date("F j, Y",$PrevTime);
$db_host = 'localhost';
$db_dbname = "hotlunch_" . date("Ymd",$PrevTime);
$db_uname = 'ezssoftwaredb';
$db_pass = 'EZsoftware7785422700@@';
$log_agent = true;
break;
case 'Previous4':
$PrevTime = time() - 60 * 60 * (24 * 4 + 1);
$currentDBTitle = date("F j, Y",$PrevTime);
$db_host = 'localhost';
$db_dbname = "hotlunch_" . date("Ymd",$PrevTime);
$db_uname = 'ezssoftwaredb';
$db_pass = 'EZsoftware7785422700@@';
$log_agent = true;
break;
case 'Previous5':
$PrevTime = time() - 60 * 60 * (24 * 5 + 1);
$currentDBTitle = date("F j, Y",$PrevTime);
$db_host = 'localhost';
$db_dbname = "hotlunch_" . date("Ymd",$PrevTime);
$db_uname = 'ezssoftwaredb';
$db_pass = 'EZsoftware7785422700@@';
$log_agent = true;
break;
default:
$db_host = 'localhost';
$db_dbname = "hotlunch_$currentDBMode";
$db_uname = 'ezssoftwaredb';
$db_pass = 'EZsoftware7785422700@@';
$log_agent = false;
break;
}
if (!is_file("databases/$db_dbname")) {
$db_dbname = "hotlunch";
$error_message = "Database Not Available";
}
$_SESSION['db_dbname'] = $db_dbname;
$usersTable = 'users';
$userSALT = '$1$ezssoftw$';
$AdminUserTypes = array('SuperUser','System Administrator','Application Administrator','Administration Team');
$AllAdminUserTypes = array('SuperUser','System Administrator','Application Administrator','Communications Administrator','Administration Team','Schedule Team','Financial','Financial Team');
//
// Session and Cookie Settings
// - session timeout 30 minutes
//
$sessionName = 'hotlunch';
$sessionTimeout = 60 * 60;
$cookiePath = '/';
if (session_status() !== PHP_SESSION_ACTIVE) {
session_name($sessionName);
session_start();
}
$QueueDelay = 0;
//
// Form processing
//
$FormTarget = "/";
$aliasesDIR = "/etc/exim/domains";
$currentTemplate = "default.html";
//
// Other parameters
//
$default_table_width = '98%';
$default_data_width = '98%';
$default_form_width = '90%';
$recordsPerPage = 50;
$numberOfPageLinks = 30;
$maxImageDimension = 300;
$maxThumbDimension = 50;
$maxGalleryImageDimension = 600;
$maxGalleryThumbDimension = 150;
$otipHDR = "<table cellpadding='1' cellspacing='1' border='0'>";
$otipROWB = "<tr><td align='right' valign='top'>";
$otipROWM = "</td><td align='left' valign='top'><b>";
$otipROWE = "</b></td></tr>";
$otipFTR = "</table>";
$otipTABLE = "<table cellpadding='1' cellspacing='1' border='0'>";
$otipTABLE300 = "<table width='400' cellpadding='1' cellspacing='1' border='0'>";
$otipTABLE400 = "<table width='400' cellpadding='1' cellspacing='1' border='0'>";
$otipTABLE500 = "<table width='400' cellpadding='1' cellspacing='1' border='0'>";
$otipTABLE600 = "<table width='600' cellpadding='1' cellspacing='1' border='0'>";
$otipTABLE700 = "<table width='700' cellpadding='1' cellspacing='1' border='0'>";
$otipWideTABLE = "<table width='400' cellpadding='1' cellspacing='1' border='0'>";
$otipROW1 = "<tr><td align='%s'>%s</td></tr>";
$otipROW2 = "<tr><td align='right' valign='top'>%s</td><td align='left' valign='top'><b>%s</b></td></tr>";
$otipROW2nb = "<tr><td align='right' valign='top'>%s</td><td align='left' valign='top'>%s</td></tr>";
$otipROW2w = "<tr><td align='right' width='300' valign='top'>%s</td><td align='left' width='400' valign='top'><b>%s</b></td></tr>";
$otipROW21 = "<tr><td align='%s' colspan='2'>%s</td></tr>";
$otipROW21hr = "<tr><td align='center' colspan='2'><hr width='80%'></td></tr>";
$otipCELL = "<td align='%s'>%s</td>";
$otipIMG = "<table cellpadding='1' border='0'><tr><td align='center'><img src='%s' height='%d' width='%d' border='1'></td></tr><tr><td align='center'><b>%s</b></td></tr></table>";
$otipNUTRITION = "<table width='450' cellpadding='2' cellspacing='2' border='0'><tr><td align='center' class='heading'><b>Information</b></td></tr><tr><td>%s</td></tr></table>";
// Character normalization
$normalizeChars = array(chr(192) => 'A', chr(193) => 'A', chr(194) => 'A', chr(195) => 'A', chr(196) => 'A', chr(197) => 'A', chr(198) => 'AE',
chr(199) => 'C', chr(200) => 'E', chr(201) => 'E', chr(202) => 'E', chr(203) => 'E', chr(204) => 'I', chr(205) => 'I',
chr(206) => 'I', chr(207) => 'I', chr(208) => 'D', chr(209) => 'N', chr(210) => 'O', chr(211) => 'O', chr(212) => 'O',
chr(213) => 'O', chr(214) => 'O', chr(215) => '', chr(216) => 'O', chr(217) => 'U', chr(218) => 'U', chr(219) => 'U',
chr(220) => 'U', chr(221) => 'Y', chr(222) => 'p', chr(223) => 'B', chr(224) => 'a', chr(225) => 'a', chr(226) => 'a',
chr(227) => 'a', chr(228) => 'a', chr(229) => 'a', chr(230) => 'ae', chr(231) => 'c', chr(232) => 'e', chr(233) => 'e',
chr(234) => 'e', chr(235) => 'e', chr(236) => 'i', chr(237) => 'i', chr(238) => 'i', chr(239) => 'i', chr(240) => 'o',
chr(241) => 'n', chr(242) => 'o', chr(243) => 'o', chr(244) => 'o', chr(245) => 'o', chr(246) => 'o', chr(247) => '',
chr(248) => 'o', chr(249) => 'u', chr(250) => 'u', chr(251) => 'u', chr(252) => 'u', chr(253) => 'y', chr(254) => 'p',
chr(255) => 'y'
);
//
// Default icon definitions
//
$edit_icon = "<img src='images/icons/edit16.png' alt='Edit' border='0'>";
$delete_icon = "<img src='images/icons/delete16.png' alt='Delete' border='0'>";
$print_icon = "<img src='images/icons/printer16.png' alt='Print' border='0'>";
$filedownload_icon = "<img src='images/icons/filedownload16.png' alt='Download' border='0'>";
$labels_icon = "<img src='images/icons/textfile-bw16.png' alt='Labels' border='0'>";
$view_icon = "<img src='images/icons/find16.png' alt='View' border='0'>";
$accept_icon = "<img src='images/icons/accept16.png' alt='Accept' border='0'>";
$change_icon = "<img src='images/icons/refresh16.png' alt='Change' border='0'>";
$money_icon = "<img src='images/icons/money16.png' alt='Account' border='0'>";
$students_icon = "<img src='images/icons/groupofusers16.png' alt='Manage Students' border='0'>";
$reminder_icon = "<img src='images/icons/mailsend16.png' alt='Send Account Login Reminder Email' border='0'>";
$email_icon = "<img src='images/icons/mailsend16.png' alt='Send Email' border='0'>";
$contact_icon = "<img src='images/icons/userid16.png' alt='View Contact Information' border='0'>";
$clock_icon = "<img src='images/icons/clock16.png' alt='Login Log' border='0'>";
$info_icon = "<img src='images/icons/infoabout16.png' alt='Information' border='0'>";
$open_icon = "<img src='images/icons/folderopenb16.png' alt='Open Folder' border='0'>";
$filesearch_icon = "<img src='images/icons/filesearch16.png' alt='Detail' border='0'>";
$edit_icon_small = "<img src='images/icons/edit16.png' alt='Edit' border='0'>";
$delete_icon_small = "<img src='images/icons/delete16.png' alt='Delete' border='0'>";
$print_icon_small = "<img src='images/icons/printer16.png' alt='Print' border='0'>";
$filedownload_icon_small = "<img src='images/icons/filedownload16.png' alt='Download' border='0'>";
$labels_icon_small = "<img src='images/icons/textfile-bw16.png' alt='Labels' border='0'>";
$view_icon_small = "<img src='images/icons/find16.png' alt='View' border='0'>";
$accept_icon_small = "<img src='images/icons/accept16.png' alt='Accept' border='0'>";
$change_icon_small = "<img src='images/icons/refresh16.png' alt='Change' border='0'>";
$money_icon_small = "<img src='images/icons/money16.png' alt='Account' border='0'>";
$students_icon_small = "<img src='images/icons/groupofusers16.png' alt='Manage Students' border='0'>";
$reminder_icon_small = "<img src='images/icons/mailsend16.png' alt='Send Account Login Reminder Email' border='0'>";
$email_icon_small = "<img src='images/icons/mailsend16.png' alt='Send Email' border='0'>";
$contact_icon_small = "<img src='images/icons/userid16.png' alt='View Contact Information' border='0'>";
$clock_icon_small = "<img src='images/icons/clock16.png' alt='Login Log' border='0'>";
$info_icon_small = "<img src='images/icons/infoabout16.png' alt='Information' border='0'>";
$open_icon_small = "<img src='images/icons/folderopenb16.png' alt='Open Folder' border='0'>";
$filesearch_icon_small = "<img src='images/icons/filesearch16.png' alt='Detail' border='0'>";
$file_icon_small = "<img src='images/icons/textfile16.png' alt='Form' border='0'>";
$users_icon_small = "<img src='images/icons/groupofusers16.png' alt='Manage Users' border='0'>";
$order_icon_small = "<img src='images/icons/textfile16.png' alt='View Order' border='0'>";
if (array_key_exists('REMOTE_ADDR',$_SERVER)) $user_ip = $_SERVER["REMOTE_ADDR"];
$markIP = "187.191.8.250";
?>