download.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. //downloading script for QuickSend desktop application
  3. if (isset($_GET['VB_download']) && $_GET['VB_download'] == "true" && isset($_GET['id']) && $_GET['id'] != ""){
  4. $id = $_GET['id'];
  5. $memodir = "Memo/";
  6. $dataType = "TEXT";
  7. if (file_exists($memodir . $id.".txt")){
  8. $myfile = fopen($memodir . $id.".txt", "r") or die("Unable to open file!");
  9. $content = hex2bin(fread($myfile,filesize($memodir . $id.".txt")));
  10. fclose($myfile);
  11. $filetrue = true;
  12. //Process the different filetype
  13. if (strpos($content, "data:image/") !== False && strpos($content, ";base64,") !== False){
  14. //This is an image encoded in base64, throw back to client to handle
  15. echo "<img src='" .$content . "'></img>";
  16. }else if (strpos($content, "data:file/") !== False){
  17. $filename = str_replace("data:file/","uploads/",$content);
  18. if (file_exists($filename) == true){
  19. echo "FILE:" . $filename;
  20. }else{
  21. echo '410 GONE';
  22. }
  23. }else{
  24. echo "TEXT:" .$content;
  25. }
  26. }else{
  27. $filetrue = false;
  28. echo '404 NOTFOUND';
  29. }
  30. }else{
  31. echo 'Invalid operation.';
  32. exit(0);
  33. }
  34. ?>