Ver Fonte

Fixes and HP additions

Fixed Default Tab name not set
Add new calendar HP goodness
New Ajax get image
Plex search load box
causefx há 8 anos atrás
pai
commit
3b3d7b68fe
5 ficheiros alterados com 169 adições e 30 exclusões
  1. 10 1
      ajax.php
  2. 0 7
      error.php
  3. 37 7
      functions.php
  4. 115 9
      homepage.php
  5. 7 6
      index.php

+ 10 - 1
ajax.php

@@ -67,6 +67,12 @@ switch ($_SERVER['REQUEST_METHOD']) {
 				echo nzbgetConnect($_GET['list'] ? $_GET['list'] : die('Error!'));
 				die();
 				break;
+			case 'show-image':
+				qualifyUser(NZBGETHOMEAUTH, true);
+				header('Content-type: image/jpeg');
+				echo file_get_contents($_GET['image']);
+				die();
+				break;
 			default:
 				sendNotification(false, 'Unsupported Action!');
 		}
@@ -74,7 +80,10 @@ switch ($_SERVER['REQUEST_METHOD']) {
 	case 'POST':
         // Check if the user is an admin and is allowed to commit values
         switch ($action) {
-            case 'search-plex':
+            case 'tvdb-get':
+			 	$response = tvdbGet($_POST['id']);
+			 	break;
+			case 'search-plex':
 			 	$response = searchPlex($_POST['searchtitle']);
 			 	break;
 			case 'validate-invite':

+ 0 - 7
error.php

@@ -20,19 +20,12 @@ $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 ini_set("display_errors", 1);
 ini_set("error_reporting", E_ALL | E_STRICT);
 
-// Load User List
-$gotUsers = $file_db->query('SELECT * FROM users');
-
-// Load Colours/Appearance
 foreach(loadAppearance() as $key => $value) {
 	$$key = $value;
 }
 
-
 $requested = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
-
 $status = (isset($_GET['error'])?$_GET['error']:404);
-
 $codes = array(  
        400 => array('Bad Request', 'The server cannot or will not process the request due to an apparent client error.', 'sowwy'),
        401 => array('Unauthorized', 'You do not have access to this page.', 'sowwy'),

+ 37 - 7
functions.php

@@ -2734,7 +2734,7 @@ function getSickrageCalendarWanted($array){
             if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
             $downloaded = "0";
             if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
-            $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
+            $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
         
     }
     
@@ -2751,7 +2751,7 @@ function getSickrageCalendarWanted($array){
             if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
             $downloaded = "0";
             if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
-            $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
+            $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
         
     }
     
@@ -2768,7 +2768,7 @@ function getSickrageCalendarWanted($array){
             if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
             $downloaded = "0";
             if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
-            $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
+            $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
         
     }
     
@@ -2785,7 +2785,7 @@ function getSickrageCalendarWanted($array){
             if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
             $downloaded = "0";
             if($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
-            $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
+            $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
         
     }
 
@@ -2806,7 +2806,7 @@ function getSickrageCalendarHistory($array){
             $episodeID = $child['tvdbid'];
             $episodeAirDate = $child['date'];
             $downloaded = "green-bg";
-            $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
+            $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
         
     }
 
@@ -2836,7 +2836,7 @@ function getSonarrCalendar($array){
         $downloaded = $child['hasFile'];
         if($downloaded == "0" && isset($unaired) && $episodePremier == "true"){ $downloaded = "light-blue-bg"; }elseif($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
         
-        $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
+        $gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded tvID--$episodeID\", imagetype: \"tv\" }, \n";
         
     }
 
@@ -2876,7 +2876,7 @@ function getRadarrCalendar($array){
             
             }
                         
-            $gotCalendar .= "{ title: \"$movieName\", start: \"$physicalRelease\", className: \"$downloaded\", imagetype: \"film\", url: \"https://www.themoviedb.org/movie/$movieID\" }, \n";
+            $gotCalendar .= "{ title: \"$movieName\", start: \"$physicalRelease\", className: \"$downloaded movieID--$movieID\", imagetype: \"film\" }, \n";
         }
         
     }
@@ -3559,6 +3559,36 @@ function customCSS(){
 	}
 }
 
+function tvdbToken(){
+	$headers = array(
+		"Accept" => "application/json", 
+		"Content-Type" => "application/json"
+	);
+	$json = array(
+		"apikey" => "FBE7B62621F4CAD7",
+         "userkey" => "328BB46EB1E9A0F5",
+         "username" => "causefx"
+	);
+	$api = curl_post("https://api.thetvdb.com/login", $json, $headers);
+    return json_decode($api['content'], true)['token'];
+}
+
+function tvdbGet($id){
+	$headers = array(
+		"Accept" => "application/json", 
+		"Authorization" => "Bearer ".tvdbToken()
+	);
+
+	$series = curl_get("https://api.thetvdb.com/series/$id", $headers);
+	$poster = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=poster", $headers);
+	$backdrop = curl_get("https://api.thetvdb.com/series/$id/images/query?keyType=fanart", $headers);
+	$api['series'] = json_decode($series, true)['data'];
+	$api['poster'] = json_decode($poster, true)['data'];
+	$api['backdrop'] = json_decode($backdrop, true)['data'];
+
+	return $api;
+}
+
 function orgEmail($header = "Message From Admin", $title = "Important Message", $user = "Organizr User", $mainMessage = "", $button = null, $buttonURL = null, $subTitle = "", $subMessage = ""){
 	return '
 	<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

+ 115 - 9
homepage.php

@@ -78,6 +78,9 @@ $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
         <script src="bower_components/respondJs/dest/respond.min.js"></script>
         <![endif]-->
         <style>
+            .fc-day-grid-event{
+                cursor: pointer;
+            }
             .recentItems {
                 padding-top: 10px;
                 margin: 5px 0;
@@ -522,6 +525,14 @@ $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
 		
         $( document ).ready(function() {
             $('#plexSearchForm').on('submit', function () {
+                var refreshBox = $(this).closest('div.content-box');
+                $("<div class='refresh-preloader'><div class='la-timer la-dark'><div></div></div></div>").appendTo(refreshBox).fadeIn(300);
+                setTimeout(function(){
+                    var refreshPreloader = refreshBox.find('.refresh-preloader'),
+                    deletedRefreshBox = refreshPreloader.fadeOut(300, function(){
+                        refreshPreloader.remove();
+                    });
+                },1000);
                 ajax_request('POST', 'search-plex', {
                     searchtitle: $('#plexSearchForm [name=search-title]').val(),
                 }).done(function(data){ $('#resultshere').html(data);});
@@ -792,17 +803,112 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
             $('#imagetype_selector').on('change',function(){
                 $('#calendar').fullCalendar('rerenderEvents');
             })
-            var $divs = $("div.row");
-
-            $('#numBnt').on('click', function () {
-                var numericallyOrderedDivs = $divs.sort(function (a, b) {
-                    return $(a).find("sort").text() > $(b).find("sort").text();
-                });
-                $("#content").html(numericallyOrderedDivs);
+                        $('td[class*=fc-event-container]').on('click tap', function(){
+                console.log("hmmm");
             });
         </script>
         <?php } ?>
+        <script>
+            function convertTime(a){
+                var hours = Math.trunc(a/60);
+                var minutes = a % 60;
+                return hours+"h "+minutes+"m";
+            }
+            function convertArray(a, type){
+                var result = "";
+                var count = 1;
+                var color = "";
+                $.each( a, function( key, value ) {
+                    if (count == 1){ color = "gray"; }else{ color = "gray"; }
+                    if(type == "MOVIE"){
+                        result += '<span class="label label-'+color+'">'+value['name']+'</span>&nbsp;';
+                    }else if(type == "TV"){
+                        result += '<span class="label label-'+color+'">'+value+'</span>&nbsp;';
+                    }
+                    count++;
+                });
+                return result;
+            }
+            function whatIsIt(a){
+                var what = Object.prototype.toString;
+                if(what.call(a) == "[object Array]"){
+                    return a[0].fileName;
+                }else if(what.call(a) == "[object Object]"){
+                    return a.fileName;
+                }
+            }
+            $(document).on('click', "a[class*=ID-]", function(){
+                var check = $(this).attr("class");
+                var ID = check.split("--")[1];
+                if (~check.indexOf("tvID")){
+                    var type = "TV";
+                    ajax_request('POST', 'tvdb-get', {
+                        id: ID,
+                    }).done(function(data){ 
+                        $('#calendarTitle').text(data.series.seriesName);
+                        $('#calendarRating').html('<span class="label label-gray"><i class="fa fa-thumbs-up white"></i> '+data.series.siteRating+'</span>&nbsp');
+                        $('#calendarRuntime').html('<span class="label label-gray"><i class="fa fa-clock-o white"></i> '+convertTime(data.series.runtime)+'</span>&nbsp;');
+                        $('#calendarSummary').text(data.series.overview);
+                        $('#calendarTagline').text("");
+                        $('#calendarGenres').html(convertArray(data.series.genre, "TV"));
+                        $('#calendarLang').html("");
+                        $('#calendarPoster').attr("src","ajax.php?a=show-image&image=http://thetvdb.com/banners/"+whatIsIt(data.poster));
+                        $('#calendarMain').attr("style","background-size: 1000px 563px; background-image: url(ajax.php?a=show-image&image=http://thetvdb.com/banners/"+whatIsIt(data.backdrop)+");background-position: center;-webkit-filter: brightness(50%) contrast(100%);filter: brightness(50%) contrast(100%);top: 0;left: 0;width: 100%;height: 100%;position: fixed;");
+                        $('#calendarExtra').modal('show');
+                        });
+                }else if (~check.indexOf("movieID")){
+                    var type = "MOVIE";
+                    $.ajax({
+                        type: 'GET',
+                        url: 'https://api.themoviedb.org/3/movie/'+ID+'?api_key=83cf4ee97bb728eeaf9d4a54e64356a1',
+                        cache: true,
+                        async: true,
+                        complete: function(xhr, status) {
+                            var result = $.parseJSON(xhr.responseText);
+                            if (xhr.statusText === "OK") {
+                                $('#calendarTitle').text(result.title);
+                                $('#calendarRating').html('<span class="label label-gray"><i class="fa fa-thumbs-up white"></i> '+result.vote_average+'</span>&nbsp;');
+                                $('#calendarRuntime').html('<span class="label label-gray"><i class="fa fa-clock-o white"></i> '+convertTime(result.runtime)+'</span>&nbsp;');
+                                $('#calendarSummary').text(result.overview);
+                                $('#calendarTagline').text(result.tagline);
+                                $('#calendarGenres').html(convertArray(result.genres, "MOVIE"));
+                                $('#calendarLang').html(convertArray(result.spoken_languages, "MOVIE"));
+                                $('#calendarPoster').attr("src","https://image.tmdb.org/t/p/w300"+result.poster_path);
+                                $('#calendarMain').attr("style","background-image: url(https://image.tmdb.org/t/p/w1000"+result.backdrop_path+");background-position: center;-webkit-filter: brightness(50%) contrast(100%);filter: brightness(50%) contrast(100%);top: 0;left: 0;width: 100%;height: 100%;position: fixed;");
+                                $('#calendarExtra').modal('show');
+                            }
+                        }
+                    });
+                }
+            });
+        </script>
+        <div id="calendarExtra" class="modal fade in" tabindex="-1" role="dialog">
+            <div class="modal-dialog modal-lg gray-bg" role="document">
+                <div class="modal-content">
+                    <div class="modal-content" id="calendarMain"></div>
+                   <div style="position: inherit; padding: 15px">
+                        <span id="calendarRuntime" class="pull-left"></span>
+                        <span id="calendarRating" class="pull-left"></span>
+                        <span id="calendarGenres" class="pull-right"></span>
+                    </div>
+                    <div class="modal-body">
+                        <div class="row">
+                            <div class="col-lg-4 col-sm-5">
+                                <img style="border-radius: 10px;box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);" id="calendarPoster" src="" height="300px;">
+                            </div>
+                            <div class="col-lg-8 col-sm-7">
+                                <h2 id="calendarTitle" class="modal-title text-center">Modal title</h2>
+                                <h6 id="calendarTagline" class="modal-title text-center"><em>Modal title</em></h6>
+                                <p id="calendarSummary">Modal Summary</p>
+                            </div>
+                        </div>
+                    </div>
+                   <div style="position: inherit; padding: 10px 15px 30px 15px; margin-top: -20px;">
+                        <span id="calendarLang" class="pull-right"></span>
+                    </div>
+                </div>
+            </div>
+        </div>
 
     </body>
-
-</html>
+</html>

+ 7 - 6
index.php

@@ -291,12 +291,12 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 
         }.bottom-bnts {
 
-            background-color: <?=$bottombar;?> !important;
+            background: <?=$bottombar;?> !important;
 
         }.gn-menu-main {
 
 
-            background-color: <?=$topbar;?>;
+            background: <?=$topbar;?>;
 
         }.gn-menu-main ul.gn-menu {
 
@@ -369,7 +369,7 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
             background-size: 0 2px,100% 1px;
             background-repeat: no-repeat;
             background-position: center bottom,center calc(100% - 1px);
-            background-color: transparent;
+            background: transparent;
             box-shadow: none;
 
         }.gn-menu li.active i.fa {
@@ -398,7 +398,7 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 
         }div#preloader {
 
-            background-color: <?=$loading;?>;
+            background: <?=$loading;?>;
 
         }.iframe {
 
@@ -1406,6 +1406,7 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
             $("li[class^='tab-item active']").first().find("img").addClass("TabOpened");
             if (defaultTab){
                 defaultTab = defaultTab.substr(0, defaultTab.length-1);
+                console.log(defaultTab);
             }else{
                 defaultTabNone = $("li[class^='tab-item']").attr("id");
                 if (defaultTabNone){
@@ -1416,8 +1417,8 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
             }
 
             if (defaultTab){
-
-                $("#content").html('<div class="iframe active" data-content-url="'+defaultTab+'"><iframe scrolling="auto" sandbox="allow-forms allow-same-origin allow-pointer-lock allow-scripts allow-popups allow-modals allow-top-navigation" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" frameborder="0" style="width:100%; height:100%; position: absolute;" src="'+defaultTab+'"></iframe></div>');
+                defaultTabName = $("li[class^='tab-item active']").attr("name");
+                $("#content").html('<div class="iframe active" data-content-name="'+defaultTabName+'" data-content-url="'+defaultTab+'"><iframe scrolling="auto" sandbox="allow-forms allow-same-origin allow-pointer-lock allow-scripts allow-popups allow-modals allow-top-navigation" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" frameborder="0" style="width:100%; height:100%; position: absolute;" src="'+defaultTab+'"></iframe></div>');
                 document.getElementById('main-wrapper').focus();
             }
             if (defaultTab == null){