|
|
@@ -930,27 +930,35 @@ function getPlexStreams($size, $showNames, $role){
|
|
|
// Perform API requests
|
|
|
$api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN);
|
|
|
$api = simplexml_load_string($api);
|
|
|
- $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
|
|
|
- if (!$getServer) { return 'Could not load!'; }
|
|
|
-
|
|
|
- // Identify the local machine
|
|
|
- $gotServer = $getServer['machineIdentifier'];
|
|
|
-
|
|
|
- $items = array();
|
|
|
- foreach($api AS $child) {
|
|
|
- $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
|
|
|
+ if (is_array($api) || is_object($api)){
|
|
|
+ if (!$api->head->title){
|
|
|
+ $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
|
|
|
+ if (!$getServer) { return 'Could not load!'; }
|
|
|
+
|
|
|
+ // Identify the local machine
|
|
|
+ $gotServer = $getServer['machineIdentifier'];
|
|
|
+
|
|
|
+ $items = array();
|
|
|
+ foreach($api AS $child) {
|
|
|
+ $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
|
|
|
+ }
|
|
|
+
|
|
|
+ return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX'), $size, 'streams-plex', $items, "
|
|
|
+ setInterval(function() {
|
|
|
+ $('<div></div>').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);
|
|
|
+ });
|
|
|
+ }, 15000);
|
|
|
+ ");
|
|
|
+ }else{
|
|
|
+ writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
|
|
|
}
|
|
|
-
|
|
|
- return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX'), $size, 'streams-plex', $items, "
|
|
|
- setInterval(function() {
|
|
|
- $('<div></div>').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);
|
|
|
- });
|
|
|
- }, 15000);
|
|
|
- ");
|
|
|
}
|
|
|
|
|
|
// Get Recent Content From Emby
|
|
|
@@ -1010,21 +1018,29 @@ function getPlexRecent($array){
|
|
|
// Perform Requests
|
|
|
$api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN);
|
|
|
$api = simplexml_load_string($api);
|
|
|
- $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
|
|
|
- if (!$getServer) { return 'Could not load!'; }
|
|
|
-
|
|
|
- // Identify the local machine
|
|
|
- $gotServer = $getServer['machineIdentifier'];
|
|
|
-
|
|
|
- $items = array();
|
|
|
- foreach($api AS $child) {
|
|
|
- $type = (string) $child['type'];
|
|
|
- if($array[$type] == "true"){
|
|
|
- $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
|
|
|
+ if (is_array($api) || is_object($api)){
|
|
|
+ if (!$api->head->title){
|
|
|
+ $getServer = simplexml_load_string(@curl_get($address."/?X-Plex-Token=".PLEXTOKEN));
|
|
|
+ if (!$getServer) { return 'Could not load!'; }
|
|
|
+
|
|
|
+ // Identify the local machine
|
|
|
+ $gotServer = $getServer['machineIdentifier'];
|
|
|
+
|
|
|
+ $items = array();
|
|
|
+ foreach($api AS $child) {
|
|
|
+ $type = (string) $child['type'];
|
|
|
+ if($array[$type] == "true"){
|
|
|
+ $items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, false, false, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return outputRecentAdded($header, $items, "", $array);
|
|
|
+ }else{
|
|
|
+ writeLog("error", "PLEX STREAM ERROR: could not connect - check token - if HTTPS, is cert valid");
|
|
|
}
|
|
|
+ }else{
|
|
|
+ writeLog("error", "PLEX STREAM ERROR: could not connect - check URL - if HTTPS, is cert valid");
|
|
|
}
|
|
|
-
|
|
|
- return outputRecentAdded($header, $items, "", $array);
|
|
|
}
|
|
|
|
|
|
// Get Image From Emby
|
|
|
@@ -1425,11 +1441,46 @@ function upgradeCheck() {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+// Get OS from server
|
|
|
+function getOS(){
|
|
|
+ if(PHP_SHLIB_SUFFIX == "dll"){
|
|
|
+ return "win";
|
|
|
+ }else{
|
|
|
+ return "nix";
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//Get Error by Server OS
|
|
|
+function getError($os, $error){
|
|
|
+ $errors = array(
|
|
|
+ 'pdo_sqlite' => array(
|
|
|
+ 'win' => 'PDO:SQLite not enabled, uncomment ;extension=php_pdo_sqlite.dll in the file php.ini',
|
|
|
+ 'nix' => 'PDO:SQLite not enabled, PHP7 -> run sudo apt-get install php7.0-sqlite | PHP5 -> run sudo apt-get install php5-sqlite',
|
|
|
+ ),
|
|
|
+ 'sqlite3' => array(
|
|
|
+ 'win' => 'SQLite3 not enabled, uncomment ;extension=php_sqlite3.dll in the file php.ini',
|
|
|
+ 'nix' => 'SQLite3 not enabled, run sudo apt-get install php-sqlite3',
|
|
|
+ ),
|
|
|
+ 'curl' => array(
|
|
|
+ 'win' => 'cURL not enabled, uncomment ;extension=php_curl.dll in the file php.ini',
|
|
|
+ 'nix' => 'cURL not enabled, PHP7 -> sudo apt-get install php-7.0 | PHP5 -> run sudo apt-get install php5-curl',
|
|
|
+ ),
|
|
|
+ 'zip' => array(
|
|
|
+ 'win' => 'PHP Zip not enabled, uncomment ;extension=php_zip.dll in the file php.ini, if that doesn\'t work remove that line',
|
|
|
+ 'nix' => 'PHP Zip not enabled, PHP7 -> run sudo apt-get install php7.0-zip | PHP5 -> run sudo apt-get install php5.6-zip',
|
|
|
+ ),
|
|
|
+
|
|
|
+ );
|
|
|
+ return (isset($errors[$error][$os]) ? $errors[$error][$os] : 'No Error Info Found');
|
|
|
+}
|
|
|
+
|
|
|
// Check if all software dependancies are met
|
|
|
function dependCheck() {
|
|
|
$output = array();
|
|
|
- if (!extension_loaded('pdo_sqlite')) { $output[] = 'PDO:SQLite not enabled, please add "extension = php_pdo_sqlite.dll" to php.ini'; }
|
|
|
- //if (!extension_loaded('sqlite3')) { $output[] = 'SQLite3 not enabled, please add "extension = php_sqlite3.dll" to php.ini'; }
|
|
|
+ if (!extension_loaded('pdo_sqlite')) { $output[] = getError(getOS(),'pdo_sqlite'); }
|
|
|
+ if (!extension_loaded('curl')) { $output[] = getError(getOS(),'curl'); }
|
|
|
+ if (!extension_loaded('zip')) { $output[] = getError(getOS(),'zip'); }
|
|
|
+ //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
|
|
|
|
|
|
if ($output) {
|
|
|
debug_out($output,1);
|
|
|
@@ -2308,42 +2359,44 @@ function nzbgetConnect($list = 'listgroups') {
|
|
|
|
|
|
$api = curl_get($url.'/'.NZBGETUSERNAME.':'.NZBGETPASSWORD.'/jsonrpc/'.$list);
|
|
|
$api = json_decode($api, true);
|
|
|
-
|
|
|
$gotNZB = array();
|
|
|
-
|
|
|
- foreach ($api['result'] AS $child) {
|
|
|
- $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[] = '<tr>
|
|
|
- <td class="col-xs-7 nzbtable-file-row">'.$downloadName.'</td>
|
|
|
- <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
|
|
|
- <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
|
|
|
- <td class="col-xs-2 nzbtable nzbtable-row">
|
|
|
- <div class="progress">
|
|
|
- <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
|
|
|
- <p class="text-center">'.round($downloadPercent).'%</p>
|
|
|
- <span class="sr-only">'.$downloadPercent.'% Complete</span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </td>
|
|
|
- </tr>';
|
|
|
- }
|
|
|
-
|
|
|
- if ($gotNZB) {
|
|
|
- return implode('',$gotNZB);
|
|
|
- } else {
|
|
|
- return '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>';
|
|
|
+ if (is_array($api) || is_object($api)){
|
|
|
+ foreach ($api['result'] AS $child) {
|
|
|
+ $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[] = '<tr>
|
|
|
+ <td class="col-xs-7 nzbtable-file-row">'.$downloadName.'</td>
|
|
|
+ <td class="col-xs-2 nzbtable nzbtable-row">'.$downloadStatus.'</td>
|
|
|
+ <td class="col-xs-1 nzbtable nzbtable-row">'.$downloadCategory.'</td>
|
|
|
+ <td class="col-xs-2 nzbtable nzbtable-row">
|
|
|
+ <div class="progress">
|
|
|
+ <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
|
|
|
+ <p class="text-center">'.round($downloadPercent).'%</p>
|
|
|
+ <span class="sr-only">'.$downloadPercent.'% Complete</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ </tr>';
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($gotNZB) {
|
|
|
+ return implode('',$gotNZB);
|
|
|
+ } else {
|
|
|
+ return '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>';
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Usernamd and Password - if HTTPS, is cert valid");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2819,41 +2872,34 @@ function getRadarrCalendar($array){
|
|
|
}
|
|
|
|
|
|
function getHeadphonesCalendar($url, $key, $list){
|
|
|
- $url = qualifyURL(HEADPHONESURL);
|
|
|
-
|
|
|
+ $url = qualifyURL(HEADPHONESURL);
|
|
|
$api = curl_get($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; }
|
|
|
-
|
|
|
+ if (is_array($api) || is_object($api)){
|
|
|
+ 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; }
|
|
|
+ }else{
|
|
|
+ writeLog("error", "HEADPHONES $list ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function checkRootPath($string){
|
|
|
@@ -2864,6 +2910,10 @@ function checkRootPath($string){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function strip($string){
|
|
|
+ return str_replace(array("\r","\n","\t"),"",$string);
|
|
|
+}
|
|
|
+
|
|
|
function writeLog($type, $message){
|
|
|
$message = date("Y-m-d H:i:s")."|".$type."|".$message."\n";
|
|
|
file_put_contents("org.log", $message, FILE_APPEND | LOCK_EX);
|