Page MenuHomeDevCentral

D3427.id8846.diff
No OneTemporary

D3427.id8846.diff

diff --git a/redirect/_documents.xml b/redirect/_documents.xml
new file mode 100644
--- /dev/null
+++ b/redirect/_documents.xml
@@ -0,0 +1,14 @@
+<!--
+ The following files are independant entry points able to be called directly, without index.php.
+
+ You can configure your web server to bypass Pluton for these. If you don't, Pluton will know not to print header/footer.
+-->
+<documents topic="redirect">
+ <document>
+ <article>index</article>
+ <title>Redirect</title>
+ <description>Redirect to the specified resource.</description>
+ <noheader />
+ <nofooter />
+ </document>
+</documents>
diff --git a/redirect/_targets.php b/redirect/_targets.php
new file mode 100644
--- /dev/null
+++ b/redirect/_targets.php
@@ -0,0 +1,6 @@
+<?php
+
+return [
+ "perdu" => "https://www.perdu.com/",
+ "visit-brussels" => "https://www.ticketing.brussels/fr/tickets?lastMinuteTickets=true&from=%%YYYY%%-%%MM%%-%%DD%%&to=%%YYYY%%-%%MM%%-%%DD%%",
+];
diff --git a/redirect/index.php b/redirect/index.php
new file mode 100644
--- /dev/null
+++ b/redirect/index.php
@@ -0,0 +1,27 @@
+<?php
+
+function resolve_url (string $url) : string {
+ $search = [
+ "%%YYYY%%",
+ "%%MM%%",
+ "%%DD%%",
+ ];
+ $replace = [
+ date('Y'),
+ date('m'),
+ date('d'),
+ ];
+
+ return str_replace($search, $replace, $url);
+}
+
+$target = $_REQUEST["target"] ?? $_REQUEST["t"] ?? "";
+$targets = require('_targets.php');
+
+if ($target !== "" && array_key_exists($target, $targets)) {
+ $target_url = resolve_url($targets[$target]);
+ header('Location: '. $target_url);
+ exit;
+}
+
+header("HTTP/1.0 404 Not Found");

File Metadata

Mime Type
text/plain
Expires
Sat, Sep 21, 00:54 (21 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2155629
Default Alt Text
D3427.id8846.diff (1 KB)

Event Timeline