mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-08-10 15:51:11 +02:00
28 lines
No EOL
1,008 B
PHP
28 lines
No EOL
1,008 B
PHP
<?php
|
|
class Response {
|
|
private static function defaultHeaders () {
|
|
header('Access-Control-Allow-Origin: *');
|
|
header('Expires: Sun, 01 Nov 2015 22:46:51 GMT');
|
|
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
|
|
header('Cache-Control: post-check=0, pre-check=0', false);
|
|
header('Pragma: no-cache');
|
|
if (strpos($_SERVER['SERVER_NAME'], 'localhost') !== false) {
|
|
# To resolve the issue with "Your connection to this site is not secure" message
|
|
header('Content-Security-Policy: upgrade-insecure-requests env=HTTPS');
|
|
}
|
|
}
|
|
|
|
public static function json ($data, $http_code = 200) {
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
Response::defaultHeaders();
|
|
http_response_code($http_code);
|
|
echo json_encode($data);
|
|
}
|
|
|
|
public static function html ($html, $http_code = 200) {
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
Response::defaultHeaders();
|
|
http_response_code($http_code);
|
|
echo $html;
|
|
}
|
|
} |