3 (C) 2005 Vidar Løkken <vidarlo@vestdata.no>
5 V.3: I've added escapeshellcmd to all user input that shows up directly
8 switch ($_REQUEST['output']) {
10 $output=escapeshellcmd("-p $_REQUEST[paper]");
13 $output=escapeshellcmd("-a $_REQUEST[paper]");
20 if (isset($_FILES['userfile']['name'])) {
22 $uploadfile = $uploaddir . $_FILES['userfile']['name'];
23 $userfile = $_FILES['userfile']['name'];
24 if (move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile)) {
26 if (strstr($output,"-p")) {
27 $psfile=strtok($userfile,$delims).".ps";
28 header("Content-Type: Application/PostScript");
29 header("Content-Disposition: attachment; filename=".$psfile);
30 $file=escapeshellcmd($uploadfile);
31 $command="antiword $output $file";
34 } elseif (strstr($output,"-a")) {
35 $psfile=strtok($userfile,$delims).".pdf";
36 header("Content-Type: Application/PDF");
37 // header("Content-Disposition: attachment; filename=".$psfile);
38 // $command="antiword $output $uploadfile";
39 $file=escapeshellcmd($uploadfile);
40 $command="antiword $output $file";
45 $file=escapeshellcmd($uploadfile);
46 $command="antiword $output $file";
48 // $command="antiword $output $uploadfile";
53 elseif (isset($_REQUEST['url'])) {
55 $url=$_REQUEST['url'];
56 $uri=escapeshellcmd($_REQUEST['url']);
58 $docfile=explode($delim,$uri);
59 exec("wget -O /tmp/$docfile $url");
60 if (strstr($output,"-p")) {
61 $psfile=strtok(end($docfile),".").".ps";
62 $safe=escapeshellcmd($docfile);
63 $command="antiword $output /tmp/$safe";
64 header("Content-Type: Application/PostScript");
65 header("Content-Disposition: attachment; filename=".$psfile);
67 @@ unlink("/tmp/$docfile");
68 } elseif (strstr($output,"-a")) {
69 $psfile=strtok(end($docfile),".").".pdf";
70 $safe=escapeshellcmd($docfile);
71 $command="antiword $output /tmp/$safe";
72 header("Content-Type: Application/PDF");
73 header("Content-Disposition: attachment; filename=".$psfile);
75 @@ unlink("/tmp/$docfile");
78 $safe=escapeshellcmd($docfile);
79 $command="antiword $output /tmp/$safe";
81 @@ unlink("/tmp/$docfile");
85 if (!isset($_FILES['userfile']['name'])) {
88 This script converts a word
file (most versions supported
) into a
89 pure ASCII
, a PDF
or a PostScript version
. Currently
, only PostScript
90 and PDF carry images
, and those images might be distorted
or such
. It
's
91 based on the nice program antiword. see <a
92 href=http://antiword.cjb.net>antiword.cjb.net</a> for more information
93 about antiword. Currently, max file size is 3MiB for the upload. This
95 </p><p>Currently, I tend to end up with the ascii version being 1/100th
96 of the word document, and the pdf/ps versions being 1/10th of the size.
97 So if you're gonna send me a word document
, rethink that
. I
'll not read
98 it. I'll read ascii
, and probably pdf
/ps too
.</p
>
100 <form enctype
="multipart/form-data" action
="antiword.php" method
="post">
101 <input type
="hidden" name
="MAX_FILE_SIZE" value
="30000" />
102 URL
:<br
/><input type
="text" name
="url" size
=50 /><br
/>
103 Send this file
:<br
/> <input name
="userfile" type
="file"/>
105 <SELECT name
="output">
107 <OPTION name
=txt
>InLine
</OPTION
>
108 <OPTION name
=ps
>PostScript
</OPTION
>
109 <OPTION name
=PDF
>PDF
</OPTION
>
112 Papersize
: <SELECT name
="paper"/>
119 <OPTION
>10x14
</OPTION
>
120 <OPTION
>executive
</OPTION
>
121 <OPTION
>folio
</OPTION
>
122 <OPTION
>legal
</OPTION
>
123 <OPTION
>letter
</OPTION
>
124 <OPTION
>note
</OPTION
>
125 <OPTION
>quarto
</OPTION
>
126 <OPTION
>statement
</OPTION
>
127 <OPTION
>tabloid
</OPTION
>
130 <input type
="submit" value
="Send File" />
132 <p
>This is running
<a href
="http://antiword.cjb.net">antiword
</a
> 0.36. <br
>
133 Please drop me a note at
antiword (at
) bitsex
.net
if you have
136 <font size
=-1>(C
)Vidar L
ø
;kken
2005</font
>
137 <!-- Version
: 0.2 as of
19. oct
. 2005 -->