diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..420b11eb --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,54 @@ +name: CI + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: [ubuntu-latest] + php-versions: ['7.4', '8.0', '8.2'] + + steps: + - name: Checkout source + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + ini-values: date.timezone="Europe/London" + + - name: Setup Apache + uses: thunder/apache-shiva-php-action@v1 + with: + php-version: ${{ matrix.php-versions }} + site-directory: $GITHUB_WORKSPACE + http-port: 8080 + + - name: Install Composer dependencies + uses: ramsey/composer-install@v2 + with: + composer-options: "--no-dev" + + - name: Create configuration + run: | + cp config/config.example.php config/config.php + sed -i -e "s,'pass' => '','pass' => 'root',g" config/config.php + printf "[client]\nuser=root\npassword=root\n" > ~/.my.cnf + + - name: Setup database + run: | + sudo systemctl start mysql.service + mysql -e 'CREATE DATABASE zookeeper' + mysql zookeeper < db/zkdbSchema.sql + mysql zookeeper < db/categories.sql + mysql zookeeper < db/chartemail.sql + mysql zookeeper < db/bootstrapUser.sql + + - name: Validate + run: php zk validate url=http://127.0.0.1:8080/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c0eacf15..00000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -language: php - -php: - - 7.4 - - 8.0 - - 8.1 - -services: - - mysql - -before_install: - - mysql -e 'CREATE DATABASE zookeeper' - -before_script: - # Install Apache - - sudo apt-get update - - sudo apt-get install apache2 libapache2-mod-fastcgi - # Enable php-fpm - - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - - 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 - - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm - # Fixup rewrites for php-fpm - - cat build/php-fpm-redirect >> api/.htaccess - # Configure Apache vhosts - - sudo cp -f build/travis-ci-apache /etc/apache2/sites-available/000-default.conf - - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf - - sudo service apache2 restart - # Set timezone - - phpenv config-add build/zookeeper.ini - # Install Composer dependencies - - composer install - # Copy configuration file - - cp config/config.example.php config/config.php - # Set up MySQL - - mysql -u root zookeeper < db/zkdbSchema.sql - - mysql -u root zookeeper < db/categories.sql - - mysql -u root zookeeper < db/chartemail.sql - - mysql -u root zookeeper < db/bootstrapUser.sql - -script: php zk validate url=http://127.0.0.1/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 383711ac..215b062f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,9 +38,6 @@ The following is an overview of the source code directory structure: api/ JSON:API implementation. - build/ - files for continuous integration - config/ config.php This is the main configuration file. It includes diff --git a/README.md b/README.md index 20e3f2d7..01c4a209 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## Zookeeper Online [![last commit](https://badgen.net/github/last-commit/RocketMan/zookeeper)](https://github.com/RocketMan/zookeeper/commits/master) -[![Build Status](https://travis-ci.com/RocketMan/zookeeper.svg?branch=master)](https://travis-ci.com/github/RocketMan/zookeeper) +[![Build Status](https://github.com/RocketMan/zookeeper/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/RocketMan/zookeeper/actions/workflows/main.yml) [![license](https://badgen.net/github/license/RocketMan/zookeeper)](https://github.com/RocketMan/zookeeper/blob/master/LICENSE) [![latest version](https://badgen.net/github/release/RocketMan/zookeeper?label=latest)](https://github.com/RocketMan/zookeeper/releases) diff --git a/build/php-fpm-redirect b/build/php-fpm-redirect deleted file mode 100644 index 2cec7a8d..00000000 --- a/build/php-fpm-redirect +++ /dev/null @@ -1,13 +0,0 @@ -# Invocation of php-fpm results in an extra rewrite, -# which prefixes the environment variables with REDIRECT_. -# -# These rules rewrite the existing REDIRECT_x to x. After -# php-fpm, they will once again be REDIRECT_x as expected, -# rather than REDIRECT_REDIRECT_x. - - -RewriteCond %{ENV:REDIRECT_APIVER} (.+) -RewriteRule .* - [E=APIVER:%1] -RewriteCond %{ENV:REDIRECT_PREFIX} (.+) -RewriteRule .* - [E=PREFIX:%1] - diff --git a/build/travis-ci-apache b/build/travis-ci-apache deleted file mode 100644 index 2cd2aaa8..00000000 --- a/build/travis-ci-apache +++ /dev/null @@ -1,25 +0,0 @@ - - # [...] - - DocumentRoot %TRAVIS_BUILD_DIR% - - - Options FollowSymLinks MultiViews ExecCGI - AllowOverride All - Require all granted - - - # Wire up Apache to use Travis CI's php-fpm. - - AddHandler php5-fcgi .php - Action php5-fcgi /php5-fcgi - Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi - FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization - - - Require all granted - - - - # [...] - diff --git a/build/zookeeper.ini b/build/zookeeper.ini deleted file mode 100644 index 79617896..00000000 --- a/build/zookeeper.ini +++ /dev/null @@ -1 +0,0 @@ -date.timezone="Europe/London" diff --git a/engine/impl/Playlist.php b/engine/impl/Playlist.php index eb778881..50d20093 100644 --- a/engine/impl/Playlist.php +++ b/engine/impl/Playlist.php @@ -700,10 +700,10 @@ public function insertTrack($playlistId, $tag, $artist, $track, $album, $label, $tagName = $haveTag ? ", tag" : ""; $tagValue = $haveTag ? ", ?" : ""; - $names = "(list, artist, track, album, label, seq, created ${tagName})"; - $values = "VALUES (?, ?, ?, ?, ?, ?, ? ${tagValue});"; + $names = "(list, artist, track, album, label, seq, created {$tagName})"; + $values = "VALUES (?, ?, ?, ?, ?, ?, ? {$tagValue});"; - $query = "INSERT INTO tracks ${names} ${values}"; + $query = "INSERT INTO tracks {$names} {$values}"; $stmt = $this->prepare($query); $stmt->bindValue(1, (int)$playlistId, \PDO::PARAM_INT); $stmt->bindValue(2, $artist); diff --git a/engine/impl/User.php b/engine/impl/User.php index bc2e0e11..247fa97a 100644 --- a/engine/impl/User.php +++ b/engine/impl/User.php @@ -200,7 +200,7 @@ public function updateUser($user, $password, $realname="XXZZ", $groups="XXZZ", $ $comma = ","; } if($groups != "XXZZ") { - $query .= $comma." groups=?"; + $query .= $comma." `groups`=?"; $comma = ","; } if($expiration != "XXZZ") @@ -226,7 +226,7 @@ public function updateUser($user, $password, $realname="XXZZ", $groups="XXZZ", $ public function insertUser($user, $password, $realname, $groups, $expiration) { $salt = substr(md5(uniqid(rand())), 0, 2); - $query = "INSERT INTO users (name, password, realname, groups, expires) VALUES (?, ?, ?, ?, ?)"; + $query = "INSERT INTO users (name, password, realname, `groups`, expires) VALUES (?, ?, ?, ?, ?)"; $stmt = $this->prepare($query); $stmt->bindValue(1, $user); $stmt->bindValue(2, $salt.md5($salt.$password)); @@ -292,7 +292,7 @@ public function deleteAPIKeys($user, array $ids) { } public function lookupAPIKey($apikey) { - $query = "SELECT user, groups, realname FROM apikeys a ". + $query = "SELECT user, `groups`, realname FROM apikeys a ". "LEFT JOIN users u ON a.user = u.name ". "WHERE apikey=?"; $stmt = $this->prepare($query);