homepage.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  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. <div id="embyRow" class="row">
  243. <sort>3</sort>
  244. <?php
  245. $embySize = 0;
  246. if(EMBYRECENTMOVIE == "true"){ $embySize++; }
  247. if(EMBYRECENTTV == "true"){ $embySize++; }
  248. if(EMBYRECENTMUSIC == "true"){ $embySize++; }
  249. if(EMBYPLAYINGNOW == "true"){ $embySize++; }
  250. if($embySize >= 4){ $embySize = 3; }elseif($embySize == 3){ $embySize = 4; }elseif($embySize == 2){ $embySize = 6; }elseif($embySize == 1){ $embySize = 12; }
  251. if(EMBYRECENTMOVIE == "true"){ echo getEmbyRecent(EMBYURL, EMBYPORT, "movie", EMBYTOKEN, $embySize, $language->translate("MOVIES")); }
  252. if(EMBYRECENTTV == "true"){ echo getEmbyRecent(EMBYURL, EMBYPORT, "season", EMBYTOKEN, $embySize, $language->translate("TV_SHOWS")); }
  253. if(EMBYRECENTMUSIC == "true"){ echo getEmbyRecent(EMBYURL, EMBYPORT, "album", EMBYTOKEN, $embySize, $language->translate("MUSIC")); }
  254. if(EMBYPLAYINGNOW == "true"){ echo getEmbyStreams(EMBYURL, EMBYPORT, EMBYTOKEN, $embySize, $language->translate("PLAYING_NOW_ON_EMBY")); }
  255. ?>
  256. </div>
  257. <?php if(SONARRURL != "" || RADARRURL != "" || HEADPHONESURL != "" || SICKRAGEURL != "") : ?>
  258. <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
  259. <sort>1</sort>
  260. <div class="col-lg-12 content-form form-inline">
  261. <div class="form-group">
  262. <select class="form-control" id="imagetype_selector" style="width: auto !important; display: inline-block">
  263. <option value="all">View All</option>
  264. <?php if(RADARRURL != ""){ echo '<option value="film">Movies</option>'; }?>
  265. <?php if(SONARRURL != "" || SICKRAGEURL != ""){ echo '<option value="tv">TV Shows</option>'; }?>
  266. <?php if(HEADPHONESURL != ""){ echo '<option value="music">Music</option>'; }?>
  267. </select>
  268. <span class="label label-primary well-sm">Available</span>
  269. <span class="label label-danger well-sm">Unavailable</span>
  270. <span class="label indigo-bg well-sm">Unreleased</span>
  271. <span class="label light-blue-bg well-sm">Premier</span>
  272. </div>
  273. </div>
  274. </div>
  275. <div id="calendarRow" class="row">
  276. <sort>1</sort>
  277. <div class="col-lg-12">
  278. <div id="calendar" class="fc-calendar box-shadow fc fc-ltr fc-unthemed"></div>
  279. </div>
  280. </div>
  281. <?php endif; ?>
  282. </div>
  283. </div>
  284. <!--Scripts-->
  285. <script src="bower_components/jquery/dist/jquery.min.js"></script>
  286. <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  287. <script src="bower_components/moment/min/moment.min.js"></script>
  288. <script src="bower_components/jquery.nicescroll/jquery.nicescroll.min.js"></script>
  289. <script src="bower_components/slimScroll/jquery.slimscroll.min.js"></script>
  290. <script src="bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.js"></script>
  291. <script src="bower_components/jquery.nicescroll/jquery.nicescroll.min.js"></script>
  292. <script src="bower_components/cta/dist/cta.min.js"></script>
  293. <script src="bower_components/fullcalendar/dist/fullcalendar.js"></script>
  294. <script src="js/jqueri_ui_custom/jquery-ui.min.js"></script>
  295. <script src="js/jquery.mousewheel.min.js" type="text/javascript"></script>
  296. <script>
  297. $( document ).ready(function() {
  298. $('.repeat-btn').click(function(){
  299. var refreshBox = $(this).closest('div.content-box');
  300. $("<div class='refresh-preloader'><div class='la-timer la-dark'><div></div></div></div>").appendTo(refreshBox).fadeIn(300);
  301. setTimeout(function(){
  302. var refreshPreloader = refreshBox.find('.refresh-preloader'),
  303. deletedRefreshBox = refreshPreloader.fadeOut(300, function(){
  304. refreshPreloader.remove();
  305. });
  306. },1500);
  307. });
  308. $("body").niceScroll({
  309. railpadding: {top:0,right:0,left:0,bottom:0},
  310. scrollspeed: 30,
  311. mousescrollstep: 60
  312. });
  313. $(".table-responsive").niceScroll({
  314. railpadding: {top:0,right:0,left:0,bottom:0},
  315. scrollspeed: 30,
  316. mousescrollstep: 60
  317. });
  318. /*$(".carousel-caption").niceScroll({
  319. railpadding: {top:0,right:0,left:0,bottom:0},
  320. scrollspeed: 30,
  321. mousescrollstep: 60
  322. });*/
  323. // check if browser support HTML5 local storage
  324. function localStorageSupport() {
  325. return (('localStorage' in window) && window['localStorage'] !== null)
  326. }
  327. <?php if(($USER->authenticated && $USER->role == "admin") && (NZBGETURL != "" || SABNZBDURL != "")){ ?>
  328. var downloaderSeconds = localStorage.getItem("downloaderSeconds");
  329. var myInterval = undefined;
  330. $("ul").find("[data-value='" + downloaderSeconds + "']").addClass("active");
  331. if( downloaderSeconds === null ) {
  332. localStorage.setItem("downloaderSeconds",'60000');
  333. var downloaderSeconds = "60000";
  334. }
  335. $('#downloaderSeconds li').click(function() {
  336. $('#downloaderSeconds li').removeClass("active");
  337. $(this).addClass("active");
  338. var newDownloaderSeconds = $(this).attr('data-value');
  339. console.log('New Time is ' + newDownloaderSeconds + ' Old Time was ' + downloaderSeconds);
  340. if (localStorageSupport) {
  341. localStorage.setItem("downloaderSeconds",newDownloaderSeconds);
  342. }
  343. if(typeof myInterval != 'undefined'){ clearInterval(myInterval); }
  344. refreshDownloader(newDownloaderSeconds);
  345. });
  346. <?php } ?>
  347. <?php if(($USER->authenticated && $USER->role == "admin") && NZBGETURL != ""){ ?>
  348. $("#downloaderHistory").load("downloader.php?downloader=nzbget&list=history");
  349. $("#downloaderQueue").load("downloader.php?downloader=nzbget&list=listgroups");
  350. refreshDownloader = function(secs){
  351. myInterval = setInterval(function(){
  352. $("#downloaderHistory").load("downloader.php?downloader=nzbget&list=history");
  353. $("#downloaderQueue").load("downloader.php?downloader=nzbget&list=listgroups");
  354. }, secs);
  355. }
  356. refreshDownloader(downloaderSeconds);
  357. $("#getDownloader").click(function(){
  358. $("#downloaderHistory").load("downloader.php?downloader=nzbget&list=history");
  359. $("#downloaderQueue").load("downloader.php?downloader=nzbget&list=listgroups");
  360. console.log('completed');
  361. });
  362. <?php } ?>
  363. <?php if(($USER->authenticated && $USER->role == "admin") && SABNZBDURL != ""){ ?>
  364. $("#downloaderHistory").load("downloader.php?downloader=sabnzbd&list=history");
  365. $("#downloaderQueue").load("downloader.php?downloader=sabnzbd&list=queue");
  366. refreshDownloader = function(secs){
  367. myInterval = setInterval(function(){
  368. $("#downloaderHistory").load("downloader.php?downloader=sabnzbd&list=history");
  369. $("#downloaderQueue").load("downloader.php?downloader=sabnzbd&list=queue");
  370. }, secs);
  371. }
  372. refreshDownloader(downloaderSeconds);
  373. $("#getDownloader").click(function(){
  374. $("#downloaderHistory").load("downloader.php?downloader=sabnzbd&list=history");
  375. $("#downloaderQueue").load("downloader.php?downloader=sabnzbd&list=queue");
  376. console.log('completed');
  377. });
  378. <?php } ?>
  379. });
  380. </script>
  381. <?php if(SONARRURL != "" || RADARRURL != "" || HEADPHONESURL != "" || SICKRAGEURL != "") : ?>
  382. <script>
  383. $(function () {
  384. var date = new Date();
  385. var d = date.getDate();
  386. var m = date.getMonth();
  387. var y = date.getFullYear();
  388. $('#calendar').fullCalendar({
  389. eventLimit: false,
  390. firstDay: <?php echo CALENDARSTART;?>,
  391. height: "auto",
  392. defaultView: '<?php echo CALENDARVIEW;?>',
  393. header: {
  394. left: 'prev,next,',
  395. center: 'title',
  396. right: 'today, month, basicDay,basicWeek,'
  397. },
  398. views: {
  399. basicDay: { buttonText: '<?php echo $language->translate("DAY");?>', eventLimit: false },
  400. basicWeek: { buttonText: '<?php echo $language->translate("WEEK");?>', eventLimit: false },
  401. month: { buttonText: '<?php echo $language->translate("MONTH");?>', eventLimit: false },
  402. today: { buttonText: '<?php echo $language->translate("TODAY");?>' },
  403. },
  404. events: [
  405. <?php if(SICKRAGEURL != ""){ echo getSickrageCalendarWanted($sickrage->future()); echo getSickrageCalendarHistory($sickrage->history("100","downloaded")); } ?>
  406. <?php if(SONARRURL != ""){ echo getSonarrCalendar($sonarr->getCalendar($startDate, $endDate)); } ?>
  407. <?php if(RADARRURL != ""){ echo getRadarrCalendar($radarr->getCalendar($startDate, $endDate)); } ?>
  408. <?php if(HEADPHONESURL != ""){ echo getHeadphonesCalendar(HEADPHONESURL, HEADPHONESPORT, HEADPHONESKEY, "getHistory"); echo getHeadphonesCalendar(HEADPHONESURL, HEADPHONESPORT, HEADPHONESKEY, "getWanted"); } ?>
  409. ],
  410. eventRender: function eventRender( event, element, view ) {
  411. return ['all', event.imagetype].indexOf($('#imagetype_selector').val()) >= 0
  412. },
  413. editable: false,
  414. droppable: false,
  415. });
  416. });
  417. $('#imagetype_selector').on('change',function(){
  418. $('#calendar').fullCalendar('rerenderEvents');
  419. })
  420. var $divs = $("div.row");
  421. $('#numBnt').on('click', function () {
  422. var numericallyOrderedDivs = $divs.sort(function (a, b) {
  423. return $(a).find("sort").text() > $(b).find("sort").text();
  424. });
  425. $("#content").html(numericallyOrderedDivs);
  426. });
  427. </script>
  428. <?php endif; ?>
  429. </body>
  430. </html>