diff options
Diffstat (limited to 'public/resolve.php')
| -rw-r--r-- | public/resolve.php | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/public/resolve.php b/public/resolve.php deleted file mode 100644 index 95b985c..0000000 --- a/public/resolve.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php -# rate limiting happens in nginx - -require_once __DIR__ . '/../vendor/autoload.php'; - -use GuzzleHttp\Client; - -function resolveURL($url) { - - $client = new Client(); - - try { - $response = $client->request('HEAD', $url, [ 'on_stats' => function( GuzzleHttp\TransferStats $stats ) use ( &$effectiveURL ){ $effectiveURL = $stats->getEffectiveUri(); }]) - ->getBody()->getContents(); - } catch(\Exception $e) { - return $url; - } - - return $effectiveURL->__toString(); -} - -function getURL() { - if ( empty($_REQUEST['url']) ) { - $data = json_decode(file_get_contents('php://input'), true); - return $data['url']; - } else { - return $_REQUEST['url']; - } -} - -echo json_encode( ['url' => resolveURL( getURL() ) ]); |
