<?php require_once('wordtable.php')?>
<?php
/* $Id: trans.php,v 1.2 2005/09/07 07:08:47 sbgt Exp sbgt $
 * ■■■
 * 俺達だけが判る暗号話し方決めようぜ 変換スクリプト
 * by sbgt http://etose.101wolves.com/trans/
 *
 * ■■■ 2ch スレ
 * 俺達だけが判る暗号話し方決めようぜ 三言目 http://etc4.2ch.net/test/read.cgi/male/1117974588/
 * 俺達だけが判る暗号話し方決めようぜ 二言目 http://etc4.2ch.net/test/read.cgi/male/1099963053/"
 * 俺達だけが判る暗号話し方決めようぜ http://human5.2ch.net/test/read.cgi/male/1099712131/
 *
 * ■■■ 説明
 * 元々mysql+phpで作成していた「俺達だけが判る暗号話し方決めようぜ」スレ用翻訳スクリプトを、
 * とりあえずDB無しで動くようにしたものです。
 * php には --with-mbstring 等のオプションが必要です。
 */
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
<title>復号化</title>
<link href="base.css" rel="stylesheet" type="text/css">
</head>

<body>
        <?php // include('./navigator.php')  ?>
<h1>復号化</h1>
<form name="form1" method="post" action="./btrans.php">
        <p>
          <textarea name="text" cols="100" rows="5"><? echo $_POST["text"] ?></textarea>
    <?php $_POST["text"]; ?>
</p>
<p>                  
  <input type="submit" name="Submit" value="  ↓  ">
  <label> </label>
  <input type="reset" name="Submit3" value="リセット">
(複数のカキコを一度に変換できますが、やりすぎるとエラーが出ます。)<br>
    復号後の表示を変えてみました。不評なら戻します。<? 
    //  <label><input type="checkbox" name="checkbox" value="checked">
    //    debug</label>
?>
        <div class="log">


        <? //30
//do { 
//    $strShort[$row_Recordset1['wordTo']] = $row_Recordset1['wordFrom'];
//} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); 

$source=$_POST["text"];
$debug=false;
if( $_POST["checkbox"]=="checked" ) $debug=true;

for($i=0;$i<mb_strlen($source,"EUC");$i++){
    $transed=false;
    
    if($debug==1) print "<br>(word ".$i.") <br>";

    for($j=15;$j>0;$j--){
        $temp=mb_substr($source,$i,$j,"EUC");    
        
        if($debug) echo "(".$j.")   ".$temp." <br> "; ///////////////////////

        if($strShort[$temp]!=""){
if($debug)            print "===hit:<font class=\"hit\">$strShort[$temp]</font>===<br>\n";
            $destinationString=$destinationString . $strShort[$temp] ;
            $i=$i+$j-1;
            $transed=true;    
            break;
        }
    }
              if($transed==false){
if($debug)            print "===no hit:<font class=\"hit\">$temp</font>===<br>\n";
                        $destinationString=$destinationString . $temp ;}
}


?> </div>
</form>

<p>
<!--textarea name="textarea2" cols="100" rows="20"><? print $destinationString; ?></textarea-->

<hr><pre><? print $destinationString; ?></pre>
</p>

<?php // include('./footer.php')  ?>

</body>
</html>

<?php
// mysql_free_result($Recordset1);
?>