Fix some Windows Server issues
This commit is contained in:
@@ -10,6 +10,18 @@ namespace Core;
|
|||||||
*/
|
*/
|
||||||
class Response
|
class Response
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Send no cache headers
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public function nocache()
|
||||||
|
{
|
||||||
|
header('Pragma: no-cache');
|
||||||
|
header('Cache-Control: no-cache, must-revalidate');
|
||||||
|
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a custom Content-Type header
|
* Send a custom Content-Type header
|
||||||
*
|
*
|
||||||
@@ -66,7 +78,7 @@ class Response
|
|||||||
public function json(array $data, $status_code = 200)
|
public function json(array $data, $status_code = 200)
|
||||||
{
|
{
|
||||||
$this->status($status_code);
|
$this->status($status_code);
|
||||||
|
$this->nocache();
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode($data);
|
echo json_encode($data);
|
||||||
|
|
||||||
@@ -83,7 +95,7 @@ class Response
|
|||||||
public function text($data, $status_code = 200)
|
public function text($data, $status_code = 200)
|
||||||
{
|
{
|
||||||
$this->status($status_code);
|
$this->status($status_code);
|
||||||
|
$this->nocache();
|
||||||
header('Content-Type: text/plain; charset=utf-8');
|
header('Content-Type: text/plain; charset=utf-8');
|
||||||
echo $data;
|
echo $data;
|
||||||
|
|
||||||
@@ -100,7 +112,7 @@ class Response
|
|||||||
public function html($data, $status_code = 200)
|
public function html($data, $status_code = 200)
|
||||||
{
|
{
|
||||||
$this->status($status_code);
|
$this->status($status_code);
|
||||||
|
$this->nocache();
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
echo $data;
|
echo $data;
|
||||||
|
|
||||||
@@ -117,7 +129,7 @@ class Response
|
|||||||
public function xml($data, $status_code = 200)
|
public function xml($data, $status_code = 200)
|
||||||
{
|
{
|
||||||
$this->status($status_code);
|
$this->status($status_code);
|
||||||
|
$this->nocache();
|
||||||
header('Content-Type: text/xml; charset=utf-8');
|
header('Content-Type: text/xml; charset=utf-8');
|
||||||
echo $data;
|
echo $data;
|
||||||
|
|
||||||
@@ -151,7 +163,7 @@ class Response
|
|||||||
public function binary($data, $status_code = 200)
|
public function binary($data, $status_code = 200)
|
||||||
{
|
{
|
||||||
$this->status($status_code);
|
$this->status($status_code);
|
||||||
|
$this->nocache();
|
||||||
header('Content-Transfer-Encoding: binary');
|
header('Content-Transfer-Encoding: binary');
|
||||||
header('Content-Type: application/octet-stream');
|
header('Content-Type: application/octet-stream');
|
||||||
echo $data;
|
echo $data;
|
||||||
|
|||||||
@@ -114,7 +114,15 @@ class Translator
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return strftime($this->get($format, $format), (int) $timestamp);
|
$format = $this->get($format, $format);
|
||||||
|
|
||||||
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||||
|
$format = str_replace('%e', '%d', $format);
|
||||||
|
$format = str_replace('%G', '%Y', $format);
|
||||||
|
$format = str_replace('%k', '%H', $format);
|
||||||
|
}
|
||||||
|
|
||||||
|
return strftime($format, (int) $timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user