2020-07-10 12:20:25 +00:00
|
|
|
<?php
|
2020-08-04 11:25:22 +00:00
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-06-12 20:41:09 +00:00
|
|
|
/**
|
2022-02-19 16:06:11 +00:00
|
|
|
* @copyright 2020 Ad Aures
|
2020-06-12 20:41:09 +00:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
2021-08-23 11:05:16 +00:00
|
|
|
namespace Modules\Analytics\Controllers;
|
2020-07-10 12:20:25 +00:00
|
|
|
|
2022-09-28 15:02:09 +00:00
|
|
|
use App\Entities\Episode;
|
|
|
|
use App\Models\EpisodeModel;
|
2021-05-19 16:35:13 +00:00
|
|
|
use CodeIgniter\Controller;
|
2022-09-28 15:02:09 +00:00
|
|
|
use CodeIgniter\Exceptions\PageNotFoundException;
|
2021-05-19 16:35:13 +00:00
|
|
|
use CodeIgniter\HTTP\RedirectResponse;
|
2020-06-12 20:41:09 +00:00
|
|
|
|
2021-04-14 15:58:40 +00:00
|
|
|
class EpisodeAnalyticsController extends Controller
|
2020-06-12 20:41:09 +00:00
|
|
|
{
|
2022-12-09 15:04:42 +00:00
|
|
|
/**
|
2022-12-14 10:02:36 +00:00
|
|
|
* @deprecated Replaced by EpisodeAudioController::index method
|
2022-12-09 15:04:42 +00:00
|
|
|
*/
|
|
|
|
public function hit(string $base64EpisodeData, string ...$audioPath): RedirectResponse
|
2021-05-19 16:35:13 +00:00
|
|
|
{
|
2020-10-29 17:27:16 +01:00
|
|
|
$episodeData = unpack(
|
|
|
|
'IpodcastId/IepisodeId/IbytesThreshold/IfileSize/Iduration/IpublicationDate',
|
2021-04-14 15:58:40 +00:00
|
|
|
base64_url_decode($base64EpisodeData),
|
2020-10-29 17:27:16 +01:00
|
|
|
);
|
|
|
|
|
2022-12-09 15:04:42 +00:00
|
|
|
if ($episodeData === false) {
|
2022-09-28 15:02:09 +00:00
|
|
|
throw PageNotFoundException::forPageNotFound();
|
|
|
|
}
|
|
|
|
|
|
|
|
$episode = (new EpisodeModel())->getEpisodeById($episodeData['episodeId']);
|
|
|
|
|
|
|
|
if (! $episode instanceof Episode) {
|
2022-12-09 15:04:42 +00:00
|
|
|
throw PageNotFoundException::forPageNotFound();
|
2022-09-28 15:02:09 +00:00
|
|
|
}
|
|
|
|
|
2022-12-13 11:34:15 +00:00
|
|
|
return redirect()->route(
|
|
|
|
'episode-audio',
|
|
|
|
[$episode->podcast->handle, $episode->slug, $episode->audio->file_extension]
|
|
|
|
);
|
2020-06-12 20:41:09 +00:00
|
|
|
}
|
|
|
|
}
|