diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 5b0e5aa..fcdfc48 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -86,3 +86,16 @@ jobs: docker build . --file .shogun/Dockerfile.dojo-basic-lite --tag dojo-basic-lite docker tag dojo-basic-lite $IMAGE_ID:$VERSION docker push $IMAGE_ID:$VERSION + + - name : Build and push scavanger-lite image + run: | + IMAGE_ID=ghcr.io/${{ github.repository_owner }}/dojo-scavenger-lite + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + [ "$VERSION" == "master" ] && VERSION=latest + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + docker build . --file .shogun/Dockerfile.dojo-scavenger-lite --tag dojo-scavenger-lite + docker tag dojo-scavenger-lite $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION diff --git a/.shogun/Dockerfile.dojo-scavenger-lite b/.shogun/Dockerfile.dojo-scavenger-lite new file mode 100644 index 0000000..d2dd06a --- /dev/null +++ b/.shogun/Dockerfile.dojo-scavenger-lite @@ -0,0 +1,29 @@ +# Dockerfile.dojo-scavenger +FROM php:7.4-apache + +# Install SQLite and PHP SQLite extension +RUN apt-get update && apt-get install -y sqlite3 libsqlite3-dev +RUN docker-php-ext-install pdo pdo_sqlite + +# Set environment variable for database type +ENV DOJO_DB_TYPE sqlite + +# Create the db directory and set permissions +RUN mkdir -p /var/www/html/db && \ + chmod 755 /var/www/html/db + +# Copy application files +COPY ./src/scavenger /var/www/html + +# Add error logging +RUN echo "error_reporting = E_ALL" >> /usr/local/etc/php/php.ini && \ + echo "display_errors = On" >> /usr/local/etc/php/php.ini && \ + echo "log_errors = On" >> /usr/local/etc/php/php.ini && \ + echo "error_log = /var/log/php_errors.log" >> /usr/local/etc/php/php.ini + +# Run init db script +RUN php /var/www/html/init_lite_db.php + +LABEL org.opencontainers.image.source=https://github.com/SamuraiWTF/samurai-dojo +LABEL org.opencontainers.image.description="Basic PHP 7.4-apache image with dojo-scavenger and SQLite/MySQL support." +LABEL org.opencontainers.image.licenses="lgpl" \ No newline at end of file diff --git a/.shogun/docker-compose-dojo-scavenger-lite.yml b/.shogun/docker-compose-dojo-scavenger-lite.yml new file mode 100644 index 0000000..33ce8f9 --- /dev/null +++ b/.shogun/docker-compose-dojo-scavenger-lite.yml @@ -0,0 +1,10 @@ +version: '3' +services: + dojo-scavenger-lite: + build: + context: .. + dockerfile: .shogun/Dockerfile.dojo-scavenger-lite + ports: + - "8081:80" + environment: + - DOJO_DB_TYPE=sqlite \ No newline at end of file diff --git a/src/scavenger/init_lite_db.php b/src/scavenger/init_lite_db.php new file mode 100644 index 0000000..281ffa0 --- /dev/null +++ b/src/scavenger/init_lite_db.php @@ -0,0 +1,21 @@ +exec("CREATE TABLE IF NOT EXISTS partners_data ( + partner_id INTEGER PRIMARY KEY AUTOINCREMENT, + username TEXT, + password TEXT +)"); + +// Insert initial data +$db->exec("INSERT OR IGNORE INTO partners_data (username, password) VALUES +('kevin', 'brenna'), +('justin', 'meeas'), +('key13', 'ed265bc903a5a097f61d3ec064d96d2e'), +('key', 'boomerang')"); + +echo "Database initialized successfully."; +$db->close(); +?> \ No newline at end of file diff --git a/src/scavenger/partners.php b/src/scavenger/partners.php index 90e6fb5..3f1314f 100644 --- a/src/scavenger/partners.php +++ b/src/scavenger/partners.php @@ -1,4 +1,8 @@ query($query); + + $result = $resultset->fetchArray(SQLITE3_ASSOC); + + if ($result !== false) { + if ($_POST["password"] == $result["password"]) { + header("Location: partner_main.php?username=".$result["username"]); + exit(); + } else { + $error = "Invalid password"; + } + } else { + $error = "User not found"; + } + + $db->close(); + } +} ?> + - + @@ -80,4 +109,4 @@ - + \ No newline at end of file