parent
2e642fe2ad
commit
63bc6fa13e
2 changed files with 64 additions and 0 deletions
@ -0,0 +1,32 @@ |
||||
<?php |
||||
function endsWith( $haystack, $needle ) { |
||||
$length = strlen( $needle ); |
||||
if( !$length ) { |
||||
return true; |
||||
} |
||||
return substr( $haystack, -$length ) === $needle; |
||||
} |
||||
|
||||
// open the file in a binary mode |
||||
$resource = $_GET["res"]; |
||||
$name = "./${resource}"; |
||||
$fp = fopen($name, 'rb'); |
||||
|
||||
// send the right headers |
||||
if(endsWith($resource, ".html")) { |
||||
header("Content-Type: text/html"); |
||||
} elseif (endsWith($resource, ".js")) { |
||||
header("Content-Type: text/javascript"); |
||||
} elseif (endsWith($resource, ".wasm")) { |
||||
header("Content-Type: application/wasm"); |
||||
} else { |
||||
header("Content-Type: text/html"); |
||||
} |
||||
header("Content-Length: " . filesize($name)); |
||||
header("Cross-Origin-Embedder-Policy: require-corp"); |
||||
header("Cross-Origin-Opener-Policy: same-origin"); |
||||
fpassthru($fp); |
||||
exit; |
||||
|
||||
?> |
||||
|
@ -0,0 +1,32 @@ |
||||
<?php |
||||
function endsWith( $haystack, $needle ) { |
||||
$length = strlen( $needle ); |
||||
if( !$length ) { |
||||
return true; |
||||
} |
||||
return substr( $haystack, -$length ) === $needle; |
||||
} |
||||
|
||||
// open the file in a binary mode |
||||
$resource = "optflow.html"; |
||||
$name = "./${resource}"; |
||||
$fp = fopen($name, 'rb'); |
||||
|
||||
// send the right headers |
||||
if(endsWith($resource, ".html")) { |
||||
header("Content-Type: text/html"); |
||||
} elseif (endsWith($resource, ".js")) { |
||||
header("Content-Type: text/javascript"); |
||||
} elseif (endsWith($resource, ".wasm")) { |
||||
header("Content-Type: application/wasm"); |
||||
} else { |
||||
header("Content-Type: text/html"); |
||||
} |
||||
header("Content-Length: " . filesize($name)); |
||||
header("Cross-Origin-Embedder-Policy: require-corp"); |
||||
header("Cross-Origin-Opener-Policy: same-origin"); |
||||
fpassthru($fp); |
||||
exit; |
||||
|
||||
?> |
||||
|
Loading…
Reference in new issue