aboutsummaryrefslogtreecommitdiffstats
path: root/api/guestbook-proxy.php
blob: 63f1446a0c3ce14c67bcefc3effc4597a5d8205e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
// Proxy for guestbook comments — sidesteps browser CORS restrictions.
// PHP fetches happen server-to-server with no CORS enforcement.

header('Content-Type: text/html; charset=utf-8');
header('Cache-Control: no-store, no-cache');
header('X-Robots-Tag: noindex');

$url = 'https://guestbook.sillylaird.ca/guestbook-comments.php';
$ctx = stream_context_create([
    'http' => [
        'timeout'     => 8,
        'user_agent'  => 'SillyLaird-Proxy/1.0',
        'ignore_errors' => true,
    ],
    'ssl' => [
        'verify_peer'      => true,
        'verify_peer_name' => true,
    ],
]);

$html = @file_get_contents($url, false, $ctx);

if ($html === false) {
    http_response_code(502);
    exit;
}

echo $html;