From 79bcc9d9e9bb7b3bf015d82675aecb1fbf336555 Mon Sep 17 00:00:00 2001 From: Devin Matte Date: Thu, 12 Apr 2018 17:34:24 -0400 Subject: [PATCH 1/5] Adding environment variables and environment config --- inc/config.env.php | 83 ++++++++++++++++++++++++++++++++++++++++++++++ index.php | 6 +++- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 inc/config.env.php diff --git a/inc/config.env.php b/inc/config.env.php new file mode 100644 index 0000000..14564d8 --- /dev/null +++ b/inc/config.env.php @@ -0,0 +1,83 @@ + $v) { + unset($process[$key][$k]); + if (is_array($v)) { + $process[$key][stripslashes($k)] = $v; + $process[] = &$process[$key][stripslashes($k)]; + } else { + $process[$key][stripslashes($k)] = stripslashes($v); + } + } + } + unset($process); +} +//////////////////////////////////////////////////////////////////////////// +// CALCULATIONS + +// Calculate the current quarter +switch(date('n')) { + case 2: + case 3: + $CURRENT_QUARTER = date("Y")-1 . '3'; // Point them to the spring + break; + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + $CURRENT_QUARTER = date("Y") . '1'; // Point them to the fall + break; + case 10: + case 11: + case 12: + case 1: + $CURRENT_QUARTER = date("Y") . '2'; // Point them to the summer + break; +} + +//////////////////////////////////////////////////////////////////////////// +// SESSION + diff --git a/index.php b/index.php index 54933e9..bd45f25 100644 --- a/index.php +++ b/index.php @@ -18,7 +18,11 @@ // REQUIRED FILES $APP_ROOT = "./"; -require_once('./inc/config.php'); +if (file_exists('./inc/config.php')) { + require_once('./inc/config.php'); +} else { + require_once('./inc/config.env.php'); +} require_once('./inc/databaseConn.php'); require_once('./inc/timeFunctions.php'); From 027636f515e4a15939d5691d6c0d01fc2f0bb8c1 Mon Sep 17 00:00:00 2001 From: Devin Matte Date: Thu, 12 Apr 2018 17:37:59 -0400 Subject: [PATCH 2/5] Adding database config --- inc/databaseConn.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/inc/databaseConn.php b/inc/databaseConn.php index 3cad8e9..66455dd 100644 --- a/inc/databaseConn.php +++ b/inc/databaseConn.php @@ -9,7 +9,11 @@ //////////////////////////////////////////////////////////////////////////// // Bring in the config data -require_once dirname(__FILE__) . "/config.php"; +if (file_exists(dirname(__FILE__) . "/config.php")) { + require_once dirname(__FILE__) . "/config.php"; +} else { + require_once dirname(__FILE__) . "/config.env.php"; +} // There is no better place to put this, as all pages require this file. From dd0a74b7f56bbb2a1c88bc1659a0c19835227a4a Mon Sep 17 00:00:00 2001 From: Devin Matte Date: Thu, 12 Apr 2018 17:42:44 -0400 Subject: [PATCH 3/5] New Docker Container --- Dockerfile | 30 ++++++++++++++++++++++++++++++ apache-config.conf | 15 +++++++++++++++ api/entity.php | 6 +++++- api/generate.php | 6 +++++- api/schedule.php | 6 +++++- api/search.php | 6 +++++- inc/config.env.php | 9 +++------ 7 files changed, 68 insertions(+), 10 deletions(-) create mode 100644 Dockerfile create mode 100644 apache-config.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0939d7e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM php:7.1-apache +MAINTAINER Devin Matte + +EXPOSE 8080 +EXPOSE 8443 + +RUN a2enmod rewrite && a2enmod headers && a2enmod expires + +RUN sed -i '/Listen/{s/\([0-9]\+\)/8080/; :a;n; ba}' /etc/apache2/ports.conf + +ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf + +RUN apt-get -yq update && \ + apt-get -yq install gnupg libmagickwand-dev --no-install-recommends + +RUN docker-php-ext-install mysqli +RUN pecl install imagick && docker-php-ext-enable imagick + +COPY . /var/www/html + +RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - && \ + apt-get -yq update && \ + apt-get -yq install nodejs && \ + npm install && \ + npm run-script build && \ + rm -rf node_modules && \ + apt-get -yq remove nodejs npm && \ + apt-get -yq clean all + +RUN chmod og+rwx /var/lock/apache2 && chmod -R og+rwx /var/run/apache2 diff --git a/apache-config.conf b/apache-config.conf new file mode 100644 index 0000000..c1bc66a --- /dev/null +++ b/apache-config.conf @@ -0,0 +1,15 @@ + + ServerAdmin webmaster@csh.rit.edu + DocumentRoot /var/www/html + + + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order deny,allow + Allow from all + + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + diff --git a/api/entity.php b/api/entity.php index d34b828..7744e3d 100644 --- a/api/entity.php +++ b/api/entity.php @@ -10,7 +10,11 @@ //////////////////////////////////////////////////////////////////////////// // REQUIRED FILES ////////////////////////////////////////////////////////// -require_once "../inc/config.php"; +if (file_exists('../inc/config.php')) { + require_once "../inc/config.php"; +} else { + require_once "../inc/config.env.php"; +} require_once "../inc/databaseConn.php"; require_once "../inc/timeFunctions.php"; require_once "../inc/ajaxError.php"; diff --git a/api/generate.php b/api/generate.php index f08c0a9..d192d9c 100644 --- a/api/generate.php +++ b/api/generate.php @@ -10,7 +10,11 @@ //////////////////////////////////////////////////////////////////////////// // REQUIRED FILES -require_once "../inc/config.php"; +if (file_exists('../inc/config.php')) { + require_once "../inc/config.php"; +} else { + require_once "../inc/config.env.php"; +} require_once "../inc/databaseConn.php"; require_once "../inc/timeFunctions.php"; require_once "../inc/ajaxError.php"; diff --git a/api/schedule.php b/api/schedule.php index 07ad92d..c3c1c14 100644 --- a/api/schedule.php +++ b/api/schedule.php @@ -9,7 +9,11 @@ //////////////////////////////////////////////////////////////////////////// // REQUIRED FILES ////////////////////////////////////////////////////////// -require_once('../inc/config.php'); +if (file_exists('../inc/config.php')) { + require_once "../inc/config.php"; +} else { + require_once "../inc/config.env.php"; +} require_once('../inc/databaseConn.php'); require_once('../inc/timeFunctions.php'); diff --git a/api/search.php b/api/search.php index 7841702..da9782d 100644 --- a/api/search.php +++ b/api/search.php @@ -25,7 +25,11 @@ function assertNumeric($var, $name) { } // REQUIRED FILES ////////////////////////////////////////////////////////// -require_once "../inc/config.php"; +if (file_exists('../inc/config.php')) { + require_once "../inc/config.php"; +} else { + require_once "../inc/config.env.php"; +} require_once "../inc/databaseConn.php"; require_once "../inc/timeFunctions.php"; require_once "../inc/ajaxError.php"; diff --git a/inc/config.env.php b/inc/config.env.php index 14564d8..f0ed34a 100644 --- a/inc/config.env.php +++ b/inc/config.env.php @@ -9,9 +9,9 @@ $COOKIE_STORE = $get_env(getenv("COOKIE_STORE"), '/tmp/siscookies.txt'); $DATABASE_SERVER = $get_env(getenv("DATABASE_SERVER"), 'mysql.csh.rit.edu'); -$DATABASE_USER = $get_env(getenv("DATABASE_USER"), ''); -$DATABASE_PASS = $get_env(getenv("DATABASE_PASS"), ''); -$DATABASE_DB = $get_env(getenv("DATABASE_DB"), ''); +$DATABASE_USER = $get_env(getenv("DATABASE_USER"), 'schedule_matted'); +$DATABASE_PASS = $get_env(getenv("DATABASE_PASS"), '47MxO5KNav1xInNG'); +$DATABASE_DB = $get_env(getenv("DATABASE_DB"), 'schedule_matted'); $DUMPCLASSES = '/mnt/share/cshclass.dat'; $DUMPCLASSATTR = '/mnt/share/cshattrib.dat'; $DUMPINSTRUCT = '/mnt/share/cshinstr.dat'; @@ -78,6 +78,3 @@ break; } -//////////////////////////////////////////////////////////////////////////// -// SESSION - From 47f69134860018c484b2777877045d323a111f51 Mon Sep 17 00:00:00 2001 From: Devin Matte Date: Sun, 15 Apr 2018 17:12:17 -0400 Subject: [PATCH 4/5] Using new Openshift Volume --- .../sm/Schedule/directives/scheduleActionsDirective.js | 2 +- img/schedules/readme.txt | 7 ------- inc/config.env.php | 6 +++--- 3 files changed, 4 insertions(+), 11 deletions(-) delete mode 100644 img/schedules/readme.txt diff --git a/assets/src/modules/sm/Schedule/directives/scheduleActionsDirective.js b/assets/src/modules/sm/Schedule/directives/scheduleActionsDirective.js index 923f5fa..99ae36d 100644 --- a/assets/src/modules/sm/Schedule/directives/scheduleActionsDirective.js +++ b/assets/src/modules/sm/Schedule/directives/scheduleActionsDirective.js @@ -169,4 +169,4 @@ angular.module('sm').directive('scheduleActions', function($http, $q, shareServi pre: scheduleActions } }; -}); \ No newline at end of file +}); diff --git a/img/schedules/readme.txt b/img/schedules/readme.txt deleted file mode 100644 index d7adecd..0000000 --- a/img/schedules/readme.txt +++ /dev/null @@ -1,7 +0,0 @@ -Images stored in this folder will 1:1 correspond to the id of the schedule they -represent. The images are generated via ImageMagick, so it is imperative that ImageMagick -be installed on the web server. - -This folder should have write permissions for the user that is running the web server. - -(The true reason for this file is to make sure this directory gets committed) \ No newline at end of file diff --git a/inc/config.env.php b/inc/config.env.php index f0ed34a..4fd1518 100644 --- a/inc/config.env.php +++ b/inc/config.env.php @@ -9,9 +9,9 @@ $COOKIE_STORE = $get_env(getenv("COOKIE_STORE"), '/tmp/siscookies.txt'); $DATABASE_SERVER = $get_env(getenv("DATABASE_SERVER"), 'mysql.csh.rit.edu'); -$DATABASE_USER = $get_env(getenv("DATABASE_USER"), 'schedule_matted'); -$DATABASE_PASS = $get_env(getenv("DATABASE_PASS"), '47MxO5KNav1xInNG'); -$DATABASE_DB = $get_env(getenv("DATABASE_DB"), 'schedule_matted'); +$DATABASE_USER = $get_env(getenv("DATABASE_USER"), ''); +$DATABASE_PASS = $get_env(getenv("DATABASE_PASS"), ''); +$DATABASE_DB = $get_env(getenv("DATABASE_DB"), ''); $DUMPCLASSES = '/mnt/share/cshclass.dat'; $DUMPCLASSATTR = '/mnt/share/cshattrib.dat'; $DUMPINSTRUCT = '/mnt/share/cshinstr.dat'; From ed68a49714aad97946b161d7fe06fa9a468419fb Mon Sep 17 00:00:00 2001 From: Devin Matte Date: Mon, 16 Apr 2018 22:45:09 -0400 Subject: [PATCH 5/5] Fixing Docker and Config --- Dockerfile | 23 +++++++++++------------ inc/config.env.php | 10 +++++----- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0939d7e..c1a549c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,18 @@ FROM php:7.1-apache MAINTAINER Devin Matte -EXPOSE 8080 -EXPOSE 8443 - -RUN a2enmod rewrite && a2enmod headers && a2enmod expires - -RUN sed -i '/Listen/{s/\([0-9]\+\)/8080/; :a;n; ba}' /etc/apache2/ports.conf - ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf +RUN a2enmod rewrite && a2enmod headers && a2enmod expires && \ + sed -i '/Listen/{s/\([0-9]\+\)/8080/; :a;n; ba}' /etc/apache2/ports.conf && \ + chmod og+rwx /var/lock/apache2 && chmod -R og+rwx /var/run/apache2 + RUN apt-get -yq update && \ - apt-get -yq install gnupg libmagickwand-dev --no-install-recommends + apt-get -yq install gnupg libmagickwand-dev --no-install-recommends && \ + apt-get -yq clean all -RUN docker-php-ext-install mysqli -RUN pecl install imagick && docker-php-ext-enable imagick +RUN docker-php-ext-install mysqli && \ + pecl install imagick && docker-php-ext-enable imagick COPY . /var/www/html @@ -24,7 +22,8 @@ RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - && \ npm install && \ npm run-script build && \ rm -rf node_modules && \ - apt-get -yq remove nodejs npm && \ + apt-get -yq remove nodejs && \ apt-get -yq clean all -RUN chmod og+rwx /var/lock/apache2 && chmod -R og+rwx /var/run/apache2 +EXPOSE 8080 +EXPOSE 8443 diff --git a/inc/config.env.php b/inc/config.env.php index 4fd1518..e5b5ab5 100644 --- a/inc/config.env.php +++ b/inc/config.env.php @@ -12,11 +12,11 @@ $DATABASE_USER = $get_env(getenv("DATABASE_USER"), ''); $DATABASE_PASS = $get_env(getenv("DATABASE_PASS"), ''); $DATABASE_DB = $get_env(getenv("DATABASE_DB"), ''); -$DUMPCLASSES = '/mnt/share/cshclass.dat'; -$DUMPCLASSATTR = '/mnt/share/cshattrib.dat'; -$DUMPINSTRUCT = '/mnt/share/cshinstr.dat'; -$DUMPMEETING = '/mnt/share/cshmtgpat.dat'; -$DUMPNOTES = '/mnt/share/cshnotes.dat'; +$DUMPCLASSES = $get_env(getenv("DUMPCLASSES"), '/mnt/share/cshclass.dat'); +$DUMPCLASSATTR = $get_env(getenv("DUMPCLASSATTR"), '/mnt/share/cshattrib.dat'); +$DUMPINSTRUCT = $get_env(getenv("DUMPINSTRUCT"), '/mnt/share/cshinstr.dat'); +$DUMPMEETING = $get_env(getenv("DUMPMEETING"), '/mnt/share/cshmtgpat.dat'); +$DUMPNOTES = $get_env(getenv("DUMPNOTES"), '/mnt/share/cshnotes.dat'); $HTTPROOTADDRESS = $get_env(getenv("HTTPROOTADDRESS"), 'http://schedule.csh.rit.edu/'); $SERVER_TYPE = $get_env(getenv("SERVER_TYPE"), 'development');