Skip to content

Commit 79bcc9d

Browse files
committed
Adding environment variables and environment config
1 parent 8033887 commit 79bcc9d

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

inc/config.env.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
$get_env = function (&$var, $default = null) {
4+
return !empty($var) ? $var : $default;
5+
};
6+
7+
////////////////////////////////////////////////////////////////////////////
8+
// DATABASE CONFIG
9+
10+
$COOKIE_STORE = $get_env(getenv("COOKIE_STORE"), '/tmp/siscookies.txt');
11+
$DATABASE_SERVER = $get_env(getenv("DATABASE_SERVER"), 'mysql.csh.rit.edu');
12+
$DATABASE_USER = $get_env(getenv("DATABASE_USER"), '');
13+
$DATABASE_PASS = $get_env(getenv("DATABASE_PASS"), '');
14+
$DATABASE_DB = $get_env(getenv("DATABASE_DB"), '');
15+
$DUMPCLASSES = '/mnt/share/cshclass.dat';
16+
$DUMPCLASSATTR = '/mnt/share/cshattrib.dat';
17+
$DUMPINSTRUCT = '/mnt/share/cshinstr.dat';
18+
$DUMPMEETING = '/mnt/share/cshmtgpat.dat';
19+
$DUMPNOTES = '/mnt/share/cshnotes.dat';
20+
21+
$HTTPROOTADDRESS = $get_env(getenv("HTTPROOTADDRESS"), 'http://schedule.csh.rit.edu/');
22+
$SERVER_TYPE = $get_env(getenv("SERVER_TYPE"), 'development');
23+
24+
////////////////////////////////////////////////////////////////////////////
25+
//// APP VERSIONS
26+
$APP_CONFIG = json_decode(file_get_contents((empty($APP_ROOT)?"../":$APP_ROOT)."package.json"), true);
27+
$APP_VERSION = $APP_CONFIG['version'];
28+
$JSSTATE_VERSION = $APP_CONFIG['config']['stateVersion'];
29+
30+
31+
////////////////////////////////////////////////////////////////////////////
32+
////// GOOGLE ANALYTICS
33+
////
34+
$GOOGLEANALYTICS = ($SERVER_TYPE == 'production')?
35+
$get_env(getenv("GOOGLEANALYTICS1"), ''):
36+
$get_env(getenv("GOOGLEANALYTICS2"), '');
37+
//
38+
39+
////////////////////////////////////////////////////////////////////////////
40+
// WORK AROUNDS
41+
if (get_magic_quotes_gpc()) {
42+
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
43+
while (list($key, $val) = each($process)) {
44+
foreach ($val as $k => $v) {
45+
unset($process[$key][$k]);
46+
if (is_array($v)) {
47+
$process[$key][stripslashes($k)] = $v;
48+
$process[] = &$process[$key][stripslashes($k)];
49+
} else {
50+
$process[$key][stripslashes($k)] = stripslashes($v);
51+
}
52+
}
53+
}
54+
unset($process);
55+
}
56+
////////////////////////////////////////////////////////////////////////////
57+
// CALCULATIONS
58+
59+
// Calculate the current quarter
60+
switch(date('n')) {
61+
case 2:
62+
case 3:
63+
$CURRENT_QUARTER = date("Y")-1 . '3'; // Point them to the spring
64+
break;
65+
case 4:
66+
case 5:
67+
case 6:
68+
case 7:
69+
case 8:
70+
case 9:
71+
$CURRENT_QUARTER = date("Y") . '1'; // Point them to the fall
72+
break;
73+
case 10:
74+
case 11:
75+
case 12:
76+
case 1:
77+
$CURRENT_QUARTER = date("Y") . '2'; // Point them to the summer
78+
break;
79+
}
80+
81+
////////////////////////////////////////////////////////////////////////////
82+
// SESSION
83+

index.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818

1919
// REQUIRED FILES
2020
$APP_ROOT = "./";
21-
require_once('./inc/config.php');
21+
if (file_exists('./inc/config.php')) {
22+
require_once('./inc/config.php');
23+
} else {
24+
require_once('./inc/config.env.php');
25+
}
2226
require_once('./inc/databaseConn.php');
2327
require_once('./inc/timeFunctions.php');
2428

0 commit comments

Comments
 (0)