Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ubc/iPeer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.1.6
Choose a base ref
...
head repository: ubc/iPeer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing 1,065 changed files with 41,673 additions and 7,803 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
.idea
.data
build
build.xml
Boxfile
Vagrantfile
app/tmp
/vendor/
75 changes: 75 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: CI to Docker Hub

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ "*" ]
tags: [ "*" ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-and-push-image:
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: ./
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -16,3 +16,8 @@ lint.cache
tags
.project
.vagrant
vendor/
.idea
.data
.DS_Store
docker-compose.override.yml
3 changes: 3 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include:
- template: Auto-DevOps.gitlab-ci.yml

12 changes: 9 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -25,9 +25,6 @@
[submodule "puppet/modules/mysql"]
path = puppet/modules/mysql
url = https://github.com/puppetlabs/puppetlabs-mysql.git
[submodule "puppet/modules/php"]
path = puppet/modules/php
url = https://github.com/thias/puppet-php.git
[submodule "nginx"]
path = puppet/modules/nginx
url = https://github.com/jfryman/puppet-nginx.git
@@ -46,3 +43,12 @@
[submodule "puppet/modules/epel"]
path = puppet/modules/epel
url = https://github.com/stahnma/puppet-module-epel.git
[submodule "puppet/modules/php"]
path = puppet/modules/php
url = https://github.com/mayflower/puppet-php.git
[submodule "puppet/modules/initfile"]
path = puppet/modules/initfile
url = https://github.com/puppetlabs/puppetlabs-inifile.git
[submodule "app/plugins/djjob/vendors"]
path = app/plugins/djjob/vendors
url = https://github.com/seatgeek/djjob.git
69 changes: 69 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
language: php
php:
- '7.2'
env:
- SERVER_TEST=http://localhost IPEER_DB_NAME=ipeer_test IPEER_DB_USER=root IPEER_DB_PASSWORD="" IPEER_DEBUG=2

services:
- mysql
install:
- composer install
before_script:
- sudo apt-get update
- sudo apt-get install -y --force-yes apache2 libapache2-mod-fastcgi
# install oauth extension
- pecl install -f oauth-2.0.2
# copy php-fpm configure files
- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
# setting user and group directives are not necessary unless we are using sudo to start php-fpm. but anyway...
- sudo sed -i '/^user =/cuser = travis' ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
- sudo sed -i '/^group =/cgroup = travis' ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
- sudo sed -i "/^;chdir =/cchdir = $(pwd)/app/webroot" ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
# dont clear env. make sure environment variables are passed to the workers
- sudo sed -i '/^;clear_env =/cclear_env = no' ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
# turn of display_errors unless we are debugging. otherwise it may affect /v1 endpoints
- sudo sed -i '/^;php_flag\[display_errors\]/cphp_flag[display_errors] = off' ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
# for debugging php-fpm
- sudo touch /var/log/fpm-access.log
- sudo chmod a+wr /var/log/fpm-access.log
- sudo touch /var/log/fpm-error.log
- sudo chmod a+wr /var/log/fpm-error.log
- sudo sed -i '/^;access.log/caccess.log = /var/log/fpm-access.log' ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
- sudo sed -i '/^;php_admin_value\[error_log\]/cphp_admin_value[error_log] = /var/log/fpm-error.log' ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
- sudo sed -i '/^;catch_workers_output/ccatch_workers_output = yes' ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
- sudo sed -i '/^;php_admin_flag\[log_errors\]/cphp_admin_flag[log_errors] = on' ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
# end of debugging php-fpm
- sudo a2enmod rewrite actions fastcgi alias
- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars
- sudo chown -R travis:travis /var/lib/apache2/fastcgi
# configure apache virtual hosts
- sudo cp -f build/travis-ci-apache /etc/apache2/sites-available/000-default.conf
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)/app/webroot?g" --in-place /etc/apache2/sites-available/000-default.conf
# restart php fpm and apache
- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
- sudo service apache2 restart
# setup mysql
- mysql -e "create database IF NOT EXISTS ipeer_test;" -uroot
# remove ONLY_FULL_GROUP_BY. otherwise some iPeer queries will fail
# also remove STRICT_TRANS_TABLES, NO_ZERO_IN_DATE and NO_ZERO_DATE for some test cases
- mysql -e "SELECT @@sql_mode;" -uroot
- mysql -e "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));" -uroot
- mysql -e "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'STRICT_TRANS_TABLES',''));" -uroot
- mysql -e "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'NO_ZERO_IN_DATE',''));" -uroot
- mysql -e "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'NO_ZERO_DATE',''));" -uroot
- mysql -e "SELECT @@sql_mode;" -uroot

script: vendor/bin/phing build-ci

#deploy:
# provider: releases
# skip_cleanup: true
# api_key:
# secure: JqPtCTP6y1zJqmtShDvvQOSsQ/Vf5iAmk4wfIuw2ATV2puQH7/ojQNmLRb7b59Ek5dJzHzIx3RmK+JZtAPHV7HHEZ4sH0qhEM4GZQjmWre4fqmYS5+XnFjQ7C0iLYmVCklAQ3ziinzzESwrfVxtehq5/XNnt6kUCJorRvS22ee8=
# file: ipeer-release.zip
# on:
# repo: ubc/iPeer
# tags: true
# php: 5.3
4 changes: 2 additions & 2 deletions Boxfile
Original file line number Diff line number Diff line change
@@ -16,9 +16,9 @@ web1:
php_display_errors: "0"
after_build:
- "mv app/config/database.pagoda.php app/config/database.php"
- "mv app/plugins/guard/config/guard.php app/config/guard.php"
- "mv app/plugins/guard/config/guard_default.php app/config/guard.php"
cron:
- "*/15 * * * *": "cake/console/cake send_emails"
db1:
name: ipeerdb
type: mysql
type: mysql
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM php:7.2-fpm

RUN apt-get update && apt-get install --no-install-recommends --no-install-suggests -y \
libpng-dev \
libxml2-dev \
libldap2-dev \
libldb-dev \
unzip \
git \
&& rm -rf /var/lib/apt/lists/* \
&& ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \
&& ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so \
&& docker-php-ext-install -j$(nproc) xml gd ldap mysqli pdo_mysql \
&& pecl install timezonedb xdebug-2.6.0\
&& docker-php-ext-enable timezonedb xdebug\
&& curl https://getcomposer.org/download/1.8.4/composer.phar -o /usr/local/bin/composer \
&& chmod +x /usr/local/bin/composer

COPY docker/php.ini /usr/local/etc/php/
COPY . /var/www/html
COPY docker/docker-entrypoint-php-fpm.sh /

RUN cd /var/www/html \
&& composer install --no-ansi --no-dev --no-interaction --no-plugins --no-progress --no-suggest --optimize-autoloader \
&& mkdir -p /var/www/html/app/tmp/cache/persistent /var/www/html/app/tmp/cache/models /var/www/html/app/tmp/logs \
&& chown www-data:www-data -R /var/www/html/app/tmp/cache \
&& chown www-data:www-data -R /var/www/html/app/tmp/logs

RUN set -ex \
## Customize PHP fpm configuration
&& sed -i -e "s/;clear_env\s*=\s*no/clear_env = no/g" /usr/local/etc/php-fpm.conf \
&& sed -i -e "s/;request_terminate_timeout\s*=[^\n]*/request_terminate_timeout = 300/g" /usr/local/etc/php-fpm.conf \
&& php-fpm --test

CMD ["/docker-entrypoint-php-fpm.sh"]
35 changes: 35 additions & 0 deletions Dockerfile-app-unittest
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM php:7.2-fpm

RUN apt-get update && apt-get install --no-install-recommends --no-install-suggests -y \
libpng-dev \
libxml2-dev \
libldap2-dev \
libldb-dev \
unzip \
git \
libpcre3-dev \
libzip-dev \
&& rm -rf /var/lib/apt/lists/* \
&& ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \
&& ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so \
&& docker-php-ext-install -j$(nproc) xml gd ldap mysqli pdo_mysql intl \
&& pecl install timezonedb \
&& docker-php-ext-enable timezonedb \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& curl https://getcomposer.org/download/1.8.4/composer.phar -o /usr/local/bin/composer \
&& chmod +x /usr/local/bin/composer \
&& pecl install -f oauth-2.0.2 \
&& pecl install -f zip

COPY docker/php.ini /usr/local/etc/php/
COPY . /var/www/html

RUN cd /var/www/html \
&& composer install --no-ansi --no-dev --no-interaction --no-plugins --no-progress --no-suggest --optimize-autoloader \
&& mkdir -p /var/www/html/app/tmp/cache/persistent /var/www/html/app/tmp/cache/models \
&& chown www-data:www-data -R /var/www/html/app/tmp/cache

RUN echo "extension=oauth.so" >> /usr/local/etc/php/php.ini
RUN echo "extension=zip.so" >> /usr/local/etc/php/php.ini
RUN echo "opcache.enable=0" >> /usr/local/etc/php/php.ini
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2005-2015 Centre for Teaching, Learning and Technology(CTLT),
University of British Columbia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
5 changes: 2 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -10,9 +10,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# please see the online documentation at vagrantup.com.

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ipeerbox"

config.vm.box_url = "puppetlabs/centos-6.5-64-puppet"
config.vm.box = "puppetlabs/centos-6.6-64-puppet"
config.vm.box_version = "1.0.1"

config.vm.define "ipeerdev" do |t|
end
31 changes: 28 additions & 3 deletions app/app_controller.php
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
uses('sanitize');
App::import('Lib', 'toolkit');
App::import('Lib', 'breadcrumb');
App::import('Lib', 'caliper');
use caliper\CaliperHooks;

/**
* AppController the base controller
@@ -80,8 +82,16 @@ public function beforeFilter()
Security::setHash('md5');
Configure::write('Security.salt', '');

// set default language for now
Configure::write('Config.language', 'eng');
$locale = $this->SysParameter->findByParameterCode('display.locale');
// default to eng if no locale is set
if (!(empty($locale) || empty($locale['SysParameter']['parameter_value']))) {
$locale = $locale['SysParameter']['parameter_value'];

// TODO: check that the locale is valid
Configure::write('Config.language', $locale);
} else {
Configure::write('Config.language', 'eng');
}

// if we have a session transfered to us
if ($this->_hasSessionTransferData()) {
@@ -122,6 +132,18 @@ public function beforeFilter()
parent::beforeFilter();
}

/**
* Called after the controller action is run, but before the view is rendered.
*
* @access public
* @link http://book.cakephp.org/1.3/en/The-Manual/Developing-With-CakePHP/Controllers.html#Callbacks
*/
function beforeRender() {
CaliperHooks::app_controller_before_render($this);

parent::beforeRender();
}

/**
* checkDatabaseVersion
*
@@ -132,7 +154,7 @@ public function _checkSystemVersion()
{
$sysv = $this->SysParameter->get('system.version');

if (User::hasPermission('controllers/upgrade') && $sysv < IPEER_VERSION) {
if (User::hasPermission('controllers/upgrade') && version_compare(IPEER_VERSION, $sysv) > 0) {
$flashMessage = "Your system version is older than the current version. ";
$flashMessage .= "Please do the <a href=" . $this->webroot ."upgrade" .">upgrade</a>.";
$this->Session->setFlash($flashMessage);
@@ -240,6 +262,8 @@ public function _afterLogin($isRedirect = true)
$this->AccessControl->loadPermissions();
$this->SysParameter->reload();
//TODO logging!

CaliperHooks::app_controller_after_login($this);
}

if (!$isRedirect) {
@@ -263,6 +287,7 @@ public function _afterLogin($isRedirect = true)
*/
function _afterLogout()
{
CaliperHooks::app_controller_after_logout($this);
$this->Session->destroy();
}

Loading