expandUrl($shortid, true); $warnCookie = false; if (isset($_COOKIE['warn']) == true) { $warnCookie = ($_COOKIE['warn'] == "true"); } $resultCode = -1; $resultMessage = NULL; $resultUrl = NULL; if ($expandedEntry == NULL) { $resultCode = 404; $resultMessage = "NOT_FOUND"; $resultUrl = NULL; } else { $resultCode = 200; $resultMessage = "OK"; $resultUrl = $expandedEntry['url']; } if (($shortext == "text") || ($shortext == "txt") || ($shortext == "plain")) { header("Content-type: text/plain"); echo $resultUrl; exit; } if ($shortext == "json") { // prevent caching header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: application/json'); echo '{ "status_code": ' . $resultCode . ', "data": { "expand": [ { "short_url": "' . $calledUrl . '", "global_hash": "' . $shortid . '", "long_url": "' . $resultUrl . '", "user_hash": "' . $shortid . '" } ] }, "status_text": "' . $resultMessage . '" }'; exit; } if ($shortext == "xml") { header("Content-type: application/xml"); echo '<'.'?xml version="1.0" encoding="UTF-8"?'.'>' . "\n"; echo '' . "\n"; echo '' . $resultCode . '' . "\n"; echo '' . $resultMessage . '' . "\n"; echo '' . "\n"; if ($resultCode == 200) { echo '' . "\n"; echo ' ' . $calledUrl . '' . "\n"; echo ' ' . $resultUrl . '' . "\n"; echo ' ' . $shortid . '' . "\n"; echo ' ' . $shortid . '' . "\n"; echo '' . "\n"; } echo '' . "\n"; echo ''; exit; } if (($shortext == "qrcode") || ($shortext == "qr")) { header("Content-type: image/png"); $qr = new Image_QRCode(); $codeData = $calledUrl; $qr->makeCode($codeData); exit; } if ($resultCode == 200) { if ($warnCookie == true) { include('expand_warnpage.php'); } else { header("Location: " . $resultUrl); } } else { include('expand_notfound.php'); } ?>