Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. <?php
  2. session_start();
  3. define('SPATH', '');
  4. require_once('inc/libs.php');
  5. $db = new DataBase(DB_HOST, DB_USER, DB_PASS, DB, false, 'utf8');
  6. $codecustomer = $_REQUEST['codecustomer'];
  7. $version = $_REQUEST['v'];
  8. $versionps = $_REQUEST['vps'];
  9. if (ctype_alnum($codecustomer)) {
  10.  
  11. $result = $db->fetchArray('SELECT * FROM ' . PREF . 'customer_modules WHERE customercode = "' . $codecustomer . '"');
  12. foreach ($result as $itemuser) {
  13. $path = '../../p/prestashow.pl/prestashow_modules/' . $itemuser['modulesname'] . '/';
  14. $w = '/moduledownload.php?codecustomer=' . $codecustomer;
  15.  
  16. if (!empty($version)) {
  17. $w.='&v=' . $version;
  18. $path.=$version . '/';
  19. }
  20. if (!empty($versionps)) {
  21. $w.='&vps=' . $versionps;
  22. $path.=$versionps . '/';
  23. }
  24. $files = scandir($path);
  25. foreach ($files as $item) {
  26.  
  27. if ($item != '.' && $item != '..' && $item != 'desc.pdf') {
  28. // echo $path;
  29. if (file_exists($path)) {
  30. if (empty($version))
  31. echo '<a href="' . $w . '&v=' . $item . '">' . $item . '</a><br>';
  32. elseif (!empty($version) && empty($versionps))
  33. echo '<a href="' . $w . '&vps=' . $item . '">' . $item . '</a><br>';
  34. else {
  35. if (!empty($version) && !empty($versionps)) {
  36.  
  37. $zip = new ZipArchive;
  38. if ($zip->open($path . $item) === TRUE) {
  39. $zip->addFromString('config/conf.txt', $codecustomer . ':dont delete and dont change this file');
  40. $zip->close();
  41. } else {
  42. echo 'failed';
  43. }
  44. $zip_name = $path . $item;
  45. header("Pragma: public");
  46. header("Expires: 0");
  47. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  48. header("Cache-Control: private", false);
  49. header('Content-type: application/zip');
  50. header('Content-Disposition: attachment; filename="' . $item . '"');
  51. readfile($zip_name);
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement