From aa2ac2c5a728f4012e9d5dcb945a8377ed17ed2b Mon Sep 17 00:00:00 2001 From: Floorb <132411956+Neetpone@users.noreply.github.com> Date: Tue, 28 Mar 2023 12:00:22 -0400 Subject: [PATCH] fix broken nginx config and other stuff that I didn't commit 2 years ago --- doc/nginx.conf | 29 ++++++++++++++++------------- public/index.php | 2 +- public/user.php | 2 +- theme/bulma/view.php | 6 +++--- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/doc/nginx.conf b/doc/nginx.conf index ca53af6..7e0b4cf 100644 --- a/doc/nginx.conf +++ b/doc/nginx.conf @@ -34,21 +34,24 @@ server { server_name ponepaste.org; - # Rewrites for pretty URLs - rewrite ^/([0-9]+) /paste.php?id=$1 last; - rewrite ^/page/([a-zA-Z0-9]+)/? /pages.php?page=$1 last; - rewrite ^/archive /archive.php last; - rewrite ^/discover /discover.php last; - rewrite ^/profile /profile.php last; + rewrite ^/$ /index.php last; + rewrite ^/([0-9]+)$ /paste.php?id=$1 last; + rewrite ^/page/([a-zA-Z0-9]+)/?$ /pages.php?page=$1 last; + + # simple routes that just map to $1.php + rewrite ^/(archive|discover|profile|contact|report|event|captcha|login|logout)/?$ /$1.php last; + + # routes for users rewrite ^/user/([^/]+)/?$ /user.php?user=$1 last; rewrite ^/user/([^/]+)/([^/]+)/?$ /user.php?user=$1&q=$2 last; - rewrite ^/contact /contact.php last; - rewrite ^/download/(.*)$ /paste.php?download&id=$1 last; - rewrite ^/raw/(.*)$ /paste.php?raw&id=$1 last; - rewrite ^/embed/(.*)$ /paste.php?embed&id=$1 last; - rewrite ^/report /report.php last; - rewrite ^/event /event.php last; - rewrite ^/rules /rules.php last; + + # routes for pastes + rewrite ^/(download|raw|embed)/(.+)$ /paste.php?$1&id=$2 last; + + # weird registration routes that use a URL parameter rather than a different page (FIXME) + rewrite ^/register$ /login.php last; + rewrite ^/forgot$ /login.php last; + location ~* \.(jpg|jpeg|png|gif|ico|css|js) { add_header "Cache-Control" "public"; diff --git a/public/index.php b/public/index.php index 80e88d0..b4c8d96 100644 --- a/public/index.php +++ b/public/index.php @@ -45,7 +45,7 @@ function calculatePasteExpiry(string $expiry) : ?string { } function validatePasteFields() : string|null { - if (empty($_POST["paste_data"]) || trim($_POST['paste_data'] === '')) { /* Empty paste input */ + if (empty($_POST["paste_data"]) || trim($_POST['paste_data']) === '') { /* Empty paste input */ return 'You cannot post an empty paste.'; } elseif (!isset($_POST['title'])) { /* No paste title POSTed */ return 'All fields must be filled out.'; diff --git a/public/user.php b/public/user.php index d8d9769..4137f7e 100644 --- a/public/user.php +++ b/public/user.php @@ -41,7 +41,7 @@ $total_pfav = array_sum( $total_yfav = $profile_info->favourites->count(); // Badges -$profile_badge = match ($profile_info['badge']) { +$profile_badge = match ((int) $profile_info['badge']) { 1 => 'Donated to PonePaste', 2 => 'You had one job', 3 => 'Won a PasteJam competition', diff --git a/theme/bulma/view.php b/theme/bulma/view.php index 5dc6fcc..60d5bc7 100644 --- a/theme/bulma/view.php +++ b/theme/bulma/view.php @@ -273,10 +273,10 @@ $selectedloader = "$bg[$i]"; // set variable equal to which random filename was
- + + Type a comma to separate each tag. +
- - Type a comma to separate each tag.