<?php
if (isset($_GET['source'])) {
    
highlight_file(__FILE__);
    exit;
}

if (isset(
$_GET['rd'])) {
    if (isset(
$_GET['obfuscate'])) {
        
header('Location: ?b64&' urlencode(base64_encode(gzdeflate($_GET['rd']))));
    }
    else {
        
header('Location: ?' urlencode($_GET['rd']));
    }
    exit;
}

if (empty(
$_SERVER['QUERY_STRING'])) {
    echo 
'<!DOCTYPE html>';
    
?>
        Content-addressed URL. This allows you to link to anything without having to create the page first. It only allows plain text for security reasons.<br>
        <br>
        Your text:
        <form>
            <textarea name=rd cols=80 rows=5></textarea><br>
            <input type=submit value='Go to URL'>
            <input type=submit value='Obfuscate/compress and go' name=obfuscate>
        </form>
    <?php
    
exit;
}

$data urldecode($_SERVER['QUERY_STRING']);
if (
substr($data04) === 'b64&') {
    
$data substr($data4);
    
$decompress true;
}
if (
substr($data04) === 'raw&') {
    
header('Content-Type: text/plain');
    
$data substr($data4);
    if (
$decompress) {
        
$data gzinflate(base64_decode($data));
    }
    print(
$data);
    exit;
}

if (
$decompress) {
    
$data gzinflate(base64_decode($data));
}

echo 
'<!DOCTYPE html>';
echo 
'<title>' htmlspecialchars(substr($data0256), ENT_COMPAT ENT_HTML401'ISO-8859-1') . '</title><div style="max-width:650px; line-height: 130%; margin-bottom: 90px;">';
echo 
nl2br(htmlspecialchars($dataENT_COMPAT ENT_HTML401'ISO-8859-1'));
echo 
'</div>';
echo 
'<a style="color:#888; font-size: 9pt;" href=".">Create your own long URL</a>';