homepage.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <?php
  2. $data = false;
  3. ini_set("display_errors", 1);
  4. ini_set("error_reporting", E_ALL | E_STRICT);
  5. require_once("user.php");
  6. require_once("translate.php");
  7. require_once("functions.php");
  8. use Kryptonit3\Sonarr\Sonarr;
  9. use Kryptonit3\SickRage\SickRage;
  10. $sonarr = new Sonarr(SONARRURL, SONARRKEY);
  11. $radarr = new Sonarr(RADARRURL, RADARRKEY);
  12. $sickrage = new SickRage(SICKRAGEURL, SICKRAGEKEY);
  13. $USER = new User("registration_callback");
  14. $dbfile = DATABASE_LOCATION . constant('User::DATABASE_NAME') . ".db";
  15. $file_db = new PDO("sqlite:" . $dbfile);
  16. $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  17. $dbOptions = $file_db->query('SELECT name FROM sqlite_master WHERE type="table" AND name="options"');
  18. $hasOptions = "No";
  19. foreach($dbOptions as $row) :
  20. if (in_array("options", $row)) :
  21. $hasOptions = "Yes";
  22. endif;
  23. endforeach;
  24. if($hasOptions == "No") :
  25. $title = "Organizr";
  26. $topbar = "#333333";
  27. $topbartext = "#66D9EF";
  28. $bottombar = "#333333";
  29. $sidebar = "#393939";
  30. $hoverbg = "#AD80FD";
  31. $activetabBG = "#F92671";
  32. $activetabicon = "#FFFFFF";
  33. $activetabtext = "#FFFFFF";
  34. $inactiveicon = "#66D9EF";
  35. $inactivetext = "#66D9EF";
  36. $loading = "#66D9EF";
  37. $hovertext = "#000000";
  38. endif;
  39. if($hasOptions == "Yes") :
  40. $resulto = $file_db->query('SELECT * FROM options');
  41. foreach($resulto as $row) :
  42. $title = isset($row['title']) ? $row['title'] : "Organizr";
  43. $topbartext = isset($row['topbartext']) ? $row['topbartext'] : "#66D9EF";
  44. $topbar = isset($row['topbar']) ? $row['topbar'] : "#333333";
  45. $bottombar = isset($row['bottombar']) ? $row['bottombar'] : "#333333";
  46. $sidebar = isset($row['sidebar']) ? $row['sidebar'] : "#393939";
  47. $hoverbg = isset($row['hoverbg']) ? $row['hoverbg'] : "#AD80FD";
  48. $activetabBG = isset($row['activetabBG']) ? $row['activetabBG'] : "#F92671";
  49. $activetabicon = isset($row['activetabicon']) ? $row['activetabicon'] : "#FFFFFF";
  50. $activetabtext = isset($row['activetabtext']) ? $row['activetabtext'] : "#FFFFFF";
  51. $inactiveicon = isset($row['inactiveicon']) ? $row['inactiveicon'] : "#66D9EF";
  52. $inactivetext = isset($row['inactivetext']) ? $row['inactivetext'] : "#66D9EF";
  53. $loading = isset($row['loading']) ? $row['loading'] : "#66D9EF";
  54. $hovertext = isset($row['hovertext']) ? $row['hovertext'] : "#000000";
  55. endforeach;
  56. endif;
  57. $startDate = date('Y-m-d',strtotime("-".CALENDARSTARTDAY." days"));
  58. $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
  59. ?>
  60. <!DOCTYPE html>
  61. <html lang="en" class="no-js">
  62. <head>
  63. <meta charset="UTF-8">
  64. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  65. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  66. <meta name="msapplication-tap-highlight" content="no" />
  67. <title><?=$title;?> Homepage</title>
  68. <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
  69. <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
  70. <link rel="stylesheet" href="bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css">
  71. <script src="js/menu/modernizr.custom.js"></script>
  72. <link rel="stylesheet" href="bower_components/animate.css/animate.min.css">
  73. <link rel="stylesheet" href="bower_components/fullcalendar/dist/fullcalendar.css">
  74. <link rel="stylesheet" href="css/style.css">
  75. <!--[if lt IE 9]>
  76. <script src="bower_components/html5shiv/dist/html5shiv.min.js"></script>
  77. <script src="bower_components/respondJs/dest/respond.min.js"></script>
  78. <![endif]-->
  79. <style>
  80. sort {
  81. display: none;
  82. }
  83. table.fc-list-table {
  84. table-layout: auto;
  85. }.tabbable{
  86. margin-bottom: 0;
  87. }.fc-day-grid-event .fc-content {
  88. white-space: normal;
  89. }.fc-list-item {
  90. table-layout: auto;
  91. position: inherit;
  92. margin: 10px;
  93. border-radius: 4px;
  94. padding: 0 5px 0 5px;
  95. color: #fff !important;
  96. }.fc-calendar .fc-toolbar {
  97. background: <?=$topbar;?>;
  98. color: <?=$topbartext;?>;
  99. border-radius: 5px 5px 0 0;
  100. padding: 15px;
  101. }.fc-calendar .fc-toolbar .fc-right {
  102. bottom: 0px;
  103. right: 20px;
  104. }.fc-calendar .fc-toolbar .fc-right button {
  105. color: <?=$topbartext;?>;
  106. }.fc-calendar .fc-toolbar .fc-prev-button, .fc-calendar .fc-toolbar .fc-next-button {
  107. color: <?=$topbartext;?>;
  108. }.carousel-image{
  109. width: 100px !important;
  110. height: 150px !important;
  111. border-radius: 3px 0 0 3px;
  112. }.carousel-image.album{
  113. width: 150px !important;
  114. height: 150px !important;
  115. border-radius: 3px 0 0 3px;
  116. }.carousel-control.album {
  117. top: 5px !important;
  118. width: 4% !important;
  119. }.carousel-control {
  120. top: 5px !important;
  121. width: 4% !important;
  122. }.carousel-caption.album {
  123. position: absolute;
  124. right: 4%;
  125. top: 0px;
  126. left: 160px;
  127. z-index: 10;
  128. bottom: 0px;
  129. padding-top: 0px;
  130. color: #fff;
  131. text-align: left;
  132. }.carousel-caption {
  133. position: absolute;
  134. right: 4%;
  135. top: 0px;
  136. left: 110px;
  137. z-index: 10;
  138. bottom: 0px;
  139. padding-top: 0px;
  140. color: #fff;
  141. text-align: left;
  142. padding-bottom: 2px !important;
  143. overflow: hidden !important;
  144. }<?php if(CUSTOMCSS == "true") :
  145. $template_file = "custom.css";
  146. $file_handle = fopen($template_file, "rb");
  147. echo fread($file_handle, filesize($template_file));
  148. fclose($file_handle);
  149. echo "\n";
  150. endif; ?>
  151. </style>
  152. </head>
  153. <body class="scroller-body" style="padding: 0px;">
  154. <div class="main-wrapper" style="position: initial;">
  155. <div id="content" class="container-fluid">
  156. <!-- <button id="numBnt">Numerical</button> -->
  157. <br/>
  158. <?php if(($USER->authenticated && $USER->role == "admin") && (NZBGETURL != "" || SABNZBDURL != "" )) : ?>
  159. <div id="downloadClientRow" class="row">
  160. <sort>2</sort>
  161. <div class="col-xs-12 col-md-12">
  162. <div class="content-box">
  163. <div class="tabbable panel with-nav-tabs panel-default">
  164. <div class="panel-heading">
  165. <div class="content-tools i-block pull-right">
  166. <a id="getDownloader" class="repeat-btn">
  167. <i class="fa fa-repeat"></i>
  168. </a>
  169. <a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
  170. <i class="fa fa-chevron-down"></i>
  171. </a>
  172. <ul id="downloaderSeconds" class="dropdown-menu" style="top: 32px !important">
  173. <li data-value="5000"><a>Refresh every 5 seconds</a></li>
  174. <li data-value="10000"><a>Refresh every 10 seconds</a></li>
  175. <li data-value="30000"><a>Refresh every 30 seconds</a></li>
  176. <li data-value="60000"><a>Refresh every 60 seconds</a></li>
  177. </ul>
  178. </div>
  179. <h3 class="pull-left"><?php if(NZBGETURL != ""){ echo "NZBGet "; } if(SABNZBDURL != ""){ echo "SABnzbd "; } ?></h3>
  180. <ul class="nav nav-tabs pull-right">
  181. <li class="active"><a href="#downloadQueue" data-toggle="tab" aria-expanded="true"><?php echo $language->translate("QUEUE");?></a></li>
  182. <li class=""><a href="#downloadHistory" data-toggle="tab" aria-expanded="false"><?php echo $language->translate("HISTORY");?></a></li>
  183. </ul>
  184. <div class="clearfix"></div>
  185. </div>
  186. <div class="panel-body">
  187. <div class="tab-content">
  188. <div class="tab-pane fade active in" id="downloadQueue">
  189. <div class="table-responsive" style="max-height: 300px">
  190. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  191. <thead>
  192. <tr>
  193. <th><?php echo $language->translate("FILE");?></th>
  194. <th><?php echo $language->translate("STATUS");?></th>
  195. <th><?php echo $language->translate("CATEGORY");?></th>
  196. <th><?php echo $language->translate("PROGRESS");?></th>
  197. </tr>
  198. </thead>
  199. <tbody id="downloaderQueue">
  200. </tbody>
  201. </table>
  202. </div>
  203. </div>
  204. <div class="tab-pane fade" id="downloadHistory">
  205. <div class="table-responsive" style="max-height: 300px">
  206. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  207. <thead>
  208. <tr>
  209. <th>File</th>
  210. <th>Status</th>
  211. <th>Category</th>
  212. <th>Progress</th>
  213. </tr>
  214. </thead>
  215. <tbody id="downloaderHistory">
  216. </tbody>
  217. </table>
  218. </div>
  219. </div>
  220. </div>
  221. </div>
  222. </div>
  223. </div>
  224. </div>
  225. </div>
  226. <?php endif; ?>
  227. <div id="plexRow" class="row">
  228. <sort>3</sort>
  229. <?php
  230. $plexSize = 0;
  231. if(PLEXRECENTMOVIE == "true"){ $plexSize++; }
  232. if(PLEXRECENTTV == "true"){ $plexSize++; }
  233. if(PLEXRECENTMUSIC == "true"){ $plexSize++; }
  234. if(PLEXPLAYINGNOW == "true"){ $plexSize++; }
  235. if($plexSize >= 4){ $plexSize = 3; }elseif($plexSize == 3){ $plexSize = 4; }elseif($plexSize == 2){ $plexSize = 6; }elseif($plexSize == 1){ $plexSize = 12; }
  236. if(PLEXRECENTMOVIE == "true"){ echo getPlexRecent(PLEXURL, PLEXPORT, "movie", PLEXTOKEN, $plexSize, $language->translate("MOVIES")); }
  237. if(PLEXRECENTTV == "true"){ echo getPlexRecent(PLEXURL, PLEXPORT, "season", PLEXTOKEN, $plexSize, $language->translate("TV_SHOWS")); }
  238. if(PLEXRECENTMUSIC == "true"){ echo getPlexRecent(PLEXURL, PLEXPORT, "album", PLEXTOKEN, $plexSize, $language->translate("MUSIC")); }
  239. if(PLEXPLAYINGNOW == "true"){ echo getPlexStreams(PLEXURL, PLEXPORT, PLEXTOKEN, $plexSize, $language->translate("PLAYING_NOW_ON_PLEX")); }
  240. ?>
  241. </div>
  242. <?php if(SONARRURL != "" || RADARRURL != "" || HEADPHONESURL != "" || SICKRAGEURL != "") : ?>
  243. <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
  244. <sort>1</sort>
  245. <div class="col-lg-4 content-form form-inline">
  246. <div class="form-group">
  247. <select class="form-control" id="imagetype_selector" style="width: auto !important; display: inline-block">
  248. <option value="all">View All</option>
  249. <?php if(RADARRURL != ""){ echo '<option value="film">Movies</option>'; }?>
  250. <?php if(SONARRURL != "" || SICKRAGEURL != ""){ echo '<option value="tv">TV Shows</option>'; }?>
  251. <?php if(HEADPHONESURL != ""){ echo '<option value="music">Music</option>'; }?>
  252. </select>
  253. <span class="label label-primary well-sm">Available</span>
  254. <span class="label label-danger well-sm">Unavailable</span>
  255. <span class="label indigo-bg well-sm">Unreleased</span>
  256. <span class="label light-blue-bg well-sm">Premier</span>
  257. </div>
  258. </div>
  259. </div>
  260. <div id="calendarRow" class="row">
  261. <sort>1</sort>
  262. <div class="col-lg-12">
  263. <div id="calendar" class="fc-calendar box-shadow fc fc-ltr fc-unthemed"></div>
  264. </div>
  265. </div>
  266. <?php endif; ?>
  267. </div>
  268. </div>
  269. <!--Scripts-->
  270. <script src="bower_components/jquery/dist/jquery.min.js"></script>
  271. <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  272. <script src="bower_components/moment/min/moment.min.js"></script>
  273. <script src="bower_components/jquery.nicescroll/jquery.nicescroll.min.js"></script>
  274. <script src="bower_components/slimScroll/jquery.slimscroll.min.js"></script>
  275. <script src="bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.js"></script>
  276. <script src="bower_components/jquery.nicescroll/jquery.nicescroll.min.js"></script>
  277. <script src="bower_components/cta/dist/cta.min.js"></script>
  278. <script src="bower_components/fullcalendar/dist/fullcalendar.js"></script>
  279. <script src="js/jqueri_ui_custom/jquery-ui.min.js"></script>
  280. <script src="js/jquery.mousewheel.min.js" type="text/javascript"></script>
  281. <script>
  282. $( document ).ready(function() {
  283. $('.repeat-btn').click(function(){
  284. var refreshBox = $(this).closest('div.content-box');
  285. $("<div class='refresh-preloader'><div class='la-timer la-dark'><div></div></div></div>").appendTo(refreshBox).fadeIn(300);
  286. setTimeout(function(){
  287. var refreshPreloader = refreshBox.find('.refresh-preloader'),
  288. deletedRefreshBox = refreshPreloader.fadeOut(300, function(){
  289. refreshPreloader.remove();
  290. });
  291. },1500);
  292. });
  293. $("body").niceScroll({
  294. railpadding: {top:0,right:0,left:0,bottom:0},
  295. scrollspeed: 30,
  296. mousescrollstep: 60
  297. });
  298. $(".table-responsive").niceScroll({
  299. railpadding: {top:0,right:0,left:0,bottom:0},
  300. scrollspeed: 30,
  301. mousescrollstep: 60
  302. });
  303. /*$(".carousel-caption").niceScroll({
  304. railpadding: {top:0,right:0,left:0,bottom:0},
  305. scrollspeed: 30,
  306. mousescrollstep: 60
  307. });*/
  308. // check if browser support HTML5 local storage
  309. function localStorageSupport() {
  310. return (('localStorage' in window) && window['localStorage'] !== null)
  311. }
  312. <?php if(($USER->authenticated && $USER->role == "admin") && (NZBGETURL != "" || SABNZBDURL != "")){ ?>
  313. var downloaderSeconds = localStorage.getItem("downloaderSeconds");
  314. var myInterval = undefined;
  315. $("ul").find("[data-value='" + downloaderSeconds + "']").addClass("active");
  316. if( downloaderSeconds === null ) {
  317. localStorage.setItem("downloaderSeconds",'60000');
  318. var downloaderSeconds = "60000";
  319. }
  320. $('#downloaderSeconds li').click(function() {
  321. $('#downloaderSeconds li').removeClass("active");
  322. $(this).addClass("active");
  323. var newDownloaderSeconds = $(this).attr('data-value');
  324. console.log('New Time is ' + newDownloaderSeconds + ' Old Time was ' + downloaderSeconds);
  325. if (localStorageSupport) {
  326. localStorage.setItem("downloaderSeconds",newDownloaderSeconds);
  327. }
  328. if(typeof myInterval != 'undefined'){ clearInterval(myInterval); }
  329. refreshDownloader(newDownloaderSeconds);
  330. });
  331. <?php } ?>
  332. <?php if(($USER->authenticated && $USER->role == "admin") && NZBGETURL != ""){ ?>
  333. $("#downloaderHistory").load("downloader.php?downloader=nzbget&list=history");
  334. $("#downloaderQueue").load("downloader.php?downloader=nzbget&list=listgroups");
  335. refreshDownloader = function(secs){
  336. myInterval = setInterval(function(){
  337. $("#downloaderHistory").load("downloader.php?downloader=nzbget&list=history");
  338. $("#downloaderQueue").load("downloader.php?downloader=nzbget&list=listgroups");
  339. }, secs);
  340. }
  341. refreshDownloader(downloaderSeconds);
  342. $("#getDownloader").click(function(){
  343. $("#downloaderHistory").load("downloader.php?downloader=nzbget&list=history");
  344. $("#downloaderQueue").load("downloader.php?downloader=nzbget&list=listgroups");
  345. console.log('completed');
  346. });
  347. <?php } ?>
  348. <?php if(($USER->authenticated && $USER->role == "admin") && SABNZBDURL != ""){ ?>
  349. $("#downloaderHistory").load("downloader.php?downloader=sabnzbd&list=history");
  350. $("#downloaderQueue").load("downloader.php?downloader=sabnzbd&list=queue");
  351. refreshDownloader = function(secs){
  352. myInterval = setInterval(function(){
  353. $("#downloaderHistory").load("downloader.php?downloader=sabnzbd&list=history");
  354. $("#downloaderQueue").load("downloader.php?downloader=sabnzbd&list=queue");
  355. }, secs);
  356. }
  357. refreshDownloader(downloaderSeconds);
  358. $("#getDownloader").click(function(){
  359. $("#downloaderHistory").load("downloader.php?downloader=sabnzbd&list=history");
  360. $("#downloaderQueue").load("downloader.php?downloader=sabnzbd&list=queue");
  361. console.log('completed');
  362. });
  363. <?php } ?>
  364. });
  365. </script>
  366. <?php if(SONARRURL != "" || RADARRURL != "" || HEADPHONESURL != "" || SICKRAGEURL != "") : ?>
  367. <script>
  368. $(function () {
  369. var date = new Date();
  370. var d = date.getDate();
  371. var m = date.getMonth();
  372. var y = date.getFullYear();
  373. $('#calendar').fullCalendar({
  374. eventLimit: false,
  375. firstDay: <?php echo CALENDARSTART;?>,
  376. height: "auto",
  377. defaultView: '<?php echo CALENDARVIEW;?>',
  378. header: {
  379. left: 'prev,next,',
  380. center: 'title',
  381. right: 'today, month, basicDay,basicWeek,'
  382. },
  383. views: {
  384. basicDay: { buttonText: '<?php echo $language->translate("DAY");?>', eventLimit: false },
  385. basicWeek: { buttonText: '<?php echo $language->translate("WEEK");?>', eventLimit: false },
  386. month: { buttonText: '<?php echo $language->translate("MONTH");?>', eventLimit: false },
  387. today: { buttonText: '<?php echo $language->translate("TODAY");?>' },
  388. },
  389. events: [
  390. <?php if(SICKRAGEURL != ""){ echo getSickrageCalendarWanted($sickrage->future()); echo getSickrageCalendarHistory($sickrage->history("100","downloaded")); } ?>
  391. <?php if(SONARRURL != ""){ echo getSonarrCalendar($sonarr->getCalendar($startDate, $endDate)); } ?>
  392. <?php if(RADARRURL != ""){ echo getRadarrCalendar($radarr->getCalendar($startDate, $endDate)); } ?>
  393. <?php if(HEADPHONESURL != ""){ echo getHeadphonesCalendar(HEADPHONESURL, HEADPHONESPORT, HEADPHONESKEY, "getHistory"); echo getHeadphonesCalendar(HEADPHONESURL, HEADPHONESPORT, HEADPHONESKEY, "getWanted"); } ?>
  394. ],
  395. eventRender: function eventRender( event, element, view ) {
  396. return ['all', event.imagetype].indexOf($('#imagetype_selector').val()) >= 0
  397. },
  398. editable: false,
  399. droppable: false,
  400. });
  401. });
  402. $('#imagetype_selector').on('change',function(){
  403. $('#calendar').fullCalendar('rerenderEvents');
  404. })
  405. var $divs = $("div.row");
  406. $('#numBnt').on('click', function () {
  407. var numericallyOrderedDivs = $divs.sort(function (a, b) {
  408. return $(a).find("sort").text() > $(b).find("sort").text();
  409. });
  410. $("#content").html(numericallyOrderedDivs);
  411. });
  412. </script>
  413. <?php endif; ?>
  414. </body>
  415. </html>