homepage.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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. <!--Scripts-->
  77. <script src="bower_components/jquery/dist/jquery.min.js"></script>
  78. <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  79. <script src="bower_components/moment/min/moment.min.js"></script>
  80. <script src="bower_components/jquery.nicescroll/jquery.nicescroll.min.js"></script>
  81. <script src="bower_components/slimScroll/jquery.slimscroll.min.js"></script>
  82. <script src="bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.js"></script>
  83. <script src="bower_components/jquery.nicescroll/jquery.nicescroll.min.js"></script>
  84. <script src="bower_components/cta/dist/cta.min.js"></script>
  85. <script src="bower_components/fullcalendar/dist/fullcalendar.js"></script>
  86. <script src="js/jqueri_ui_custom/jquery-ui.min.js"></script>
  87. <script src="js/jquery.mousewheel.min.js" type="text/javascript"></script>
  88. <!--Other-->
  89. <script src="js/ajax.js?v=<?php echo INSTALLEDVERSION; ?>"></script>
  90. <!--[if lt IE 9]>
  91. <script src="bower_components/html5shiv/dist/html5shiv.min.js"></script>
  92. <script src="bower_components/respondJs/dest/respond.min.js"></script>
  93. <![endif]-->
  94. <style>
  95. sort {
  96. display: none;
  97. }
  98. table.fc-list-table {
  99. table-layout: auto;
  100. }.tabbable{
  101. margin-bottom: 0;
  102. }.fc-day-grid-event .fc-content {
  103. white-space: normal;
  104. }.fc-list-item {
  105. table-layout: auto;
  106. position: inherit;
  107. margin: 10px;
  108. border-radius: 4px;
  109. padding: 0 5px 0 5px;
  110. color: #fff !important;
  111. }.fc-calendar .fc-toolbar {
  112. background: <?=$topbar;?>;
  113. color: <?=$topbartext;?>;
  114. border-radius: 5px 5px 0 0;
  115. padding: 15px;
  116. }.fc-calendar .fc-toolbar .fc-right {
  117. bottom: 0px;
  118. right: 20px;
  119. }.fc-calendar .fc-toolbar .fc-right button {
  120. color: <?=$topbartext;?>;
  121. }.fc-calendar .fc-toolbar .fc-prev-button, .fc-calendar .fc-toolbar .fc-next-button {
  122. color: <?=$topbartext;?>;
  123. }.carousel-image{
  124. width: 100px !important;
  125. height: 150px !important;
  126. border-radius: 3px 0 0 3px;
  127. }.carousel-image.album{
  128. width: 150px !important;
  129. height: 150px !important;
  130. border-radius: 3px 0 0 3px;
  131. }.carousel-control.album {
  132. top: 5px !important;
  133. width: 4% !important;
  134. }.carousel-control {
  135. top: 5px !important;
  136. width: 4% !important;
  137. }.carousel-caption.album {
  138. position: absolute;
  139. right: 4%;
  140. top: 0px;
  141. left: 160px;
  142. z-index: 10;
  143. bottom: 0px;
  144. padding-top: 0px;
  145. color: #fff;
  146. text-align: left;
  147. }.carousel-caption {
  148. position: absolute;
  149. right: 4%;
  150. top: 0px;
  151. left: 110px;
  152. z-index: 10;
  153. bottom: 0px;
  154. padding-top: 0px;
  155. color: #fff;
  156. text-align: left;
  157. padding-bottom: 2px !important;
  158. overflow: hidden !important;
  159. }<?php if(CUSTOMCSS == "true") :
  160. $template_file = "custom.css";
  161. $file_handle = fopen($template_file, "rb");
  162. echo fread($file_handle, filesize($template_file));
  163. fclose($file_handle);
  164. echo "\n";
  165. endif; ?>
  166. </style>
  167. </head>
  168. <body class="scroller-body" style="padding: 0px;">
  169. <div class="main-wrapper" style="position: initial;">
  170. <div id="content" class="container-fluid">
  171. <!-- <button id="numBnt">Numerical</button> -->
  172. <br/>
  173. <?php if((NZBGETURL != "" && qualifyUser(NZBGETHOMEAUTH)) || (SABNZBDURL != "" && qualifyUser(SABNZBDHOMEAUTH))) { ?>
  174. <div id="downloadClientRow" class="row">
  175. <sort>2</sort>
  176. <div class="col-xs-12 col-md-12">
  177. <div class="content-box">
  178. <div class="tabbable panel with-nav-tabs panel-default">
  179. <div class="panel-heading">
  180. <div class="content-tools i-block pull-right">
  181. <a id="getDownloader" class="repeat-btn">
  182. <i class="fa fa-repeat"></i>
  183. </a>
  184. <a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
  185. <i class="fa fa-chevron-down"></i>
  186. </a>
  187. <!-- Lets Move This To Homepage Settings
  188. <ul id="downloaderSeconds" class="dropdown-menu" style="top: 32px !important">
  189. <li data-value="5000"><a>Refresh every 5 seconds</a></li>
  190. <li data-value="10000"><a>Refresh every 10 seconds</a></li>
  191. <li data-value="30000"><a>Refresh every 30 seconds</a></li>
  192. <li data-value="60000"><a>Refresh every 60 seconds</a></li>
  193. </ul>
  194. -->
  195. </div>
  196. <h3 class="pull-left"><?php if(NZBGETURL != ""){ echo "NZBGet "; } if(SABNZBDURL != ""){ echo "SABnzbd "; } ?></h3>
  197. <ul class="nav nav-tabs pull-right">
  198. <li class="active"><a href="#downloadQueue" data-toggle="tab" aria-expanded="true"><?php echo $language->translate("QUEUE");?></a></li>
  199. <li class=""><a href="#downloadHistory" data-toggle="tab" aria-expanded="false"><?php echo $language->translate("HISTORY");?></a></li>
  200. </ul>
  201. <div class="clearfix"></div>
  202. </div>
  203. <div class="panel-body">
  204. <div class="tab-content">
  205. <div class="tab-pane fade active in" id="downloadQueue">
  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><?php echo $language->translate("FILE");?></th>
  211. <th><?php echo $language->translate("STATUS");?></th>
  212. <th><?php echo $language->translate("CATEGORY");?></th>
  213. <th><?php echo $language->translate("PROGRESS");?></th>
  214. </tr>
  215. </thead>
  216. <tbody class="dl-queue sabnzbd"></tbody>
  217. <tbody class="dl-queue nzbget"></tbody>
  218. </table>
  219. </div>
  220. </div>
  221. <div class="tab-pane fade" id="downloadHistory">
  222. <div class="table-responsive" style="max-height: 300px">
  223. <table class="table table-striped progress-widget zero-m" style="max-height: 300px">
  224. <thead>
  225. <tr>
  226. <th><?php echo $language->translate("FILE");?></th>
  227. <th><?php echo $language->translate("STATUS");?></th>
  228. <th><?php echo $language->translate("CATEGORY");?></th>
  229. <th><?php echo $language->translate("PROGRESS");?></th>
  230. </tr>
  231. </thead>
  232. <tbody class="dl-history sabnzbd"></tbody>
  233. <tbody class="dl-history nzbget"></tbody>
  234. </table>
  235. </div>
  236. </div>
  237. </div>
  238. </div>
  239. </div>
  240. </div>
  241. </div>
  242. </div>
  243. <?php } ?>
  244. <?php if (qualifyUser(PLEXHOMEAUTH) && PLEXTOKEN) { ?>
  245. <div id="plexRow" class="row">
  246. <sort>3</sort>
  247. <?php
  248. $plexSize = (PLEXRECENTMOVIE == "true") + (PLEXRECENTTV == "true") + (PLEXRECENTMUSIC == "true") + (PLEXPLAYINGNOW == "true");
  249. if(PLEXRECENTMOVIE == "true"){ echo getPlexRecent("movie", 12/$plexSize); }
  250. if(PLEXRECENTTV == "true"){ echo getPlexRecent("season", 12/$plexSize); }
  251. if(PLEXRECENTMUSIC == "true"){ echo getPlexRecent("album", 12/$plexSize); }
  252. if(PLEXPLAYINGNOW == "true"){ echo getPlexStreams(12/$plexSize); }
  253. ?>
  254. </div>
  255. <?php } ?>
  256. <?php if (qualifyUser(EMBYHOMEAUTH) && EMBYTOKEN) { ?>
  257. <div id="embyRow" class="row">
  258. <sort>3</sort>
  259. <?php
  260. $embySize = (EMBYRECENTMOVIE == "true") + (EMBYRECENTTV == "true") + (EMBYRECENTMUSIC == "true") + (EMBYPLAYINGNOW == "true");
  261. if(EMBYRECENTMOVIE == "true"){ echo getEmbyRecent("movie", 12/$embySize); }
  262. if(EMBYRECENTTV == "true"){ echo getEmbyRecent("season", 12/$embySize); }
  263. if(EMBYRECENTMUSIC == "true"){ echo getEmbyRecent("album", 12/$embySize); }
  264. if(EMBYPLAYINGNOW == "true"){ echo getEmbyStreams(12/$embySize); }
  265. ?>
  266. </div>
  267. <?php } ?>
  268. <?php if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH))) { ?>
  269. <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
  270. <sort>1</sort>
  271. <div class="col-lg-12 content-form form-inline">
  272. <div class="form-group">
  273. <select class="form-control" id="imagetype_selector" style="width: auto !important; display: inline-block">
  274. <option value="all">View All</option>
  275. <?php if(RADARRURL != ""){ echo '<option value="film">Movies</option>'; }?>
  276. <?php if(SONARRURL != "" || SICKRAGEURL != ""){ echo '<option value="tv">TV Shows</option>'; }?>
  277. <?php if(HEADPHONESURL != ""){ echo '<option value="music">Music</option>'; }?>
  278. </select>
  279. <span class="label label-primary well-sm">Available</span>
  280. <span class="label label-danger well-sm">Unavailable</span>
  281. <span class="label indigo-bg well-sm">Unreleased</span>
  282. <span class="label light-blue-bg well-sm">Premier</span>
  283. </div>
  284. </div>
  285. </div>
  286. <div id="calendarRow" class="row">
  287. <sort>1</sort>
  288. <div class="col-lg-12">
  289. <div id="calendar" class="fc-calendar box-shadow fc fc-ltr fc-unthemed"></div>
  290. </div>
  291. </div>
  292. <?php } ?>
  293. <?php if (qualifyUser(HOMEPAGECUSTOMHTML1AUTH) && HOMEPAGECUSTOMHTML1) { ?>
  294. <div>
  295. <?php echo HOMEPAGECUSTOMHTML1; ?>
  296. </div>
  297. <?php } ?>
  298. </div>
  299. </div>
  300. <script>
  301. function localStorageSupport() {
  302. return (('localStorage' in window) && window['localStorage'] !== null)
  303. }
  304. $( document ).ready(function() {
  305. $('.repeat-btn').click(function(){
  306. var refreshBox = $(this).closest('div.content-box');
  307. $("<div class='refresh-preloader'><div class='la-timer la-dark'><div></div></div></div>").appendTo(refreshBox).fadeIn(300);
  308. setTimeout(function(){
  309. var refreshPreloader = refreshBox.find('.refresh-preloader'),
  310. deletedRefreshBox = refreshPreloader.fadeOut(300, function(){
  311. refreshPreloader.remove();
  312. });
  313. },1500);
  314. });
  315. $("body").niceScroll({
  316. railpadding: {top:0,right:0,left:0,bottom:0},
  317. scrollspeed: 30,
  318. mousescrollstep: 60
  319. });
  320. $(".table-responsive").niceScroll({
  321. railpadding: {top:0,right:0,left:0,bottom:0},
  322. scrollspeed: 30,
  323. mousescrollstep: 60
  324. });
  325. /*$(".carousel-caption").niceScroll({
  326. railpadding: {top:0,right:0,left:0,bottom:0},
  327. scrollspeed: 30,
  328. mousescrollstep: 60
  329. });*/
  330. // check if browser support HTML5 local storage
  331. <?php if((NZBGETURL != "" && qualifyUser(NZBGETHOMEAUTH)) || (SABNZBDURL != "" && qualifyUser(SABNZBDHOMEAUTH))){ ?>
  332. var queueRefresh = 30000;
  333. var historyRefresh = 120000; // This really doesn't need to happen that often
  334. var queueLoad = function() {
  335. <?php if(SABNZBDURL != "") { echo '$("tbody.dl-queue.sabnzbd").load("ajax.php?a=sabnzbd-update&list=queue");'; } ?>
  336. <?php if(NZBGETURL != "") { echo '$("tbody.dl-queue.nzbget").load("ajax.php?a=nzbget-update&list=listgroups");'; } ?>
  337. };
  338. var historyLoad = function() {
  339. <?php if(SABNZBDURL != "") { echo '$("tbody.dl-history.sabnzbd").load("ajax.php?a=sabnzbd-update&list=history");'; } ?>
  340. <?php if(NZBGETURL != "") { echo '$("tbody.dl-history.nzbget").load("ajax.php?a=nzbget-update&list=history");'; } ?>
  341. };
  342. // Initial Loads
  343. queueLoad();
  344. historyLoad();
  345. // Interval Loads
  346. var queueInterval = setInterval(queueLoad, queueRefresh);
  347. var historyInterval = setInterval(historyLoad, historyRefresh);
  348. // Manual Load
  349. $("#getDownloader").click(function() {
  350. queueLoad();
  351. historyLoad();
  352. });
  353. <?php } ?>
  354. });
  355. </script>
  356. <?php if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH))) { ?>
  357. <script>
  358. $(function () {
  359. var date = new Date();
  360. var d = date.getDate();
  361. var m = date.getMonth();
  362. var y = date.getFullYear();
  363. $('#calendar').fullCalendar({
  364. eventLimit: false,
  365. firstDay: <?php echo CALENDARSTART;?>,
  366. height: "auto",
  367. defaultView: '<?php echo CALENDARVIEW;?>',
  368. header: {
  369. left: 'prev,next,',
  370. center: 'title',
  371. right: 'today, month, basicDay,basicWeek,'
  372. },
  373. views: {
  374. basicDay: { buttonText: '<?php echo $language->translate("DAY");?>', eventLimit: false },
  375. basicWeek: { buttonText: '<?php echo $language->translate("WEEK");?>', eventLimit: false },
  376. month: { buttonText: '<?php echo $language->translate("MONTH");?>', eventLimit: false },
  377. today: { buttonText: '<?php echo $language->translate("TODAY");?>' },
  378. },
  379. events: [
  380. <?php if (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)){ echo getSickrageCalendarWanted($sickrage->future()); echo getSickrageCalendarHistory($sickrage->history("100","downloaded")); } ?>
  381. <?php if (SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)){ echo getSonarrCalendar($sonarr->getCalendar($startDate, $endDate)); } ?>
  382. <?php if (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)){ echo getRadarrCalendar($radarr->getCalendar($startDate, $endDate)); } ?>
  383. <?php if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){ echo getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory"); echo getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted"); } ?>
  384. ],
  385. eventRender: function eventRender( event, element, view ) {
  386. return ['all', event.imagetype].indexOf($('#imagetype_selector').val()) >= 0
  387. },
  388. editable: false,
  389. droppable: false,
  390. timeFormat: '<?php echo CALTIMEFORMAT; ?>',
  391. });
  392. });
  393. $('#imagetype_selector').on('change',function(){
  394. $('#calendar').fullCalendar('rerenderEvents');
  395. })
  396. var $divs = $("div.row");
  397. $('#numBnt').on('click', function () {
  398. var numericallyOrderedDivs = $divs.sort(function (a, b) {
  399. return $(a).find("sort").text() > $(b).find("sort").text();
  400. });
  401. $("#content").html(numericallyOrderedDivs);
  402. });
  403. </script>
  404. <?php } ?>
  405. </body>
  406. </html>