Software /
code /
prosody-modules
Comparison
mod_http_upload_external/share_v2.php @ 3226:3b13f19652e2
mod_http_upload_external: Update share.php and share_v2.php to allow cross-domain requests
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 14 Aug 2018 17:47:44 +0100 |
parent | 3164:5176b8d81ec7 |
child | 3228:bada43f3a546 |
comparison
equal
deleted
inserted
replaced
3225:517c7f0333e3 | 3226:3b13f19652e2 |
---|---|
68 $upload_file_name = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])+1); | 68 $upload_file_name = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])+1); |
69 $store_file_name = $CONFIG_STORE_DIR . '/store-' . hash('sha256', $upload_file_name); | 69 $store_file_name = $CONFIG_STORE_DIR . '/store-' . hash('sha256', $upload_file_name); |
70 | 70 |
71 $request_method = $_SERVER['REQUEST_METHOD']; | 71 $request_method = $_SERVER['REQUEST_METHOD']; |
72 | 72 |
73 /* Set CORS headers */ | |
74 header('Access-Control-Allow-Methods: GET, PUT, OPTIONS'); | |
75 header('Access-Control-Allow-Headers: Content-Type'); | |
76 header('Access-Control-Max-Age: 7200'); | |
77 header('Access-Control-Allow-Origin: *'); | |
78 | |
73 if(array_key_exists('v2', $_GET) === TRUE && $request_method === 'PUT') { | 79 if(array_key_exists('v2', $_GET) === TRUE && $request_method === 'PUT') { |
74 error_log(var_export($_SERVER, TRUE)); | 80 error_log(var_export($_SERVER, TRUE)); |
75 $upload_file_size = $_SERVER['CONTENT_LENGTH']; | 81 $upload_file_size = $_SERVER['CONTENT_LENGTH']; |
76 $upload_token = $_GET['v2']; | 82 $upload_token = $_GET['v2']; |
77 | 83 |
139 readfile($store_file_name); | 145 readfile($store_file_name); |
140 } | 146 } |
141 } else { | 147 } else { |
142 header('HTTP/1.0 404 Not Found'); | 148 header('HTTP/1.0 404 Not Found'); |
143 } | 149 } |
150 } else if($request_method === 'OPTIONS') { | |
144 } else { | 151 } else { |
145 header('HTTP/1.0 400 Bad Request'); | 152 header('HTTP/1.0 400 Bad Request'); |
146 } | 153 } |
147 | 154 |
148 exit; | 155 exit; |