Created
April 16, 2018 21:51
-
-
Save iamcal/4a7f4d1afaee0d686fc607ed3e130c19 to your computer and use it in GitHub Desktop.
I'm pretty sure this a decoder for something in Homestuck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Unstuck</title> | |
<style> | |
#main { | |
text-align: left; | |
margin: 30px auto; | |
width: 760px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="main"> | |
<h1>Unstuck</h1> | |
<?php | |
if ($_POST['text']){ | |
$lines = array(); | |
$raw = explode("\n", $_POST['text']); | |
foreach ($raw as $l){ | |
if (preg_match('!^([A-Z]{2}): (.*)$!', trim($l), $m)){ | |
echo translate_line($m[1], $m[2]).'<br />'; | |
}else{ | |
echo HtmlSpecialChars(trim($l)).'<br />'; | |
} | |
} | |
echo "<hr />"; | |
} | |
function translate_line($who, $line){ | |
$color = '#000'; | |
$map = array(); | |
$lower = false; | |
if ($who == 'TA'){ | |
$map = array( | |
'1' => 'i', | |
'2' => 's', | |
'4' => 'a', | |
'ii' => 'i', | |
'II' => 'I', | |
'two' => 'to', | |
); | |
$color = '#a1a100'; | |
} | |
if ($who == 'GC'){ | |
$map = array( | |
'1' => 'i', | |
'2' => 's', | |
'3' => 'e', | |
'4' => 'a', | |
); | |
$color = '#008282'; | |
$lower = true; | |
} | |
if ($who == 'AA'){ | |
$map = array( | |
'0' => 'o', | |
); | |
$color = '#a10000'; | |
} | |
if ($who == 'CG'){ | |
$lower = true; | |
$color = '#626262'; | |
} | |
$line = str_replace(array_keys($map), $map, $line); | |
if ($lower) $line = preg_replace('!\b([a-zA-Z]+)\b!e', 'strtolower("$1")', $line); | |
$line = preg_replace('!\b(i)(d|m|ve)\b!', 'I\'$2', $line); | |
$line = preg_replace("!\bi(\b|')!", 'I$2', $line); | |
$line = ucfirst($line); | |
$line = preg_replace('!\b(aa|gc|ta)\b!e', 'strtoupper($1)', $line); | |
echo "<span style=\"color: {$color}\">$who: ".HtmlSpecialChars($line)."</span>"; | |
} | |
?> | |
<form action="./" method="post"> | |
<textarea name="text" style="width: 100%; height: 200px;" wrap="virtual"><?php echo HtmlSpecialChars($_POST['text']); ?></textarea> | |
<input type="submit" value="unstick" /> | |
</form> | |
</div> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment