1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-04 10:19:24 +02:00

Commiting modifications

This commit is contained in:
Daniel 2022-02-04 12:37:14 -03:00
parent 0c02baeda4
commit f837ed080e

View file

@ -5625,7 +5625,27 @@ function forbiddenPage($message = '', $logMessage = false, $unlockPassword = '',
if ($logMessage) {
_error_log($message);
}
$headers = headers_list(); // get list of headers
foreach ($headers as $header) { // iterate over that list of headers
if (stripos($header, 'Content-Type') !== FALSE) { // if the current header hasthe String "Content-Type" in it
$headerParts = explode(':', $header); // split the string, getting an array
$headerValue = trim($headerParts[1]); // take second part as value
$contentType = $headerValue;
break;
}
}
if(empty($unlockPassword) && preg_match('/json/i', $contentType)){
header("Content-Type: application/json");
$obj = new stdClass();
$obj->error = true;
$obj->msg = $message;
$obj->forbiddenPage = true;
die(json_encode($obj));
}else{
header("Content-Type: text/html");
include $global['systemRootPath'] . 'view/forbiddenPage.php';
}
exit;
}