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 getPlexRecent($url, $port, $type, $token, $size, $header){
$urlCheck = stripos($url, "http");
if ($urlCheck === false) {
$url = "http://" . $url;
}
if($port !== ""){ $url = $url . ":" . $port; }
$address = $url;
$api = file_get_contents($address."/library/recentlyAdded?X-Plex-Token=".$token);
$api = simplexml_load_string($api);
$getServer = file_get_contents($address."/servers?X-Plex-Token=".$token);
$getServer = simplexml_load_string($getServer);
foreach($getServer AS $child) {
$gotServer = $child['machineIdentifier'];
}
$i = 0;
$gotPlex = '
'.$header.'
';
foreach($api AS $child) {
if($child['type'] == $type){
$i++;
if($i == 1){ $active = "active"; }else{ $active = "";}
$thumb = $child['thumb'];
$plexLink = "https://app.plex.tv/web/app#!/server/$gotServer/details?key=/library/metadata/".$child['ratingKey'];
if($type == "movie"){
$title = $child['title'];
$summary = $child['summary'];
$height = "150";
$width = "100";
}elseif($type == "season"){
$title = $child['parentTitle'];
$summary = $child['parentSummary'];
$height = "150";
$width = "100";
}elseif($type == "album"){
$title = $child['parentTitle'];
$summary = $child['title'];
$height = "150";
$width = "150";
}
$gotPlex .= '
'.$title.'
'.$summary.' ';
$plexLink = "";
}
}
$gotPlex .= '
';
if ($i > 1){
$gotPlex .= '
PreviousNext';
}
$gotPlex .= '
';
$noPlex = ''.$header.'
';
$noPlex .= '
';
$noPlex .= '
';
$noPlex .= '
';
$noPlex .= "

";
$noPlex .= '
Nothing New
Get to Adding! ';
if ($i != 0){ return $gotPlex; }
if ($i == 0){ return $noPlex; }
}
function getPlexStreams($url, $port, $token, $size, $header){
$urlCheck = stripos($url, "http");
if ($urlCheck === false) {
$url = "http://" . $url;
}
if($port !== ""){ $url = $url . ":" . $port; }
$address = $url;
$api = file_get_contents($address."/status/sessions?X-Plex-Token=".$token);
$api = simplexml_load_string($api);
$getServer = file_get_contents($address."/servers?X-Plex-Token=".$token);
$getServer = simplexml_load_string($getServer);
foreach($getServer AS $child) {
$gotServer = $child['machineIdentifier'];
}
$i = 0;
$gotPlex = ''.$header.'
';
$gotPlex .= '
';
$gotPlex .= '
';
foreach($api AS $child) {
$type = $child['type'];
$plexLink = "https://app.plex.tv/web/app#!/server/$gotServer/details?key=/library/metadata/".$child['ratingKey'];
$i++;
if($i == 1){ $active = "active"; }else{ $active = "";}
if($type == "movie"){
$title = $child['title'];
$summary = htmlentities($child['summary'], ENT_QUOTES);
$thumb = $child['thumb'];
$image = "movie";
$height = "150";
$width = "100";
}elseif($type == "episode"){
$title = $child['grandparentTitle'];
$summary = htmlentities($child['summary'], ENT_QUOTES);
$thumb = $child['grandparentThumb'];
$image = "season";
$height = "150";
$width = "100";
}elseif($type == "track"){
$title = $child['grandparentTitle'] . " - " . $child['parentTitle'];
$summary = htmlentities($child['title'], ENT_QUOTES);
$thumb = $child['thumb'];
$image = "album";
$height = "150";
$width = "150";
}elseif($type == "clip"){
$title = $child['title'].' - Trailer';
$summary = ($child['summary'] != "" ? $child['summary'] : "
No summary loaded.");
$thumb = ($child['thumb'] != "" ? $child['thumb'] : 'images/nadaplaying.jpg');
$image = "movie";
$height = "150";
$width = "100";
}
$gotPlex .= '
';
$gotPlex .= "

";
$gotPlex .= '
'.$title.'
'.$summary.'';
$plexLink = "";
}
$gotPlex .= '
';
if ($i > 1){
$gotPlex .= '
PreviousNext';
}
$gotPlex .= '
';
$noPlex = ''.$header.'
';
$noPlex .= '
';
$noPlex .= '
';
$noPlex .= '
';
$noPlex .= "

";
$noPlex .= '
Nothing Playing
Get to Streaming! ';
if ($i != 0){ return $gotPlex; }
if ($i == 0){ return $noPlex; }
}
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'];
$runtime = $child['series']['runtime'];
$episodeID = $child['series']['imdbId'];
$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: \"http://www.imdb.com/title/$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['imdbId'];
$runtime = $child['runtime'];
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: \"http://www.imdb.com/title/$movieID\" }, \n";
}
}
if ($i != 0){ return $gotCalendar; }
}
function nzbgetConnect($url, $port, $username, $password, $list){
$urlCheck = stripos($url, "http");
if ($urlCheck === false) {
$url = "http://" . $url;
}
if($port !== ""){ $url = $url . ":" . $port; }
$address = $url;
$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, $port, $key, $list){
$urlCheck = stripos($url, "http");
if ($urlCheck === false) {
$url = "http://" . $url;
}
if($port !== ""){ $url = $url . ":" . $port; }
$address = $url;
$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, $port, $key, $list){
$urlCheck = stripos($url, "http");
if ($urlCheck === false) {
$url = "http://" . $url;
}
if($port !== ""){ $url = $url . ":" . $port; }
$address = $url;
$api = file_get_contents($address."/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; }
}
?>