summaryrefslogtreecommitdiff
path: root/upload-msword.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-08-28 23:12:10 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-08-28 23:12:10 -0400
commitf24e77857c4af0c53ac4c7db7e671c3fbf9dc67b (patch)
tree4e3f0fe3f6d0c2ab7492a06b82918d879eb7b70c /upload-msword.php
A neat little weekend (well, two Fridays and a Sunday) project to 1) generate org-mode files from copy/pasted data from MS-word 2) generate Wordpress posts from such org-mode files
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