This commit is contained in:
Cody Cook 2024-05-19 20:01:13 -07:00
commit 70c8a87e15
25 changed files with 508 additions and 187 deletions

View file

@ -9,7 +9,7 @@ class DJ
private string $name = ""; private string $name = "";
private string $bio = ""; private string $bio = "";
private string $slug = ""; private string $slug = "";
private string $img = "img/no-image1.png"; private string $img = "/img/no-image1.png";
private bool $active = false; private bool $active = false;
private bool $claimed = false; private bool $claimed = false;
private string $email = ""; private string $email = "";
@ -17,7 +17,7 @@ class DJ
private string $created = ""; private string $created = "";
private string $updated = ""; private string $updated = "";
private string $claimed_by = ""; private string $claimedBy = "";
private $db; private $db;
private array $mixes = []; private array $mixes = [];
@ -27,22 +27,21 @@ class DJ
$this->db = $db; $this->db = $db;
if (ctype_digit((string)$value)) { if (ctype_digit((string)$value)) {
$this->id = (int)$value; $this->id = (int)$value;
return $this->load_from_id(); return $this->loadByID();
} else { } else {
$this->slug = $value; $this->slug = $value;
return $this->load_from_slug(); return $this->loadBySlug();
} }
} }
private function load_from_id(): bool private function loadByID(): bool
{ {
$socials = []; $dj = $this->getDJbyID($this->id);
$dj = $this->get_dj_by_id($this->id); return $this->buildDJ($dj);
return $this->build_dj($dj);
} }
private function get_dj_by_id() private function getDJbyID()
{ {
$stmt = $this->db->prepare("SELECT * FROM djs WHERE id = ?"); $stmt = $this->db->prepare("SELECT * FROM djs WHERE id = ?");
$stmt->bind_param("i", $this->id); $stmt->bind_param("i", $this->id);
@ -57,7 +56,7 @@ class DJ
* @param $dj * @param $dj
* @return bool * @return bool
*/ */
private function build_dj($dj): bool private function buildDJ($dj): bool
{ {
if ($dj) { if ($dj) {
if (isset($dj['id'])) { if (isset($dj['id'])) {
@ -130,7 +129,7 @@ class DJ
$this->updated = $dj['lastupdated']; $this->updated = $dj['lastupdated'];
} }
$this->load_dj_mixes(); $this->loadDJMixes();
return true; return true;
} else { } else {
@ -138,7 +137,7 @@ class DJ
} }
} }
private function load_dj_mixes(): void private function loadDJMixes(): void
{ {
$stmt = $this->db->prepare("SELECT * FROM mix WHERE dj1 = ? OR dj2 = ? OR dj3 = ?"); $stmt = $this->db->prepare("SELECT * FROM mix WHERE dj1 = ? OR dj2 = ? OR dj3 = ?");
$stmt->bind_param("iii", $this->id, $this->id, $this->id); $stmt->bind_param("iii", $this->id, $this->id, $this->id);
@ -154,14 +153,14 @@ class DJ
} }
private function load_from_slug(): bool private function loadBySlug(): bool
{ {
$socials = []; $socials = [];
$dj = $this->get_dj_by_slug($this->slug); $dj = $this->getDJbySlug($this->slug);
return $this->build_dj($dj); return $this->buildDJ($dj);
} }
private function get_dj_by_slug($slug) private function getDJbySlug($slug)
{ {
$stmt = $this->db->prepare("SELECT * FROM djs WHERE slug = ?"); $stmt = $this->db->prepare("SELECT * FROM djs WHERE slug = ?");
$stmt->bind_param("s", $slug); $stmt->bind_param("s", $slug);
@ -172,63 +171,70 @@ class DJ
return $dj; return $dj;
} }
public function get_slug(): string public function getSlug(): string
{ {
return $this->slug; return $this->slug;
} }
public function get_id(): int public function getID(): int
{ {
return $this->id; return $this->id;
} }
public function get_name(): string public function getName(): string
{ {
return $this->name; return $this->name;
} }
public function get_bio(): string public function getBio(): string
{ {
return $this->bio; return $this->bio;
} }
public function get_img(): string public function getImg(): string
{ {
return $this->img; return $this->img;
} }
public function get_active(): bool public function getActive(): bool
{ {
return $this->active; return $this->active;
} }
public function get_email(): string public function getEmail(): string
{ {
return $this->email; return $this->email;
} }
public function get_socials(): array public function getSocials(): array
{ {
return $this->socials; return $this->socials;
} }
public function get_created(): string public function getCreated(): string
{ {
return $this->created; return $this->created;
} }
public function get_updated(): string public function getUpdated(): string
{ {
return $this->updated; return $this->updated;
} }
public function get_claimed(): bool public function getClaimed(): bool
{ {
return $this->claimed; return $this->claimed;
} }
public function get_dj_mixes() public function getDJMixes()
{ {
return $this->mixes; return $this->mixes;
} }
public function getClaimedBy()
{
return $this->claimedBy;
}
} }

View file

@ -49,4 +49,4 @@ class DJs
$stmt->close(); $stmt->close();
return $djs; return $djs;
} }
} }

View file

@ -13,4 +13,4 @@ class Database extends mysqli
// call the parent constructor with the config file // call the parent constructor with the config file
parent::__construct($config['database']['host'], $config['database']['user'], $config['database']['pass'], $config['database']['db'], $config['database']['port'] ?? 3306); parent::__construct($config['database']['host'], $config['database']['user'], $config['database']['pass'], $config['database']['db'], $config['database']['port'] ?? 3306);
} }
} }

106
classes/DownloadMix.php Normal file
View file

@ -0,0 +1,106 @@
<?php
namespace DJMixHosting;
class DownloadMix
{
private $db;
private $mix;
private $ready = false;
private $name;
private $djs;
private $filename;
private $url;
private $mix_id;
private $content;
private $filesize = 0;
private $ext;
public function __construct($mix, $db)
{
$this->db = $db;
$this->mix = $mix;
$this->mix_id = $mix->get_id();
$this->preDownload();
}
private function preDownload()
{
$this->name = $this->mix->get_name();
$buildDJs = $this->mix->get_djs();
$this->url = $this->mix->get_url();
$this->djs = '';
$djCount = 0;
foreach ($buildDJs as $dj) {
if ($djCount > 0) {
$this->djs .= ', ';
}
$this->djs .= $dj->getName();
$djCount++;
}
}
public function download()
{
$this->loadDownload();
if (!$this->ready) {
echo "I had a problem downloading the file.";
return;
} else {
if ($this->checkForMixDownloadCount()) {
$this->incrementMixDownloadCount();
} else {
$this->addMixDownloadCount();
}
header("Content-Description: File Transfer");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"" . $this->filename . "\"");
echo $this->content;
}
}
private function loadDownload()
{
$this->content = file_get_contents($this->url);
$this->filesize = strlen($this->content);
$this->ext = pathinfo(basename($this->url), PATHINFO_EXTENSION);
$this->filename = $this->djs . ' - ' . $this->name . ' (Downloaded from UtahsDJs.com).' . pathinfo(basename($this->url), PATHINFO_EXTENSION);
if ($this->filesize > 0) {
$this->ready = true;
}
}
private function checkForMixDownloadCount()
{
$stmt = $this->db->prepare("SELECT * FROM mix_meta WHERE attribute = 'downloads' and mix_id = ?");
$stmt->bind_param('i', $this->mix_id);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
$stmt->close();
if ($row) {
return true;
} else {
return false;
}
}
private function incrementMixDownloadCount()
{
$stmt = $this->db->prepare("UPDATE mix_meta SET value = value + 1 WHERE attribute = 'downloads' and mix_id = ?");
$stmt->bind_param('i', $this->mix_id);
$stmt->execute();
$stmt->close();
}
private function addMixDownloadCount()
{
$stmt = $this->db->prepare("INSERT INTO mix_meta (mix_id, attribute, value) VALUES (?, 'downloads', 1)");
$stmt->bind_param('i', $this->mix_id);
$stmt->execute();
$stmt->close();
}
}

View file

@ -96,7 +96,7 @@ class Genre
public function get_img(): string public function get_img(): string
{ {
return "img/no-image1.png"; return "/img/no-image1.png";
} }
public function get_count(): int public function get_count(): int
@ -123,4 +123,4 @@ class Genre
return $mixes; return $mixes;
} }
} }

View file

@ -52,4 +52,4 @@ class Genres
$stmt->close(); $stmt->close();
return $genres; return $genres;
} }
} }

View file

@ -76,19 +76,8 @@ class Mix
$this->name = $mix['title']; $this->name = $mix['title'];
$this->slug = $mix['slug']; $this->slug = $mix['slug'];
$this->description = $mix['description']; $this->description = $mix['description'];
if (isset($mix['cover'])) { $this->cover = $this->legacyFix($mix['cover']);
$this->url = $this->legacyFix($mix['url']);
// is this legacy code?
// the code is legacy if it starts with /dj/,
// if it does, prefix with https://www.utahsdjs.com
if (substr($mix['cover'], 0, 5) == "/djs/") {
$mix['cover'] = substr($mix['cover'], 4);
$this->cover = "https://cdn.utahsdjs.com" . $mix['cover'];
} else {
$this->cover = $mix['cover'];
}
}
$this->url = $mix['url'];
$this->seconds = $mix['seconds']; $this->seconds = $mix['seconds'];
$this->duration = $this->configure_duration(); $this->duration = $this->configure_duration();
$this->download_only = $mix['mediaplayer']; $this->download_only = $mix['mediaplayer'];
@ -114,6 +103,15 @@ class Mix
return true; return true;
} }
private function legacyFix(mixed $item)
{
if (str_starts_with($item, "/djs/")) {
return "https://cdn.utahsdjs.com" . substr($item, 4);
} else {
return $item;
}
}
private function configure_duration(): array private function configure_duration(): array
{ {
$seconds = $this->seconds; $seconds = $this->seconds;
@ -201,14 +199,18 @@ class Mix
private function load_by_slug(): bool private function load_by_slug(): bool
{ {
$mix = $this->get_mix_by_slug(); $mix = $this->get_mix_by_slug();
if ($mix) {
if ($mix['title'] != "") { if ($mix['title'] != "") {
return $this->build_mix($mix); return $this->build_mix($mix);
} else {
return false;
}
} else { } else {
return false; return false;
} }
} }
private function get_mix_by_slug() private function get_mix_by_slug()
{ {
$stmt = $this->db->prepare("SELECT * FROM mix WHERE slug = ?"); $stmt = $this->db->prepare("SELECT * FROM mix WHERE slug = ?");
@ -235,7 +237,7 @@ class Mix
return $this->updated; return $this->updated;
} }
public function get_img(): string public function get_img()
{ {
return $this->cover; return $this->cover;
} }
@ -275,7 +277,7 @@ class Mix
return $this->url; return $this->url;
} }
public function get_cover(): string public function get_cover()
{ {
return $this->cover; return $this->cover;
} }
@ -316,5 +318,3 @@ class Mix
} }
} }

View file

@ -11,7 +11,7 @@ class Mixshow
private $slug = ""; private $slug = "";
private $db = null; private $db = null;
private $description = ""; private $description = "";
private $cover = "img/no-image1.png"; private $cover = "/img/no-image1.png";
private $count; private $count;
private $mixes = []; private $mixes = [];
private $updated; private $updated;
@ -145,4 +145,4 @@ class Mixshow
return $this->updated; return $this->updated;
} }
} }

View file

@ -52,4 +52,4 @@ class Mixshows
$stmt->close(); $stmt->close();
return $mixshows; return $mixshows;
} }
} }

61
classes/Playcount.php Normal file
View file

@ -0,0 +1,61 @@
<?php
namespace DJMixHosting;
class Playcount
{
private $db;
private $mix_id;
public function __construct($mix, $db)
{
$this->db = $db;
$this->mix_id = $mix;
}
public function getPlaycount()
{
$sql = "SELECT value FROM mix_meta WHERE mix_id = ? AND attribute = 'playcount'";
$stmt = $this->db->prepare($sql);
$stmt->execute([$this->mix_id]);
$result = $stmt->get_result();
$row = $result->fetch_assoc();
return $row['value'];
}
public function updatePlaycount(): void
{
if ($this->checkForPlaycount()) {
$this->incrementPlaycount();
} else {
$this->addPlaycount();
}
}
private function checkForPlaycount()
{
$sql = "SELECT meta_id FROM mix_meta WHERE mix_id = ? AND attribute = 'playcount'";
$stmt = $this->db->prepare($sql);
$stmt->bind_param('i', $this->mix_id);
$stmt->execute();
$result = $stmt->get_result();
return $result->fetch_assoc();
}
private function incrementPlaycount()
{
$sql = "UPDATE mix_meta SET value = value + 1 WHERE mix_id = ? AND attribute = 'playcount'";
$stmt = $this->db->prepare($sql);
$stmt->execute([$this->mix_id]);
}
public function addPlaycount()
{
$sql = "INSERT INTO mix_meta (mix_id, attribute, value) VALUES (?, 'playcount', 1)";
$stmt = $this->db->prepare($sql);
$stmt->execute([$this->mix_id]);
}
}

View file

@ -59,4 +59,4 @@ class Schema
*/ */
} }

42
dj.php
View file

@ -2,6 +2,7 @@
require_once 'includes/globals.php'; require_once 'includes/globals.php';
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';
use DJMixHosting\Database; use DJMixHosting\Database;
use DJMixHosting\DJ; use DJMixHosting\DJ;
use DJMixHosting\Genre; use DJMixHosting\Genre;
@ -13,11 +14,12 @@ $db = new Database($config);
$djFound = false; $djFound = false;
if (isset($_GET['dj']) && $_GET['dj'] != "") { if (isset($_GET['dj']) && $_GET['dj'] != "") {
$dj = new DJ($_GET['dj'], $db); $dj = new DJ($_GET['dj'], $db);
if ($dj->get_name() != "") { if ($dj->getName() != "") {
$djFound = true; $djFound = true;
$title = $dj->getName();
} }
} }
$title = $dj->get_name();
require_once 'includes/header.php'; require_once 'includes/header.php';
?> ?>
<section> <section>
@ -27,13 +29,15 @@ require_once 'includes/header.php';
<nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4"> <nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4">
<ol class="breadcrumb mb-0"> <ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li> <li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li>
<li class="breadcrumb-item"><a href="/djs.php"><?php echo $locale['djs']; ?></a></li> <li class="breadcrumb-item"><a href="/djs"><?php echo $locale['djs']; ?></a></li>
<li class="breadcrumb-item active" <li class="breadcrumb-item active"
aria-current="page"><?php aria-current="page"><?php
if ($dj && $dj->get_name() != "") { if (isset($dj)) {
echo $dj->get_name(); if ($dj->getName() != "") {
} else { echo $dj->getName();
echo $locale['notfound']; } else {
echo $locale['notfound'];
}
} }
?></li> ?></li>
</ol> </ol>
@ -46,14 +50,14 @@ require_once 'includes/header.php';
<div class="col-lg-4"> <div class="col-lg-4">
<div class="card mb-4"> <div class="card mb-4">
<div class="card-body bg-body-secondary text-center"> <div class="card-body bg-body-secondary text-center">
<img src="<?php echo $dj->get_img(); ?>" <img src="<?php echo $dj->getImg(); ?>"
alt="avatar" alt="avatar"
class="rounded-circle img-fluid" style="width: 150px;"> class="rounded-circle img-fluid" style="width: 150px;">
<h5 class="my-3"><?php echo $dj->get_name(); <h5 class="my-3"><?php echo $dj->getName();
?></h5> ?></h5>
<?php <?php
if ($dj->get_claimed()) { if ($dj->getClaimed()) {
echo '<p class="text-muted mb-1">'; echo '<p class="text-muted mb-1">';
echo "<i class='fa fa-user-shield' style='color: gold'>Claimed</i>"; echo "<i class='fa fa-user-shield' style='color: gold'>Claimed</i>";
echo "</p>"; echo "</p>";
@ -71,13 +75,13 @@ require_once 'includes/header.php';
</div> </div>
</div> </div>
<?php <?php
if ($dj->get_socials() != []) { if ($dj->getSocials() != []) {
?> ?>
<div class="card mb-4 mb-lg-0"> <div class="card mb-4 mb-lg-0">
<div class="card-body p-0 "> <div class="card-body p-0 ">
<ul class="list-group list-group-flush rounded-3"> <ul class="list-group list-group-flush rounded-3">
<?php <?php
$socials = $dj->get_socials(); $socials = $dj->getSocials();
foreach ($socials as $key => $value) { foreach ($socials as $key => $value) {
echo social_line($key, $value); echo social_line($key, $value);
} }
@ -95,14 +99,14 @@ require_once 'includes/header.php';
<p class="mb-0"><?php echo $locale['djName']; ?></p> <p class="mb-0"><?php echo $locale['djName']; ?></p>
</div> </div>
<div class="col-sm-9"> <div class="col-sm-9">
<p class="text-muted mb-0"><?php echo $dj->get_name(); ?></p> <p class="text-muted mb-0"><?php echo $dj->getName(); ?></p>
</div> </div>
</div> </div>
<?php <?php
if ($dj->get_bio() != "") { if ($dj->getBio() != "") {
echo box_line($locale['bio'], $dj->get_bio()); echo box_line($locale['bio'], $dj->getBio());
} }
echo box_line($locale['lastupdated'], $dj->get_updated()); echo box_line($locale['lastupdated'], $dj->getUpdated());
?> ?>
</div> </div>
</div> </div>
@ -112,7 +116,7 @@ require_once 'includes/header.php';
<div class="card mb-4"> <div class="card mb-4">
<div class="card-body bg-body-secondary"> <div class="card-body bg-body-secondary">
<?php <?php
$mixes = $dj->get_dj_mixes(); $mixes = $dj->getDJMixes();
$count = 0; $count = 0;
foreach ($mixes as $mix) { foreach ($mixes as $mix) {
@ -130,7 +134,7 @@ require_once 'includes/header.php';
// Column for mix name and link // Column for mix name and link
echo '<div class="col-md text-truncate" >'; echo '<div class="col-md text-truncate" >';
echo '<p class="mb-0 " >'; echo '<p class="mb-0 " >';
echo '<a title="' . $output->get_name() . '" href="/mix.php?mix=' . $output->get_slug() . '">'; echo '<a title="' . $output->get_name() . '" href="/mix/' . $output->get_slug() . '">';
echo $output->get_name(); echo $output->get_name();
echo '</a>'; echo '</a>';
echo '</p>'; echo '</p>';
@ -140,7 +144,7 @@ require_once 'includes/header.php';
echo '<div class="col-md ">'; echo '<div class="col-md ">';
echo '<p class="mb-0">'; echo '<p class="mb-0">';
foreach ($genrelist as $slug => $name) { foreach ($genrelist as $slug => $name) {
echo ' <a href="/genre.php?genre=' . $slug . '">'; echo ' <a href="/genre/' . $slug . '">';
// ellipse the genre name if it's too long // ellipse the genre name if it's too long
echo '<span class="">' . $name . '</span>'; echo '<span class="">' . $name . '</span>';
echo '</a>'; echo '</a>';

54
djs.php
View file

@ -1,4 +1,5 @@
<?php <?php
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';
require_once 'includes/globals.php'; require_once 'includes/globals.php';
@ -10,37 +11,36 @@ $djs = new DJs($db);
$title = $locale['djs']; $title = $locale['djs'];
require_once 'includes/header.php'; require_once 'includes/header.php';
?> ?>
<section> <section>
<div class="container py-5"> <div class="container py-5">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4"> <nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4">
<ol class="breadcrumb mb-0"> <ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li> <li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li>
<li class="breadcrumb-item active"><a href="/djs.php"><?php echo $locale['djs']; ?></a> <li class="breadcrumb-item active"><a href="/djs"><?php echo $locale['djs']; ?></a></li>
</li> </ol>
</ol> </nav>
</nav> </div>
</div> </div>
</div>
<?php <?php
$djs = $djs->get_nonzero_djs(); $djs = $djs->get_nonzero_djs();
$count = 0; $count = 0;
foreach ($djs as $dj) { foreach ($djs as $dj) {
card_output($count, $dj, $locale); card_output($count, $dj, $locale);
echo '<a href="/dj.php?dj=' . $dj['slug'] . '" class="btn btn-primary">' . $locale['view'] . '</a>'; echo '<a href="/dj/' . $dj['slug'] . '" class="btn btn-primary">' . $locale['view'] . '</a>';
echo '</div>';
echo '</div>';
echo '</div>';
if ($count % 4 == 3) {
echo '</div>'; echo '</div>';
echo '</div>';
echo '</div>';
if ($count % 4 == 3) {
echo '</div>';
}
$count++;
} }
$count++; ?>
}
?>
</div> </div>
</section> </section>
<?php require_once 'includes/footer.php'; ?> <?php require_once 'includes/footer.php'; ?>

17
download.php Normal file
View file

@ -0,0 +1,17 @@
<?php
require_once 'includes/globals.php';
require_once 'vendor/autoload.php';
use DJMixHosting\Database;
use DJMixHosting\Mix;
use DJMixHosting\DownloadMix;
if (isset($_GET['slug'])) {
$db = new Database($config);
$download = new DownloadMix(new Mix($_GET['slug'], $db), $db);
$download->download();
} else {
header("Location: /");
exit();
}

View file

@ -31,7 +31,7 @@ require_once 'includes/header.php';
<nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4"> <nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4">
<ol class="breadcrumb mb-0"> <ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li> <li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li>
<li class="breadcrumb-item"><a href="/genres.php"><?php echo $locale['genres']; ?></a></li> <li class="breadcrumb-item"><a href="/genres"><?php echo $locale['genres']; ?></a></li>
<li class="breadcrumb-item active" <li class="breadcrumb-item active"
aria-current="page"><?php aria-current="page"><?php
if ($genre && $genre->get_name() != "") { if ($genre && $genre->get_name() != "") {
@ -101,15 +101,15 @@ require_once 'includes/header.php';
$output = new Mix($mix, $db); $output = new Mix($mix, $db);
echo '<div class="row">'; echo '<div class="row">';
echo '<p class="mb-0">'; echo '<p class="mb-0">';
echo '<a href="/mix.php?mix=' . $output->get_slug() . '">'; echo '<a href="/mix/' . $output->get_slug() . '">';
echo $output->get_name(); echo $output->get_name();
echo '</a>'; echo '</a>';
echo ' &dash; '; echo ' &dash; ';
$djs = $output->get_djs(); $djs = $output->get_djs();
$djCount = 0; $djCount = 0;
foreach ($djs as $dj) { foreach ($djs as $dj) {
echo '<a href="/dj.php?dj=' . $dj->get_slug() . '">'; echo '<a href="/dj/' . $dj->getSlug() . '">';
echo $dj->get_name(); echo $dj->getName();
echo '</a>'; echo '</a>';
$djCount++; $djCount++;
if ($djCount < count($djs)) { if ($djCount < count($djs)) {

View file

@ -19,7 +19,7 @@ require_once 'includes/header.php';
<nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4"> <nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4">
<ol class="breadcrumb mb-0"> <ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li> <li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li>
<li class="breadcrumb-item active"><a href="/genres.php"><?php echo $locale['genres']; ?></a> <li class="breadcrumb-item active"><a href="/genres"><?php echo $locale['genres']; ?></a>
</li> </li>
</ol> </ol>
</nav> </nav>
@ -35,7 +35,7 @@ require_once 'includes/header.php';
$count = 0; $count = 0;
foreach ($genres as $genre) { foreach ($genres as $genre) {
card_output($count, $genre, $locale); card_output($count, $genre, $locale);
echo '<a href="/genre.php?genre=' . $genre['slug'] . '" class="btn btn-primary">' . $locale['view'] . '</a>'; echo '<a href="/genre/' . $genre['slug'] . '" class="btn btn-primary">' . $locale['view'] . '</a>';
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';

View file

@ -11,6 +11,15 @@ require_once 'includes/sessions.php';
require_once 'includes/lang_loader.php'; require_once 'includes/lang_loader.php';
$mixshowsPages = ["/mixshows", "/mixshows/", "/mixshows.php"];
$djsPages = ["/djs", "/djs/", "/djs.php"];
$genrePages = ["/genres", "/genres/", "/genres.php"];
$specialStyle = array_merge($mixshowsPages, $djsPages, $genrePages);
/** /**
* @param int $count * @param int $count
* @param mixed $dj * @param mixed $dj

View file

@ -0,0 +1,2 @@
<?php
//header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://apis.google.com https://cdnjs.cloudflare.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://cdnjs.cloudflare.com; img-src 'self' data: https://cdn.utahsdjs.com.com; font-src 'self' https://fonts.gstatic.com; connect-src 'self' https://api.example.com; frame-src 'self' https://www.youtube.com; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests; block-all-mixed-content;");

View file

@ -1,16 +1,26 @@
<?php require_once 'includes/header-security.php'; ?>
<!doctype html > <!doctype html >
<html lang="<?php echo $lang ?>" <?php <html lang="<?php echo $lang ?>" <?php
// dark mode checker // dark mode checker
if (isset($_SESSION['darkmode']) && $_SESSION['darkmode'] == 'true') { if (isset($_SESSION['darkmode']) && $_SESSION['darkmode'] == 'true') {
echo 'data-bs-theme="dark"'; echo 'data-bs-theme="dark"';
} ?><head> } ?>
<head>
<?php if (isset($config['seo']['google']) && $config['seo']['google']) { <?php if (isset($config['seo']['google']) && $config['seo']['google']) {
require_once 'includes/google_tag_manager.php'; require_once 'includes/google_tag_manager.php';
echo get_google_tag_manager_header($config['seo']['gtm']['key']); echo get_google_tag_manager_header($config['seo']['gtm']['key']);
} ?> } ?>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $title . " | " . $config['app']['name']; ?></title> <title><?php
$pageTitle = "";
if (isset($title)) {
$pageTitle .= $title . " | ";
}
$pageTitle .= $config['app']['name'];
echo $pageTitle; ?></title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css" <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css"
integrity="sha512-jnSuA4Ss2PkkikSOLtYs8BlYIeeIK1h99ty4YfvRPAlzr377vr3CXDb7sb7eEEBYjDtcYj+AjBH3FLv5uSJuXg==" integrity="sha512-jnSuA4Ss2PkkikSOLtYs8BlYIeeIK1h99ty4YfvRPAlzr377vr3CXDb7sb7eEEBYjDtcYj+AjBH3FLv5uSJuXg=="
crossorigin="anonymous" referrerpolicy="no-referrer"/> crossorigin="anonymous" referrerpolicy="no-referrer"/>
@ -29,9 +39,9 @@ if (isset($_SESSION['darkmode']) && $_SESSION['darkmode'] == 'true') {
<link href="data:image/x-icon;base64,AAABAAEAEBAAAAAAAABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAA////APj4+AB/f38A8fHxAOrq6gATExMA/v7+AAUFBQASEhIA/f39AAsLCwCYmJgABAQEAOjo6AD8/PwAq6urAO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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEBAQoHEwEHEwEKBwEBAQEBAQEKCQAAAAAQCgEBAQEBAQEOAxcAAAAAFwAZAQEBAQEFBxMTFQAAAAAXFQEBAQ8TFRcHDwgAFwAAAAAXBwcBCxIIEhMAEg0SAAAADRgBCgAAAAAAAQEBDwgAAAAACgcAAAAVDwEBBwEAAAAAFwcKAAAAFQEBBgIBABUAABUBAQAAABcAEwEBAQAXAAAXCgENAAAAAAwHAQAXFwAXGgEBGwAAAAAAABUTARUAFAEPAQESAAAAAAAAEgoKFBEBAQEHARUAFwAAAAAPBA4BAQEBAQcHFg0AAAAAFxMBAQEBAQEBAQoKAQcBBwoPAQEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
rel="icon" type="image/x-icon"> rel="icon" type="image/x-icon">
<?php require_once 'includes/hreflang.php'; ?> <?php require_once 'includes/hreflang.php';
<?php if (basename($_SERVER['SCRIPT_NAME']) == 'genres.php' || basename($_SERVER['SCRIPT_NAME']) == 'djs.php') { ?> if (isset($specialStyle) && in_array($_SERVER['SCRIPT_NAME'], $specialStyle)) { ?>
<style> <style>
.card { .card {
height: 160px; height: 160px;

View file

@ -10,8 +10,8 @@ if (isset($_GET['lang']) && array_key_exists($_GET['lang'], $languages)) {
$_SESSION['lang'] = $_GET['lang']; $_SESSION['lang'] = $_GET['lang'];
} }
$current_lang = $_SESSION['lang'] ?? $config['app']['locale']; $current_lang = $_SESSION['lang'] ?? $config['app']['locale'];
?> ?>
<header class="navbar navbar-expand-md bg-body sticky-top shadow"> <header class="navbar navbar-expand-md bg-body sticky-top shadow">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand pe-3" href="/"><?php echo htmlspecialchars($config['app']['name']); ?></a> <a class="navbar-brand pe-3" href="/"><?php echo htmlspecialchars($config['app']['name']); ?></a>
@ -31,21 +31,24 @@ $current_lang = $_SESSION['lang'] ?? $config['app']['locale'];
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link<?php <a class="nav-link<?php
if (basename($_SERVER['SCRIPT_NAME']) == 'genres.php') {
if (in_array($_SERVER['SCRIPT_NAME'], $genrePages)) {
echo current_list(); echo current_list();
} ?>" href="/genres.php"><?php echo $locale['genres']; ?></a> } ?>" href="/genres"><?php echo $locale['genres']; ?></a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link<?php <a class="nav-link<?php
if (basename($_SERVER['SCRIPT_NAME']) == 'djs.php') {
if (in_array($_SERVER['SCRIPT_NAME'], $djsPages)) {
echo current_list(); echo current_list();
} ?>" href="/djs.php"><?php echo $locale['djs']; ?></a> } ?>" href="/djs"><?php echo $locale['djs']; ?></a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link<?php <a class="nav-link<?php
if (basename($_SERVER['SCRIPT_NAME']) == 'mixshows.php') {
if (in_array($_SERVER['SCRIPT_NAME'], $mixshowsPages)) {
echo current_list(); echo current_list();
} ?>" href="/mixshows.php"><?php echo $locale['mixshows']; ?></a> } ?>" href="/mixshows"><?php echo $locale['mixshows']; ?></a>
</li> </li>
</ul> </ul>

View file

@ -58,6 +58,10 @@ return [
"mixshows" => "Mixshows", "mixshows" => "Mixshows",
"mixshow" => "Mixshow", "mixshow" => "Mixshow",
"mixshowName" => "Mixshow Name", "mixshowName" => "Mixshow Name",
"share" => "Share",
"sahrethismix" => "Share this mix",
"sharethismixshow" => "Share this mixshow",

176
mix.php
View file

@ -2,10 +2,12 @@
require_once 'includes/globals.php'; require_once 'includes/globals.php';
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';
use DJMixHosting\Database; use DJMixHosting\Database;
use DJMixHosting\Genre;
use DJMixHosting\Mix; use DJMixHosting\Mix;
use DJMixHosting\Mixshow; use DJMixHosting\Mixshow;
use DJMixHosting\Genre; use DJMixHosting\Playcount;
$db = new Database($config); $db = new Database($config);
@ -22,6 +24,15 @@ if (isset($_GET['mix']) && $_GET['mix'] != "") {
$title = $locale['notfound']; $title = $locale['notfound'];
} }
// if this is a playcount PUT request, update the playcount
if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
$data = json_decode(file_get_contents('php://input'), true);
if (isset($data['mix']) && $data['mix'] != "") {
$playcount = new Playcount($data['mix'], $db);
$playcount->updatePlaycount();
}
}
require_once 'includes/header.php'; ?> require_once 'includes/header.php'; ?>
<section> <section>
@ -68,15 +79,11 @@ require_once 'includes/header.php'; ?>
<div class="card-body bg-body-secondary text-center"> <div class="card-body bg-body-secondary text-center">
<?php <?php
if ($mix->is_download_only()) { if ($mix->is_download_only()) {
echo "<a href='" . $mix->get_url() . "' class='btn btn-primary'>" . $locale['download'] . "</a>"; echo "<a href='/mix/" . $mix->get_slug() . "/download" . "' class='btn btn-primary'>" . $locale['download'] . "</a>";
} else { } else {
echo "<audio controls controlsList='nodownload'>"; echo "<audio controls controlsList='nodownload'>";
$url = $mix->get_url(); $url = $mix->get_url();
// if $url starts with /djs/, cut that. echo "<source src='" . $url . "' type='audio/mpeg'>";
if (substr($url, 0, 4) == "/djs") {
$url = substr($url, 4);
}
echo "<source src='https://cdn.utahsdjs.com" . $url . "' type='audio/mpeg'>";
echo $locale['audioNotSupported']; echo $locale['audioNotSupported'];
echo "</audio>"; echo "</audio>";
@ -85,7 +92,22 @@ require_once 'includes/header.php'; ?>
?> ?>
</div> </div>
</div> </div>
<div class="card mb-4">
<div class="card-body bg-body-secondary text-center">
<a href="#" class="btn btn-secondary w-100 mb-2"
id="shareBtn"><?php echo $locale['share']; ?></a>
<?php if (!$mix->is_download_only()) : ?>
<a href="<?php
echo "/mix/" . $mix->get_slug() . "/download";
?>"
class="btn btn-primary w-100 mb-2"><?php echo $locale['download']; ?></a>
<?php endif; ?>
</div>
</div>
</div> </div>
<div class="col-lg-8"> <div class="col-lg-8">
<div class="card mb-4"> <div class="card mb-4">
<div class="card-body bg-body-secondary"> <div class="card-body bg-body-secondary">
@ -111,9 +133,9 @@ require_once 'includes/header.php'; ?>
$djCount = count($djs); $djCount = count($djs);
$i = 0; $i = 0;
foreach ($djs as $dj) { foreach ($djs as $dj) {
echo "<a href='/dj.php?dj="; echo "<a href='/dj/";
echo $dj->get_slug(); echo $dj->getSlug();
echo "'>" . $dj->get_name() . "</a>"; echo "'>" . $dj->getName() . "</a>";
if ($i < $djCount - 1) { if ($i < $djCount - 1) {
echo ", "; echo ", ";
} }
@ -139,10 +161,9 @@ require_once 'includes/header.php'; ?>
<p class="text-muted mb-0"> <p class="text-muted mb-0">
<?php <?php
$i = 0; $i = 0;
require_once 'classes/Genre.php';
foreach ($genres as $genre) { foreach ($genres as $genre) {
$genre = new Genre($genre, $db); $genre = new Genre($genre, $db);
echo "<a href='/genre.php?genre="; echo "<a href='/genre/";
echo $genre->get_slug(); echo $genre->get_slug();
echo "'>" . $genre->get_name() . "</a>"; echo "'>" . $genre->get_name() . "</a>";
if ($i < $genreCount - 1) { if ($i < $genreCount - 1) {
@ -158,9 +179,9 @@ require_once 'includes/header.php'; ?>
$mixshows = $mix->get_mixshow(); $mixshows = $mix->get_mixshow();
$mixshowsCount = count($mixshows); $mixshowsCount = count($mixshows);
if ($mixshowsCount > 0) { if ($mixshowsCount > 0) {
?> ?>
<hr> <hr>
<div class="row"> <div class="row">
<div class="col-sm-3"> <div class="col-sm-3">
<p class="mb-0"><?php echo $locale['mixshow'] ?></p> <p class="mb-0"><?php echo $locale['mixshow'] ?></p>
</div> </div>
@ -170,7 +191,7 @@ require_once 'includes/header.php'; ?>
$i = 0; $i = 0;
foreach ($mixshows as $mixshow) { foreach ($mixshows as $mixshow) {
$mixshow = new Mixshow($mixshow, $db); $mixshow = new Mixshow($mixshow, $db);
echo "<a href='/mixshow.php?mixshow="; echo "<a href='/mixshow/";
echo $mixshow->get_slug(); echo $mixshow->get_slug();
echo "'>" . $mixshow->get_name() . "</a>"; echo "'>" . $mixshow->get_name() . "</a>";
if ($i < $mixshowsCount - 1) { if ($i < $mixshowsCount - 1) {
@ -180,7 +201,7 @@ require_once 'includes/header.php'; ?>
} }
?> ?>
</div> </div>
</div><?php } ?> </div><?php } ?>
<hr> <hr>
<div class="row"> <div class="row">
<div class="col-sm-3"> <div class="col-sm-3">
@ -288,7 +309,7 @@ require_once 'includes/header.php'; ?>
$i = 0; $i = 0;
$djnamelist = []; $djnamelist = [];
foreach ($djs as $dj) { foreach ($djs as $dj) {
$djnamelist[] = $dj->get_name(); $djnamelist[] = $dj->getName();
$i++; $i++;
} }
@ -331,29 +352,84 @@ require_once 'includes/header.php'; ?>
<?php endif; ?> <?php endif; ?>
</div> </div>
</div> </div>
<?php
if ($mix->get_tracklist() != []) {
echo "<div class='card mb-4 bg-body-secondary'>";
echo "<div class='card-body '>";
echo "<p class='mb-4'><span class='text-primary font-italic me-1'>" . $locale['tracklist'] . "</span></p>";
echo "<ul class='list-group list-group-flush rounded-3 bg-body-secondary'>";
$tracklist = $mix->get_tracklist();
foreach ($tracklist as $track) {
echo "<li class='list-group-item bg-body-secondary d-flex justify-content-between align-items-center'>";
echo $track;
echo "</li>";
}
echo "</ul>";
echo "</div>";
echo "</div>";
}
?>
</div> </div>
<?php
if ($mix->get_tracklist() != []) {
echo "<div class='card mb-4 bg-body-secondary'>";
echo "<div class='card-body '>";
echo "<p class='mb-4'><span class='text-primary font-italic me-1'>" . $locale['tracklist'] . "</span></p>";
echo "<ul class='list-group list-group-flush rounded-3 bg-body-secondary'>";
$tracklist = $mix->get_tracklist();
foreach ($tracklist as $track) {
echo "<li class='list-group-item bg-body-secondary d-flex justify-content-between align-items-center'>";
echo $track;
echo "</li>";
}
echo "</ul>";
echo "</div>";
echo "</div>";
}
?>
</div> </div>
</div> </div>
</div>
<div id="shareModal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2><?php echo $locale['share']; ?></h2>
<a href="#" id="copyLinkBtn" class="btn btn-secondary w-100 mb-2">Copy URL</a>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode('https://utahsdjs.com/mix/' . $_GET['mix']); ?>"
target="_blank" class="btn btn-primary w-100 mb-2">Share to Facebook</a>
<a href="https://twitter.com/intent/tweet?url=<?php echo urlencode('https://utahsdjs.com/mix/' . $_GET['mix']); ?>"
target="_blank" class="btn btn-info w-100 mb-2">Share to X (Twitter)</a>
<a href="https://www.instagram.com/" target="_blank" class="btn btn-danger w-100">Share to Instagram</a>
</div>
</div>
<script>
// Get the modal
var modal = document.getElementById("shareModal");
// Get the button that opens the modal
var btn = document.getElementById("shareBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// Get the copy link button
var copyLinkBtn = document.getElementById("copyLinkBtn");
// Get the URL to be copied
var urlToCopy = window.location.href;
// When the user clicks the button, open the modal
btn.onclick = function () {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function () {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
// When the user clicks the copy link button, copy the URL to the clipboard
copyLinkBtn.onclick = function () {
navigator.clipboard.writeText(urlToCopy).then(function () {
alert('URL copied to clipboard');
}, function (err) {
alert('Failed to copy URL: ', err);
});
}
</script>
<?php else: ?> <?php else: ?>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
@ -362,6 +438,7 @@ require_once 'includes/header.php'; ?>
</div> </div>
</div> </div>
</div> </div>
<?php endif; <?php endif;
?> ?>
@ -369,4 +446,27 @@ require_once 'includes/header.php'; ?>
</div> </div>
</section> </section>
<script>
// when the audio is played, send a PUT request to the page to update the playcount
document.addEventListener('DOMContentLoaded', function () {
const audioElement = document.querySelector('audio');
audioElement.addEventListener('play', function () {
fetch(window.location.href, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({mix: '<?php echo $mix->get_id(); ?>'}),
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
.catch((error) => {
console.error('Error:', error);
});
});
});
</script>
<?php require_once 'includes/footer.php'; ?> <?php require_once 'includes/footer.php'; ?>

View file

@ -17,9 +17,10 @@ if (isset($_GET['mixshow']) && $_GET['mixshow'] != "") {
if ($mixshow->get_name() != "") { if ($mixshow->get_name() != "") {
$mixshowFound = true; $mixshowFound = true;
$title = $mixshow->get_name();
} }
} }
$title = $mixshow->get_name();
require_once 'includes/header.php'; require_once 'includes/header.php';
?> ?>
<section> <section>
@ -29,7 +30,7 @@ require_once 'includes/header.php';
<nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4"> <nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4">
<ol class="breadcrumb mb-0"> <ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li> <li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li>
<li class="breadcrumb-item"><a href="/mixshows.php"><?php echo $locale['mixshows']; ?></a></li> <li class="breadcrumb-item"><a href="/mixshows"><?php echo $locale['mixshows']; ?></a></li>
<li class="breadcrumb-item active" <li class="breadcrumb-item active"
aria-current="page"><?php aria-current="page"><?php
if ($mixshow && $mixshow->get_name() != "") { if ($mixshow && $mixshow->get_name() != "") {
@ -108,7 +109,7 @@ require_once 'includes/header.php';
// Column for mix name and link // Column for mix name and link
echo '<div class="col-md">'; echo '<div class="col-md">';
echo '<p class="mb-0 " >'; echo '<p class="mb-0 " >';
echo '<a href="/mix.php?mix=' . $output->get_slug() . '">'; echo '<a href="/mix/' . $output->get_slug() . '">';
echo $output->get_name(); echo $output->get_name();
echo '</a>'; echo '</a>';
echo '</p>'; echo '</p>';
@ -118,7 +119,7 @@ require_once 'includes/header.php';
echo '<div class="col-md ">'; echo '<div class="col-md ">';
echo '<p class="mb-0">'; echo '<p class="mb-0">';
foreach ($genrelist as $slug => $name) { foreach ($genrelist as $slug => $name) {
echo ' <a href="/genre.php?genre=' . $slug . '">'; echo ' <a href="/genre/' . $slug . '">';
// ellipse the genre name if it's too long // ellipse the genre name if it's too long
echo '<span class="">' . $name . '</span>'; echo '<span class="">' . $name . '</span>';
echo '</a>'; echo '</a>';

View file

@ -1,7 +1,7 @@
<?php <?php
require_once 'includes/globals.php';
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';
require_once 'includes/globals.php';
use DJMixHosting\Database; use DJMixHosting\Database;
use DJMixHosting\Mixshows; use DJMixHosting\Mixshows;
@ -18,9 +18,7 @@ require_once 'includes/header.php';
<nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4"> <nav aria-label="breadcrumb" class="bg-body-tertiary rounded-3 p-3 mb-4">
<ol class="breadcrumb mb-0"> <ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li> <li class="breadcrumb-item"><a href="/"><?php echo $locale['home']; ?></a></li>
<li class="breadcrumb-item active"><a <li class="breadcrumb-item active"><a href="/mixshows"><?php echo $locale['mixshows']; ?></a></li>
href="/mixshows.php"><?php echo $locale['mixshows']; ?></a>
</li>
</ol> </ol>
</nav> </nav>
</div> </div>
@ -32,7 +30,7 @@ require_once 'includes/header.php';
$count = 0; $count = 0;
foreach ($mixshows as $mixshow) { foreach ($mixshows as $mixshow) {
card_output($count, $mixshow, $locale); card_output($count, $mixshow, $locale);
echo '<a href="/mixshow.php?mixshow=' . $mixshow['slug'] . '" class="btn btn-primary">' . $locale['view'] . '</a>'; echo '<a href="/mixshow/' . $mixshow['slug'] . '" class="btn btn-primary">' . $locale['view'] . '</a>';
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';

View file

@ -29,16 +29,16 @@ class DJTest extends TestCase
$this->dj = new DJ(1, $this->mockDb); $this->dj = new DJ(1, $this->mockDb);
// Assertions to verify that the DJ object is correctly built // Assertions to verify that the DJ object is correctly built
$this->assertEquals(1, $this->dj->get_id()); $this->assertEquals(1, $this->dj->getID());
$this->assertEquals('Test DJ', $this->dj->get_name()); $this->assertEquals('Test DJ', $this->dj->getName());
$this->assertEquals('This is a test bio', $this->dj->get_bio()); $this->assertEquals('This is a test bio', $this->dj->getBio());
$this->assertEquals('test-dj', $this->dj->get_slug()); $this->assertEquals('test-dj', $this->dj->getSlug());
$this->assertEquals('https://cdn.utahsdjs.com/test-dj.png', $this->dj->get_img()); $this->assertEquals('https://cdn.utahsdjs.com/test-dj.png', $this->dj->getImg());
$this->assertEquals('test@example.com', $this->dj->get_email()); $this->assertEquals('test@example.com', $this->dj->getEmail());
$this->assertTrue($this->dj->get_active()); $this->assertTrue($this->dj->getActive());
$this->assertEquals('2021-01-01 00:00:00', $this->dj->get_created()); $this->assertEquals('2021-01-01 00:00:00', $this->dj->getCreated());
$this->assertEquals('2021-01-01 00:00:00', $this->dj->get_updated()); $this->assertEquals('2021-01-01 00:00:00', $this->dj->getUpdated());
$this->assertFalse($this->dj->get_claimed()); $this->assertFalse($this->dj->getClaimed());
} }
public function testLoadFromSlug() public function testLoadFromSlug()
@ -58,16 +58,16 @@ class DJTest extends TestCase
$this->dj = new DJ('test-dj', $this->mockDb); $this->dj = new DJ('test-dj', $this->mockDb);
// Assertions to verify that the DJ object is correctly built // Assertions to verify that the DJ object is correctly built
$this->assertEquals(1, $this->dj->get_id()); $this->assertEquals(1, $this->dj->getID());
$this->assertEquals('Test DJ', $this->dj->get_name()); $this->assertEquals('Test DJ', $this->dj->getName());
$this->assertEquals('This is a test bio', $this->dj->get_bio()); $this->assertEquals('This is a test bio', $this->dj->getBio());
$this->assertEquals('test-dj', $this->dj->get_slug()); $this->assertEquals('test-dj', $this->dj->getSlug());
$this->assertEquals('https://cdn.utahsdjs.com/test-dj.png', $this->dj->get_img()); $this->assertEquals('https://cdn.utahsdjs.com/test-dj.png', $this->dj->getImg());
$this->assertEquals('test@example.com', $this->dj->get_email()); $this->assertEquals('test@example.com', $this->dj->getEmail());
$this->assertTrue($this->dj->get_active()); $this->assertTrue($this->dj->getActive());
$this->assertEquals('2021-01-01 00:00:00', $this->dj->get_created()); $this->assertEquals('2021-01-01 00:00:00', $this->dj->getCreated());
$this->assertEquals('2021-01-01 00:00:00', $this->dj->get_updated()); $this->assertEquals('2021-01-01 00:00:00', $this->dj->getUpdated());
$this->assertFalse($this->dj->get_claimed()); $this->assertFalse($this->dj->getClaimed());
} }
protected function setUp(): void protected function setUp(): void