Guest User

Untitled

a guest
Apr 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Unstuck</title>
  4. <style>
  5.  
  6. #main {
  7. text-align: left;
  8. margin: 30px auto;
  9. width: 760px;
  10. }
  11.  
  12. </style>
  13. </head>
  14. <body>
  15.  
  16. <div id="main">
  17.  
  18. <h1>Unstuck</h1>
  19.  
  20. <?php
  21. if ($_POST['text']){
  22.  
  23. $lines = array();
  24. $raw = explode("\n", $_POST['text']);
  25. foreach ($raw as $l){
  26. if (preg_match('!^([A-Z]{2}): (.*)$!', trim($l), $m)){
  27. echo translate_line($m[1], $m[2]).'<br />';
  28. }else{
  29. echo HtmlSpecialChars(trim($l)).'<br />';
  30. }
  31. }
  32.  
  33. echo "<hr />";
  34. }
  35.  
  36.  
  37. function translate_line($who, $line){
  38.  
  39. $color = '#000';
  40. $map = array();
  41. $lower = false;
  42.  
  43. if ($who == 'TA'){
  44. $map = array(
  45. '1' => 'i',
  46. '2' => 's',
  47. '4' => 'a',
  48. 'ii' => 'i',
  49. 'II' => 'I',
  50. 'two' => 'to',
  51. );
  52. $color = '#a1a100';
  53. }
  54.  
  55. if ($who == 'GC'){
  56. $map = array(
  57. '1' => 'i',
  58. '2' => 's',
  59. '3' => 'e',
  60. '4' => 'a',
  61. );
  62. $color = '#008282';
  63. $lower = true;
  64. }
  65.  
  66. if ($who == 'AA'){
  67. $map = array(
  68. '0' => 'o',
  69. );
  70. $color = '#a10000';
  71. }
  72.  
  73. if ($who == 'CG'){
  74. $lower = true;
  75. $color = '#626262';
  76. }
  77.  
  78. $line = str_replace(array_keys($map), $map, $line);
  79.  
  80. if ($lower) $line = preg_replace('!\b([a-zA-Z]+)\b!e', 'strtolower("$1")', $line);
  81.  
  82. $line = preg_replace('!\b(i)(d|m|ve)\b!', 'I\'$2', $line);
  83. $line = preg_replace("!\bi(\b|')!", 'I$2', $line);
  84. $line = ucfirst($line);
  85. $line = preg_replace('!\b(aa|gc|ta)\b!e', 'strtoupper($1)', $line);
  86.  
  87. echo "<span style=\"color: {$color}\">$who: ".HtmlSpecialChars($line)."</span>";
  88. }
  89.  
  90. ?>
  91.  
  92. <form action="./" method="post">
  93. <textarea name="text" style="width: 100%; height: 200px;" wrap="virtual"><?php echo HtmlSpecialChars($_POST['text']); ?></textarea>
  94. <input type="submit" value="unstick" />
  95. </form>
  96.  
  97. </div>
  98.  
  99. </body>
  100. </html>
Add Comment
Please, Sign In to add comment