{"id":815,"date":"2017-11-19T23:55:31","date_gmt":"2017-11-20T08:55:31","guid":{"rendered":"\/blog\/?p=815"},"modified":"2023-09-21T09:37:41","modified_gmt":"2023-09-21T00:37:41","slug":"download-php","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=815","title":{"rendered":"download.php"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\n\/\/ \ud30c\uc77c \ub2e4\uc6b4\ub85c\ub4dc\n\/\/ \uc0ac\uc6a9\ubc29\ubc95 : http:\/\/test.esvali.com\/download.php?download_file=outlaws.mp4\"\n\nignore_user_abort(true);\nset_time_limit(0); \/\/ disable the time limit for this script\n\n$path = \"\/var\/www\/test.esvali.com\/\"; \/\/ change the path to fit your websites document structure\n\n$dl_file = preg_replace(\"([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).]|[\\.]{2,})\", '', $_GET['download_file']); \/\/ simple file name validation\n$dl_file = filter_var($dl_file, FILTER_SANITIZE_URL); \/\/ Remove (more) invalid characters\n$fullPath = $path.$dl_file;\n\nif ($fd = fopen ($fullPath, \"r\")) {\n    $fsize = filesize($fullPath);\n    $path_parts = pathinfo($fullPath);\n    $ext = strtolower($path_parts[\"extension\"]);\n    switch ($ext) {\n        case \"pdf\":\n        header(\"Content-type: application\/pdf\");\n        header(\"Content-Disposition: attachment; filename=\\\"\".$path_parts[\"basename\"].\"\\\"\"); \/\/ use 'attachment' to force a file download\n        break;\n        \/\/ add more headers for other content types here\n        default;\n        header(\"Content-type: application\/octet-stream\");\n        header(\"Content-Disposition: filename=\\\"\".$path_parts[\"basename\"].\"\\\"\");\n        break;\n    }\n    header(\"Content-length: $fsize\");\n    header(\"Cache-control: private\"); \/\/use this to open files directly\n    while(!feof($fd)) {\n        $buffer = fread($fd, 2048);\n        echo $buffer;\n    }\n}\nfclose ($fd);\nexit;<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[23],"tags":[],"class_list":["post-815","post","type-post","status-publish","format-standard","hentry","category-development_web"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=815"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/815\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}