فهرست منبع

LoadAppearance Fix

causefx 9 سال پیش
والد
کامیت
d8008f188d
4فایلهای تغییر یافته به همراه66 افزوده شده و 37 حذف شده
  1. 1 1
      ajax.php
  2. 26 23
      functions.php
  3. 38 12
      homepage.php
  4. 1 1
      settings.php

+ 1 - 1
ajax.php

@@ -109,7 +109,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
                         sendResult(frameTest($_POST['checkurl']), "flask", $_POST['checkurl'], "IFRAME_CAN_BE_FRAMED", "IFRAME_CANNOT_BE_FRAMED");
                         break;
                     case 'upload-images':
-                        uploadFiles('images/', array('jpg', 'png', 'svg', 'jpeg', 'bmp'));
+                        uploadFiles('images/', array('jpg', 'png', 'svg', 'jpeg', 'bmp', 'gif'));
                         sendNotification(true);
                         break;
                     case 'remove-images':

+ 26 - 23
functions.php

@@ -733,7 +733,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
                 $state = (($item->Player['state'] == "paused") ? "pause" : "play");
                 $topTitle = '<h5 class="text-center zero-m elip">'.$title.' - '.$item['title'].'</h5>';
                 $bottomTitle = '<small class="zero-m">S'.$item['parentIndex'].' · E'.$item['index'].'</small>';
-                if($showNames == "true"){ $bottomTitle .= '</small><small class="zero-m pull-right">'.$user.'</small>'; }
+                if($showNames == "true"){ $bottomTitle .= '<small class="zero-m pull-right">'.$user.'</small>'; }
             }
             break;
         case 'clip':
@@ -842,7 +842,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
             }
 		}
 	
-		if (substr_count(PLEXURL, ':') == 2) {
+		if (substr_count(PLEXURL, '.') != 2) {
 			$address = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
 		}else{
 			$address = PLEXURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$item['ratingKey'];
@@ -945,7 +945,7 @@ function getPlexStreams($size, $showNames, $role){
 				$items[] = resolvePlexItem($gotServer, PLEXTOKEN, $child, true, $showNames, $role);
 			}
 
-			return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX'), $size, 'streams-plex', $items, "
+			return outputNowPlaying(translate('PLAYING_NOW_ON_PLEX')." <code>".count($items)." Streams</code>", $size, 'streams-plex', $items, "
 				setInterval(function() {
 					$('<div></div>').load('ajax.php?a=plex-streams',function() {
 						var element = $(this).find('[id]');
@@ -1481,13 +1481,15 @@ function getError($os, $error){
 // Check if all software dependancies are met
 function dependCheck() {
 	$output = array();
-	if (!extension_loaded('pdo_sqlite')) { $output[] = getError(getOS(),'pdo_sqlite'); }
-	if (!extension_loaded('curl')) { $output[] = getError(getOS(),'curl'); }
-	if (!extension_loaded('zip')) { $output[] = getError(getOS(),'zip'); }
+	$i = 1;
+	if (!extension_loaded('pdo_sqlite')) { $output["Step $i"] = getError(getOS(),'pdo_sqlite'); $i++; }
+	if (!extension_loaded('curl')) { $output["Step $i"] = getError(getOS(),'curl'); $i++; }
+	if (!extension_loaded('zip')) { $output["Step $i"] = getError(getOS(),'zip'); $i++; }
 	//if (!extension_loaded('sqlite3')) { $output[] = getError(getOS(),'sqlite3'); }
 	
 	if ($output) {
-		$output[] = "<b>Please visit here to also check status of necessary components after you fix them: <a href='check.php'>check.php<a/></b>";
+		$output["Step $i"] = "<b>Restart PHP and/or Webserver to apply changes</b>"; $i++; 
+		$output["Step $i"] = "<b>Please visit here to also check status of necessary components after you fix them: <a href='check.php'>check.php<a/></b>"; $i++; 
 		debug_out($output,1);
 	}
 	return true;
@@ -2207,11 +2209,6 @@ function sendNotification($success, $message = false, $send = true) {
 
 // Load colours from the database
 function loadAppearance() {
-	if (!isset($GLOBALS['file_db'])) {
-		$GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
-		$GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-	}
-	
 	// Defaults
 	$defaults = array(
 		'title' => 'Organizr',
@@ -2228,19 +2225,25 @@ function loadAppearance() {
 		'loading' => '#66D9EF',
 		'hovertext' => '#000000',
 	);
-	
-	// Database Lookup
-	$options = $GLOBALS['file_db']->query('SELECT * FROM options');
-	
-	// Replace defaults with filled options
-	foreach($options as $row) {
-		foreach($defaults as $key => $value) {
-			if (isset($row[$key]) && $row[$key]) {
-				$defaults[$key] = $row[$key];
+
+	if (DATABASE_LOCATION) {
+		if (!isset($GLOBALS['file_db'])) {
+			$GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
+			$GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+			// Database Lookup
+			$options = $GLOBALS['file_db']->query('SELECT * FROM options');
+			// Replace defaults with filled options
+			foreach($options as $row) {
+				foreach($defaults as $key => $value) {
+					if (isset($row[$key]) && $row[$key]) {
+						$defaults[$key] = $row[$key];
+					}
+				}
 			}
 		}
-	}
 	
+	}
+
 	// Return the Results
 	return $defaults;
 }
@@ -3219,7 +3222,7 @@ function searchPlex($query){
     		}
     		if(!$results['image']){ $image_url = "images/no-search.png"; $key = "no-search"; }
 			
-			if (substr_count(PLEXURL, ':') == 2) {
+			if (substr_count(PLEXURL, '.') != 2) {
 				$link = "https://app.plex.tv/web/app#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];
 			}else{
 				$link = PLEXURL."/web/index.html#!/server/$server/details?key=/library/metadata/".$results['ratingkey'];

+ 38 - 12
homepage.php

@@ -819,9 +819,13 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
         <?php } ?>
         <script>
             function convertTime(a){
-                var hours = Math.trunc(a/60);
-                var minutes = a % 60;
-                return hours+"h "+minutes+"m";
+                if(a){
+                    var hours = Math.trunc(a/60);
+                    var minutes = a % 60;
+                    return hours+"h "+minutes+"m";
+                }else{
+                    return "N/A";
+                }
             }
             function convertArray(a, type){
                 var result = "";
@@ -843,12 +847,25 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                 var count = 1;
                 $.each( a.results, function( key, value ) {
                     if (count == 1){
-                        result += '<span id="openTrailer" style="cursor:pointer;width: 200px;display: block;" data-key="'+value['key']+'" data-name="'+value['name']+'" data-site="'+value['site']+'" class="label label-danger">Watch Trailer</span>&nbsp;';
+                        result += '<span id="openTrailer" style="cursor:pointer;width: 100%;display: block;" data-key="'+value['key']+'" data-name="'+value['name']+'" data-site="'+value['site']+'" class="label label-danger"><i class="fa fa-youtube-play" aria-hidden="true"></i> &nbsp;Watch Trailer</span>&nbsp;';
                     }
                     count++;
                 });
                 return result;
             }
+            function convertCast(a){
+                var result = "";
+                var count = 1;
+                $.each( a.cast, function( key, value ) {
+                    if( value['profile_path'] ){
+                        if (count <= 6){
+                            result += '<div class="col-lg-2 col-xs-2"><div class="zero-m"><img style="border-radius:10%;margin-left: auto;margin-right: auto;display: block;" height="50px" src="https://image.tmdb.org/t/p/w150'+value['profile_path']+'" alt="profile"><h5 class="text-center"><strong>'+value['name']+'</strong></h5><h6 class="text-center">'+value['character']+'</h6></div></div>';
+                            count++;
+                        }
+                    }
+                });
+                return result;
+            }
             function whatIsIt(a){
                 var what = Object.prototype.toString;
                 if(what.call(a) == "[object Array]"){
@@ -890,7 +907,7 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                         if( data.trakt ) {                        
                             $.ajax({
                                 type: 'GET',
-                                url: 'https://api.themoviedb.org/3/tv/'+data.trakt.tmdb+'?api_key=83cf4ee97bb728eeaf9d4a54e64356a1&append_to_response=videos',
+                                url: 'https://api.themoviedb.org/3/tv/'+data.trakt.tmdb+'?api_key=83cf4ee97bb728eeaf9d4a54e64356a1&append_to_response=videos,credits',
                                 cache: true,
                                 async: true,
                                 complete: function(xhr, status) {
@@ -903,6 +920,7 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                                         $('#calendarSummary').text(result.overview);
                                         $('#calendarTagline').text("");
                                         $('#calendarTrailer').html(convertTrailer(result.videos));
+                                        $('#calendarCast').html(convertCast(result.credits));
                                         $('#calendarGenres').html(convertArray(result.genres, "MOVIE"));
                                         $('#calendarLang').html(convertArray(result.languages, "TV"));
                                         $('#calendarPoster').attr("src","https://image.tmdb.org/t/p/w300"+result.poster_path);
@@ -918,6 +936,7 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                             $('#calendarSummary').text(data.series.overview);
                             $('#calendarTagline').text("");
                             $('#calendarTrailer').html("");
+                            $('#calendarCast').html("");
                             $('#calendarGenres').html(convertArray(data.series.genre, "TV"));
                             $('#calendarLang').html("");
                             $('#calendarPoster').attr("src","https://thetvdb.com/banners/_cache/"+whatIsIt(data.poster));
@@ -929,12 +948,13 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                     var type = "MOVIE";
                     $.ajax({
                         type: 'GET',
-                        url: 'https://api.themoviedb.org/3/movie/'+ID+'?api_key=83cf4ee97bb728eeaf9d4a54e64356a1&append_to_response=videos',
+                        url: 'https://api.themoviedb.org/3/movie/'+ID+'?api_key=83cf4ee97bb728eeaf9d4a54e64356a1&append_to_response=videos,credits',
                         cache: true,
                         async: true,
                         complete: function(xhr, status) {
                             var result = $.parseJSON(xhr.responseText);
                             console.log(result);
+                            console.log(convertCast(result.credits));
                             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;');
@@ -942,6 +962,7 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                                 $('#calendarSummary').text(result.overview);
                                 $('#calendarTagline').text(result.tagline);
                                 $('#calendarTrailer').html(convertTrailer(result.videos));
+                                $('#calendarCast').html(convertCast(result.credits));
                                 $('#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);
@@ -964,19 +985,24 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                     </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 class="col-lg-2 col-xs-4">
+                                <img style="width:100%;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="">
                             </div>
-                            <div class="col-lg-8 col-sm-7">
+                            <div class="col-lg-10 col-sm-8">
                                 <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 class="" id="calendarCast">Modal Summary</div>
                             </div>
                         </div>
                     </div>
-                   <div style="position: inherit; padding: 10px 15px 30px 15px; margin-top: -20px;">
-                        <span id="calendarTrailer" class="pull-left"></span>
-                        <span id="calendarLang" class="pull-right"></span>
+                   <div style="position: inherit; padding: 15px 0px 30px 0px; margin-top: -20px;">
+                        <div class="col-lg-2 col-xs-4">
+                            <span id="calendarTrailer" class="pull-left" style="width:100%"></span>
+                        </div> 
+                        <div class="col-lg-10 col-sm-8">   
+                            <span id="calendarLang" class="pull-right"></span>
+                        </div>                        
                     </div>
                 </div>
             </div>

+ 1 - 1
settings.php

@@ -733,7 +733,7 @@ echo buildSettings(
 					),
 					array(
 						'type' => 'text',
-						'placeholder' => "plex",
+						'placeholder' => "Name of Plex Tab i.e. Plex",
 						'labelTranslate' => 'PLEX_TAB_NAME',
 						'name' => 'plexTabName',
 						'value' => PLEXTABNAME,