summaryrefslogtreecommitdiff
path: root/upload-msword.php
diff options
context:
space:
mode:
Diffstat (limited to 'upload-msword.php')
-rw-r--r--upload-msword.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/upload-msword.php b/upload-msword.php
new file mode 100644
index 0000000..b234381
--- /dev/null
+++ b/upload-msword.php
@@ -0,0 +1,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
+} \ No newline at end of file