tos can be download as pdf or txt now
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 2 Oct 2014 15:53:25 +0000 (17:53 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 2 Oct 2014 15:53:25 +0000 (17:53 +0200)
web/doc_download.php

index d447c19..9e86ef1 100644 (file)
@@ -9,16 +9,23 @@ function main()
         return(FALSE);
     }
 
-    $fname = sprintf("%s%s.pdf", $G_doc_path, basename($_GET['doc']));
+    $ext = "pdf";
+    $cont_type = "application/octet-stream";
+    if (isset($_GET['ext']) && ($_GET['ext'] == "txt")) {
+        $cont_type = "plain/text";
+        $ext = $_GET['ext'];
+    }
+
+    $fname = sprintf("%s%s.%s", $G_doc_path, basename($_GET['doc']), $ext);
     if (! file_exists($fname)) {
         return(FALSE);
     }
 
-    header("Content-Type: application/octet-stream");
+    header(sprintf("Content-Type: %s", $cont_type));
     header(sprintf("Content-Disposition: attachment; filename=brisk_%s", basename($fname)));
     readfile($fname);
     return(TRUE);
 }
 
 main();
-?>
\ No newline at end of file
+?>