Time to do an update.
This commit is contained in:
parent
70c8a87e15
commit
0b0697bb42
22 changed files with 4352 additions and 268 deletions
|
@ -10,7 +10,7 @@ class Genre
|
|||
private $count = 0;
|
||||
private $name = "";
|
||||
private $slug = "";
|
||||
private $db = "";
|
||||
private $db;
|
||||
private $mixes = [];
|
||||
|
||||
public function __construct($value, $db)
|
||||
|
|
218
classes/HeaderMeta.php
Normal file
218
classes/HeaderMeta.php
Normal file
|
@ -0,0 +1,218 @@
|
|||
<?php
|
||||
|
||||
namespace DJMixHosting;
|
||||
|
||||
use DJMixHosting\Genre;
|
||||
|
||||
class HeaderMeta
|
||||
{
|
||||
|
||||
private $config;
|
||||
private $title = "";
|
||||
private $description = "";
|
||||
private $url = "";
|
||||
private $image = "";
|
||||
private $type = "";
|
||||
private $duration_seconds = "";
|
||||
private $musician = "";
|
||||
private $audio = "";
|
||||
private $keywords = "";
|
||||
private $canonical = "";
|
||||
private $robot = "";
|
||||
private $noindex = "";
|
||||
|
||||
public function __construct($object, $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
// detect if it is DJMixHosting\Mix, DJMixHosting\Genre, DJMixHosting\Mixshow, or DJMixHosting\DJ in $object
|
||||
if ($object instanceof Mix) {
|
||||
$djs = $object->get_djs();
|
||||
$djList = "";
|
||||
foreach ($djs as $dj) {
|
||||
$djList .= $dj->getName() . ", ";
|
||||
}
|
||||
$djList = rtrim($djList, ", ");
|
||||
|
||||
$genres = $object->get_genres();
|
||||
$genreNames = "";
|
||||
|
||||
$genreList = rtrim($genreNames, ", ");
|
||||
|
||||
|
||||
$this->set_ogTitle($object->get_name());
|
||||
$this->set_ogDescription($object->get_description());
|
||||
$this->set_ogUrl($object->get_page_url());
|
||||
$this->set_ogImage($object->get_cover());
|
||||
$this->set_ogType("music.song");
|
||||
$this->set_ogDurationSeconds($object->get_seconds());
|
||||
$this->set_ogMusician($djList);
|
||||
$this->set_ogAudio($object->get_download_url());
|
||||
$this->set_ogKeywords($genreList);
|
||||
$this->set_ogCanonical($object->get_page_url());
|
||||
$this->set_ogRobot("index, follow");
|
||||
$this->set_ogNoindex("");
|
||||
}
|
||||
}
|
||||
|
||||
private function set_ogTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
private function set_ogDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
private function set_ogUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
private function set_ogImage($image)
|
||||
{
|
||||
$this->image = $image;
|
||||
}
|
||||
|
||||
private function set_ogType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
private function set_ogDurationSeconds($duration_seconds)
|
||||
{
|
||||
$this->duration_seconds = $duration_seconds;
|
||||
}
|
||||
|
||||
private function set_ogMusician($musician)
|
||||
{
|
||||
$this->musician = $musician;
|
||||
}
|
||||
|
||||
private function set_ogAudio($audio)
|
||||
{
|
||||
$this->audio = $audio;
|
||||
}
|
||||
|
||||
private function set_ogKeywords($keywords)
|
||||
{
|
||||
$this->keywords = $keywords;
|
||||
}
|
||||
|
||||
private function set_ogCanonical($canonical)
|
||||
{
|
||||
$this->canonical = $canonical;
|
||||
}
|
||||
|
||||
private function set_ogRobot($robot)
|
||||
{
|
||||
$this->robot = $robot;
|
||||
}
|
||||
|
||||
private function set_ogNoindex($noindex)
|
||||
{
|
||||
$this->noindex = $noindex;
|
||||
}
|
||||
|
||||
public function mixMetaOutput()
|
||||
{
|
||||
global $config;
|
||||
$output = $this->buildMeta("og:title", $this->get_ogTitle());
|
||||
$output .= $this->buildMeta("og:type", $this->get_ogType());
|
||||
$output .= $this->buildMeta("og:url", $this->get_ogUrl());
|
||||
$output .= $this->buildMeta("og:image", $this->get_ogImage());
|
||||
$output .= $this->buildMeta("og:description", $this->get_ogDescription());
|
||||
$output .= $this->buildMeta("og:locale", "en_US");
|
||||
$output .= $this->buildMeta("og:site_name", $config['app']['name']);
|
||||
$output .= $this->buildMeta("music:duration", $this->get_ogDurationSeconds());
|
||||
$output .= $this->buildMeta("music:musician", $this->get_ogMusician());
|
||||
$output .= $this->buildMetaName("description", $this->get_ogDescription());
|
||||
$output .= $this->buildMeta("og:audio", $this->get_ogAudio());
|
||||
$output .= $this->buildMetaName("keywords", $this->get_ogKeywords());
|
||||
$output .= $this->buildMeta("canonical", $this->get_ogCanonical());
|
||||
$output .= $this->buildMetaName("robots", $this->get_ogRobot());
|
||||
$output .= $this->buildMetaName("robots", $this->get_ogNoindex());
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
private function buildMeta($property, $content)
|
||||
{
|
||||
if ($content == "" || $content == null) {
|
||||
return "";
|
||||
} else {
|
||||
return "<meta property=\"$property\" content=\"$content\"/>".PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_ogTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function get_ogType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function get_ogUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function get_ogImage()
|
||||
{
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
public function get_ogDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function get_ogDurationSeconds()
|
||||
{
|
||||
return $this->duration_seconds;
|
||||
}
|
||||
|
||||
public function get_ogMusician()
|
||||
{
|
||||
return $this->musician;
|
||||
}
|
||||
|
||||
private function buildMetaName($name, $content)
|
||||
{
|
||||
if ($content == "" || $content == null) {
|
||||
return "";
|
||||
} else {
|
||||
return "<meta name=\"$name\" content=\"$content\"/>" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_ogAudio()
|
||||
{
|
||||
return $this->audio;
|
||||
}
|
||||
|
||||
public function get_ogKeywords()
|
||||
{
|
||||
return $this->keywords;
|
||||
}
|
||||
|
||||
public function get_ogCanonical()
|
||||
{
|
||||
return $this->canonical;
|
||||
}
|
||||
|
||||
public function get_ogRobot()
|
||||
{
|
||||
return $this->robot;
|
||||
}
|
||||
|
||||
public function get_ogNoindex()
|
||||
{
|
||||
return $this->noindex;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -317,4 +317,14 @@ class Mix
|
|||
return $this->mixshow;
|
||||
}
|
||||
|
||||
public function get_download_url()
|
||||
{
|
||||
return "https://beta.utahsdjs.com/mix/" . "$this->slug" . "/download";
|
||||
}
|
||||
|
||||
public function get_page_url()
|
||||
{
|
||||
return "https://beta.utahsdjs.com/mix/" . "$this->slug";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
36
classes/RSS.php
Normal file
36
classes/RSS.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace DJMixHosting;
|
||||
|
||||
class RSS
|
||||
{
|
||||
|
||||
private $db;
|
||||
private string $header = '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||
private string $rss = '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"
|
||||
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
|
||||
xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0">';
|
||||
|
||||
|
||||
private function itemMix($mix)
|
||||
{
|
||||
$output = new Mix($mix, $this->db);
|
||||
|
||||
if ($output->get_recorded() != "") {
|
||||
$pubdate = date('D, d M Y H:i:s O', strtotime($output->get_recorded()));
|
||||
} elseif ($output->get_created() != "") {
|
||||
$pubdate = date('D, d M Y H:i:s O', strtotime($output->get_created()));
|
||||
} else {
|
||||
$pubdate = date('D, d M Y H:i:s O', strtotime('2008-01-01 12:00:00'));
|
||||
}
|
||||
|
||||
echo '<item>';
|
||||
echo '<title>' . $output->get_name() . '</title>';
|
||||
echo '<description>' . $output->get_description() . '</description>';
|
||||
echo '<link>' . $output->get_url() . '</link>';
|
||||
echo '<guid>' . $output->get_slug() . '</guid>';
|
||||
echo '<pubDate>' . $pubdate . '</pubDate>';
|
||||
echo '</item>';
|
||||
}
|
||||
|
||||
}
|
|
@ -27,6 +27,9 @@ Class User{
|
|||
* @throws RandomException
|
||||
*/
|
||||
public function newUser($username, $password, $email){
|
||||
if ($this->check_existing_user($username, $email)){
|
||||
throw new RandomException("User already exists");
|
||||
}
|
||||
$this->username = $username;
|
||||
$this->email = $email;
|
||||
$password2 = password_hash($password, PASSWORD_DEFAULT);
|
||||
|
@ -48,5 +51,19 @@ Class User{
|
|||
|
||||
}
|
||||
|
||||
private function check_existing_user($username, $email){
|
||||
$stmt = $this->db->prepare("SELECT * FROM users WHERE username = ? OR email = ?");
|
||||
$stmt->bind_param("ss", $username, $email);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$user = $result->fetch_assoc();
|
||||
$stmt->close();
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function login(mixed $username, mixed $password)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue