homepage.php 25 KB

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