Update README.md and sync files.

This commit is contained in:
Cody Cook 2024-05-06 21:48:35 -07:00
commit da93d643d9
11 changed files with 763 additions and 2 deletions

60
classes/Schema.php Normal file
View file

@ -0,0 +1,60 @@
<?php
class Schema
{
private $albumProductionType = "DJMixAlbum";
private $type = "";
private $name = "";
private $byArtist = "";
private $inAlbum = "";
private $genre = "";
private $url = "";
private $image = "";
private $duration = "";
private $datePublished = "";
/*
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "MusicRecording",
"name": "Future Primitive",
"byArtist": {
"@type": "MusicGroup",
"name": "10-E",
"image": "/djs/10e/profile.jpg"
},
"inAlbum": {
"@type": "MusicAlbum",
"name": "Future Primitive"
},
"genre": "Trance",
"url": "https://utahsdjs.com/mix/future-primitive",
"image": "https://utahsdjs.com//djs/no-art-provided.png",
"duration": "PT1H11M5S",
"datePublished": "2009-03-02 23:57:01",
"description": "Listen to Future Primitive on Utah's DJs.",
"interactionStatistic": {
"@type": "InteractionCounter",
"interactionType": "https://schema.org/ListenAction",
"userInteractionCount": "537",
"url": "https://utahsdjs.com/mix/future-primitive/download"
}
}
*/
}

60
classes/Telegram.php Normal file
View file

@ -0,0 +1,60 @@
<?php
class Telegram
{
private $token = "";
private $chat_id = "";
private $parse_mode = "HTML";
private $disable_web_page_preview = true;
private $disable_notification = false;
private $reply_to_message_id = 0;
private $message = "";
private $url = "https://api.telegram.org/bot";
public function __construct($token, $chat_id, $reply_to_message_id = 0)
{
$this->token = $token;
$this->chat_id = $chat_id;
$this->reply_to_message_id = $reply_to_message_id;
$this->url .= $this->token;
}
public function send_message($message)
{
$this->message = $message;
$result = $this->sendMessage();
if ($result) {
return json_decode($result, true);
}
return false;
}
private function sendMessage()
{
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $this->url . "/sendMessage",
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => [
'chat_id' => $this->chat_id,
'text' => $this->message,
'parse_mode' => $this->parse_mode,
'disable_web_page_preview' => $this->disable_web_page_preview,
'disable_notification' => $this->disable_notification,
'reply_to_message_id' => $this->reply_to_message_id
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_SSL_VERIFYPEER => false
]);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
}

88
classes/Upload.php Normal file
View file

@ -0,0 +1,88 @@
<?php
class Upload
{
private $file;
private $file_name;
private $file_size;
private $file_tmp;
private $file_type;
private $file_ext;
private $file_path;
private $extensions = array("mp3", "zip");
private $upload_dir = "uploads/";
private $errors = array();
private $ok = false;
private $config;
private $uuid = "";
public function __construct($file, $config)
{
$this->file = $file;
$this->file_name = $file['name'];
$this->file_size = $file['size'];
$this->file_tmp = $file['tmp_name'];
$this->file_type = $file['type'];
$this->config = $config;
$ext = explode('.', $file['name']);
$this->file_ext = strtolower(end($ext));
$this->uuid = uniqid();
}
private function check_file_size(): bool
{
if ($this->file_size > $this->config['uploads']['max_file_size']){
$this->errors[] = "File size is too large";
return false;
}
return true;
}
private function check_file_extension(): bool
{
if (!in_array($this->file_ext, $this->extensions)){
$this->errors[] = "Invalid file extension";
return false;
}
return true;
}
private function check_file_exists(): bool
{
if (file_exists($this->upload_dir . $this->file_name)){
$this->errors[] = "File already exists";
return false;
}
return true;
}
private function move_file(): bool
{
if (move_uploaded_file($this->file_tmp, $this->upload_dir . $this->uuid)){
$this->file_path = $this->upload_dir . $this->uuid;
return true;
}
return false;
}
public function dump_all()
{
$array = array(
"file" => $this->file,
"file_name" => $this->file_name,
"file_size" => $this->file_size,
"file_tmp" => $this->file_tmp,
"file_type" => $this->file_type,
"file_ext" => $this->file_ext,
"file_path" => $this->file_path,
"extensions" => $this->extensions,
"upload_dir" => $this->upload_dir,
"errors" => $this->errors,
"ok" => $this->ok,
"uuid" => $this->uuid
);
}
}