php wrapper around widget creating missing include
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 13 May 2019 21:14:25 +0000 (23:14 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 13 May 2019 21:14:25 +0000 (23:14 +0200)
Generates any unknown profile id include before showing static page.
Still defers to cron scripts for expiration and clan filters.

.htaccess
widget.php [new file with mode: 0644]

index f391cd071ff79650775594710ab2d52dcf5464e6..bacadc7435ad759a8b3f598376bffb4b8d03b09e 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -1,3 +1,5 @@
+AddHandler application/x-httpd-php php
+
 RewriteEngine  on
-RewriteCond    %{REQUEST_FILENAME}.html -f
-RewriteRule    ^([^/]+)  $1.html
+RewriteCond    %{REQUEST_FILENAME}.php -f
+RewriteRule    ^([^/]+)(.*)  $1.php$2
diff --git a/widget.php b/widget.php
new file mode 100644 (file)
index 0000000..e5aa326
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+$request = trim($_SERVER['PATH_INFO'], '/');
+if (!file_exists("$request.json")) {
+       if (!is_numeric($request)) {
+               die("unknown profile request $request");
+       }
+       system("./getsc2clan $request | sponge $request.json", $exitcode);
+       if ($exitcode) {
+               die("no results for profile id $request from Blizzard");
+       }
+}
+require('widget.html');