Last active
November 28, 2020 16:48
-
-
Save leonardostefani/08029bd521d0e760f3a01e1253dbbdb2 to your computer and use it in GitHub Desktop.
Opencart SSL e Access Origin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if($_SERVER['HTTP_HOST'] == 'mercadogun.com' || $_SERVER['HTTP_HOST'] == 'www.mercadogun.com') { | |
echo('<center>Em breve!</center>'); | |
die(); | |
} | |
// Redireciona para https | |
if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === "off") { | |
$location = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
header('HTTP/1.1 301 Moved Permanently'); | |
header('Location: ' . $location); | |
exit; | |
} | |
header('Access-Control-Allow-Origin: *'); | |
header('Access-Control-Allow-Methods: GET, POST'); | |
header("Access-Control-Allow-Headers: Content-Type"); | |
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') | |
exit; | |
// If is JSON request | |
$json_payload = json_decode(file_get_contents('php://input'), true); | |
if($json_payload != NULL) { | |
$_POST = $json_payload; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment