diff --git a/.gitea/workflows/update_phar.yml b/.gitea/workflows/update_phar.yml deleted file mode 100644 index 80f55c0..0000000 --- a/.gitea/workflows/update_phar.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Update AWS SDK PHAR - -on: - workflow_dispatch: - schedule: - - cron: '34 3 * * *' # 03:34 UTC == 00:34 BRT - -permissions: - contents: write - -jobs: - download-aws-sdk: - runs-on: ubuntu-latest - container: - image: catthehacker/ubuntu:act-latest - permissions: - contents: write - actions: write # needed to dispatch another workflow - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Download AWS SDK PHAR - run: | - mkdir -p vendor - wget https://github.com/aws/aws-sdk-php/releases/latest/download/aws.phar -O vendor/aws.phar - - - name: Commit and push changes - id: commit_step - run: | - git config --global --add safe.directory '*' - git config user.name "Gitea Actions" - git config user.email "actions@git.icc.gg" - git add vendor/aws.phar - - # If there are changes, commit & push; set output flag accordingly - if git diff --quiet && git diff --staged --quiet; then - echo "No changes to commit" - echo "changes_committed=false" >> $GITHUB_OUTPUT - else - git commit -m "Update AWS SDK PHAR [▶️]" - git push origin HEAD:main - echo "changes_committed=true" >> $GITHUB_OUTPUT - fi diff --git a/Dockerfile b/Dockerfile index 60676f3..953c6be 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,21 @@ FROM php:8.4-fpm-alpine # Install Nginx and MariaDB client; install PHP extensions (mysqli) and clean up -RUN apk add --no-cache --update nginx \ +RUN apk add --no-cache --update nginx git unzip \ && docker-php-ext-install mysqli \ && rm -rf /var/cache/apk/* /tmp/* -# Copy your application code +# Install Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Copy only composer files first to leverage Docker cache +COPY composer.json /var/www/html/ + +# Increase timeout and install dependencies +ENV COMPOSER_PROCESS_TIMEOUT=2000 +RUN composer install --no-dev --optimize-autoloader + +# Copy the rest of the application code COPY . /var/www/html/ # Create nginx.conf directly in the Docker build diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..935cd99 --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "aws/aws-sdk-php": "^3.0" + } +} diff --git a/public/manage_ddns.php b/public/manage_ddns.php index d9c6097..245d565 100644 --- a/public/manage_ddns.php +++ b/public/manage_ddns.php @@ -6,7 +6,7 @@ if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) { } include '../dbconfig.php'; -require '../vendor/aws.phar'; +require '../vendor/autoload.php'; use Aws\Route53\Route53Client; use Aws\Exception\AwsException; @@ -40,10 +40,10 @@ if ($aws_result = $link->query($aws_sql)) { // Initialize the Route53 client try { $route53 = new Route53Client([ - 'version' => 'latest', - 'region' => $region, + 'version' => 'latest', + 'region' => $region, 'credentials' => [ - 'key' => $access_key_id, + 'key' => $access_key_id, 'secret' => $secret_access_key, ], ]); @@ -86,7 +86,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add_ddns'])) { 'ResourceRecordSet' => [ 'Name' => $ddns_fqdn . '.', 'Type' => 'A', - 'TTL' => (int)$ttl, + 'TTL' => (int) $ttl, 'ResourceRecords' => [ [ 'Value' => $initial_ip, @@ -101,7 +101,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add_ddns'])) { // Create the DNS record in Route53 $result = $route53->changeResourceRecordSets([ 'HostedZoneId' => $hosted_zone_id, - 'ChangeBatch' => $changeBatch, + 'ChangeBatch' => $changeBatch, ]); // Insert the new DDNS entry into the database @@ -168,7 +168,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_ip'])) { 'ResourceRecordSet' => [ 'Name' => $ddns_fqdn . '.', 'Type' => 'A', - 'TTL' => (int)$new_ttl, + 'TTL' => (int) $new_ttl, 'ResourceRecords' => [ [ 'Value' => $new_ip, @@ -183,7 +183,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_ip'])) { // Update the DNS record in Route53 $result = $route53->changeResourceRecordSets([ 'HostedZoneId' => $hosted_zone_id, - 'ChangeBatch' => $changeBatch, + 'ChangeBatch' => $changeBatch, ]); // Update the IP and TTL in the database @@ -237,7 +237,7 @@ if (isset($_GET['delete'])) { 'ResourceRecordSet' => [ 'Name' => $ddns_fqdn . '.', 'Type' => 'A', - 'TTL' => (int)$ttl, + 'TTL' => (int) $ttl, 'ResourceRecords' => [ [ 'Value' => $last_ipv4, @@ -252,7 +252,7 @@ if (isset($_GET['delete'])) { // Delete the DNS record in Route53 $result = $route53->changeResourceRecordSets([ 'HostedZoneId' => $hosted_zone_id, - 'ChangeBatch' => $changeBatch, + 'ChangeBatch' => $changeBatch, ]); // Delete the DDNS entry from the database @@ -284,6 +284,7 @@ if ($result = $link->query($sql)) { ?> +
@@ -295,29 +296,34 @@ if ($result = $link->query($sql)) { cursor: pointer; position: relative; } + th.sortable:hover { background-color: #f0f0f0; } + th.sortable::after { content: '↕'; position: absolute; right: 8px; opacity: 0.3; } + th.sortable.asc::after { content: '↑'; opacity: 1; } + th.sortable.desc::after { content: '↓'; opacity: 1; } +