archive.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. $file = '/tmp/cv.tar';
  15. $json = '/tmp/json';
  16. try {
  17. $a = new PharData($file);
  18. file_put_contents ($json, $_POST['json']);
  19. $a->addFile('../cv.html', 'cv/cv.html');
  20. $a->addFile('../demo.html', 'cv/demo.html');
  21. $a->addFile('../js/cv.js', 'cv/js/cv.js');
  22. $a->addFile('../cvgen.html', 'cv/cvgen.html');
  23. $a->addFile('../js/reglages.js', 'cv/js/reglages.js');
  24. $a->addFile('../js/cvgen.js', 'cv/js/cvgen.js');
  25. $a->addFile('../js/info.js', 'cv/js/info.js');
  26. $a->addFile('../js/content.js', 'cv/js/content.js');
  27. $a->addFile('../server/ping.php', 'cv/server/ping.php');
  28. $a->addFile('../server/archive.php', 'cv/server/archive.php');
  29. $a->addFile('../server/download.php', 'cv/server/download.php');
  30. $a->addFile('../js/bootstrap.min.js', 'cv/js/bootstrap.min.js');
  31. $a->addFile('../js/jquery.min.js', 'cv/js/jquery.min.js');
  32. $a->addFile('../js/trianglify.min.js', 'cv/js/trianglify.min.js');
  33. $a->addFile('../js/background.js', 'cv/js/background.js');
  34. $a->addFile('../css/bootstrap.min.css', 'cv/css/bootstrap.min.css');
  35. $a->addFile('../css/cv.css', 'cv/css/cv.css');
  36. $a->addFile('../css/cvgen.css', 'cv/css/cvgen.css');
  37. $a->addFile($json, 'cv/data/cv.json');
  38. $a->addFile('../README.md', 'cv/README.md');
  39. $a->addFile('../data/demo.json', 'cv/data/demo.json');
  40. $a->addFile('../icons/johndoe.jpg', 'cv/icons/johndoe.jpg');
  41. $a->addFile('../LICENSE', 'cv/LICENSE');
  42. $a->addFile($_FILES['uploadFileImage']['tmp_name'], $_POST['img']);
  43. $a->compress(Phar::GZ);
  44. } catch (Exception $e) {
  45. }
  46. $file= $file. ".gz";
  47. if (file_exists($file)) {
  48. $b64 = base64_encode(file_get_contents($file));
  49. header('Content-Description: File Transfer');
  50. header('Content-Type: application/x-tgz');
  51. header('Content-Disposition: attachment; filename='.basename($file));
  52. header('Content-Transfer-Encoding: binary');
  53. header('Content-Length: ' . /*filesize($file)*/ strlen($b64));
  54. ob_clean();
  55. flush();
  56. ob_get_clean();
  57. echo $b64;
  58. ob_end_flush();
  59. unlink($file);
  60. exit;
  61. }
  62. ?>