functions.php 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  1. <?php
  2. // Debugging output functions
  3. function debug_out($variable, $die = false) {
  4. $trace = debug_backtrace()[0];
  5. echo '<pre style="background-color: #f2f2f2; border: 2px solid black; border-radius: 5px; padding: 5px; margin: 5px;">'.$trace['file'].':'.$trace['line']."\n\n".print_r($variable, true).'</pre>';
  6. if ($die) { http_response_code(503); die(); }
  7. }
  8. // ==== Auth Plugins START ====
  9. // Pass credentials to LDAP backend
  10. function plugin_auth_ldap($username, $password) {
  11. // returns true or false
  12. $ldap = ldap_connect(AUTHBACKENDHOST.(AUTHBACKENDPORT?':'.AUTHBACKENDPORT:'389'));
  13. if ($bind = ldap_bind($ldap, AUTHBACKENDDOMAIN.'\\'.$username, $password)) {
  14. return true;
  15. } else {
  16. return false;
  17. }
  18. return false;
  19. }
  20. // Pass credentials to FTP backend
  21. function plugin_auth_ftp($username, $password) {
  22. // returns true or false
  23. // Connect to FTP
  24. $conn_id = ftp_ssl_connect(AUTHBACKENDHOST, (AUTHBACKENDPORT?AUTHBACKENDPORT:21), 20); // 20 Second Timeout
  25. // Check if valid FTP connection
  26. if ($conn_id) {
  27. // Attempt login
  28. @$login_result = ftp_login($conn_id, $username, $password);
  29. // Return Result
  30. if ($login_result) {
  31. return true;
  32. } else {
  33. return false;
  34. }
  35. } else {
  36. return false;
  37. }
  38. return false;
  39. }
  40. // Authenticate Against Emby Local (first) and Emby Connect
  41. function plugin_auth_emby_all($username, $password) {
  42. return plugin_auth_emby_local($username, $password) || plugin_auth_emby_connect($username, $password);
  43. }
  44. // Authenicate against emby connect
  45. function plugin_auth_emby_connect($username, $password) {
  46. $urlCheck = stripos(AUTHBACKENDHOST, "http");
  47. if ($urlCheck === false) {
  48. $embyAddress = "http://" . AUTHBACKENDHOST;
  49. } else {
  50. $embyAddress = AUTHBACKENDHOST;
  51. }
  52. if(AUTHBACKENDPORT !== "") { $embyAddress .= ":" . AUTHBACKENDPORT; }
  53. // Get A User
  54. $connectId = '';
  55. $userIds = json_decode(file_get_contents($embyAddress.'/Users?api_key='.EMBYTOKEN),true);
  56. if (is_array($userIds)) {
  57. foreach ($userIds as $key => $value) { // Scan for this user
  58. if (isset($value['ConnectUserName']) && isset($value['ConnectUserId'])) { // Qualifty as connect account
  59. if ($value['ConnectUserName'] == $username || $value['Name'] == $username) {
  60. $connectId = $value['ConnectUserId'];
  61. break;
  62. }
  63. }
  64. }
  65. if ($connectId) {
  66. $connectURL = 'https://connect.emby.media/service/user/authenticate';
  67. $headers = array(
  68. 'Accept'=> 'application/json',
  69. 'Content-Type' => 'application/x-www-form-urlencoded',
  70. );
  71. $body = array(
  72. 'nameOrEmail' => $username,
  73. 'rawpw' => $password,
  74. );
  75. $result = curl_post($connectURL, $body, $headers);
  76. if (isset($result['content'])) {
  77. $json = json_decode($result['content'], true);
  78. if (is_array($json) && isset($json['AccessToken']) && isset($json['User']) && $json['User']['Id'] == $connectId) {
  79. return true;
  80. }
  81. }
  82. }
  83. }
  84. return false;
  85. }
  86. // Pass credentials to Emby Backend
  87. function plugin_auth_emby_local($username, $password) {
  88. $urlCheck = stripos(AUTHBACKENDHOST, "http");
  89. if ($urlCheck === false) {
  90. $embyAddress = "http://" . AUTHBACKENDHOST;
  91. } else {
  92. $embyAddress = AUTHBACKENDHOST;
  93. }
  94. if(AUTHBACKENDPORT !== ""){ $embyAddress .= ":" . AUTHBACKENDPORT; }
  95. $headers = array(
  96. 'Authorization'=> 'MediaBrowser UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="None", Device="Organizr", DeviceId="xxx", Version="1.0.0.0"',
  97. 'Content-Type' => 'application/json',
  98. );
  99. $body = array(
  100. 'Username' => $username,
  101. 'Password' => sha1($password),
  102. 'PasswordMd5' => md5($password),
  103. );
  104. $response = post_router($embyAddress.'/Users/AuthenticateByName', $body, $headers);
  105. if (isset($response['content'])) {
  106. $json = json_decode($response['content'], true);
  107. if (is_array($json) && isset($json['SessionInfo']) && isset($json['User']) && $json['User']['HasPassword'] == true) {
  108. // Login Success - Now Logout Emby Session As We No Longer Need It
  109. $headers = array(
  110. 'X-Mediabrowser-Token' => $json['AccessToken'],
  111. );
  112. $response = post_router($embyAddress.'/Sessions/Logout', array(), $headers);
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. // Pass credentials to Plex Backend
  119. function plugin_auth_plex($username, $password) {
  120. // Quick out
  121. if ((strtolower(PLEXUSERNAME) == strtolower($username)) && $password == PLEXPASSWORD) {
  122. return true;
  123. }
  124. //Get User List
  125. $approvedUsers = array();
  126. $userURL = 'https://plex.tv/pms/friends/all';
  127. $userHeaders = array(
  128. 'Authorization' => 'Basic '.base64_encode(PLEXUSERNAME.':'.PLEXPASSWORD),
  129. );
  130. $userXML = simplexml_load_string(curl_get($userURL, $userHeaders));
  131. //Build User List array
  132. foreach($userXML AS $child) {
  133. if(isset($child['username']) && $child['username'] != ""){
  134. array_push($approvedUsers, $child['username']);
  135. }
  136. }
  137. //Check If User Is Approved
  138. if(!in_arrayi("$username", $approvedUsers)){
  139. return false;
  140. }
  141. //Login User
  142. $connectURL = 'https://plex.tv/users/sign_in.json';
  143. $headers = array(
  144. 'Accept'=> 'application/json',
  145. 'Content-Type' => 'application/x-www-form-urlencoded',
  146. 'X-Plex-Product' => 'Organizr',
  147. 'X-Plex-Version' => '1.0',
  148. 'X-Plex-Client-Identifier' => '01010101-10101010',
  149. );
  150. $body = array(
  151. 'user[login]' => $username,
  152. 'user[password]' => $password,
  153. );
  154. $result = curl_post($connectURL, $body, $headers);
  155. if (isset($result['content'])) {
  156. $json = json_decode($result['content'], true);
  157. if (is_array($json) && isset($json['user']) && isset($json['user']['username']) && $json['user']['username'] == $username) {
  158. return true;
  159. }
  160. }
  161. return false;
  162. }
  163. // ==== Auth Plugins END ====
  164. // ==== General Class Definitions START ====
  165. class setLanguage {
  166. private $language = null;
  167. private $langCode = null;
  168. function __construct($language = false) {
  169. // Default
  170. if (!$language) {
  171. $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : "en";
  172. }
  173. $this->langCode = $language;
  174. if (file_exists("lang/{$language}.ini")) {
  175. $this->language = parse_ini_file("lang/{$language}.ini", false, INI_SCANNER_RAW);
  176. } else {
  177. $this->language = parse_ini_file("lang/en.ini", false, INI_SCANNER_RAW);
  178. }
  179. }
  180. public function getLang() {
  181. return $this->langCode;
  182. }
  183. public function translate($originalWord) {
  184. $getArg = func_num_args();
  185. if ($getArg > 1) {
  186. $allWords = func_get_args();
  187. array_shift($allWords);
  188. } else {
  189. $allWords = array();
  190. }
  191. $translatedWord = isset($this->language[$originalWord]) ? $this->language[$originalWord] : null;
  192. if (!$translatedWord) {
  193. echo ("Translation not found for: $originalWord");
  194. }
  195. $translatedWord = htmlspecialchars($translatedWord, ENT_QUOTES);
  196. return vsprintf($translatedWord, $allWords);
  197. }
  198. }
  199. $language = new setLanguage;
  200. // ==== General Class Definitions END ====
  201. // Direct request to curl if it exists, otherwise handle if not HTTPS
  202. function post_router($url, $data, $headers = array(), $referer='') {
  203. if (function_exists('curl_version')) {
  204. return curl_post($url, $data, $headers, $referer);
  205. } else {
  206. return post_request($url, $data, $headers, $referer);
  207. }
  208. }
  209. // Curl Post
  210. function curl_post($url, $data, $headers = array(), $referer='') {
  211. // Initiate cURL
  212. $curlReq = curl_init($url);
  213. // As post request
  214. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "POST");
  215. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  216. // Format Data
  217. switch (isset($headers['Content-Type'])?$headers['Content-Type']:'') {
  218. case 'application/json':
  219. curl_setopt($curlReq, CURLOPT_POSTFIELDS, json_encode($data));
  220. break;
  221. case 'application/x-www-form-urlencoded';
  222. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  223. break;
  224. default:
  225. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  226. curl_setopt($curlReq, CURLOPT_POSTFIELDS, http_build_query($data));
  227. }
  228. // Format Headers
  229. $cHeaders = array();
  230. foreach ($headers as $k => $v) {
  231. $cHeaders[] = $k.': '.$v;
  232. }
  233. if (count($cHeaders)) {
  234. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  235. }
  236. // Execute
  237. $result = curl_exec($curlReq);
  238. // Close
  239. curl_close($curlReq);
  240. // Return
  241. return array('content'=>$result);
  242. }
  243. //Curl Get Function
  244. function curl_get($url, $headers = array()) {
  245. // Initiate cURL
  246. $curlReq = curl_init($url);
  247. // As post request
  248. curl_setopt($curlReq, CURLOPT_CUSTOMREQUEST, "GET");
  249. curl_setopt($curlReq, CURLOPT_RETURNTRANSFER, true);
  250. // Format Headers
  251. $cHeaders = array();
  252. foreach ($headers as $k => $v) {
  253. $cHeaders[] = $k.': '.$v;
  254. }
  255. if (count($cHeaders)) {
  256. curl_setopt($curlReq, CURLOPT_HTTPHEADER, $cHeaders);
  257. }
  258. // Execute
  259. $result = curl_exec($curlReq);
  260. // Close
  261. curl_close($curlReq);
  262. // Return
  263. return $result;
  264. }
  265. //Case-Insensitive Function
  266. function in_arrayi($needle, $haystack) {
  267. return in_array(strtolower($needle), array_map('strtolower', $haystack));
  268. }
  269. // HTTP post request (Removes need for curl, probably useless)
  270. function post_request($url, $data, $headers = array(), $referer='') {
  271. // Adapted from http://stackoverflow.com/a/28387011/6810513
  272. // Convert the data array into URL Parameters like a=b&foo=bar etc.
  273. if (isset($headers['Content-Type'])) {
  274. switch ($headers['Content-Type']) {
  275. case 'application/json':
  276. $data = json_encode($data);
  277. break;
  278. case 'application/x-www-form-urlencoded':
  279. $data = http_build_query($data);
  280. break;
  281. }
  282. } else {
  283. $headers['Content-Type'] = 'application/x-www-form-urlencoded';
  284. $data = http_build_query($data);
  285. }
  286. // parse the given URL
  287. $urlDigest = parse_url($url);
  288. // extract host and path:
  289. $host = $urlDigest['host'].(isset($urlDigest['port'])?':'.$urlDigest['port']:'');
  290. $path = $urlDigest['path'];
  291. if ($urlDigest['scheme'] != 'http') {
  292. die('Error: Only HTTP request are supported, please use cURL to add HTTPS support! ('.$urlDigest['scheme'].'://'.$host.')');
  293. }
  294. // open a socket connection on port 80 - timeout: 30 sec
  295. $fp = fsockopen($host, 80, $errno, $errstr, 30);
  296. if ($fp){
  297. // send the request headers:
  298. fputs($fp, "POST $path HTTP/1.1\r\n");
  299. fputs($fp, "Host: $host\r\n");
  300. if ($referer != '')
  301. fputs($fp, "Referer: $referer\r\n");
  302. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  303. foreach($headers as $k => $v) {
  304. fputs($fp, $k.": ".$v."\r\n");
  305. }
  306. fputs($fp, "Connection: close\r\n\r\n");
  307. fputs($fp, $data);
  308. $result = '';
  309. while(!feof($fp)) {
  310. // receive the results of the request
  311. $result .= fgets($fp, 128);
  312. }
  313. }
  314. else {
  315. return array(
  316. 'status' => 'err',
  317. 'error' => "$errstr ($errno)"
  318. );
  319. }
  320. // close the socket connection:
  321. fclose($fp);
  322. // split the result header from the content
  323. $result = explode("\r\n\r\n", $result, 2);
  324. $header = isset($result[0]) ? $result[0] : '';
  325. $content = isset($result[1]) ? $result[1] : '';
  326. // return as structured array:
  327. return array(
  328. 'status' => 'ok',
  329. 'header' => $header,
  330. 'content' => $content,
  331. );
  332. }
  333. // Format item from Emby for Carousel
  334. function resolveEmbyItem($address, $token, $item) {
  335. // Static Height
  336. $height = 150;
  337. // Get Item Details
  338. $itemDetails = json_decode(file_get_contents($address.'/Items?Ids='.$item['Id'].'&Fields=Overview&api_key='.$token),true)['Items'][0];
  339. switch ($item['Type']) {
  340. case 'Episode':
  341. $title = $item['SeriesName'].': '.$item['Name'].' (Season '.$item['ParentIndexNumber'].': Episode '.$item['IndexNumber'].')';
  342. $imageId = $itemDetails['SeriesId'];
  343. $width = 100;
  344. $image = 'carousel-image season';
  345. $style = '';
  346. break;
  347. case 'MusicAlbum':
  348. $title = $item['Name'];
  349. $imageId = $itemDetails['Id'];
  350. $width = 150;
  351. $image = 'music';
  352. $style = 'left: 160px !important;';
  353. break;
  354. default:
  355. $title = $item['Name'];
  356. $imageId = $item['Id'];
  357. $width = 100;
  358. $image = 'carousel-image movie';
  359. $style = '';
  360. }
  361. // If No Overview
  362. if (!isset($itemDetails['Overview'])) {
  363. $itemDetails['Overview'] = '';
  364. }
  365. // Assemble Item And Cache Into Array
  366. return '<div class="item"><a href="'.$address.'/web/itemdetails.html?id='.$item['Id'].'" target="_blank"><img alt="'.$item['Name'].'" class="'.$image.'" src="image.php?source=emby&img='.$imageId.'&height='.$height.'&width='.$width.'"></a><div class="carousel-caption" style="'.$style.'"><h4>'.$title.'</h4><small><em>'.$itemDetails['Overview'].'</em></small></div></div>';
  367. }
  368. // Format item from Plex for Carousel
  369. function resolvePlexItem($server, $token, $item) {
  370. // Static Height
  371. $height = 150;
  372. $address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
  373. switch ($item['type']) {
  374. case 'season':
  375. $title = $item['parentTitle'];
  376. $summary = $item['parentSummary'];
  377. $width = 100;
  378. $image = 'carousel-image season';
  379. $style = '';
  380. break;
  381. case 'album':
  382. $title = $item['parentTitle'];
  383. $summary = $item['title'];
  384. $width = 150;
  385. $image = 'album';
  386. $style = 'left: 160px !important;';
  387. break;
  388. default:
  389. $title = $item['title'];
  390. $summary = $item['summary'];
  391. $width = 100;
  392. $image = 'carousel-image movie';
  393. $style = '';
  394. }
  395. // If No Overview
  396. if (!isset($itemDetails['Overview'])) {
  397. $itemDetails['Overview'] = '';
  398. }
  399. // Assemble Item And Cache Into Array
  400. return '<div class="item"><a href="'.$address.'" target="_blank"><img alt="'.$item['Name'].'" class="'.$image.'" src="image.php?source=plex&img='.$item['thumb'].'&height='.$height.'&width='.$width.'"></a><div class="carousel-caption" style="'.$style.'"><h4>'.$title.'</h4><small><em>'.$summary.'</em></small></div></div>';
  401. }
  402. // Create Carousel
  403. function outputCarousel($header, $size, $type, $items) {
  404. // If None Populate Empty Item
  405. if (!count($items)) {
  406. $items = array('<div class="item"><img alt="nada" class="carousel-image movie" src="images/nadaplaying.jpg"><div class="carousel-caption"><h4>Nothing To Show</h4><small><em>Get Some Stuff Going!</em></small></div></div>');
  407. }
  408. // Set First As Active
  409. $items[0] = preg_replace('/^<div class="item ?">/','<div class="item active">', $items[0]);
  410. // Add Buttons
  411. $buttons = '';
  412. if (count($items) > 1) {
  413. $buttons = '
  414. <a class="left carousel-control '.$type.'" href="#carousel-'.$type.'" role="button" data-slide="prev"><span class="fa fa-chevron-left" aria-hidden="true"></span><span class="sr-only">Previous</span></a>
  415. <a class="right carousel-control '.$type.'" href="#carousel-'.$type.'" role="button" data-slide="next"><span class="fa fa-chevron-right" aria-hidden="true"></span><span class="sr-only">Next</span></a>';
  416. }
  417. return '
  418. <div class="col-lg-'.$size.'">
  419. <h5 class="text-center">'.$header.'</h5>
  420. <div id="carousel-'.$type.'" class="carousel slide box-shadow white-bg" data-ride="carousel"><div class="carousel-inner" role="listbox">
  421. '.implode('',$items).'
  422. </div>'.$buttons.'
  423. </div></div>';
  424. }
  425. // Get Now Playing Streams From Emby
  426. function getEmbyStreams($url, $port, $token, $size, $header) {
  427. if (stripos($url, "http") === false) {
  428. $url = "http://" . $url;
  429. }
  430. if ($port !== "") {
  431. $url = $url . ":" . $port;
  432. }
  433. $address = $url;
  434. $api = json_decode(file_get_contents($address.'/Sessions?api_key='.$token),true);
  435. $playingItems = array();
  436. foreach($api as $key => $value) {
  437. if (isset($value['NowPlayingItem'])) {
  438. $playingItems[] = resolveEmbyItem($address, $token, $value['NowPlayingItem']);
  439. }
  440. }
  441. return outputCarousel($header, $size, 'streams-emby', $playingItems);
  442. }
  443. // Get Now Playing Streams From Plex
  444. function getPlexStreams($url, $port, $token, $size, $header){
  445. if (stripos($url, "http") === false) {
  446. $url = "http://" . $url;
  447. }
  448. if ($port !== "") {
  449. $url = $url . ":" . $port;
  450. }
  451. $address = $url;
  452. // Perform API requests
  453. $api = file_get_contents($address."/status/sessions?X-Plex-Token=".$token);
  454. $api = simplexml_load_string($api);
  455. $getServer = simplexml_load_string(file_get_contents($address."/?X-Plex-Token=".$token));
  456. // Identify the local machine
  457. $gotServer = $getServer['machineIdentifier'];
  458. $items = array();
  459. foreach($api AS $child) {
  460. $items[] = resolvePlexItem($gotServer, $token, $child);
  461. }
  462. return outputCarousel($header, $size, 'streams-plex', $items);
  463. }
  464. // Get Recent Content From Emby
  465. function getEmbyRecent($url, $port, $type, $token, $size, $header) {
  466. if (stripos($url, "http") === false) {
  467. $url = "http://" . $url;
  468. }
  469. if ($port !== "") {
  470. $url = $url . ":" . $port;
  471. }
  472. $address = $url;
  473. // Resolve Types
  474. switch ($type) {
  475. case 'movie':
  476. $embyTypeQuery = 'IncludeItemTypes=Movie&';
  477. break;
  478. case 'season':
  479. $embyTypeQuery = 'IncludeItemTypes=Episode&';
  480. break;
  481. case 'album':
  482. $embyTypeQuery = 'IncludeItemTypes=MusicAlbum&';
  483. break;
  484. default:
  485. $embyTypeQuery = '';
  486. }
  487. // Get A User
  488. $userIds = json_decode(file_get_contents($address.'/Users?api_key='.$token),true);
  489. foreach ($userIds as $value) { // Scan for admin user
  490. $userId = $value['Id'];
  491. if (isset($value['Policy']) && isset($value['Policy']['IsAdministrator']) && $value['Policy']['IsAdministrator']) {
  492. break;
  493. }
  494. }
  495. // Get the latest Items
  496. $latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?'.$embyTypeQuery.'EnableImages=false&api_key='.$token),true);
  497. // For Each Item In Category
  498. $items = array();
  499. foreach ($latest as $k => $v) {
  500. $items[] = resolveEmbyItem($address, $token, $v);
  501. }
  502. return outputCarousel($header, $size, $type.'-emby', $items);
  503. }
  504. // Get Recent Content From Plex
  505. function getPlexRecent($url, $port, $type, $token, $size, $header){
  506. if (stripos($url, "http") === false) {
  507. $url = "http://" . $url;
  508. }
  509. if ($port !== "") {
  510. $url = $url . ":" . $port;
  511. }
  512. $address = $url;
  513. // Perform Requests
  514. $api = file_get_contents($address."/library/recentlyAdded?X-Plex-Token=".$token);
  515. $api = simplexml_load_string($api);
  516. $getServer = simplexml_load_string(file_get_contents($address."/?X-Plex-Token=".$token));
  517. // Identify the local machine
  518. $gotServer = $getServer['machineIdentifier'];
  519. $items = array();
  520. foreach($api AS $child) {
  521. if($child['type'] == $type){
  522. $items[] = resolvePlexItem($gotServer, $token, $child);
  523. }
  524. }
  525. return outputCarousel($header, $size, $type.'-plex', $items);
  526. }
  527. // Simplier access to class
  528. function translate($string) {
  529. if (isset($GLOBALS['language'])) {
  530. return $GLOBALS['language']->translate($string);
  531. } else {
  532. return '!Translations Not Loaded!';
  533. }
  534. }
  535. // Generate Random string
  536. function randString($length = 10) {
  537. $tmp = '';
  538. $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
  539. for ($i = 0; $i < $length; $i++) {
  540. $tmp .= substr(str_shuffle($chars), 0, 1);
  541. }
  542. return $tmp;
  543. }
  544. // Create config file in the return syntax
  545. function createConfig($array, $path, $nest = 0) {
  546. $output = array();
  547. foreach ($array as $k => $v) {
  548. $allowCommit = true;
  549. switch (gettype($v)) {
  550. case 'boolean':
  551. $item = ($v?'true':'false');
  552. break;
  553. case 'integer':
  554. case 'double':
  555. case 'integer':
  556. case 'NULL':
  557. $item = $v;
  558. break;
  559. case 'string':
  560. $item = '"'.addslashes($v).'"';
  561. break;
  562. case 'array':
  563. $item = createConfig($v, false, $nest+1);
  564. break;
  565. default:
  566. $allowCommit = false;
  567. }
  568. if($allowCommit) {
  569. $output[] = str_repeat("\t",$nest+1).'"'.$k.'" => '.$item;
  570. }
  571. }
  572. $output = (!$nest?"<?php\nreturn ":'')."array(\n".implode(",\n",$output)."\n".str_repeat("\t",$nest).')'.(!$nest?';':'');
  573. if (!$nest && $path) {
  574. $pathDigest = pathinfo($path);
  575. @mkdir($pathDigest['dirname'], 0770, true);
  576. if (file_exists($path)) {
  577. rename($path, $path.'.bak');
  578. }
  579. $file = fopen($path, 'w');
  580. fwrite($file, $output);
  581. fclose($file);
  582. if (file_exists($path)) {
  583. unlink($path.'.bak');
  584. return true;
  585. }
  586. return false;
  587. } else {
  588. return $output;
  589. }
  590. }
  591. // Load a config file written in the return syntax
  592. function loadConfig($path) {
  593. // Adapted from http://stackoverflow.com/a/14173339/6810513
  594. if (!is_file($path)) {
  595. return null;
  596. } else {
  597. return (array) call_user_func(function() use($path) {
  598. return include($path);
  599. });
  600. }
  601. }
  602. // Inject Defaults As Needed
  603. function fillDefaultConfig($array, $path = 'config/configDefaults.php') {
  604. if (is_string($path)) {
  605. $loadedDefaults = loadConfig($path);
  606. } else {
  607. $loadedDefaults = $path;
  608. }
  609. function recurse($current, $defaults) {
  610. foreach($defaults as $k => $v) {
  611. if (!isset($current[$k])) {
  612. $current[$k] = $v;
  613. } else if (is_array($current[$k]) && is_array($v)) {
  614. $current[$k] = recurse($current[$k], $v);
  615. }
  616. }
  617. return $current;
  618. };
  619. return (is_array($loadedDefaults) ? recurse($array, $loadedDefaults) : false);
  620. }
  621. // ==============
  622. function clean($strin) {
  623. $strout = null;
  624. for ($i = 0; $i < strlen($strin); $i++) {
  625. $ord = ord($strin[$i]);
  626. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  627. $strout .= "&amp;#{$ord};";
  628. }
  629. else {
  630. switch ($strin[$i]) {
  631. case '<':
  632. $strout .= '&lt;';
  633. break;
  634. case '>':
  635. $strout .= '&gt;';
  636. break;
  637. case '&':
  638. $strout .= '&amp;';
  639. break;
  640. case '"':
  641. $strout .= '&quot;';
  642. break;
  643. default:
  644. $strout .= $strin[$i];
  645. }
  646. }
  647. }
  648. return $strout;
  649. }
  650. function registration_callback($username, $email, $userdir){
  651. global $data;
  652. $data = array($username, $email, $userdir);
  653. }
  654. function printArray($arrayName){
  655. $messageCount = count($arrayName);
  656. $i = 0;
  657. foreach ( $arrayName as $item ) :
  658. $i++;
  659. if($i < $messageCount) :
  660. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  661. elseif($i = $messageCount) :
  662. echo "<small class='text-uppercase'>" . $item . "</small>";
  663. endif;
  664. endforeach;
  665. }
  666. function write_ini_file($content, $path) {
  667. if (!$handle = fopen($path, 'w')) {
  668. return false;
  669. }
  670. $success = fwrite($handle, trim($content));
  671. fclose($handle);
  672. return $success;
  673. }
  674. function gotTimezone(){
  675. $regions = array(
  676. 'Africa' => DateTimeZone::AFRICA,
  677. 'America' => DateTimeZone::AMERICA,
  678. 'Antarctica' => DateTimeZone::ANTARCTICA,
  679. 'Arctic' => DateTimeZone::ARCTIC,
  680. 'Asia' => DateTimeZone::ASIA,
  681. 'Atlantic' => DateTimeZone::ATLANTIC,
  682. 'Australia' => DateTimeZone::AUSTRALIA,
  683. 'Europe' => DateTimeZone::EUROPE,
  684. 'Indian' => DateTimeZone::INDIAN,
  685. 'Pacific' => DateTimeZone::PACIFIC
  686. );
  687. $timezones = array();
  688. foreach ($regions as $name => $mask) {
  689. $zones = DateTimeZone::listIdentifiers($mask);
  690. foreach($zones as $timezone) {
  691. $time = new DateTime(NULL, new DateTimeZone($timezone));
  692. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  693. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  694. }
  695. }
  696. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  697. foreach($timezones as $region => $list) {
  698. print '<optgroup label="' . $region . '">' . "\n";
  699. foreach($list as $timezone => $name) {
  700. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  701. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  702. }
  703. print '</optgroup>' . "\n";
  704. }
  705. print '</select>';
  706. }
  707. function getTimezone(){
  708. $regions = array(
  709. 'Africa' => DateTimeZone::AFRICA,
  710. 'America' => DateTimeZone::AMERICA,
  711. 'Antarctica' => DateTimeZone::ANTARCTICA,
  712. 'Arctic' => DateTimeZone::ARCTIC,
  713. 'Asia' => DateTimeZone::ASIA,
  714. 'Atlantic' => DateTimeZone::ATLANTIC,
  715. 'Australia' => DateTimeZone::AUSTRALIA,
  716. 'Europe' => DateTimeZone::EUROPE,
  717. 'Indian' => DateTimeZone::INDIAN,
  718. 'Pacific' => DateTimeZone::PACIFIC
  719. );
  720. $timezones = array();
  721. foreach ($regions as $name => $mask) {
  722. $zones = DateTimeZone::listIdentifiers($mask);
  723. foreach($zones as $timezone) {
  724. $time = new DateTime(NULL, new DateTimeZone($timezone));
  725. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  726. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  727. }
  728. }
  729. print '<select name="timezone" id="timezone" class="form-control material" required>';
  730. foreach($timezones as $region => $list) {
  731. print '<optgroup label="' . $region . '">' . "\n";
  732. foreach($list as $timezone => $name) {
  733. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  734. }
  735. print '</optgroup>' . "\n";
  736. }
  737. print '</select>';
  738. }
  739. function explosion($string, $position){
  740. $getWord = explode("|", $string);
  741. return $getWord[$position];
  742. }
  743. function getServerPath() {
  744. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  745. $protocol = "https://";
  746. } else {
  747. $protocol = "http://";
  748. }
  749. return $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']);
  750. }
  751. function get_browser_name() {
  752. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  753. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  754. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  755. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  756. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  757. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  758. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  759. return 'Other';
  760. }
  761. function getSickrageCalendarWanted($array){
  762. $array = json_decode($array, true);
  763. $gotCalendar = "";
  764. $i = 0;
  765. foreach($array['data']['missed'] AS $child) {
  766. $i++;
  767. $seriesName = $child['show_name'];
  768. $episodeID = $child['tvdbid'];
  769. $episodeAirDate = $child['airdate'];
  770. $episodeAirDateTime = explode(" ",$child['airs']);
  771. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  772. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  773. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  774. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  775. $downloaded = "0";
  776. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  777. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
  778. }
  779. foreach($array['data']['today'] AS $child) {
  780. $i++;
  781. $seriesName = $child['show_name'];
  782. $episodeID = $child['tvdbid'];
  783. $episodeAirDate = $child['airdate'];
  784. $episodeAirDateTime = explode(" ",$child['airs']);
  785. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  786. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  787. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  788. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  789. $downloaded = "0";
  790. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  791. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
  792. }
  793. foreach($array['data']['soon'] AS $child) {
  794. $i++;
  795. $seriesName = $child['show_name'];
  796. $episodeID = $child['tvdbid'];
  797. $episodeAirDate = $child['airdate'];
  798. $episodeAirDateTime = explode(" ",$child['airs']);
  799. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  800. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  801. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  802. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  803. $downloaded = "0";
  804. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  805. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
  806. }
  807. foreach($array['data']['later'] AS $child) {
  808. $i++;
  809. $seriesName = $child['show_name'];
  810. $episodeID = $child['tvdbid'];
  811. $episodeAirDate = $child['airdate'];
  812. $episodeAirDateTime = explode(" ",$child['airs']);
  813. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  814. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  815. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  816. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  817. $downloaded = "0";
  818. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  819. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
  820. }
  821. if ($i != 0){ return $gotCalendar; }
  822. }
  823. function getSickrageCalendarHistory($array){
  824. $array = json_decode($array, true);
  825. $gotCalendar = "";
  826. $i = 0;
  827. foreach($array['data'] AS $child) {
  828. $i++;
  829. $seriesName = $child['show_name'];
  830. $episodeID = $child['tvdbid'];
  831. $episodeAirDate = $child['date'];
  832. $downloaded = "green-bg";
  833. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
  834. }
  835. if ($i != 0){ return $gotCalendar; }
  836. }
  837. function getSonarrCalendar($array){
  838. $array = json_decode($array, true);
  839. $gotCalendar = "";
  840. $i = 0;
  841. foreach($array AS $child) {
  842. $i++;
  843. $seriesName = $child['series']['title'];
  844. $episodeID = $child['series']['tvdbId'];
  845. if(!isset($episodeID)){ $episodeID = ""; }
  846. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  847. if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
  848. $episodeAirDate = $child['airDateUtc'];
  849. $episodeAirDate = strtotime($episodeAirDate);
  850. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  851. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  852. $downloaded = $child['hasFile'];
  853. 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"; }
  854. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
  855. }
  856. if ($i != 0){ return $gotCalendar; }
  857. }
  858. function getRadarrCalendar($array){
  859. $array = json_decode($array, true);
  860. $gotCalendar = "";
  861. $i = 0;
  862. foreach($array AS $child) {
  863. if(isset($child['inCinemas'])){
  864. $i++;
  865. $movieName = $child['title'];
  866. $movieID = $child['tmdbId'];
  867. if(!isset($movieID)){ $movieID = ""; }
  868. if(isset($child['inCinemas']) && isset($child['physicalRelease'])){
  869. $physicalRelease = $child['physicalRelease'];
  870. $physicalRelease = strtotime($physicalRelease);
  871. $physicalRelease = date("Y-m-d", $physicalRelease);
  872. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  873. $downloaded = $child['hasFile'];
  874. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  875. }else{
  876. $physicalRelease = $child['inCinemas'];
  877. $downloaded = "light-blue-bg";
  878. }
  879. $gotCalendar .= "{ title: \"$movieName\", start: \"$physicalRelease\", className: \"$downloaded\", imagetype: \"film\", url: \"https://www.themoviedb.org/movie/$movieID\" }, \n";
  880. }
  881. }
  882. if ($i != 0){ return $gotCalendar; }
  883. }
  884. function nzbgetConnect($url, $port, $username, $password, $list){
  885. $urlCheck = stripos($url, "http");
  886. if ($urlCheck === false) {
  887. $url = "http://" . $url;
  888. }
  889. if($port !== ""){ $url = $url . ":" . $port; }
  890. $address = $url;
  891. $api = file_get_contents("$url/$username:$password/jsonrpc/$list");
  892. $api = json_decode($api, true);
  893. $i = 0;
  894. $gotNZB = "";
  895. foreach ($api['result'] AS $child) {
  896. $i++;
  897. //echo '<pre>' . var_export($child, true) . '</pre>';
  898. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  899. $downloadStatus = $child['Status'];
  900. $downloadCategory = $child['Category'];
  901. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  902. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  903. if($child['Health'] <= "750"){
  904. $downloadHealth = "danger";
  905. }elseif($child['Health'] <= "900"){
  906. $downloadHealth = "warning";
  907. }elseif($child['Health'] <= "1000"){
  908. $downloadHealth = "success";
  909. }
  910. $gotNZB .= '<tr>
  911. <td>'.$downloadName.'</td>
  912. <td>'.$downloadStatus.'</td>
  913. <td>'.$downloadCategory.'</td>
  914. <td>
  915. <div class="progress">
  916. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  917. <p class="text-center">'.round($downloadPercent).'%</p>
  918. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  919. </div>
  920. </div>
  921. </td>
  922. </tr>';
  923. }
  924. if($i > 0){ return $gotNZB; }
  925. if($i == 0){ echo '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>'; }
  926. }
  927. function sabnzbdConnect($url, $port, $key, $list){
  928. $urlCheck = stripos($url, "http");
  929. if ($urlCheck === false) {
  930. $url = "http://" . $url;
  931. }
  932. if($port !== ""){ $url = $url . ":" . $port; }
  933. $address = $url;
  934. $api = file_get_contents("$url/api?mode=$list&output=json&apikey=$key");
  935. $api = json_decode($api, true);
  936. $i = 0;
  937. $gotNZB = "";
  938. foreach ($api[$list]['slots'] AS $child) {
  939. $i++;
  940. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  941. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  942. $downloadStatus = $child['status'];
  943. $gotNZB .= '<tr>
  944. <td>'.$downloadName.'</td>
  945. <td>'.$downloadStatus.'</td>
  946. <td>'.$downloadCategory.'</td>
  947. <td>
  948. <div class="progress">
  949. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  950. <p class="text-center">'.round($downloadPercent).'%</p>
  951. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  952. </div>
  953. </div>
  954. </td>
  955. </tr>';
  956. }
  957. if($i > 0){ return $gotNZB; }
  958. if($i == 0){ echo '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>'; }
  959. }
  960. function getHeadphonesCalendar($url, $port, $key, $list){
  961. $urlCheck = stripos($url, "http");
  962. if ($urlCheck === false) {
  963. $url = "http://" . $url;
  964. }
  965. if($port !== ""){ $url = $url . ":" . $port; }
  966. $address = $url;
  967. $api = file_get_contents($address."/api?apikey=".$key."&cmd=$list");
  968. $api = json_decode($api, true);
  969. $i = 0;
  970. $gotCalendar = "";
  971. foreach($api AS $child) {
  972. if($child['Status'] == "Wanted"){
  973. $i++;
  974. $albumName = addslashes($child['AlbumTitle']);
  975. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  976. $albumDate = $child['ReleaseDate'];
  977. $albumID = $child['AlbumID'];
  978. $albumDate = strtotime($albumDate);
  979. $albumDate = date("Y-m-d", $albumDate);
  980. $albumStatus = $child['Status'];
  981. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  982. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  983. $gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
  984. }
  985. }
  986. if ($i != 0){ return $gotCalendar; }
  987. }
  988. ?>