From ba19e43d1188c180c9f34f26a34dbefeff28b18a Mon Sep 17 00:00:00 2001 From: dabenzel Date: Sun, 8 Oct 2017 15:26:16 +0200 Subject: [PATCH 01/73] Added newest German translations --- lang/de.ini | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lang/de.ini b/lang/de.ini index 9b35e1b44..673d728e9 100644 --- a/lang/de.ini +++ b/lang/de.ini @@ -312,24 +312,24 @@ CHECK_FRAME = "Frame testen" GENERATE_API_KEY = "Generate API Schlüssel" ORGANIZR_API_KEY = "Organizr API Schlüssel" TEST_EMAIL = "Test E-Mail senden" -BACKUP_CREATED = "Backup Created" -BACKUP_ERROR = "Backup Creation Error" -BACKUP_NOW = "Backup Now" -BACKUP_LIST = "Backup List" +BACKUP_CREATED = "Sicherung erstellt" +BACKUP_ERROR = "Fehler beim erstellen der Sicherung" +BACKUP_NOW = "Jetzt sichern" +BACKUP_LIST = "Liste der Sicherungen" SPLASH = "Splash" PING = "Ping" PING_URL = "Ping URL" URL = "URL" -TEST_URL = "Enter URL to Test" -MORE = "More" -LESS = "Less" -ENABLE_SPLASH_SCREEN = "Enable Splash Screen" -ENABLE_CHAT = "Enable Chat" -CHAT_AUTH = "Minimum authentication level to access Chat" -AUTHBACKENDDOMAINFORMAT = "Advanced Domain to use for LDAP i.e. uid=s,ou=People,dc=example,dc=com" -TOGGLE_ALL = "Toggle All" -CALENDAR_REFRESH = "Calendar Refresh" +TEST_URL = "URL zum testen eingeben" +MORE = "Mehr" +LESS = "Weniger" +ENABLE_SPLASH_SCREEN = "Splash Screen aktivieren" +ENABLE_CHAT = "Chat aktivieren" +CHAT_AUTH = "Niedrigstes Benutzerlevel, um den Chat zu sehen" +AUTHBACKENDDOMAINFORMAT = "Erweitere Domäne zu nutzen von LDAP i.e. uid=s,ou=People,dc=example,dc=com" +TOGGLE_ALL = "Alle wechseln" +CALENDAR_REFRESH = "Kalender neu laden" COUCH_URL = "Couchpotato URL" -COUCH_KEY = "Couchpotato API/Key" -DELETE_CHAT_DATABASE = "Delete Chat Database" -INSTALLED_THEME = "Installed Theme" +COUCH_KEY = "Couchpotato API/Schlüssel" +DELETE_CHAT_DATABASE = "Chat Datenbank löschen" +INSTALLED_THEME = "Installiertes Thema" From 7055b02d439895e9ecf273dab564de9b4e6cbbfb Mon Sep 17 00:00:00 2001 From: causefx Date: Mon, 9 Oct 2017 10:01:54 -0700 Subject: [PATCH 02/73] fix more/less button in settings. --- functions.php | 750 +++++++++++++++++++++++++------------------------- 1 file changed, 375 insertions(+), 375 deletions(-) diff --git a/functions.php b/functions.php index f3974d093..ca7f64ed7 100755 --- a/functions.php +++ b/functions.php @@ -27,19 +27,19 @@ function plugin_auth_ldap($username, $password) { $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:'ldap')); $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:'')); $port = (isset($digest['port'])?$digest['port']:(strtolower($scheme)=='ldap'?389:636)); - + // Reassign $ldapServers[$key] = $scheme.'://'.$host.':'.$port; } - + // returns true or false $ldap = ldap_connect(implode(' ',$ldapServers)); if(empty(AUTHBACKENDDOMAINFORMAT)){ if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) { - writeLog("success", "LDAP authentication success"); + writeLog("success", "LDAP authentication success"); return true; } else { - writeLog("error", "LDAP could not authenticate"); + writeLog("error", "LDAP could not authenticate"); return false; } }else{ @@ -47,14 +47,14 @@ function plugin_auth_ldap($username, $password) { ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); $bind = ldap_bind($ldap, sprinf(AUTHBACKENDDOMAINFORMAT, $username), $password); if ($bind) { - writeLog("success", "LDAP authentication success"); + writeLog("success", "LDAP authentication success"); return true; } else { - writeLog("error", "LDPA could not authenticate"); + writeLog("error", "LDPA could not authenticate"); return false; - } + } } - writeLog("error", "LDAP could not authenticate"); + writeLog("error", "LDAP could not authenticate"); return false; } else : @@ -71,7 +71,7 @@ function plugin_auth_ftp($username, $password) { $scheme = strtolower((isset($digest['scheme'])?$digest['scheme']:(function_exists('ftp_ssl_connect')?'ftps':'ftp'))); $host = (isset($digest['host'])?$digest['host']:(isset($digest['path'])?$digest['path']:'')); $port = (isset($digest['port'])?$digest['port']:21); - + // Determine Connection Type if ($scheme == 'ftps') { $conn_id = ftp_ssl_connect($host, $port, 20); @@ -79,22 +79,22 @@ function plugin_auth_ftp($username, $password) { $conn_id = ftp_connect($host, $port, 20); } else { debug_out('Invalid FTP scheme. Use ftp or ftps'); - writeLog("error", "invalid FTP scheme"); + writeLog("error", "invalid FTP scheme"); return false; } - + // Check if valid FTP connection if ($conn_id) { // Attempt login @$login_result = ftp_login($conn_id, $username, $password); ftp_close($conn_id); - + // Return Result if ($login_result) { - writeLog("success", "$username authenticated"); + writeLog("success", "$username authenticated"); return true; } else { - writeLog("error", "$username could not authenticate"); + writeLog("error", "$username could not authenticate"); return false; } } else { @@ -106,7 +106,7 @@ function plugin_auth_ftp($username, $password) { // Pass credentials to Emby Backend function plugin_auth_emby_local($username, $password) { $embyAddress = qualifyURL(EMBYURL); - + $headers = array( 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"', 'Content-Type' => 'application/json', @@ -116,9 +116,9 @@ function plugin_auth_emby_local($username, $password) { 'Password' => sha1($password), 'PasswordMd5' => md5($password), ); - + $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers); - + if (isset($response['content'])) { $json = json_decode($response['content'], true); if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) { @@ -143,11 +143,11 @@ function plugin_auth_emby_all($username, $password) { return plugin_auth_emby_connect($username, $password); } } - + // Authenicate against emby connect function plugin_auth_emby_connect($username, $password) { $embyAddress = qualifyURL(EMBYURL); - + // Get A User $connectId = ''; $userIds = json_decode(file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true); @@ -158,10 +158,10 @@ function plugin_auth_emby_connect($username, $password) { $connectId = $value['ConnectUserId']; break; } - + } } - + if ($connectId) { $connectURL = 'https://connect.emby.media/service/user/authenticate'; $headers = array( @@ -172,9 +172,9 @@ function plugin_auth_emby_connect($username, $password) { 'nameOrEmail' => $username, 'rawpw' => $password, ); - + $result = curl_post($connectURL, $body, $headers); - + if (isset($result['content'])) { $json = json_decode($result['content'], true); if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) { @@ -186,7 +186,7 @@ function plugin_auth_emby_connect($username, $password) { } } } - + return false; } @@ -197,15 +197,15 @@ function plugin_auth_plex($username, $password) { writeLog("success", $username." authenticated by plex"); return true; } - + //Get User List $userURL = 'https://plex.tv/pms/friends/all'; $userHeaders = array( - 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD), + 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD), ); libxml_use_internal_errors(true); $userXML = simplexml_load_string(curl_get($userURL, $userHeaders)); - + if (is_array($userXML) || is_object($userXML)) { $isUser = false; $usernameLower = strtolower($username); @@ -216,7 +216,7 @@ function plugin_auth_plex($username, $password) { break; } } - + if ($isUser) { //Login User $connectURL = 'https://plex.tv/users/sign_in.json'; @@ -246,7 +246,7 @@ function plugin_auth_plex($username, $password) { writeLog("error", "$username is not an authorized PLEX user or entered invalid password"); } }else{ - writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini"); + writeLog("error", "error occured logging into plex might want to check curl.cainfo=/path/to/downloaded/cacert.pem in php.ini"); } return false; } @@ -255,12 +255,12 @@ function plugin_auth_plex($username, $password) { function plugin_auth_plex_disabled() { return 'Plex - Disabled (Dependancy: php-curl missing!)'; } - + // Emby Connect Auth Missing Dependancy function plugin_auth_emby_connect_disabled() { return 'Emby Connect - Disabled (Dependancy: php-curl missing!)'; } - + // Emby Both Auth Missing Dependancy function plugin_auth_emby_both_disabled() { return 'Emby Both - Disabled (Dependancy: php-curl missing!)'; @@ -269,14 +269,14 @@ function plugin_auth_emby_both_disabled() { // ==== Auth Plugins END ==== // ==== General Class Definitions START ==== $userLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en"; -class setLanguage { +class setLanguage { private $language = null; private $langCode = null; - + function __construct($language = false) { // Default if (!$language) { - $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en"; + $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en"; } if (!file_exists("lang/{$language}.ini")) { @@ -292,19 +292,19 @@ function __construct($language = false) { } } } - - + + public function getLang() { return $this->langCode; } - + public function translate($originalWord) { $getArg = func_num_args(); if ($getArg > 1) { $allWords = func_get_args(); - array_shift($allWords); + array_shift($allWords); } else { - $allWords = array(); + $allWords = array(); } $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null; @@ -314,10 +314,10 @@ public function translate($originalWord) { } $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES); - + return vsprintf($translatedWord, $allWords); } -} +} $language = new setLanguage; // ==== General Class Definitions END ==== @@ -336,7 +336,7 @@ function curl_post($url, $data, $headers = array(), $referer='') { // Initiate cURL $curlReq = curl_init($url); // As post request - curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlReq, CURLOPT_CAINFO, getCert()); if(localURL($url)){ @@ -345,7 +345,7 @@ function curl_post($url, $data, $headers = array(), $referer='') { } // Format Data switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') { - case 'application/json': + case 'application/json': curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data)); break; case 'application/x-www-form-urlencoded'; @@ -377,7 +377,7 @@ function curl_get($url, $headers = array()) { // Initiate cURL $curlReq = curl_init($url); // As post request - curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET"); + curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlReq, CURLOPT_CAINFO, getCert()); curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5); @@ -400,13 +400,13 @@ function curl_get($url, $headers = array()) { // Return return $result; } - + //Curl Delete Function function curl_delete($url, $headers = array()) { // Initiate cURL $curlReq = curl_init($url); // As post request - curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE"); + curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlReq, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($curlReq, CURLOPT_CAINFO, getCert()); @@ -440,7 +440,7 @@ function in_arrayi($needle, $haystack) { // HTTP post request (Removes need for curl, probably useless) function post_request($url, $data, $headers = array(), $referer='') { // Adapted from http://stackoverflow.com/a/28387011/6810513 - + // Convert the data array into URL Parameters like a=b&foo=bar etc. if (isset($headers['Content-Type'])) { switch ($headers['Content-Type']) { @@ -455,14 +455,14 @@ function post_request($url, $data, $headers = array(), $referer='') { $headers['Content-Type'] = 'application/x-www-form-urlencoded'; $data = http_build_query($data); } - + // parse the given URL $urlDigest = parse_url($url); // extract host and path: $host = $urlDigest['host']; $path = $urlDigest['path']; - + if ($urlDigest['scheme'] != 'http') { die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')'); } @@ -478,7 +478,7 @@ function post_request($url, $data, $headers = array(), $referer='') { if ($referer != '') fputs($fp, "Referer: $referer\r\n"); - + fputs($fp, "Content-length: ". strlen($data) ."\r\n"); foreach($headers as $k => $v) { fputs($fp, $k.": ".$v."\r\n"); @@ -520,7 +520,7 @@ function post_request($url, $data, $headers = array(), $referer='') { function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $moreInfo = false) { // Static Height $height = 444; - + // Get Item Details $itemDetails = json_decode(file_get_contents($address.'/Items?Ids='.$item['Id'].'&api_key='.$token),true)['Items'][0]; /*if (substr_count(EMBYURL, ':') == 2) { @@ -536,7 +536,7 @@ function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showName $width = 300; $style = ''; $image = 'slick-image-tall'; - if(!$nowPlaying){ + if(!$nowPlaying){ $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false); $key = $itemDetails['Id'] . "-list"; }else{ @@ -572,7 +572,7 @@ function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showName $width = 444; $style = ''; $image = 'slick-image-short'; - if(!$nowPlaying){ + if(!$nowPlaying){ $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false); $key = $itemDetails['Id'] . "-list"; }else{ @@ -606,7 +606,7 @@ function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showName $width = 300; $style = ''; $image = 'slick-image-tall'; - if(!$nowPlaying){ + if(!$nowPlaying){ $imageType = "Primary"; $key = $itemDetails['Id'] . "-list"; }else{ @@ -638,7 +638,7 @@ function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showName $width = 300; $style = ''; $image = 'slick-image-tall'; - if(!$nowPlaying){ + if(!$nowPlaying){ $imageType = (isset($itemDetails['ImageTags']['Primary']) ? "Primary" : false); $key = $itemDetails['Id'] . "-list"; }else{ @@ -666,17 +666,17 @@ function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showName if($showNames == "true"){ $bottomTitle .= ''.$user.''; } } } - + // If No Overview if (!isset($itemDetails['Overview'])) { $itemDetails['Overview'] = ''; } - + if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; } if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) { - $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.''; + $image_url = 'ajax.php?a=emby-image&type='.$imageType.'&img='.$imageId.'&height='.$height.'&width='.$width.'&key='.$key.''; } - + if($nowPlaying){ if(!$imageType){ $image_url = "images/no-np.png"; $key = "no-np"; } if(!$imageId){ $image_url = "images/no-np.png"; $key = "no-np"; } @@ -685,8 +685,8 @@ function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showName if(!$imageId){ $image_url = "images/no-list.png"; $key = "no-list"; } } if(isset($useImage)){ $image_url = $useImage; } - - // Assemble Item And Cache Into Array + + // Assemble Item And Cache Into Array if($nowPlaying){ //prettyPrint($itemDetails); return '
'.$itemDetails['Name'].'
'.$topTitle.''.$bottomTitle.'
'; @@ -698,8 +698,8 @@ function resolveEmbyItem($address, $token, $item, $nowPlaying = false, $showName // Format item from Plex for Carousel function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames = false, $role = false, $playlist = false) { // Static Height - $height = 444; - $playlist = ($playlist) ? " playlist-$playlist" : ""; + $height = 444; + $playlist = ($playlist) ? " playlist-$playlist" : ""; switch ($item['type']) { case 'season': @@ -708,10 +708,10 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames $width = 300; $image = 'slick-image-tall'; $style = ''; - if(!$nowPlaying){ + if(!$nowPlaying){ $thumb = $item['thumb']; $key = $item['ratingKey'] . "-list"; - }else { + }else { $height = 281; $width = 500; $thumb = $item['art']; @@ -739,10 +739,10 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames $width = 300; $image = 'slick-image-tall'; $style = ''; - if(!$nowPlaying){ + if(!$nowPlaying){ $thumb = ($item['parentThumb'] ? $item['parentThumb'] : $item['grandparentThumb']); $key = $item['ratingKey'] . "-list"; - }else { + }else { $height = 281; $width = 500; $thumb = $item['art']; @@ -773,10 +773,10 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames $width = 300; $image = 'slick-image-tall'; $style = ''; - if(!$nowPlaying){ + if(!$nowPlaying){ $thumb = $item['thumb']; $key = $item['ratingKey'] . "-list"; - }else { + }else { $height = 281; $width = 500; $thumb = $item['art']; @@ -810,11 +810,11 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames $image = 'slick-image-short'; $style = 'left: 160px !important;'; $item['ratingKey'] = $item['parentRatingKey']; - if(!$nowPlaying){ + if(!$nowPlaying){ $width = 444; $thumb = $item['thumb']; $key = $item['ratingKey'] . "-list"; - }else { + }else { $height = 281; $width = 500; $thumb = $item['art']; @@ -843,11 +843,11 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames $summary = $item['summary']; $image = 'slick-image-tall'; $style = ''; - if(!$nowPlaying){ + if(!$nowPlaying){ $width = 300; $thumb = $item['thumb']; $key = $item['ratingKey'] . "-list"; - }else { + }else { $height = 281; $width = 500; $thumb = $item['art']; @@ -872,7 +872,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames if($showNames == "true"){ $bottomTitle .= ''.$user.''; } } } - + if (substr_count(PLEXURL, '.') != 2) { $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey']; }else{ @@ -884,7 +884,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames if (file_exists('images/cache/'.$key.'.jpg')){ $image_url = 'images/cache/'.$key.'.jpg'; } if (file_exists('images/cache/'.$key.'.jpg') && (time() - 604800) > filemtime('images/cache/'.$key.'.jpg') || !file_exists('images/cache/'.$key.'.jpg')) { - $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.''; + $image_url = 'ajax.php?a=plex-image&img='.$thumb.'&height='.$height.'&width='.$width.'&key='.$key.''; } if($nowPlaying){ if(!$thumb){ $image_url = "images/no-np.png"; $key = "no-np"; } @@ -893,7 +893,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames } if(isset($useImage)){ $image_url = $useImage; } $openTab = (PLEXTABNAME) ? "true" : "false"; - // Assemble Item And Cache Into Array + // Assemble Item And Cache Into Array if($nowPlaying){ return '
'.$item['Name'].'
'.$topTitle.''.$bottomTitle.'
'; }else{ @@ -922,7 +922,7 @@ function outputRecentAdded($header, $items, $script = false, $array) { $className = str_replace(' ', '', $header); return '
'.$header.'
'.$hideMenu.'


'.implode('',$items).'
'.($script?'':''); } - + } // Create Carousel @@ -933,23 +933,23 @@ function outputNowPlaying($header, $size, $type, $items, $script = false) { }else{ return '
'.$header.'
'.implode('',$items).'
'.($script?'':''); } - + } // Get Now Playing Streams From Emby function getEmbyStreams($size, $showNames, $role) { $address = qualifyURL(EMBYURL); - + $api = json_decode(@file_get_contents($address.'/Sessions?api_key='.EMBYTOKEN),true); if (!is_array($api)) { return 'Could not load!'; } - + $playingItems = array(); foreach($api as $key => $value) { if (isset($value['NowPlayingItem'])) { $playingItems[] = resolveEmbyItem($address, EMBYTOKEN, $value['NowPlayingItem'], true, $showNames, $role, $value); } } - + return outputNowPlaying(translate('PLAYING_NOW_ON_EMBY'), $size, 'streams-emby', $playingItems, " setInterval(function() { $('
').load('ajax.php?a=emby-streams',function() { @@ -965,7 +965,7 @@ function getEmbyStreams($size, $showNames, $role) { // Get Now Playing Streams From Plex function getPlexStreams($size, $showNames, $role){ $address = qualifyURL(PLEXURL); - + // Perform API requests $api = @curl_get($address."/status/sessions?X-Plex-Token=".PLEXTOKEN); libxml_use_internal_errors(true); @@ -1029,7 +1029,7 @@ function getEmbyRecent($array) { // Get the latest Items $latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?EnableImages=false&Limit='.EMBYRECENTITEMS.'&api_key='.EMBYTOKEN.($showPlayed?'':'&IsPlayed=false')),true); - + // For Each Item In Category $items = array(); foreach ($latest as $k => $v) { @@ -1054,7 +1054,7 @@ function getEmbyRecent($array) { function getPlexRecent($array){ $address = qualifyURL(PLEXURL); $header = translate('RECENT_CONTENT'); - + // Perform Requests $api = @curl_get($address."/library/recentlyAdded?limit=".PLEXRECENTITEMS."&X-Plex-Token=".PLEXTOKEN); libxml_use_internal_errors(true); @@ -1128,12 +1128,12 @@ function getPlexImage() { if (!file_exists('images/cache')) { mkdir('images/cache', 0777, true); } - + $image_url = $_GET['img']; $key = $_GET['key']; $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; $cachefile = 'images/cache/'.$key.'.jpg'; @@ -1154,7 +1154,7 @@ function getPlexImage() { ob_end_flush(); // Send the output to the browser die(); } else { - echo "Invalid Plex Request"; + echo "Invalid Plex Request"; } } @@ -1180,10 +1180,10 @@ function randString($length = 10, $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ function createConfig($array, $path = 'config/config.php', $nest = 0) { // Define Initial Value $output = array(); - + // Sort Items ksort($array); - + // Update the current config version if (!$nest) { // Inject Current Version @@ -1191,7 +1191,7 @@ function createConfig($array, $path = 'config/config.php', $nest = 0) { } unset($array['CONFIG_VERSION']); unset($array['apply_CONFIG_VERSION']); - + // Process Settings foreach ($array as $k => $v) { $allowCommit = true; @@ -1214,24 +1214,24 @@ function createConfig($array, $path = 'config/config.php', $nest = 0) { default: $allowCommit = false; } - + if($allowCommit) { $output[] = str_repeat("\t",$nest+1)."'$k' => $item"; } } - + // Build output $output = (!$nest?" $v) { $current[$k] = $v; } - + // Return Create return createConfig($current); } @@ -1283,7 +1283,7 @@ function fillDefaultConfig($array, $path = 'config/configDefaults.php') { } else { $loadedDefaults = $path; } - + return (is_array($loadedDefaults) ? fillDefaultConfig_recurse($array, $loadedDefaults) : false); } @@ -1300,7 +1300,7 @@ function fillDefaultConfig_recurse($current, $defaults) { }; // Define Scalar Variables (nest non-secular with underscores) -function defineConfig($array, $anyCase = true, $nest_prefix = false) { +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); @@ -1318,7 +1318,7 @@ function configLazy($path = 'config/config.php') { } else { $config = loadConfig('config/configDefaults.php'); } - + if (is_array($config)) { defineConfig($config); } @@ -1329,16 +1329,16 @@ function configLazy($path = 'config/config.php') { function qualifyURL($url) { //local address? if(substr($url, 0,1) == "/"){ - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { - $protocol = "https://"; - } else { - $protocol = "http://"; + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { + $protocol = "https://"; + } else { + $protocol = "http://"; } $url = $protocol.getServer().$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))) { @@ -1349,16 +1349,16 @@ function qualifyURL($url) { } 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; } @@ -1369,31 +1369,31 @@ function upgradeCheck() { 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'] = preg_replace('/\/\/$/','/',$config['databaseLocation'].'/'); $config['user_home'] = $config['database_Location'].'users/'; unset($config['databaseLocation']); - + // Turn Off Emby And Plex Recent $config["embyURL"] = $config["embyURL"].(!empty($config["embyPort"])?':'.$config["embyPort"]:''); unset($config["embyPort"]); @@ -1405,12 +1405,12 @@ function upgradeCheck() { unset($config["sabnzbdPort"]); $config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:''); unset($config["headphonesPort"]); - + // Write config file $config['CONFIG_VERSION'] = '1.32'; copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][pre1.32].bak.php'); $createConfigSuccess = createConfig($config); - + // Create new config if ($createConfigSuccess) { if (file_exists('config/config.php')) { @@ -1423,7 +1423,7 @@ function upgradeCheck() { debug_out('Couldn\'t create updated configuration.' ,1); } } - + // Upgrade to 1.33 $config = loadConfig(); if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) { @@ -1431,47 +1431,47 @@ function upgradeCheck() { $config['database_Location'] = preg_replace('/\/\/$/','/',$config['database_Location'].'/'); $config['user_home'] = $config['database_Location'].'users/'; unset($config['USER_HOME']); - + // Backend auth merge if (isset($config['authBackendPort']) && !isset(parse_url($config['authBackendHost'])['port'])) { $config['authBackendHost'] .= ':'.$config['authBackendPort']; } unset($config['authBackendPort']); - + // If auth is being used move it to embyURL as that is now used in auth functions if ((isset($config['authType']) && $config['authType'] == 'true') && (isset($config['authBackendHost']) && $config['authBackendHost'] == 'true') && (isset($config['authBackend']) && in_array($config['authBackend'], array('emby_all','emby_local','emby_connect')))) { $config['embyURL'] = $config['authBackendHost']; } - + // Upgrade database to latest version updateSQLiteDB($config['database_Location'],'1.32'); - + // Update Version and Commit $config['apply_CONFIG_VERSION'] = '1.33'; copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.32].bak.php'); $createConfigSuccess = createConfig($config); unset($config); } - + // Upgrade to 1.34 $config = loadConfig(); if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.34')) { // Upgrade database to latest version updateSQLiteDB($config['database_Location'],'1.33'); - + // Update Version and Commit $config['CONFIG_VERSION'] = '1.34'; copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.33].bak.php'); $createConfigSuccess = createConfig($config); unset($config); } - + // Upgrade to 1.40 $config = loadConfig(); if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.40')) { // Upgrade database to latest version updateSQLiteDB($config['database_Location'],'1.38'); - + // Update Version and Commit $config['CONFIG_VERSION'] = '1.40'; copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.38].bak.php'); @@ -1484,14 +1484,14 @@ function upgradeCheck() { if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.50')) { // Upgrade database to latest version updateSQLiteDB($config['database_Location'],'1.40'); - + // Update Version and Commit $config['CONFIG_VERSION'] = '1.50'; copy('config/config.php', 'config/config['.date('Y-m-d_H-i-s').'][1.40].bak.php'); $createConfigSuccess = createConfig($config); unset($config); } - + return true; } @@ -1525,7 +1525,7 @@ function getError($os, $error){ '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'); } @@ -1538,10 +1538,10 @@ function dependCheck() { if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; } if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; } //if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); } - + if ($output) { - $output["Step $i"] = "Restart PHP and/or Webserver to apply changes"; $i++; - $output["Step $i"] = "Please visit here to also check status of necessary components after you fix them: check.php"; $i++; + $output["Step $i"] = "Restart PHP and/or Webserver to apply changes"; $i++; + $output["Step $i"] = "Please visit here to also check status of necessary components after you fix them: check.php"; $i++; debug_out($output,1); } return true; @@ -1575,7 +1575,7 @@ function uploadFiles($path, $ext_mask = null) { writeLog("error", $files['metas'][0]['name']." was not able to upload"); echo json_encode($errors); } - } else { + } else { writeLog("error", "image was not uploaded"); echo json_encode('No files submitted!'); } @@ -1608,7 +1608,7 @@ function uploadAvatar($path, $ext_mask = null) { writeLog("error", $files['metas'][0]['name']." was not able to upload"); echo json_encode($errors); } - } else { + } else { writeLog("error", "image was not uploaded"); echo json_encode('No files submitted!'); } @@ -1642,7 +1642,7 @@ function resolveSelectOptions($array, $selected = '', $multi = false) { } else { $output[] = ''; } - + } return implode('',$output); } @@ -1653,7 +1653,7 @@ function qualifyUser($type, $errOnFail = false) { require_once("user.php"); $GLOBALS['USER'] = new User('registration_callback'); } - + if (is_bool($type)) { if ($type === true) { $authorized = ($GLOBALS['USER']->authenticated == true); @@ -1672,7 +1672,7 @@ function qualifyUser($type, $errOnFail = false) { } else { debug_out('Invalid Syntax!',1); } - + if (!$authorized && $errOnFail) { if ($GLOBALS['USER']->authenticated) { header('Location: '.rtrim(dirname($_SERVER['SCRIPT_NAME']), '/').'/error.php?error=401'); @@ -1705,9 +1705,9 @@ function buildSettings($array) { ), ); */ - + $notifyExplode = explode("-", NOTIFYEFFECT); - + $fieldFunc = function($fieldArr) { $fields = '
'; foreach($fieldArr as $key => $value) { @@ -1724,9 +1724,9 @@ function buildSettings($array) { $fields .= '
'; return $fields; }; - + $fields = (isset($array['fields'])?$fieldFunc($array['fields']):''); - + $tabSelectors = array(); $tabContent = array(); if (isset($array['tabs'])) { @@ -1736,10 +1736,10 @@ function buildSettings($array) { $tabContent[$key] = '
'.$fieldFunc($value['fields']).'
'; } } - + $pageID = (isset($array['id'])?$array['id']:str_replace(array(' ','"',"'"),array('_'),strtolower($array['id']))); $extraClick = ($pageID == 'appearance_settings' ? "$('#advanced_settings_form_submit').click();console.log('add theme settings');" : ""); - + return '