1<?php 2/* 3 * vim:set softtabstop=4 shiftwidth=4 expandtab: 4 * 5 * LICENSE: GNU Affero General Public License, version 3 (AGPL-3.0-or-later) 6 * Copyright 2001 - 2020 Ampache.org 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Affero General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Affero General Public License for more details. 17 * 18 * You should have received a copy of the GNU Affero General Public License 19 * along with this program. If not, see <https://www.gnu.org/licenses/>. 20 * 21 */ 22 23declare(strict_types=1); 24 25namespace Ampache\Module\Application\Utility; 26 27use Ampache\Module\Application\ApplicationActionInterface; 28use Ampache\Module\Authorization\GuiGatekeeperInterface; 29use Psr\Http\Message\ResponseFactoryInterface; 30use Psr\Http\Message\ResponseInterface; 31use Psr\Http\Message\ServerRequestInterface; 32use Teapot\StatusCode; 33 34/** 35 * This is a little bit of a special file, it takes the 36 * content of $_SESSION['iframe']['target'] and does a header 37 * redirect to that spot! 38 */ 39final class ShowAction implements ApplicationActionInterface 40{ 41 public const REQUEST_KEY = 'show'; 42 43 private ResponseFactoryInterface $responseFactory; 44 45 public function __construct( 46 ResponseFactoryInterface $responseFactory 47 ) { 48 $this->responseFactory = $responseFactory; 49 } 50 51 public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface 52 { 53 $response = $this->responseFactory 54 ->createResponse() 55 ->withHeader( 56 'Expires', 57 'Tuesday, 27 Mar 1984 05:00:00 GMT' 58 ) 59 ->withHeader( 60 'Last-Modified', 61 gmdate('D, d M Y H:i:s') . " GMT" 62 ) 63 ->withHeader( 64 'Cache-Control', 65 'no-store, no-cache, must-revalidate' 66 ) 67 ->withHeader( 68 'Pragma', 69 'no-cache' 70 ); 71 72 if (isset($_SESSION['iframe']['target'])) { 73 $target = $_SESSION['iframe']['target']; 74 unset($_SESSION['iframe']['target']); 75 76 $response = $response->withHeader( 77 'Location', 78 $target 79 )->withStatus(StatusCode::FOUND); 80 } else { 81 // Prevent the update query as it's pointless 82 define('NO_SESSION_UPDATE', '1'); 83 } 84 85 return $response; 86 } 87} 88