functions.php 40 KB

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