処理結果

999 || $count < 1) { echo "

エラー: $count

"; } elseif ($_POST['submit'] == "PDF生成" && $_POST['text'] != "") { $f = fopen("work/$count.tex", "w"); fwrite($f, $_POST['text']); fwrite($f, "\n"); fclose($f); echo "

platex -kanji=utf8 $count

"; echo "
\n";
    $dvi = 0;  $log = 0;
    $f = popen("HOME=/tmp; cd work; ulimit -t 10 -f 2048; /usr/local/texlive/2016/bin/x86_64-linux/platex -kanji=utf8 -interaction=nonstopmode $count.tex", "r");
    if ($f) {
      while ($buf = fgets($f, 4096)) {
        if (preg_match("/^Output written on \d+\.dvi/", $buf)) $dvi = 1;
        if (preg_match("/^Transcript written on \d+\.log/", $buf)) $log = 1;
        echo htmlspecialchars($buf);
      }
      pclose($f);
    } else {
      echo "

Cannot run platex

\n"; } echo "
\n"; if ($log) echo "

$count.log

\n"; if ($dvi) { echo "

$count.dvi

\n"; $good = 0; echo "

dvipdfmx $count

"; echo "
\n";
      $f = popen("HOME=/tmp; cd work; ulimit -t 10 -f 2048; /usr/local/texlive/2016/bin/x86_64-linux/dvipdfmx $count.dvi 2>&1", "r");
      if ($f) {
        while ($buf = fgets($f, 4096)) {
          if (preg_match("/\d+\.pdf/", $buf)) $good = 1;
          echo htmlspecialchars($buf);
        }
        pclose($f);
        echo "
\n"; if ($good) { echo "

$count.pdf

\n"; } else { echo "

dvipdfmx: エラー

\n"; } } else { echo "

dvipdfmx: エラー\n"; } } else { echo "

platex: エラー\n"; } } elseif ($_POST['submit'] == "関連ファイル削除") { echo "

rm -f $count.*


"; echo "
\n";
    system("cd work; /bin/rm -f $count.*");
    echo "
\n"; } else { echo "

エラー

\n"; } ?>