Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <?
  2. if (isset($_GET["module"])) {
  3. $order_id = (int)$_GET["module"];
  4. if (preg_match("@^[0-9]{1,6}$@i", $order_id)) {
  5. if ($functions->existsOrderById($order_id)){
  6. $getOrderData = $db->query("SELECT * FROM orders WHERE id='".$order_id."'")->fetch_assoc();
  7. if ($_globalUserData["company_id"] == $getOrderData["client_id"] || $functions->isPrivileged($_SESSION["PublicAccess"])) {
  8. if (isset($_GET["submodule"])) {
  9. $attachment_id = (int)$_GET["submodule"];
  10. if (preg_match("@^[0-9]{1,8}$@i", $attachment_id)) {
  11. $set_query = $db->query("SELECT * FROM attachments WHERE id=".$attachment_id." AND order_id=".$order_id);
  12. if ($set_query->num_rows > 0) {
  13. $fetch_file = $set_query->fetch_assoc();
  14. $file = UPLOAD_PATH.$fetch_file["file_name"];
  15. if (file_exists($file) && is_file($file)) {
  16. if(ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); }
  17. header('Content-Type: "application/octet-stream"');
  18. header('Content-Disposition: attachment; filename="'.basename($file).'"');
  19. header("Content-Transfer-Encoding: binary");
  20. header('Expires: 0');
  21. header('Pragma: no-cache');
  22. header("Content-Length: ".filesize($file));
  23. } else {
  24. $smarty->assign("error", $ErrorMessages["ERROR_INEXISTENT"]);
  25. $smarty->display("error");
  26. echo "Kod wystąpienia: 10001";
  27. }
  28. } else {
  29. $smarty->assign("error", $ErrorMessages["ERROR_INEXISTENT"]);
  30. $smarty->display("error");
  31. echo "Kod wystąpienia: 10002";
  32. }
  33. } else {
  34. $smarty->assign("error", $ErrorMessages["ERROR_FORMAT"]);
  35. $smarty->display("error");
  36. echo "Kod wystąpienia: 10003";
  37. }
  38. } else {
  39. $smarty->assign("error", $ErrorMessages["ERROR_INEXISTENT"]);
  40. $smarty->display("error");
  41. echo "Kod wystąpienia: 10004";
  42. }
  43. } else {
  44. $smarty->assign("error", $ErrorMessages["ERROR_ACCESS"]);
  45. $smarty->display("error");
  46. echo "Kod wystąpienia: 10005";
  47. }
  48. } else {
  49. $smarty->assign("error", $ErrorMessages["ERROR_INEXISTENT"]);
  50. $smarty->display("error");
  51. echo "Kod wystąpienia: 10006";
  52. }
  53. } else {
  54. $smarty->assign("error", $ErrorMessages["ERROR_FORMAT"]);
  55. $smarty->display("error");
  56. echo "Kod wystąpienia: 10007";
  57. }
  58. } else {
  59. $smarty->assign("error", $ErrorMessages["ERROR_INEXISTENT"]);
  60. $smarty->display("error");
  61. echo "Kod wystąpienia: 10008";
  62. }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement