Advertisement
Guest User

Untitled

a guest
Feb 27th, 2012
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2.    "http://www.w3.org/TR/html4/loose.dtd">
  3. <html lang="en">
  4. <head>
  5.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6.         <title>Swath Web</title>
  7.         <meta name="generator" content="TextMate http://macromates.com/">
  8.         <meta name="author" content="Vee Satayamas">
  9.  
  10. </head>
  11. <body>
  12. <form method="post">
  13. <textarea name="input_text" cols="80" rows="10"></textarea>
  14. <input type="submit" value="submit">
  15. </form>
  16. <?php
  17.  
  18.     function swath($input_text)
  19.     {
  20.         $input_filename= tempnam("/tmp", "swath_");
  21.         $output_filename= tempnam("/tmp", "swath_");
  22.         $input_text_tis620 = iconv("UTF-8", "TIS-620", $input_text);
  23.         file_put_contents($input_filename, $input_text_tis620);
  24.         system("/usr/bin/swath < $input_filename > $output_filename");
  25.         $raw = file_get_contents($output_filename);
  26.         $raw_utf8 = iconv("TIS-620", "UTF-8", $raw);
  27.         unlink($input_filename);
  28.         unlink($output_filename);
  29.         return preg_split('/\|/', $raw_utf8);
  30.     }
  31.  
  32.     if($_REQUEST['input_text']) {
  33.         $output = swath($_REQUEST['input_text']);
  34.         print implode(" ", $output);
  35.     }
  36. ?>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement