diff --git a/classes/Mixshow.php b/classes/Mixshow.php index 693bd04..08037dc 100644 --- a/classes/Mixshow.php +++ b/classes/Mixshow.php @@ -9,9 +9,10 @@ class Mixshow private $slug = ""; private $db = null; private $description = ""; - private $cover = ""; + private $cover = "img/no-image1.png"; private $count; private $mixes = []; + private $updated; public function __construct($value, $db) { @@ -29,7 +30,7 @@ class Mixshow private function load_by_id() { $mixshow = $this->get_mixshow_by_id(); - if ($mixshow && $mixshow['title'] != "") { + if ($mixshow && $mixshow['name'] != "") { return $this->build_mixshow($mixshow); } else { return false; @@ -52,8 +53,16 @@ class Mixshow $this->name = $mixshow['name']; $this->slug = $mixshow['slug']; $this->description = $mixshow['description']; - $this->cover = $mixshow['cover']; - $this->enabled = $mixshow['enabled']; + // is this legacy code? + // the code is legacy if it starts with /dj/, + // if it does, prefix with https://www.utahsdjs.com + if (substr($mixshow['cover'], 0, 5) == "/djs/") { + // remove /djs/ from the string + $mixshow['cover'] = substr($mixshow['cover'], 4); + $this->cover = "https://cdn.utahsdjs.com" . $mixshow['cover']; + } + + $this->updated = $mixshow['lastupdated']; $this->count = $mixshow['count']; $this->load_mixes(); return true; @@ -61,7 +70,7 @@ class Mixshow private function load_mixes() { - $stmt = $this->db->prepare("SELECT value FROM mix_meta WHERE value = ?"); + $stmt = $this->db->prepare("SELECT mix_id FROM mix_meta WHERE value = ? AND attribute = 'mixshow'"); $stmt->bind_param("i", $this->id); $stmt->execute(); $result = $stmt->get_result(); @@ -74,7 +83,7 @@ class Mixshow private function load_by_slug() { $mixshow = $this->get_mixshow_by_slug(); - if ($mixshow && $mixshow['title'] != "") { + if ($mixshow && $mixshow['name'] != "") { return $this->build_mixshow($mixshow); } else { return false; @@ -130,5 +139,8 @@ class Mixshow return $this->mixes; } + public function get_updated(){ + return $this->updated; + } } \ No newline at end of file diff --git a/classes/Mixshows.php b/classes/Mixshows.php new file mode 100644 index 0000000..c2415cf --- /dev/null +++ b/classes/Mixshows.php @@ -0,0 +1,53 @@ +db = $db; + if (!$this->load_all_mixshows()) { + return false; + } else { + return true; + } + + } + + private function load_all_mixshows(): bool + { + $mixshows = $this->get_all_mixshows(); + if ($mixshows) { + $this->mixshows = $mixshows; + return true; + } else { + return false; + } + + + } + + public function get_all_mixshows($order = "ASC") + { + $stmt = $this->db->prepare("SELECT * FROM shows ORDER BY name $order"); + $stmt->execute(); + $result = $stmt->get_result(); + $mixshows = $result->fetch_all(MYSQLI_ASSOC); + $stmt->close(); + return $mixshows; + } + + public function get_nonzero_mixshows() + { + $stmt = $this->db->prepare("SELECT * FROM shows WHERE count > 0 ORDER BY name ASC"); + $stmt->execute(); + $result = $stmt->get_result(); + $mixshows = $result->fetch_all(MYSQLI_ASSOC); + $stmt->close(); + return $mixshows; + } +} \ No newline at end of file diff --git a/classes/User.php b/classes/User.php new file mode 100644 index 0000000..e69fd8e --- /dev/null +++ b/classes/User.php @@ -0,0 +1,50 @@ +db = $db; + } + + /** + * @throws RandomException + */ + public function newUser($username, $password, $email){ + $this->username = $username; + $this->email = $email; + $password2 = password_hash($password, PASSWORD_DEFAULT); + $this->password = $password2; + + $this->location = ""; + $this->bio = ""; + $this->created = date('Y-m-d H:i:s'); + $this->updated = date('Y-m-d H:i:s'); + $this->verified = 0; + $this->role = "user"; + $this->img = ""; + $this->api_key = bin2hex(random_bytes(32)); + + $stmt = $this->db->prepare("INSERT INTO users (username, password, email, img) VALUES (?, ?, ?, ?)"); + $stmt->bind_param("ssss", $this->username, $this->password, $this->email, $this->img); + $stmt->execute(); + $stmt->close(); + + } + + +} \ No newline at end of file diff --git a/dj.php b/dj.php index e7a94d6..9e0b6c0 100644 --- a/dj.php +++ b/dj.php @@ -72,7 +72,7 @@ require_once 'includes/header.php'; if ($dj->get_socials() != []) { ?>
-
+
    get_socials(); @@ -123,22 +123,23 @@ require_once 'includes/header.php'; $genrelist[$genr->get_slug()] = $genr->get_name(); } - echo '
    '; // Start row for each mix + echo '
    '; // Start row for each mix // Column for mix name and link - echo '
    '; - echo '

    '; - echo ''; + echo '

    '; // End column // Column for genres - echo '
    '; + echo '
    '; echo '

    '; foreach ($genrelist as $slug => $name) { echo ' '; + // ellipse the genre name if it's too long echo '' . $name . ''; echo ''; } @@ -146,12 +147,27 @@ require_once 'includes/header.php'; echo '

    '; // End column // Column for duration - echo '
    '; + echo '
    '; echo '

    '; $duration = $output->get_duration(); echo $duration['t']; echo '

    '; echo '
    '; // End column + + // Column for date + echo '
    '; + echo '

    '; + // date format should just be year + $date = $output->get_recorded(); + if ($date == "") { + $date = $output->get_created(); + } + echo date('Y', strtotime($date)); + + echo '

    '; + echo '
    '; // End column + + echo '
    '; // End row $count++; @@ -168,12 +184,12 @@ require_once 'includes/header.php';
    -
    - +
    + -
    +
    +
    diff --git a/genre.php b/genre.php index 0535235..3e0e19d 100644 --- a/genre.php +++ b/genre.php @@ -66,6 +66,16 @@ require_once 'includes/header.php';
    +
    +
    +

    +
    +
    +

    get_name(); ?> +

    +
    +
    +

    @@ -92,6 +102,18 @@ require_once 'includes/header.php'; echo ''; echo $output->get_name(); echo ''; + echo ' ‐ '; + $djs = $output->get_djs(); + $djCount = 0; + foreach ($djs as $dj) { + echo ''; + echo $dj->get_name(); + echo ''; + $djCount++; + if ($djCount < count($djs)) { + echo ', '; + } + } echo '

    '; echo '
    '; $count++; diff --git a/includes/globals.php b/includes/globals.php index 6d7f4de..449a98a 100644 --- a/includes/globals.php +++ b/includes/globals.php @@ -25,7 +25,7 @@ function card_output(int $count, mixed $dj, mixed $locale): void echo '
    '; echo '
    '; echo '
    '; - echo '
    ' . $dj['name'] . '
    '; + echo '
    ' . $dj['name'] . '
    '; echo '

    ' . $dj['count'] . ' '; if ($dj['count'] == 1) { echo $locale['mix']; diff --git a/includes/navbar.php b/includes/navbar.php index 2487ce5..5afcf1b 100644 --- a/includes/navbar.php +++ b/includes/navbar.php @@ -41,6 +41,12 @@ $current_lang = $_SESSION['lang'] ?? $config['app']['locale']; echo current_list(); } ?>" href="/djs.php"> +

'Welcome to our Website!', 'description' => 'This is a description in English.', + 'desc' => 'Description', 'userProfile' => "User Profile", 'user' => 'User', 'home' => 'Home', @@ -23,6 +24,7 @@ return [ "mixes" => "Mixes", "mix" => "Mix", "mixNotFound" => "Could not load mix; either the mix wasn't found, was empty, or this mix is private.", + "mixshowNotFound" => "Could not load mixshow; either the mixshow wasn't found, was empty, or this mixshow is private.", "mixName" => "Mix Name", "mixDescription" => "Mix Description", "mixLength" => "Mix Length", @@ -53,6 +55,9 @@ return [ "play" => "Play", "contactus" => "Contact Us", "allrightsreserved" => "All rights reserved.", + "mixshows" => "Mixshows", + "mixshow" => "Mixshow", + "mixshowName" => "Mixshow Name", diff --git a/login.php b/login.php new file mode 100644 index 0000000..98b4f2b --- /dev/null +++ b/login.php @@ -0,0 +1,58 @@ +login($username, $password); + } +} + +require_once 'includes/header.php'; ?> +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + +
+
+ + +
+ +
+
+
+
+
+
+ +
+ + \ No newline at end of file diff --git a/mix.php b/mix.php index 15f4f03..ae39f25 100644 --- a/mix.php +++ b/mix.php @@ -150,6 +150,34 @@ require_once 'includes/header.php'; ?> ?>
+ + get_mixshow(); + $mixshowsCount = count($mixshows); + if ($mixshowsCount > 0) { + ?> +
+
+
+

+
+
+

+ get_slug(); + echo "'>" . $mixshow->get_name() . ""; + if ($i < $mixshowsCount - 1) { + echo ", "; + } + $i++; + } + ?> +

+

@@ -303,13 +331,13 @@ require_once 'includes/header.php'; ?> get_tracklist() != []) { - echo "
"; - echo "
"; + echo "
"; + echo "
"; echo "

" . $locale['tracklist'] . "

"; - echo "
    "; + echo "
      "; $tracklist = $mix->get_tracklist(); foreach ($tracklist as $track) { - echo "
    • "; + echo "
    • "; echo $track; echo "
    • "; } diff --git a/mixshow.php b/mixshow.php new file mode 100644 index 0000000..7babd1d --- /dev/null +++ b/mixshow.php @@ -0,0 +1,174 @@ +get_name() != "") { + + $mixshowFound = true; + } +} +$title = $mixshow->get_name(); +require_once 'includes/header.php'; +?> +
      +
      +
      +
      + +
      +
      + + +
      +
      +
      +
      + avatar +
      get_name(); + ?>
      + +
      + +
      +
      +
      +
      +
      +
      +
      +
      +
      +

      +
      +
      +

      get_name(); ?>

      +
      +
      + get_description() != "") { + echo box_line($locale['desc'], $mixshow->get_description()); + } + echo box_line($locale['lastupdated'], $mixshow->get_updated()); + ?> +
      +
      + +
      +
      +
      +
      + get_mixes(); + $count = 0; + + foreach ($mixes as $mix) { + $output = new Mix($mix['mix_id'], $db); + $genres = $output->get_genres(); + $genrelist = []; + + foreach ($genres as $genre) { + $genr = new Genre($genre, $db); + $genrelist[$genr->get_slug()] = $genr->get_name(); + } + + echo '
      '; // Start row for each mix + + // Column for mix name and link + echo '
      '; + echo '

      '; + echo ''; + echo $output->get_name(); + echo ''; + echo '

      '; + echo '
      '; // End column + + // Column for genres + echo '
      '; + echo '

      '; + foreach ($genrelist as $slug => $name) { + echo ' '; + // ellipse the genre name if it's too long + echo '' . $name . ''; + echo ''; + } + echo '

      '; + echo '
      '; // End column + + // Column for duration + echo '
      '; + echo '

      '; + $duration = $output->get_duration(); + echo $duration['t']; + echo '

      '; + echo '
      '; // End column + + // Column for date + echo '
      '; + echo '

      '; + // date format should just be year + $date = $output->get_recorded(); + if ($date == "") { + $date = $output->get_created(); + } + echo date('Y', strtotime($date)); + + echo '

      '; + echo '
      '; // End column + + + echo '
      '; // End row + + $count++; + // Add horizontal rule only if it's not the last mix + if ($count < count($mixes)) { + echo '
      '; + } + } + ?> + +
      +
      +
      +
      + +
      +
      + +
      +
      +
      +
      +
      +
      + diff --git a/mixshows.php b/mixshows.php new file mode 100644 index 0000000..ad07e1b --- /dev/null +++ b/mixshows.php @@ -0,0 +1,46 @@ + +
      +
      +
      +
      + +
      +
      + + get_nonzero_mixshows(); + $count = 0; + foreach ($mixshows as $mixshow) { + card_output($count, $mixshow, $locale); + echo '' . $locale['view'] . ''; + echo '
      '; + echo '
'; + echo '
'; + if ($count % 4 == 3) { + echo '
'; + } + $count++; + } + ?> + +
+ + \ No newline at end of file