Procházet zdrojové kódy

Merge pull request #532 from causefx/develop

Develop
causefx před 9 roky
rodič
revize
3614954cd9
6 změnil soubory, kde provedl 147 přidání a 16 odebrání
  1. 36 0
      api.php
  2. 1 0
      config/configDefaults.php
  3. 10 7
      functions.php
  4. 7 7
      homepage.php
  5. 87 2
      index.php
  6. 6 0
      settings.php

+ 36 - 0
api.php

@@ -0,0 +1,36 @@
+<?php
+// Include functions
+require_once('functions.php');
+// Lazyload settings
+$databaseConfig = configLazy('config/config.php');
+// Get Action
+if (isset($_POST['a'])) { $action = $_POST['a']; }
+if (isset($_POST['k'])) { $key = $_POST['k']; }
+if (isset($_GET['a'])) { $action = $_GET['a']; }
+if (isset($_GET['k'])) { $key = $_GET['k']; }
+unset($_POST['a']);
+unset($_POST['k']);
+//Set Default Result
+$result = "An error has occurred";
+//Check Key
+if (!isset($key)) {
+    exit(json_encode("No API Key set"));
+}elseif (strtolower(ORGANIZRAPI) != strtolower($key)) {
+    exit(json_encode("API Key mismatch"));
+}
+//Start API Call
+if (isset($action)) {
+    switch ($action) {
+        case "1":
+            $result = "test";
+            break;
+        case "2":
+            $result = "other test";
+            break;
+        default:
+            $result = "$action not defined";
+    }
+}
+//return JSON array
+exit(json_encode($result));
+?>

+ 1 - 0
config/configDefaults.php

@@ -90,4 +90,5 @@ return array(
 	"historyRefresh" => "120000",
 	"downloadRefresh" => "30000",
 	"organizrAPI" => "",
+	"splash" => "false",
 );

+ 10 - 7
functions.php

@@ -686,7 +686,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
                 $thumb = $item['art'];
                 $key = $item['ratingKey'] . "-np";
                 $elapsed = $item['viewOffset'];
-                $duration = $item['duration'];
+                $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
                 $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
                 $transcoded = floor($item->TranscodeSession['progress']- $watched);
                 $stream = $item->Media->Part->Stream['decision'];
@@ -717,7 +717,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
                 $thumb = $item['art'];
                 $key = $item['ratingKey'] . "-np";
                 $elapsed = $item['viewOffset'];
-                $duration = $item['duration'];
+                $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
                 $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
                 $transcoded = floor($item->TranscodeSession['progress']- $watched);
                 $stream = $item->Media->Part->Stream['decision'];
@@ -753,7 +753,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
 				$useImage = (isset($item['live']) ? "images/livetv.png" : null);
 				$extraInfo = isset($item['extraType']) ? "Trailer" : (isset($item['live']) ? "Live TV" : ":)");
                 $elapsed = $item['viewOffset'];
-                $duration = $item['duration'];
+                $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
                 $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
                 $transcoded = floor($item->TranscodeSession['progress']- $watched);
                 $stream = $item->Media->Part->Stream['decision'];
@@ -789,7 +789,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
                 $thumb = $item['art'];
                 $key = $item['ratingKey'] . "-np";
                 $elapsed = $item['viewOffset'];
-                $duration = $item['duration'];
+                $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
                 $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
                 $transcoded = floor($item->TranscodeSession['progress']- $watched);
                 $stream = $item->Media->Part->Stream['decision'];
@@ -822,7 +822,7 @@ function resolvePlexItem($server, $token, $item, $nowPlaying = false, $showNames
                 $thumb = $item['art'];
                 $key = $item['ratingKey'] . "-np";
                 $elapsed = $item['viewOffset'];
-                $duration = $item['duration'];
+                $duration = ($item['duration']) ? $item['duration'] : $item->Media['duration'];
                 $watched = (!empty($elapsed) ? floor(($elapsed / $duration) * 100) : 0);
                 $transcoded = floor($item->TranscodeSession['progress']- $watched);
                 $stream = $item->Media->Part->Stream['decision'];
@@ -2909,7 +2909,7 @@ function getHeadphonesCalendar($url, $key, $list){
 				$i++;
 				$albumName = addslashes($child['AlbumTitle']);
 				$albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
-				$albumDate = $child['ReleaseDate'];
+				$albumDate = (strlen($child['ReleaseDate']) > 4) ? $child['ReleaseDate'] : $child['ReleaseDate']."-01-01";
 				$albumID = $child['AlbumID'];
 				$albumDate = strtotime($albumDate);
 				$albumDate = date("Y-m-d", $albumDate);
@@ -2923,7 +2923,10 @@ function getHeadphonesCalendar($url, $key, $list){
 			}
 			if($child['Status'] == "Processed" && $list == "getHistory"){
 				$i++;
-				$albumName = addslashes($child['Title']);
+				$find = array('_','[', ']', '\n');
+				$replace = array(' ','(', ')', ' ');
+				$albumName = addslashes(str_replace($find,$replace,$child['FolderName']));
+				//$albumName = addslashes($child['Title']);
 				$albumDate = $child['DateAdded'];
 				$albumID = $child['AlbumID'];
 				$albumDate = strtotime($albumDate);

+ 7 - 7
homepage.php

@@ -989,7 +989,7 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                                         $('#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);
-                                        $('#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;");
+                                        $('#calendarMain').attr("style","background-size: cover; background: linear-gradient(rgba(25,27,29,.75),rgba(25,27,29,.75)),url(https://image.tmdb.org/t/p/w1000"+result.backdrop_path+");top: 0;left: 0;width: 100%;height: 100%;position: fixed;");
                                         $('#calendarExtra').modal('show');
                                     }
                                 }
@@ -1005,7 +1005,7 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                             $('#calendarGenres').html(convertArray(data.series.genre, "TV"));
                             $('#calendarLang').html("");
                             $('#calendarPoster').attr("src","https://thetvdb.com/banners/_cache/"+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;");
+                            $('#calendarMain').attr("style","background-size: cover; background: linear-gradient(rgba(25,27,29,.75),rgba(25,27,29,.75)),url(ajax.php?a=show-image&image=http://thetvdb.com/banners/"+whatIsIt(data.backdrop)+");top: 0;left: 0;width: 100%;height: 100%;position: fixed;");
                             $('#calendarExtra').modal('show');
                         }
                     });
@@ -1031,7 +1031,7 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                                 $('#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;");
+                                $('#calendarMain').attr("style","background-size: cover; background: linear-gradient(rgba(25,27,29,.75),rgba(25,27,29,.75)),url(https://image.tmdb.org/t/p/w1000"+result.backdrop_path+");top: 0;left: 0;width: 100%;height: 100%;position: fixed;");
                                 $('#calendarExtra').modal('show');
                             }
                         }
@@ -1050,10 +1050,10 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                     </div>
                     <div class="modal-body">
                         <div class="row">
-                            <div class="col-lg-2 col-xs-4">
+                            <div class="col-sm-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-10 col-sm-8">
+                            <div class="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>
@@ -1062,10 +1062,10 @@ if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
                         </div>
                     </div>
                    <div style="position: inherit; padding: 15px 0px 30px 0px; margin-top: -20px;">
-                        <div class="col-lg-2 col-xs-4">
+                        <div class="col-sm-4">
                             <span id="calendarTrailer" class="pull-left" style="width:100%"></span>
                         </div> 
-                        <div class="col-lg-10 col-sm-8">   
+                        <div class="col-sm-8">   
                             <span id="calendarLang" class="pull-right"></span>
                         </div>                        
                     </div>

+ 87 - 2
index.php

@@ -128,6 +128,7 @@ if (file_exists('config/config.php')) {
         if($USER->authenticated && $USER->role == "admin") :
 
             $result = $file_db->query('SELECT * FROM tabs WHERE active = "true" ORDER BY `order` asc');
+            $splash = $file_db->query('SELECT * FROM tabs WHERE active = "true" ORDER BY `order` asc');
             $getsettings = $file_db->query('SELECT * FROM tabs WHERE active = "true" ORDER BY `order` asc');
 
             foreach($getsettings as $row) :
@@ -143,10 +144,12 @@ if (file_exists('config/config.php')) {
         elseif($USER->authenticated && $USER->role == "user") :
 
             $result = $file_db->query('SELECT * FROM tabs WHERE active = "true" AND user = "true" ORDER BY `order` asc');
+            $splash = $file_db->query('SELECT * FROM tabs WHERE active = "true" AND user = "true" ORDER BY `order` asc');
 
         else :
 
             $result = $file_db->query('SELECT * FROM tabs WHERE active = "true" AND guest = "true" ORDER BY `order` asc');
+            $splash = $file_db->query('SELECT * FROM tabs WHERE active = "true" AND guest = "true" ORDER BY `order` asc');
 
         endif;
 
@@ -285,6 +288,23 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
         <![endif]-->
     </head>
     <style>
+        .splash-item {
+            max-width: 100%;
+
+            -moz-transition: all 0.3s;
+            -webkit-transition: all 0.3s;
+            transition: all 0.3s;
+            opacity: .8 !important;
+        }
+        .splash-item:hover {
+            -moz-transform: scale(1.1);
+            -webkit-transform: scale(1.1);
+            transform: scale(1.1);
+            z-index: 10000000;
+            border-radius: 10px;
+            opacity: 1 !important;
+            box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
+        }
         .TabOpened {
             -webkit-filter: drop-shadow(0px 0px 5px <?=$topbartext;?>);
             filter: drop-shadow(0px 0px 5px <?=$topbartext;?>);
@@ -1127,7 +1147,62 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 				</div>
 			</div>
 		</div>
-		<?php } ?>
+        <?php } ?>
+        <?php if (file_exists('config/config.php') && $configReady = "Yes" && $tabSetup == "No" && SPLASH == "true") {?>
+        <div id="splashScreen" class="splash-modal modal fade">
+			<div style="background:<?=$sidebar;?>;" class="table-wrapper big-box">
+				
+                <button style="color:<?=$topbartext;?>;" type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+                <br/><br/>
+                <div class="row">
+                    <div class="col-lg-12">
+                        <div class="row">                      
+                            <?php if($tabSetup == "No") : $tabCount = 1; foreach($splash as $row) : ?>
+                            <div class="col-xs-6 col-sm-4 col-md-3 col-lg-2" id="splash-<?php echo strtolower($row['name']);?>">
+                                <li style="list-style-type: none; cursor: pointer;" window="<?=$row['window'];?>" class="splash-item content-box small-box ultra-widget gray-bg" name="<?php echo strtolower($row['name']);?>">
+                                    <div class="w-content">
+                                        <div class="w-icon">
+                                            <center>
+                                                <?php if($row['iconurl']) : ?>
+                                                    <i style="">
+                                                        <img src="<?=$row['iconurl'];?>" style="height: 100px; margin-top: -10px;" class="">
+                                                    </i>
+                                                <?php else : ?>
+                                                    <i style="padding-bottom: 8px" class="fa <?=$row['icon'];?> fa-sm"></i>
+                                                <?php endif; ?>
+                                            </center>
+                                        </div>
+                                        <div class="text-center"><span class="text-uppercase w-name elip"><?=$row['name'];?></span></div>
+                                    </div>
+                                </li>
+                            </div>
+                            <?php $tabCount++; endforeach; endif;?>  
+                        </div>
+                        <?php if( $USER->authenticated && $USER->role == "admin" ){ ?>
+                        <div class="row">                      
+                            <div class="col-lg-12">
+                                <li style="list-style-type: none; cursor: pointer;" class="splash-item content-box small-box ultra-widget gray-bg" data-title="" name="settings">
+                                    <div class="w-content">
+                                        <div class="w-icon">
+                                            <center>
+                                                <i style="">
+                                                    <img src="images/settings.png" style="height: 100px; margin-top: -10px;" class="">
+                                                </i>
+                                            </center>
+                                        </div>
+                                        <div class="text-center"><span class="text-uppercase w-name elip">Settings</span></div>
+                                    </div>
+                                </li>
+                            </div>
+                        </div>
+                        <?php } ?>
+                    </div>
+                </div>
+			</div>
+        </div>
+        <?php } ?>
 
         <!--Scripts-->
         <script src="<?=$baseURL;?>bower_components/jquery/dist/jquery.min.js"></script>
@@ -1159,7 +1234,9 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
         <script src="js/jquery.mousewheel.min.js" type="text/javascript"></script>
 
         <script>
-
+        <?php if (file_exists('config/config.php') && $configReady = "Yes" && $tabSetup == "No" && SPLASH == "true") {?>    
+        $('.splash-modal').modal("show");
+        <?php } ?>
         var fixed = document.getElementById('gn-scroller');
         fixed.addEventListener('touchmove', function(e) {
 
@@ -1575,6 +1652,14 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
             setHeight();
 
         });
+
+        $("li[class^='splash-item']").on('click vclick', function(){
+            var thisname = $(this).attr("name");
+            var splashTab = $("#tabList li[name^='" + thisname + "']");
+            splashTab.trigger("click");
+            $('.splash-modal').modal("hide");
+
+        });
             
         $("li[class^='tab-item']").on('click vclick', function(){
             var thisidfull = $(this).attr("id");

+ 6 - 0
settings.php

@@ -1546,6 +1546,12 @@ echo buildSettings(
 						),
 					),
 					array(
+                        array(
+							'type' => 'checkbox',
+							'labelTranslate' => 'ENABLE_SPLASH_SCREEN',
+							'name' => 'splash',
+							'value' => SPLASH,
+						),
 						array(
 							'type' => 'checkbox',
 							'labelTranslate' => 'ENABLE_LOADING_SCREEN',