homepage.php 25 KB

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