functions.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. <?php
  2. function clean($strin) {
  3. $strout = null;
  4. for ($i = 0; $i < strlen($strin); $i++) {
  5. $ord = ord($strin[$i]);
  6. if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
  7. $strout .= "&amp;#{$ord};";
  8. }
  9. else {
  10. switch ($strin[$i]) {
  11. case '<':
  12. $strout .= '&lt;';
  13. break;
  14. case '>':
  15. $strout .= '&gt;';
  16. break;
  17. case '&':
  18. $strout .= '&amp;';
  19. break;
  20. case '"':
  21. $strout .= '&quot;';
  22. break;
  23. default:
  24. $strout .= $strin[$i];
  25. }
  26. }
  27. }
  28. return $strout;
  29. }
  30. function registration_callback($username, $email, $userdir){
  31. global $data;
  32. $data = array($username, $email, $userdir);
  33. }
  34. function printArray($arrayName){
  35. $messageCount = count($arrayName);
  36. $i = 0;
  37. foreach ( $arrayName as $item ) :
  38. $i++;
  39. if($i < $messageCount) :
  40. echo "<small class='text-uppercase'>" . $item . "</small> & ";
  41. elseif($i = $messageCount) :
  42. echo "<small class='text-uppercase'>" . $item . "</small>";
  43. endif;
  44. endforeach;
  45. }
  46. function write_ini_file($content, $path) {
  47. if (!$handle = fopen($path, 'w')) {
  48. return false;
  49. }
  50. $success = fwrite($handle, trim($content));
  51. fclose($handle);
  52. return $success;
  53. }
  54. function gotTimezone(){
  55. $regions = array(
  56. 'Africa' => DateTimeZone::AFRICA,
  57. 'America' => DateTimeZone::AMERICA,
  58. 'Antarctica' => DateTimeZone::ANTARCTICA,
  59. 'Arctic' => DateTimeZone::ARCTIC,
  60. 'Asia' => DateTimeZone::ASIA,
  61. 'Atlantic' => DateTimeZone::ATLANTIC,
  62. 'Australia' => DateTimeZone::AUSTRALIA,
  63. 'Europe' => DateTimeZone::EUROPE,
  64. 'Indian' => DateTimeZone::INDIAN,
  65. 'Pacific' => DateTimeZone::PACIFIC
  66. );
  67. $timezones = array();
  68. foreach ($regions as $name => $mask) {
  69. $zones = DateTimeZone::listIdentifiers($mask);
  70. foreach($zones as $timezone) {
  71. $time = new DateTime(NULL, new DateTimeZone($timezone));
  72. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  73. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  74. }
  75. }
  76. print '<select name="timezone" id="timezone" class="form-control material input-sm" required>';
  77. foreach($timezones as $region => $list) {
  78. print '<optgroup label="' . $region . '">' . "\n";
  79. foreach($list as $timezone => $name) {
  80. if($timezone == TIMEZONE) : $selected = " selected"; else : $selected = ""; endif;
  81. print '<option value="' . $timezone . '"' . $selected . '>' . $name . '</option>' . "\n";
  82. }
  83. print '</optgroup>' . "\n";
  84. }
  85. print '</select>';
  86. }
  87. function getTimezone(){
  88. $regions = array(
  89. 'Africa' => DateTimeZone::AFRICA,
  90. 'America' => DateTimeZone::AMERICA,
  91. 'Antarctica' => DateTimeZone::ANTARCTICA,
  92. 'Arctic' => DateTimeZone::ARCTIC,
  93. 'Asia' => DateTimeZone::ASIA,
  94. 'Atlantic' => DateTimeZone::ATLANTIC,
  95. 'Australia' => DateTimeZone::AUSTRALIA,
  96. 'Europe' => DateTimeZone::EUROPE,
  97. 'Indian' => DateTimeZone::INDIAN,
  98. 'Pacific' => DateTimeZone::PACIFIC
  99. );
  100. $timezones = array();
  101. foreach ($regions as $name => $mask) {
  102. $zones = DateTimeZone::listIdentifiers($mask);
  103. foreach($zones as $timezone) {
  104. $time = new DateTime(NULL, new DateTimeZone($timezone));
  105. $ampm = $time->format('H') > 12 ? ' ('. $time->format('g:i a'). ')' : '';
  106. $timezones[$name][$timezone] = substr($timezone, strlen($name) + 1) . ' - ' . $time->format('H:i') . $ampm;
  107. }
  108. }
  109. print '<select name="timezone" id="timezone" class="form-control material" required>';
  110. foreach($timezones as $region => $list) {
  111. print '<optgroup label="' . $region . '">' . "\n";
  112. foreach($list as $timezone => $name) {
  113. print '<option value="' . $timezone . '">' . $name . '</option>' . "\n";
  114. }
  115. print '</optgroup>' . "\n";
  116. }
  117. print '</select>';
  118. }
  119. function explosion($string, $position){
  120. $getWord = explode("|", $string);
  121. return $getWord[$position];
  122. }
  123. function getServerPath() {
  124. if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
  125. $protocol = "https://";
  126. } else {
  127. $protocol = "http://";
  128. }
  129. return $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']);
  130. }
  131. function get_browser_name() {
  132. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  133. if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';
  134. elseif (strpos($user_agent, 'Edge')) return 'Edge';
  135. elseif (strpos($user_agent, 'Chrome')) return 'Chrome';
  136. elseif (strpos($user_agent, 'Safari')) return 'Safari';
  137. elseif (strpos($user_agent, 'Firefox')) return 'Firefox';
  138. elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';
  139. return 'Other';
  140. }
  141. function getPlexRecent($url, $port, $type, $token, $size, $header){
  142. $urlCheck = stripos($url, "http");
  143. if ($urlCheck === false) {
  144. $url = "http://" . $url;
  145. }
  146. if($port !== ""){ $url = $url . ":" . $port; }
  147. $address = $url;
  148. $api = file_get_contents($address."/library/recentlyAdded?X-Plex-Token=".$token);
  149. $api = simplexml_load_string($api);
  150. $getServer = file_get_contents($address."/servers?X-Plex-Token=".$token);
  151. $getServer = simplexml_load_string($getServer);
  152. foreach($getServer AS $child) {
  153. $gotServer = $child['machineIdentifier'];
  154. }
  155. $i = 0;
  156. $gotPlex = '<div class="col-lg-'.$size.'"><h5 class="text-center">'.$header.'</h5><div id="carousel-'.$type.'" class="carousel slide box-shadow white-bg" data-ride="carousel"><div class="carousel-inner" role="listbox">';
  157. foreach($api AS $child) {
  158. if($child['type'] == $type){
  159. $i++;
  160. if($i == 1){ $active = "active"; }else{ $active = "";}
  161. $thumb = $child['thumb'];
  162. $plexLink = "https://app.plex.tv/web/app#!/server/$gotServer/details?key=/library/metadata/".$child['ratingKey'];
  163. if($type == "movie"){
  164. $title = $child['title'];
  165. $summary = $child['summary'];
  166. $height = "150";
  167. $width = "100";
  168. }elseif($type == "season"){
  169. $title = $child['parentTitle'];
  170. $summary = $child['parentSummary'];
  171. $height = "150";
  172. $width = "100";
  173. }elseif($type == "album"){
  174. $title = $child['parentTitle'];
  175. $summary = $child['title'];
  176. $height = "150";
  177. $width = "150";
  178. }
  179. $gotPlex .= '<div class="item '.$active.'"> <a href="'.$plexLink.'" target="_blank"> <img alt="'.$title.'" class="carousel-image '.$type.'" src="image.php?img='.$thumb.'&height='.$height.'&width='.$width.'"> </a> <div class="carousel-caption '.$type.'"> <h4>'.$title.'</h4> <small> <em>'.$summary.'</em> </small> </div> </div>';
  180. $plexLink = "";
  181. }
  182. }
  183. $gotPlex .= '</div>';
  184. if ($i > 1){
  185. $gotPlex .= '<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><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>';
  186. }
  187. $gotPlex .= '</div></div>';
  188. $noPlex = '<div class="col-lg-'.$size.'"><h5 class="text-center">'.$header.'</h5>';
  189. $noPlex .= '<div id="carousel-'.$type.'" class="carousel slide box-shadow white-bg" data-ride="carousel">';
  190. $noPlex .= '<div class="carousel-inner" role="listbox">';
  191. $noPlex .= '<div class="item active">';
  192. $noPlex .= "<img alt='nada' class='carousel-image movie' src='images/nadaplaying.jpg'>";
  193. $noPlex .= '<div class="carousel-caption"> <h4>Nothing New</h4> <small> <em>Get to Adding!</em> </small></div></div></div></div></div>';
  194. if ($i != 0){ return $gotPlex; }
  195. if ($i == 0){ return $noPlex; }
  196. }
  197. function getPlexStreams($url, $port, $token, $size, $header){
  198. $urlCheck = stripos($url, "http");
  199. if ($urlCheck === false) {
  200. $url = "http://" . $url;
  201. }
  202. if($port !== ""){ $url = $url . ":" . $port; }
  203. $address = $url;
  204. $api = file_get_contents($address."/status/sessions?X-Plex-Token=".$token);
  205. $api = simplexml_load_string($api);
  206. $getServer = file_get_contents($address."/servers?X-Plex-Token=".$token);
  207. $getServer = simplexml_load_string($getServer);
  208. foreach($getServer AS $child) {
  209. $gotServer = $child['machineIdentifier'];
  210. }
  211. $i = 0;
  212. $gotPlex = '<div class="col-lg-'.$size.'"><h5 class="text-center">'.$header.'</h5>';
  213. $gotPlex .= '<div id="carousel-streams" class="carousel slide box-shadow white-bg" data-ride="carousel">';
  214. $gotPlex .= '<div class="carousel-inner" role="listbox">';
  215. foreach($api AS $child) {
  216. $type = $child['type'];
  217. $plexLink = "https://app.plex.tv/web/app#!/server/$gotServer/details?key=/library/metadata/".$child['ratingKey'];
  218. $i++;
  219. if($i == 1){ $active = "active"; }else{ $active = "";}
  220. if($type == "movie"){
  221. $title = $child['title'];
  222. $summary = htmlentities($child['summary'], ENT_QUOTES);
  223. $thumb = $child['thumb'];
  224. $image = "movie";
  225. $height = "150";
  226. $width = "100";
  227. }elseif($type == "episode"){
  228. $title = $child['grandparentTitle'];
  229. $summary = htmlentities($child['summary'], ENT_QUOTES);
  230. $thumb = $child['grandparentThumb'];
  231. $image = "season";
  232. $height = "150";
  233. $width = "100";
  234. }elseif($type == "track"){
  235. $title = $child['grandparentTitle'] . " - " . $child['parentTitle'];
  236. $summary = htmlentities($child['title'], ENT_QUOTES);
  237. $thumb = $child['thumb'];
  238. $image = "album";
  239. $height = "150";
  240. $width = "150";
  241. }elseif($type == "clip"){
  242. $title = $child['title'].' - Trailer';
  243. $summary = ($child['summary'] != "" ? $child['summary'] : "<i>No summary loaded.</i>");
  244. $thumb = ($child['thumb'] != "" ? $child['thumb'] : 'images/nadaplaying.jpg');
  245. $image = "movie";
  246. $height = "150";
  247. $width = "100";
  248. }
  249. $gotPlex .= '<div class="item '.$active.'">';
  250. $gotPlex .= "<a href='$plexLink' target='_blank'><img alt='$title' class='carousel-image $image' src='image.php?img=$thumb&height=$height&width=$width'></a>";
  251. $gotPlex .= '<div class="carousel-caption '. $image . '""><h4>'.$title.'</h4><small><em>'.$summary.'</em></small></div></div>';
  252. $plexLink = "";
  253. }
  254. $gotPlex .= '</div>';
  255. if ($i > 1){
  256. $gotPlex .= '<a class="left carousel-control streams" href="#carousel-streams" role="button" data-slide="prev"><span class="fa fa-chevron-left" aria-hidden="true"></span><span class="sr-only">Previous</span></a><a class="right carousel-control streams" href="#carousel-streams" role="button" data-slide="next"><span class="fa fa-chevron-right" aria-hidden="true"></span><span class="sr-only">Next</span></a>';
  257. }
  258. $gotPlex .= '</div></div>';
  259. $noPlex = '<div class="col-lg-'.$size.'"><h5 class="text-center">'.$header.'</h5>';
  260. $noPlex .= '<div id="carousel-streams" class="carousel slide box-shadow white-bg" data-ride="carousel">';
  261. $noPlex .= '<div class="carousel-inner" role="listbox">';
  262. $noPlex .= '<div class="item active">';
  263. $noPlex .= "<img alt='nada' class='carousel-image movie' src='images/nadaplaying.jpg'>";
  264. $noPlex .= '<div class="carousel-caption"><h4>Nothing Playing</h4><small><em>Get to Streaming!</em></small></div></div></div></div></div>';
  265. if ($i != 0){ return $gotPlex; }
  266. if ($i == 0){ return $noPlex; }
  267. }
  268. function getSickrageCalendarWanted($array){
  269. $array = json_decode($array, true);
  270. $gotCalendar = "";
  271. $i = 0;
  272. foreach($array['data']['missed'] AS $child) {
  273. $i++;
  274. $seriesName = $child['show_name'];
  275. $episodeAirDate = $child['airdate'];
  276. $episodeAirDateTime = explode(" ",$child['airs']);
  277. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  278. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  279. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  280. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  281. $downloaded = "0";
  282. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  283. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\" }, \n";
  284. }
  285. foreach($array['data']['today'] AS $child) {
  286. $i++;
  287. $seriesName = $child['show_name'];
  288. $episodeAirDate = $child['airdate'];
  289. $episodeAirDateTime = explode(" ",$child['airs']);
  290. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  291. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  292. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  293. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  294. $downloaded = "0";
  295. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  296. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\" }, \n";
  297. }
  298. foreach($array['data']['soon'] AS $child) {
  299. $i++;
  300. $seriesName = $child['show_name'];
  301. $episodeAirDate = $child['airdate'];
  302. $episodeAirDateTime = explode(" ",$child['airs']);
  303. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  304. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  305. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  306. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  307. $downloaded = "0";
  308. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  309. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\" }, \n";
  310. }
  311. foreach($array['data']['later'] AS $child) {
  312. $i++;
  313. $seriesName = $child['show_name'];
  314. $episodeAirDate = $child['airdate'];
  315. $episodeAirDateTime = explode(" ",$child['airs']);
  316. $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
  317. $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
  318. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  319. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  320. $downloaded = "0";
  321. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  322. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\" }, \n";
  323. }
  324. if ($i != 0){ return $gotCalendar; }
  325. }
  326. function getSickrageCalendarHistory($array){
  327. $array = json_decode($array, true);
  328. $gotCalendar = "";
  329. $i = 0;
  330. foreach($array['data'] AS $child) {
  331. $i++;
  332. $seriesName = $child['show_name'];
  333. $episodeAirDate = $child['date'];
  334. $downloaded = "green-bg";
  335. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\" }, \n";
  336. }
  337. if ($i != 0){ return $gotCalendar; }
  338. }
  339. function getSonarrCalendar($array){
  340. $array = json_decode($array, true);
  341. $gotCalendar = "";
  342. $i = 0;
  343. foreach($array AS $child) {
  344. $i++;
  345. $seriesName = htmlentities($child['series']['title'], ENT_QUOTES);
  346. $runtime = $child['series']['runtime'];
  347. $episodeName = htmlentities($child['title'], ENT_QUOTES);
  348. $episodeAirDate = $child['airDateUtc'];
  349. $episodeAirDate = strtotime($episodeAirDate);
  350. $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
  351. if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
  352. $downloaded = $child['hasFile'];
  353. if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
  354. $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\" }, \n";
  355. }
  356. if ($i != 0){ return $gotCalendar; }
  357. }
  358. function getRadarrCalendar($array){
  359. $array = json_decode($array, true);
  360. $gotCalendar = "";
  361. $i = 0;
  362. foreach($array AS $child) {
  363. if(isset($child['physicalRelease'])){
  364. $i++;
  365. $movieName = htmlentities($child['title'], ENT_QUOTES);
  366. $runtime = $child['runtime'];
  367. $physicalRelease = $child['physicalRelease'];
  368. $physicalRelease = strtotime($physicalRelease);
  369. $physicalRelease = date("Y-m-d", $physicalRelease);
  370. if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  371. $downloaded = $child['hasFile'];
  372. if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
  373. $gotCalendar .= "{ title: \"$movieName\", start: \"$physicalRelease\", className: \"$downloaded\", imagetype: \"film\" }, \n";
  374. }
  375. }
  376. if ($i != 0){ return $gotCalendar; }
  377. }
  378. function nzbgetConnect($url, $port, $username, $password, $list){
  379. $urlCheck = stripos($url, "http");
  380. if ($urlCheck === false) {
  381. $url = "http://" . $url;
  382. }
  383. if($port !== ""){ $url = $url . ":" . $port; }
  384. $address = $url;
  385. $api = file_get_contents("$url/$username:$password/jsonrpc/$list");
  386. $api = json_decode($api, true);
  387. $i = 0;
  388. $gotNZB = "";
  389. foreach ($api['result'] AS $child) {
  390. $i++;
  391. //echo '<pre>' . var_export($child, true) . '</pre>';
  392. $downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
  393. $downloadStatus = $child['Status'];
  394. $downloadCategory = $child['Category'];
  395. if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
  396. if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
  397. if($child['Health'] <= "750"){
  398. $downloadHealth = "danger";
  399. }elseif($child['Health'] <= "900"){
  400. $downloadHealth = "warning";
  401. }elseif($child['Health'] <= "1000"){
  402. $downloadHealth = "success";
  403. }
  404. $gotNZB .= '<tr>
  405. <td>'.$downloadName.'</td>
  406. <td>'.$downloadStatus.'</td>
  407. <td>'.$downloadCategory.'</td>
  408. <td>
  409. <div class="progress">
  410. <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  411. <p class="text-center">'.round($downloadPercent).'%</p>
  412. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  413. </div>
  414. </div>
  415. </td>
  416. </tr>';
  417. }
  418. if($i > 0){ return $gotNZB; }
  419. if($i == 0){ echo '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>'; }
  420. }
  421. function sabnzbdConnect($url, $port, $key, $list){
  422. $urlCheck = stripos($url, "http");
  423. if ($urlCheck === false) {
  424. $url = "http://" . $url;
  425. }
  426. if($port !== ""){ $url = $url . ":" . $port; }
  427. $address = $url;
  428. $api = file_get_contents("$url/api?mode=$list&output=json&apikey=$key");
  429. $api = json_decode($api, true);
  430. $i = 0;
  431. $gotNZB = "";
  432. foreach ($api[$list]['slots'] AS $child) {
  433. $i++;
  434. if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
  435. if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
  436. $downloadStatus = $child['status'];
  437. $gotNZB .= '<tr>
  438. <td>'.$downloadName.'</td>
  439. <td>'.$downloadStatus.'</td>
  440. <td>'.$downloadCategory.'</td>
  441. <td>
  442. <div class="progress">
  443. <div class="progress-bar progress-bar-success '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
  444. <p class="text-center">'.round($downloadPercent).'%</p>
  445. <span class="sr-only">'.$downloadPercent.'% Complete</span>
  446. </div>
  447. </div>
  448. </td>
  449. </tr>';
  450. }
  451. if($i > 0){ return $gotNZB; }
  452. if($i == 0){ echo '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>'; }
  453. }
  454. function getHeadphonesCalendar($url, $port, $key, $list){
  455. $urlCheck = stripos($url, "http");
  456. if ($urlCheck === false) {
  457. $url = "http://" . $url;
  458. }
  459. if($port !== ""){ $url = $url . ":" . $port; }
  460. $address = $url;
  461. $api = file_get_contents($address."/api?apikey=".$key."&cmd=$list");
  462. $api = json_decode($api, true);
  463. $i = 0;
  464. $gotCalendar = "";
  465. foreach($api AS $child) {
  466. if($child['Status'] != "Skipped"){
  467. $i++;
  468. $albumName = addslashes($child['AlbumTitle']);
  469. $albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
  470. $albumDate = $child['ReleaseDate'];
  471. $albumDate = strtotime($albumDate);
  472. $albumDate = date("Y-m-d", $albumDate);
  473. $albumStatus = $child['Status'];
  474. if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
  475. if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
  476. $gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\" }, \n";
  477. }
  478. }
  479. if ($i != 0){ return $gotCalendar; }
  480. }
  481. ?>