Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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>
Add Comment
Please, Sign In to add comment