Skip to content

Instantly share code, notes, and snippets.

@leonardostefani
Last active November 28, 2020 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonardostefani/08029bd521d0e760f3a01e1253dbbdb2 to your computer and use it in GitHub Desktop.
Save leonardostefani/08029bd521d0e760f3a01e1253dbbdb2 to your computer and use it in GitHub Desktop.
Opencart SSL e Access Origin
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