From a3968036d4889e99ade8580aedd79d0c3ecd2e70 Mon Sep 17 00:00:00 2001 From: Meezaan-ud-Din Abdu Dhil-Jalali Wal-Ikram Date: Fri, 16 Apr 2021 17:41:00 +0400 Subject: [PATCH] Re-add redirect --- html/media/index.php | 108 +++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/html/media/index.php b/html/media/index.php index c4b9515..212e2a6 100644 --- a/html/media/index.php +++ b/html/media/index.php @@ -191,18 +191,18 @@ $number = $request->getAttribute('number'); $edition = $request->getAttribute('edition'); $url = $this->s3url . "audio/" . $this->s3[$edition]['low'] . "/" . $edition . "/" . $number . ".mp3"; - //return $response->withStatus(301)->withHeader('Location', $url); - if (($this->urlExists)($url)) { - $response = $response->withHeader('Content-Description', 'Audio File Transfer') - ->withHeader('Content-Type', 'audio/mp3') - ->withHeader('Expires', gmdate ("D, d M Y H:i:s", time() + 31104000) . " GMT") - ->withHeader('Cache-Control', 'must-revalidate') - ->withHeader('Pragma', 'public'); - readfile($url); - } - else { - $response = $response->withStatus(404)->getBody()->write('Not found'); - } + return $response->withStatus(301)->withHeader('Location', $url); +// if (($this->urlExists)($url)) { +// $response = $response->withHeader('Content-Description', 'Audio File Transfer') +// ->withHeader('Content-Type', 'audio/mp3') +// ->withHeader('Expires', gmdate ("D, d M Y H:i:s", time() + 31104000) . " GMT") +// ->withHeader('Cache-Control', 'must-revalidate') +// ->withHeader('Pragma', 'public'); +// readfile($url); +// } +// else { +// $response = $response->withStatus(404)->getBody()->write('Not found'); +// } return $response; }); @@ -213,20 +213,20 @@ $number = $request->getAttribute('number'); $edition = $request->getAttribute('edition'); $url = $this->s3url . "audio/" . $this->s3[$edition]['high'] . "/" . $edition . "/" . $number . ".mp3"; - //return $response->withStatus(301)->withHeader('Location', $url); - if (($this->urlExists)($url)) { - $response = $response->withHeader('Content-Description', 'Audio File Transfer') - ->withHeader('Content-Type', 'audio/mp3') - ->withHeader('Expires', gmdate ("D, d M Y H:i:s", time() + 31104000) . " GMT") - ->withHeader('Cache-Control', 'must-revalidate') - ->withHeader('Pragma', 'public'); - readfile($url); - } - else { - $response = $response->withStatus(404)->getBody()->write('Not found'); - } - - return $response; + return $response->withStatus(301)->withHeader('Location', $url); +// if (($this->urlExists)($url)) { +// $response = $response->withHeader('Content-Description', 'Audio File Transfer') +// ->withHeader('Content-Type', 'audio/mp3') +// ->withHeader('Expires', gmdate ("D, d M Y H:i:s", time() + 31104000) . " GMT") +// ->withHeader('Cache-Control', 'must-revalidate') +// ->withHeader('Pragma', 'public'); +// readfile($url); +// } +// else { +// $response = $response->withStatus(404)->getBody()->write('Not found'); +// } +// +// return $response; }); @@ -235,20 +235,20 @@ $number = $request->getAttribute('number'); $edition = $request->getAttribute('edition'); $url = $this->s3url . "audio/" . $this->s3[$edition]['medium'] . "/" . $edition . "/" . $number . ".mp3"; - //return $response->withStatus(301)->withHeader('Location', $url); - if (($this->urlExists)($url)) { - $response = $response->withHeader('Content-Description', 'Audio File Transfer') - ->withHeader('Content-Type', 'audio/mp3') - ->withHeader('Expires', gmdate ("D, d M Y H:i:s", time() + 31104000) . " GMT") - ->withHeader('Cache-Control', 'must-revalidate') - ->withHeader('Pragma', 'public'); - readfile($url); - } - else { - $response = $response->withStatus(404)->getBody()->write('Not found'); - } - - return $response; + return $response->withStatus(301)->withHeader('Location', $url); +// if (($this->urlExists)($url)) { +// $response = $response->withHeader('Content-Description', 'Audio File Transfer') +// ->withHeader('Content-Type', 'audio/mp3') +// ->withHeader('Expires', gmdate ("D, d M Y H:i:s", time() + 31104000) . " GMT") +// ->withHeader('Cache-Control', 'must-revalidate') +// ->withHeader('Pragma', 'public'); +// readfile($url); +// } +// else { +// $response = $response->withStatus(404)->getBody()->write('Not found'); +// } +// +// return $response; }); @@ -264,20 +264,20 @@ $surah = $request->getAttribute('surah'); $ayah = $request->getAttribute('ayah'); $url = $this->s3url . 'images/' . $surah . '_' . $ayah . '.png'; - //return $response->withStatus(301)->withHeader('Location', $url); - if (($this->urlExists)($url)) { - $response = $response->withHeader('Content-Description', 'PNG File Transfer') - ->withHeader('Content-Type', 'image/png') - ->withHeader('Expires', gmdate ("D, d M Y H:i:s", time() + 31104000) . " GMT") - ->withHeader('Cache-Control', 'must-revalidate') - ->withHeader('Pragma', 'public'); - readfile($url); - } - else { - $response = $response->withStatus(404)->getBody()->write('Not found'); - } - - return $response; + return $response->withStatus(301)->withHeader('Location', $url); +// if (($this->urlExists)($url)) { +// $response = $response->withHeader('Content-Description', 'PNG File Transfer') +// ->withHeader('Content-Type', 'image/png') +// ->withHeader('Expires', gmdate ("D, d M Y H:i:s", time() + 31104000) . " GMT") +// ->withHeader('Cache-Control', 'must-revalidate') +// ->withHeader('Pragma', 'public'); +// readfile($url); +// } +// else { +// $response = $response->withStatus(404)->getBody()->write('Not found'); +// } +// +// return $response; }); /** Can be expensive, so do not run in pipeline