Diff -- /var/www/vhosts/3dshawn.com/ptmatrix.3dshawn.com/404.cgi

O Operator
Diff

/var/www/vhosts/3dshawn.com/ptmatrix.3dshawn.com/404.cgi

added on local at 2026-07-01 12:33:51

Added
+156
lines
Removed
-0
lines
Context
0
unchanged
Blobs
from
to b955941b7e1d
Restore this content →
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.
1#!/usr/bin/perl
2
3##################################################################################################################################
4# ______ ____ ____ ______ ______ ____ ___ __ ___ ______ _ __ ____ ____ __ __ _ __ _____ ____
5# / ____// __ \ / __ \ / ____/ / ____// __ \ / | / |/ // ____/| | / // __ \ / __ \ / //_/ | | / /|__ / / __ \
6# / / / / / // / / // __/ / /_ / /_/ // /| | / /|_/ // __/ | | /| / // / / // /_/ // ,< | | / / /_ < / / / /
7# / /___ / /_/ // /_/ // /___ / __/ / _, _// ___ | / / / // /___ | |/ |/ // /_/ // _, _// /| | | |/ / ___/ /_ / /_/ /
8# \____/ \____//_____//_____/ /_/ /_/ |_|/_/ |_|/_/ /_//_____/ |__/|__/ \____//_/ |_|/_/ |_| |___/ /____/(_)\____/
9#
10# - Written by: Shawn Pickering
11# - shawn@shawnpickering.com
12##################################################################################################################################
13use strict;
14use lib '/var/www/vhosts/3dshawn.com/ptmatrix.3dshawn.com';
15
16
17#############################################################
18## Variables
19#############################################################
20#Apache passes the original URL the user tried to hit via REDIRECT_URL
21#(falling back to REQUEST_URI). Strip the obvious-XSS chars and clip.
22my $orig = $ENV{REDIRECT_URL} || $ENV{REQUEST_URI} || '';
23$orig =~ s/[<>"'&]//g;
24$orig = substr($orig, 0, 200);
25
26
27
28############################################################
29# Modules
30############################################################
31#Load the CGI module
32use CGI;
33my $query = new CGI;
34my $form = $query->Vars;
35
36#Load the login module
37use MODS::Login;
38my $login = new MODS::Login;
39
40#Load Urls
41use MODS::PTMatrix::Urls;
42my $getlist = new MODS::PTMatrix::Urls;
43my $url = $getlist->urls();
44
45#Page Wrapper Module - only loaded when user is signed in
46use MODS::PTMatrix::Wrapper;
47my $load = new MODS::PTMatrix::Wrapper;
48
49
50
51#############################################################
52## Get form data
53#############################################################
54#Escapes bad characters
55foreach my $line(keys %$form){
56 $form->{$line} =~ s/[^!-~\s]//g; #Remove non ascii chars
57 $form->{$line} = quotemeta("$form->{$line}");
58}
59
60
61
62############################################################
63# Program Controls
64############################################################
65$|=1;
66my $userinfo = $login->login_verify();
67print qq~Status: 404 Not Found\nContent-type:text/html; Cache-Control:no-cache;\n\n~;
68if($userinfo){&not_found_authed;}
69else{&not_found_public;}
70
71
72############################################################
73# Subroutines
74############################################################
75sub not_found_authed{
76 #Logged-in 404 - in-app shell with friendly back-to-dashboard CTA
77 my $body = qq~
78 <div style="max-width:560px;margin:80px auto;text-align:center">
79 <div style="font-size:60px;font-weight:800;color:var(--col-text-dim);letter-spacing:.04em">404</div>
80 <h2 style="margin:8px 0 14px;font-size:22px">Page not found</h2>
81 <p style="color:var(--col-text-dim);font-size:14px;line-height:1.6">
82 We couldn&rsquo;t find <code style="background:var(--col-bg-2);padding:2px 6px;border-radius:4px">$orig</code>
83 anywhere. It may have moved, been renamed, or never existed.
84 </p>
85 <div style="margin-top:24px;display:flex;gap:10px;justify-content:center;flex-wrap:wrap">
86 <a href="$url->{dashboard}" class="btn btn-primary">Back to dashboard</a>
87 <a href="$url->{help}" class="btn btn-ghost">Help center</a>
88 </div>
89 </div>
90 ~;
91
92 $load->render({
93 userinfo => $userinfo,
94 page_key => '404',
95 title => 'Not found',
96 body => $body,
97 });
98}
99
100sub not_found_public{
101 #Public 404 - standalone page with the marketing nav so a prospect
102 #who clicked a stale link still has somewhere to go
103 print <<HTML;
104<!doctype html>
105<html><head>
106<meta charset="utf-8">
107<title>Page not found &middot; PTMatrix</title>
108<link rel="stylesheet" href="/assets/css/site.css">
109<meta name="viewport" content="width=device-width,initial-scale=1">
110<style>
111.s404-nav{padding:14px 28px;border-bottom:1px solid var(--col-border);display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px}
112.s404-nav .brand{display:flex;align-items:center;gap:10px;text-decoration:none;color:var(--col-text);font-weight:700;font-size:17px}
113.s404-nav .brand-logo{width:30px;height:30px;border-radius:7px;background:var(--col-brand-1);color:#fff;display:grid;place-items:center;font-weight:800;font-size:13px}
114.s404-nav .nav-links{display:flex;align-items:center;gap:18px}
115.s404-nav .nav-links a{color:var(--col-text-dim);text-decoration:none;font-size:14px}
116.s404-nav .nav-links a:hover{color:var(--col-text)}
117.s404-nav .nav-cta{display:flex;align-items:center;gap:10px}
118.s404-nav .btn-signin{color:var(--col-text);text-decoration:none;font-size:13px;padding:7px 14px;border:1px solid var(--col-border);border-radius:7px}
119.s404-nav .btn-trial{color:#fff;background:var(--col-brand-1);text-decoration:none;font-size:13px;padding:7px 14px;border-radius:7px;font-weight:600}
120.s404-card{max-width:560px;margin:80px auto;padding:40px 32px;text-align:center;background:var(--col-bg-2);border:1px solid var(--col-border);border-radius:14px}
121.s404-num{font-size:72px;font-weight:800;color:var(--col-text-dim);letter-spacing:.04em;margin:0}
122.s404-card h1{margin:8px 0 14px;font-size:24px}
123.s404-card p{color:var(--col-text-dim);font-size:14px;line-height:1.6;margin:0 0 24px}
124.s404-card code{background:var(--col-bg-3);padding:2px 6px;border-radius:4px;font-size:13px}
125.s404-actions{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
126.s404-actions .btn{display:inline-block;padding:10px 18px;border-radius:8px;text-decoration:none;font-size:14px;font-weight:600;border:1px solid var(--col-border)}
127.s404-actions .btn-primary{background:var(--col-brand-1);color:#fff;border-color:var(--col-brand-2)}
128.s404-actions .btn-ghost{color:var(--col-text);background:transparent}
129\@media(max-width:640px){.s404-nav .nav-links{display:none}}
130</style>
131</head><body style="background:var(--col-bg-1);color:var(--col-text);min-height:100vh;font-family:system-ui,-apple-system,sans-serif">
132<nav class="s404-nav">
133 <a class="brand" href="/"><span class="brand-logo">PT</span><span>PTMatrix</span></a>
134 <div class="nav-links">
135 <a href="$url->{features}">Features</a>
136 <a href="$url->{pricing}">Pricing</a>
137 <a href="$url->{about}">About</a>
138 <a href="$url->{contact}">Contact</a>
139 </div>
140 <div class="nav-cta">
141 <a class="btn-signin" href="$url->{login}">Sign in</a>
142 <a class="btn-trial" href="$url->{signup}">Start free trial</a>
143 </div>
144</nav>
145<div class="s404-card">
146 <p class="s404-num">404</p>
147 <h1>We couldn&rsquo;t find that page.</h1>
148 <p>The link <code>$orig</code> doesn&rsquo;t lead anywhere here. It may have moved, been renamed, or never existed.</p>
149 <div class="s404-actions">
150 <a class="btn btn-primary" href="/">Back to home</a>
151 <a class="btn btn-ghost" href="$url->{contact}">Contact support</a>
152 </div>
153</div>
154</body></html>
155HTML
156}