Mixshows.
This commit is contained in:
parent
8b4dfe0c0c
commit
ef4eedcd6e
12 changed files with 493 additions and 23 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
53
classes/Mixshows.php
Normal file
53
classes/Mixshows.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
class Mixshows
|
||||
{
|
||||
|
||||
private $db;
|
||||
private $mixshows = [];
|
||||
|
||||
public function __construct($db)
|
||||
{
|
||||
|
||||
$this->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;
|
||||
}
|
||||
}
|
50
classes/User.php
Normal file
50
classes/User.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
use Random\RandomException;
|
||||
|
||||
Class User{
|
||||
|
||||
private $db;
|
||||
private $id;
|
||||
private $username;
|
||||
private $email;
|
||||
private $location;
|
||||
private $bio;
|
||||
private $created;
|
||||
private $updated;
|
||||
private $verified;
|
||||
private $role;
|
||||
private $img;
|
||||
private $api_key;
|
||||
|
||||
public function __construct($db){
|
||||
$this->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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue