blob: b23438116071bf639b5765a3dd067f52d80546b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?php
header('Content-type: text/html; charset=utf-8');
$dir = '/home/luke/j1-uploads';
$set = isset($_POST['word_data']) && isset($_POST['filename']);
if ($set) {
$tmp = $dir.'/'.rawurlencode($_POST['filename']).'.tmp';
$fd = fopen($tmp, 'w');
fwrite($fd, $_POST['word_data']);
fclose($fd);
$filename = $dir.'/'.rawurlencode($_POST['filename']).'.org';
$cmd = "< '$tmp' dos2unix | ".dirname(__FILE__)."/word2org.sh 2>&1 > '$filename'";
echo '<pre>'.htmlentities($cmd).'</pre>';
echo '<pre>';
system($cmd, $status);
echo '</pre>';
unlink($tmp);
if ($status != 0) {
unlink($filename);
echo '<p>error</p>';
}
} else {
?>
<form method="post" action="upload-msword.php">
<input type="text" name="filename" />
<textarea name="word_data"></textarea>
<input type="submit" value="upload" />
</form>
<?php
}
|