X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/d1a708afbff086d1600f4d87e6946f82016e2e3a..67f24b02807a1ff7e9d1a97453ed84c404c0af0f:/wp-app.php diff --git a/wp-app.php b/wp-app.php index 0ada250e..11f4ec77 100644 --- a/wp-app.php +++ b/wp-app.php @@ -780,6 +780,7 @@ EOD; } $location = get_post_meta($entry['ID'], '_wp_attached_file', true); + $location = get_option ('upload_path') . '/' . $location; $filetype = wp_check_filetype($location); if(!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext'])) @@ -789,11 +790,19 @@ EOD; header('Content-Type: ' . $entry['post_mime_type']); header('Connection: close'); - $fp = fopen($location, "rb"); - while(!feof($fp)) { - echo fread($fp, 4096); + if ($fp = fopen($location, "rb")) { + status_header('200'); + header('Content-Type: ' . $entry['post_mime_type']); + header('Connection: close'); + + while(!feof($fp)) { + echo fread($fp, 4096); + } + + fclose($fp); + } else { + status_header ('404'); } - fclose($fp); log_app('function',"get_file($postID)"); exit;