OLD | NEW |
(Empty) | |
| 1 <?PHP |
| 2 // |
| 3 // OPTIONS |
| 4 // |
| 5 if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { |
| 6 // |
| 7 // FAIL |
| 8 // |
| 9 if ($_GET['preflight'] == "fail-with-500") { |
| 10 header("HTTP/1.1 500"); |
| 11 exit; |
| 12 } |
| 13 if ($_GET['preflight'] == "fail-without-allow") { |
| 14 header("HTTP/1.1 200"); |
| 15 header("Access-Control-Allow-Origin: ${_SERVER['HTTP_ORIGIN']}"); |
| 16 header("Access-Control-Allow-Methods: GET"); |
| 17 exit; |
| 18 } |
| 19 |
| 20 // |
| 21 // PASS |
| 22 // |
| 23 if ($_GET['preflight'] == "pass") { |
| 24 header("HTTP/1.1 200"); |
| 25 header("Access-Control-Allow-Origin: ${_SERVER['HTTP_ORIGIN']}"); |
| 26 header("Access-Control-Allow-Methods: GET"); |
| 27 header("Access-Control-Allow-External: true"); |
| 28 exit; |
| 29 } |
| 30 } |
| 31 |
| 32 // |
| 33 // GET |
| 34 // |
| 35 if ($_SERVER['REQUEST_METHOD'] == 'GET') { |
| 36 header("HTTP/1.1 200"); |
| 37 header("Access-Control-Allow-Origin: ${_SERVER['HTTP_ORIGIN']}"); |
| 38 |
| 39 $arr = array('jsonpResult' => 'success', |
| 40 'method' => $_SERVER['REQUEST_METHOD'], |
| 41 'headers' => getallheaders()); |
| 42 $result = json_encode($arr); |
| 43 |
| 44 if ($_GET['out'] == "img") { |
| 45 header('Content-Type: image/png'); |
| 46 $fn = fopen("abe.png", "r"); |
| 47 fpassthru($fn); |
| 48 fclose($fn); |
| 49 exit; |
| 50 } else if ($_GET['out'] == "frame") { |
| 51 echo "<script>window.top.postMessage(${result}, '*');</script>"; |
| 52 } else { |
| 53 header('Content-Type: application/json'); |
| 54 echo $result; |
| 55 } |
| 56 } |
| 57 |
| 58 ?> |
OLD | NEW |