', $items[0]);
// Add Buttons
$buttons = '';
if (count($items) > 1) {
$buttons = '
Previous
Next';
}
return '
'.$header.'
'.implode('',$items).'
'.$buttons.'
'.($script?'':'');
}
// Get Now Playing Streams From Emby
function getEmbyStreams($size) {
$address = qualifyURL(EMBYURL);
$api = json_decode(file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true);
$playingItems = array();
foreach($api as $key => $value) {
if (isset($value['NowPlayingItem'])) {
$playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem']);
}
}
return outputCarousel(translate('PLAYING_NOW_ON_EMBY'), $size, 'streams-emby', $playingItems, "
setInterval(function() {
$('
').load('ajax.php?a=emby-streams',function() {
var element = $(this).find('[id]');
var loadedID = element.attr('id');
$('#'+loadedID).replaceWith(element);
console.log('Loaded updated: '+loadedID);
});
}, 10000);
");
}
// Get Now Playing Streams From Plex
function getPlexStreams($size){
$address = qualifyURL(PLEXURL);
// Perform API requests
$api = file_get_contents($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
$api = simplexml_load_string($api);
$getServer = simplexml_load_string(file_get_contents($address."/?X-Plex-Token=".PLEXTOKEN));
// Identify the local machine
$gotServer = $getServer['machineIdentifier'];
$items = array();
foreach($api AS $child) {
$items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child);
}
return outputCarousel(translate('PLAYING_NOW_ON_PLEX'), $size, 'streams-plex', $items, "
setInterval(function() {
$('
').load('ajax.php?a=plex-streams',function() {
var element = $(this).find('[id]');
var loadedID = element.attr('id');
$('#'+loadedID).replaceWith(element);
console.log('Loaded updated: '+loadedID);
});
}, 10000);
");
}
// Get Recent Content From Emby
function getEmbyRecent($type, $size) {
$address = qualifyURL(EMBYURL);
// Resolve Types
switch ($type) {
case 'movie':
$embyTypeQuery = 'IncludeItemTypes=Movie&';
$header = translate('MOVIES');
break;
case 'season':
$embyTypeQuery = 'IncludeItemTypes=Episode&';
$header = translate('TV_SHOWS');
break;
case 'album':
$embyTypeQuery = 'IncludeItemTypes=MusicAlbum&';
$header = translate('MUSIC');
break;
default:
$embyTypeQuery = '';
$header = translate('RECENT_CONTENT');
}
// Get A User
$userIds = json_decode(file_get_contents($address.'/Users?api_key='.EMBYTOKEN),true);
foreach ($userIds as $value) { // Scan for admin user
$userId = $value['Id'];
if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
break;
}
}
// Get the latest Items
$latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?'.$embyTypeQuery.'EnableImages=false&api_key='.EMBYTOKEN),true);
// For Each Item In Category
$items = array();
foreach ($latest as $k => $v) {
$items[] = resolveEmbyItem($address, EMBYTOKEN, $v);
}
return outputCarousel($header, $size, $type.'-emby', $items);
}
// Get Recent Content From Plex
function getPlexRecent($type, $size){
$address = qualifyURL(PLEXURL);
// Resolve Types
switch ($type) {
case 'movie':
$header = translate('MOVIES');
break;
case 'season':
$header = translate('TV_SHOWS');
break;
case 'album':
$header = translate('MUSIC');
break;
default:
$header = translate('RECENT_CONTENT');
}
// Perform Requests
$api = file_get_contents($address."/library/recentlyAdded?X-Plex-Token=".PLEXTOKEN);
$api = simplexml_load_string($api);
$getServer = simplexml_load_string(file_get_contents($address."/?X-Plex-Token=".PLEXTOKEN));
// Identify the local machine
$gotServer = $getServer['machineIdentifier'];
$items = array();
foreach($api AS $child) {
if($child['type'] == $type){
$items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child);
}
}
return outputCarousel($header, $size, $type.'-plex', $items);
}
// Get Image From Emby
function getEmbyImage() {
$embyAddress = qualifyURL(EMBYURL);
$itemId = $_GET['img'];
$imgParams = array();
if (isset($_GET['height'])) { $imgParams['height'] = 'maxHeight='.$_GET['height']; }
if (isset($_GET['width'])) { $imgParams['width'] = 'maxWidth='.$_GET['width']; }
if(isset($itemId)) {
$image_src = $embyAddress . '/Items/'.$itemId.'/Images/Primary?'.implode('&', $imgParams);
header('Content-type: image/jpeg');
readfile($image_src);
} else {
debug_out('Invalid Request',1);
}
}
// Get Image From Plex
function getPlexImage() {
$plexAddress = qualifyURL(PLEXURL);
$image_url = $_GET['img'];
$image_height = $_GET['height'];
$image_width = $_GET['width'];
if(isset($image_url) && isset($image_height) && isset($image_width)) {
$image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
header('Content-type: image/jpeg');
readfile($image_src);
} else {
echo "Invalid Plex Request";
}
}
// Simplier access to class
function translate($string) {
if (isset($GLOBALS['language'])) {
return $GLOBALS['language']->translate($string);
} else {
return '!Translations Not Loaded!';
}
}
// Generate Random string
function randString($length = 10) {
$tmp = '';
$chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
for ($i = 0; $i < $length; $i++) {
$tmp .= substr(str_shuffle($chars), 0, 1);
}
return $tmp;
}
// Create config file in the return syntax
function createConfig($array, $path = 'config/config.php', $nest = 0) {
$output = array();
foreach ($array as $k => $v) {
$allowCommit = true;
switch (gettype($v)) {
case 'boolean':
$item = ($v?'true':'false');
break;
case 'integer':
case 'double':
case 'integer':
case 'NULL':
$item = $v;
break;
case 'string':
$item = '"'.addslashes($v).'"';
break;
case 'array':
$item = createConfig($v, false, $nest+1);
break;
default:
$allowCommit = false;
}
if($allowCommit) {
$output[] = str_repeat("\t",$nest+1).'"'.$k.'" => '.$item;
}
}
$output = (!$nest?" $v) {
$current[$k] = $v;
}
// Return Create
return createConfig($current);
}
// Inject Defaults As Needed
function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
if (is_string($path)) {
$loadedDefaults = loadConfig($path);
} else {
$loadedDefaults = $path;
}
return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false);
}
// support function for fillDefaultConfig()
function fillDefaultConfig_recurse($current, $defaults) {
foreach($defaults as $k => $v) {
if (!isset($current[$k])) {
$current[$k] = $v;
} else if (is_array($current[$k]) && is_array($v)) {
$current[$k] = fillDefaultConfig_recurse($current[$k], $v);
}
}
return $current;
};
// Define Scalar Variables (nest non-secular with underscores)
function defineConfig($array, $anyCase = true, $nest_prefix = false) {
foreach($array as $k => $v) {
if (is_scalar($v) && !defined($nest_prefix.$k)) {
define($nest_prefix.$k, $v, $anyCase);
} else if (is_array($v)) {
defineConfig($v, $anyCase, $nest_prefix.$k.'_');
}
}
}
// This function exists only because I am lazy
function configLazy($path) {
$config = fillDefaultConfig(loadConfig($path));
if (is_array($config)) {
defineConfig($config);
}
return $config;
}
// Qualify URL
function qualifyURL($url) {
// Get Digest
$digest = parse_url($url);
// http/https
if (!isset($digest['scheme'])) {
if (isset($digest['port']) && in_array($digest['port'], array(80,8080,8096,32400,7878,8989,8182,8081,6789))) {
$scheme = 'http';
} else {
$scheme = 'https';
}
} else {
$scheme = $digest['scheme'];
}
// Host
$host = (isset($digest['host'])?$digest['host']:'');
// Port
$port = (isset($digest['port'])?':'.$digest['port']:'');
// Path
$path = (isset($digest['path'])?$digest['path']:'');
// Output
return $scheme.'://'.$host.$port.$path;
}
// Function to be called at top of each to allow upgrading environment as the spec changes
function upgradeCheck() {
// Upgrade to 1.31
if (file_exists('homepageSettings.ini.php')) {
$databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
$homepageConfig = parse_ini_file('homepageSettings.ini.php', true);
$databaseConfig = array_merge($databaseConfig, $homepageConfig);
$databaseData = '; ' . "\r\n";
foreach($databaseConfig as $k => $v) {
if(substr($v, -1) == "/") : $v = rtrim($v, "/"); endif;
$databaseData .= $k . " = \"" . $v . "\"\r\n";
}
write_ini_file($databaseData, 'databaseLocation.ini.php');
unlink('homepageSettings.ini.php');
unset($databaseData);
unset($homepageConfig);
}
// Upgrade to 1.32
if (file_exists('databaseLocation.ini.php')) {
// Load Existing
$config = parse_ini_file('databaseLocation.ini.php', true);
// Refactor
$config['database_Location'] = str_replace('//','/',$config['databaseLocation'].'/');
$config['user_home'] = $config['databaseLocation'].'users/';
unset($config['databaseLocation']);
// Turn Off Emby And Plex Recent
$config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:'');
unset($config["embyPort"]);
$config["plexURL"] = $config["plexURL"].(!empty($config["plexPort"])?':'.$config["plexPort"]:'');
unset($config["plexPort"]);
$config["nzbgetURL"] = $config["nzbgetURL"].(!empty($config["nzbgetPort"])?':'.$config["nzbgetPort"]:'');
unset($config["nzbgetPort"]);
$config["sabnzbdURL"] = $config["sabnzbdURL"].(!empty($config["sabnzbdPort"])?':'.$config["sabnzbdPort"]:'');
unset($config["sabnzbdPort"]);
$config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
unset($config["headphonesPort"]);
$createConfigSuccess = createConfig($config, 'config/config.php', $nest = 0);
// Create new config
if ($createConfigSuccess) {
// Make Config Dir (this should never happen as the dir and defaults file should be there);
@mkdir('config', 0775, true);
// Remove Old ini file
unlink('databaseLocation.ini.php');
} else {
debug_out('Couldn\'t create updated configuration.' ,1);
}
}
return true;
}
// Check if all software dependancies are met
function dependCheck() {
return true;
}
// Process file uploads
function uploadFiles($path, $ext_mask = null) {
if (isset($_FILES) && count($_FILES)) {
require_once('class.uploader.php');
$uploader = new Uploader();
$data = $uploader->upload($_FILES['files'], array(
'limit' => 10,
'maxSize' => 10,
'extensions' => $ext_mask,
'required' => false,
'uploadDir' => str_replace('//','/',$path.'/'),
'title' => array('name'),
'removeFiles' => true,
'replace' => true,
));
if($data['isComplete']){
$files = $data['data'];
echo json_encode($files['metas'][0]['name']);
}
if($data['hasErrors']){
$errors = $data['errors'];
echo json_encode($errors);
}
} else {
echo json_encode('No files submitted!');
}
}
// Remove file
function removeFiles($path) {
if(is_file($path)) {
unlink($path);
} else {
echo json_encode('No file specified for removal!');
}
}
// ==============
function clean($strin) {
$strout = null;
for ($i = 0; $i < strlen($strin); $i++) {
$ord = ord($strin[$i]);
if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
$strout .= "&#{$ord};";
}
else {
switch ($strin[$i]) {
case '<':
$strout .= '<';
break;
case '>':
$strout .= '>';
break;
case '&':
$strout .= '&';
break;
case '"':
$strout .= '"';
break;
default:
$strout .= $strin[$i];
}
}
}
return $strout;
}
function registration_callback($username, $email, $userdir){
global $data;
$data = array($username, $email, $userdir);
}
function printArray($arrayName){
$messageCount = count($arrayName);
$i = 0;
foreach ( $arrayName as $item ) :
$i++;
if($i < $messageCount) :
echo "
" . $item . " & ";
elseif($i = $messageCount) :
echo "
" . $item . "";
endif;
endforeach;
}
function write_ini_file($content, $path) {
if (!$handle = fopen($path, 'w')) {
return false;
}
$success = fwrite($handle, trim($content));
fclose($handle);
return $success;
}
function gotTimezone(){
$regions = array(
'Africa' => DateTimeZone::AFRICA,
'America' => DateTimeZone::AMERICA,
'Antarctica' => DateTimeZone::ANTARCTICA,
'Arctic' => DateTimeZone::ARCTIC,
'Asia' => DateTimeZone::ASIA,
'Atlantic' => DateTimeZone::ATLANTIC,
'Australia' => DateTimeZone::AUSTRALIA,
'Europe' => DateTimeZone::EUROPE,
'Indian' => DateTimeZone::INDIAN,
'Pacific' => DateTimeZone::PACIFIC
);
$timezones = array();
foreach ($regions as $name => $mask) {
$zones = DateTimeZone::listIdentifiers($mask);
foreach($zones as $timezone) {
$time = new DateTime(NULL, new DateTimeZone($timezone));
$ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
$timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
}
}
print '
';
}
function getTimezone(){
$regions = array(
'Africa' => DateTimeZone::AFRICA,
'America' => DateTimeZone::AMERICA,
'Antarctica' => DateTimeZone::ANTARCTICA,
'Arctic' => DateTimeZone::ARCTIC,
'Asia' => DateTimeZone::ASIA,
'Atlantic' => DateTimeZone::ATLANTIC,
'Australia' => DateTimeZone::AUSTRALIA,
'Europe' => DateTimeZone::EUROPE,
'Indian' => DateTimeZone::INDIAN,
'Pacific' => DateTimeZone::PACIFIC
);
$timezones = array();
foreach ($regions as $name => $mask) {
$zones = DateTimeZone::listIdentifiers($mask);
foreach($zones as $timezone) {
$time = new DateTime(NULL, new DateTimeZone($timezone));
$ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
$timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
}
}
print '
';
}
function explosion($string, $position){
$getWord = explode("|", $string);
return $getWord[$position];
}
function getServerPath() {
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
$protocol = "https://";
} else {
$protocol = "http://";
}
return $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']);
}
function get_browser_name() {
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
elseif (strpos($user_agent, 'Edge')) return 'Edge';
elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
elseif (strpos($user_agent, 'Safari')) return 'Safari';
elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
return 'Other';
}
function getSickrageCalendarWanted($array){
$array = json_decode($array, true);
$gotCalendar = "";
$i = 0;
foreach($array['data']['missed'] AS $child) {
$i++;
$seriesName = $child['show_name'];
$episodeID = $child['tvdbid'];
$episodeAirDate = $child['airdate'];
$episodeAirDateTime = explode(" ",$child['airs']);
$episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
$episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
$episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
$downloaded = "0";
if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
}
foreach($array['data']['today'] AS $child) {
$i++;
$seriesName = $child['show_name'];
$episodeID = $child['tvdbid'];
$episodeAirDate = $child['airdate'];
$episodeAirDateTime = explode(" ",$child['airs']);
$episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
$episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
$episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
$downloaded = "0";
if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
}
foreach($array['data']['soon'] AS $child) {
$i++;
$seriesName = $child['show_name'];
$episodeID = $child['tvdbid'];
$episodeAirDate = $child['airdate'];
$episodeAirDateTime = explode(" ",$child['airs']);
$episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
$episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
$episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
$downloaded = "0";
if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
}
foreach($array['data']['later'] AS $child) {
$i++;
$seriesName = $child['show_name'];
$episodeID = $child['tvdbid'];
$episodeAirDate = $child['airdate'];
$episodeAirDateTime = explode(" ",$child['airs']);
$episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
$episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
$episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
$downloaded = "0";
if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
}
if ($i != 0){ return $gotCalendar; }
}
function getSickrageCalendarHistory($array){
$array = json_decode($array, true);
$gotCalendar = "";
$i = 0;
foreach($array['data'] AS $child) {
$i++;
$seriesName = $child['show_name'];
$episodeID = $child['tvdbid'];
$episodeAirDate = $child['date'];
$downloaded = "green-bg";
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
}
if ($i != 0){ return $gotCalendar; }
}
function getSonarrCalendar($array){
$array = json_decode($array, true);
$gotCalendar = "";
$i = 0;
foreach($array AS $child) {
$i++;
$seriesName = $child['series']['title'];
$episodeID = $child['series']['tvdbId'];
if(!isset($episodeID)){ $episodeID = ""; }
$episodeName = htmlentities($child['title'], ENT_QUOTES);
if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
$episodeAirDate = $child['airDateUtc'];
$episodeAirDate = strtotime($episodeAirDate);
$episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
$downloaded = $child['hasFile'];
if($downloaded == "0" && isset($unaired) && $episodePremier == "true"){ $downloaded = "light-blue-bg"; }elseif($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
}
if ($i != 0){ return $gotCalendar; }
}
function getRadarrCalendar($array){
$array = json_decode($array, true);
$gotCalendar = "";
$i = 0;
foreach($array AS $child) {
if(isset($child['inCinemas'])){
$i++;
$movieName = $child['title'];
$movieID = $child['tmdbId'];
if(!isset($movieID)){ $movieID = ""; }
if(isset($child['inCinemas']) && isset($child['physicalRelease'])){
$physicalRelease = $child['physicalRelease'];
$physicalRelease = strtotime($physicalRelease);
$physicalRelease = date("Y-m-d", $physicalRelease);
if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
$downloaded = $child['hasFile'];
if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
}else{
$physicalRelease = $child['inCinemas'];
$downloaded = "light-blue-bg";
}
$gotCalendar .= "{ title: \"$movieName\", start: \"$physicalRelease\", className: \"$downloaded\", imagetype: \"film\", url: \"https://www.themoviedb.org/movie/$movieID\" }, \n";
}
}
if ($i != 0){ return $gotCalendar; }
}
function nzbgetConnect($url, $username, $password, $list){
$url = qualifyURL(NZBGETURL);
$api = file_get_contents("$url/$username:$password/jsonrpc/$list");
$api = json_decode($api, true);
$i = 0;
$gotNZB = "";
foreach ($api['result'] AS $child) {
$i++;
//echo '
' . var_export($child, true) . '
';
$downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
$downloadStatus = $child['Status'];
$downloadCategory = $child['Category'];
if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
if($child['Health'] <= "750"){
$downloadHealth = "danger";
}elseif($child['Health'] <= "900"){
$downloadHealth = "warning";
}elseif($child['Health'] <= "1000"){
$downloadHealth = "success";
}
$gotNZB .= '
| '.$downloadName.' |
'.$downloadStatus.' |
'.$downloadCategory.' |
'.round($downloadPercent).'%
'.$downloadPercent.'% Complete
|
';
}
if($i > 0){ return $gotNZB; }
if($i == 0){ echo '
No Results |
'; }
}
function sabnzbdConnect($url, $key, $list){
$url = qualifyURL(SABNZBDURL);
$api = file_get_contents("$url/api?mode=$list&output=json&apikey=$key");
$api = json_decode($api, true);
$i = 0;
$gotNZB = "";
foreach ($api[$list]['slots'] AS $child) {
$i++;
if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
$downloadStatus = $child['status'];
$gotNZB .= '
| '.$downloadName.' |
'.$downloadStatus.' |
'.$downloadCategory.' |
'.round($downloadPercent).'%
'.$downloadPercent.'% Complete
|
';
}
if($i > 0){ return $gotNZB; }
if($i == 0){ echo '
No Results |
'; }
}
function getHeadphonesCalendar($url, $key, $list){
$url = qualifyURL(HEADPHONESURL);
$api = file_get_contents($url."/api?apikey=".$key."&cmd=$list");
$api = json_decode($api, true);
$i = 0;
$gotCalendar = "";
foreach($api AS $child) {
if($child['Status'] == "Wanted"){
$i++;
$albumName = addslashes($child['AlbumTitle']);
$albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
$albumDate = $child['ReleaseDate'];
$albumID = $child['AlbumID'];
$albumDate = strtotime($albumDate);
$albumDate = date("Y-m-d", $albumDate);
$albumStatus = $child['Status'];
if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
}
}
if ($i != 0){ return $gotCalendar; }
}
?>