Explorar o código

Added Version Checker, Settings background color, Speed up resize

causefx %!s(int64=9) %!d(string=hai) anos
pai
achega
4b81b0fb50
Modificáronse 3 ficheiros con 85 adicións e 31 borrados
  1. 28 27
      index.php
  2. 56 3
      settings.php
  3. 1 1
      swap.php

+ 28 - 27
index.php

@@ -194,37 +194,38 @@ foreach ($config as $keyname => $section) {
     }
 
 }
-    if($_COOKIE["logged"] !== $cookiepass){
-        $lasttablist .= "<li><a>Login" . $guesticons . "</a></li>\n";
+
+if($_COOKIE["logged"] !== $cookiepass){
+    $lasttablist .= "<li><a>Login" . $guesticons . "</a></li>\n";
+    $lasttaburl .= "<div class=\"z-nopadding\" data-content-url=\"setup.php\" data-content-type=\"iframe\"></div>\n";
+    $defaulttab = $defaulttabguest;
+}
+
+if($_COOKIE["logged"] == $cookiepass){
+
+    if($groupCount > 1){
+
+        $lasttablist .= "<li class=\"donthide\"><a>Settings" . $adminicons . "</a></li><li class=\"donthide\"><a class=\"swapGroup\">Swap Group" . $swapicons . "</a></li>\n";
         $lasttaburl .= "<div class=\"z-nopadding\" data-content-url=\"setup.php\" data-content-type=\"iframe\"></div>\n";
-        $defaulttab = $defaulttabguest;
-    }
+        $lasttaburl .= "<div class=\"z-nopadding\" data-content-url=\"swap.php\" data-content-type=\"iframe\"></div>\n";
 
-    if($_COOKIE["logged"] == $cookiepass){
-        
-        if($groupCount > 1){
-            
-            $lasttablist .= "<li class=\"donthide\"><a>Settings" . $adminicons . "</a></li><li class=\"donthide\"><a class=\"swapGroup\">Swap Group" . $swapicons . "</a></li>\n";
-            $lasttaburl .= "<div class=\"z-nopadding\" data-content-url=\"setup.php\" data-content-type=\"iframe\"></div>\n";
-            $lasttaburl .= "<div class=\"z-nopadding\" data-content-url=\"swap.php\" data-content-type=\"iframe\"></div>\n";
-            
-        }elseif(!isset($groupCount) || $groupCount == 1){
-            
-            $lasttablist .= "<li class=\"donthide\"><a>Settings" . $adminicons . "</a></li>\n";
-            $lasttaburl .= "<div class=\"z-nopadding\" data-content-url=\"setup.php\" data-content-type=\"iframe\"></div>\n";
-            
-        }
-        
-        
-        $defaulttab = $defaulttabuser;
-    }
+    }elseif(!isset($groupCount) || $groupCount == 1){
+
+        $lasttablist .= "<li class=\"donthide\"><a>Settings" . $adminicons . "</a></li>\n";
+        $lasttaburl .= "<div class=\"z-nopadding\" data-content-url=\"setup.php\" data-content-type=\"iframe\"></div>\n";
 
-    if(!file_exists('settings.ini.php')){
-        $lasttablist = "<li><a>Setup<span><i class=\"fa fa-spinner\"></i></span></a></li>\n";
-        $lasttaburl = "<div class=\"z-nopadding\" data-content-url=\"setup.php\" data-content-type=\"iframe\"></div>\n";
     }
 
-    if(empty($defaulttab)){ $defaulttab = "tab1";}
+
+    $defaulttab = $defaulttabuser;
+}
+
+if(!file_exists('settings.ini.php')){
+    $lasttablist = "<li><a>Setup<span><i class=\"fa fa-spinner\"></i></span></a></li>\n";
+    $lasttaburl = "<div class=\"z-nopadding\" data-content-url=\"setup.php\" data-content-type=\"iframe\"></div>\n";
+}
+
+if(empty($defaulttab)){ $defaulttab = "tab1";}
 
 ?>
 
@@ -445,7 +446,7 @@ foreach ($config as $keyname => $section) {
         
         <script>           
 
-            $(window).load(function(){
+            $(window).ready(function(){
             
                 var countTabs = $("ul").find(".1, .donthide").length;
 

+ 56 - 3
settings.php

@@ -12,9 +12,60 @@ try {
 
 }
 
+function githubVersion (){
+    
+    $html = "https://github.com/causefx/iDashboard-PHP/releases/latest";
+    
+    $doc = new DOMDocument();
+    
+    $doc->loadHTMLFile($html);
+    
+    $xpath = new DomXpath($doc);
+
+    $version = $xpath->query('//span[@class="css-truncate-target"]')->item(0)->nodeValue;
+    
+    if(!isset($version)){
+
+        $version = "null";
+    }
+    
+    return $version;
+        
+}
+
+$githubVersion = githubVersion();
+
 foreach ($config as $keyname => $section) {
     
-    if(($keyname == "general")) {$cookiepass = $section["password"];}
+    if(($keyname == "general")) {
+        
+        $cookiepass = $section["password"];
+    
+        $currentVersion = $section["version"];
+        
+        $backgroundColor = $section["tabcolor"];
+    
+    }
+    
+}
+
+if($currentVersion == $githubVersion){
+    
+    $versionText = "You're Up-To-Date!";
+    $versionIcon = "check";
+    $versionColor = "#5cb85c";
+    
+}elseif($githubVersion == "null"){
+    
+    $versionText = "Failed to check for update!";
+    $versionIcon = "question";
+    $versionColor = "#f0ad4e";
+    
+}elseif($currentVersion < $githubVersion){
+    
+    $versionText = "New Version is out <a href=\"https://github.com/causefx/iDashboard-PHP/archive/master.zip\"> Download Here</a>";
+    $versionIcon = "times";
+    $versionColor = "#d9534f";
     
 }
 
@@ -170,7 +221,7 @@ if(array_key_exists('category-0', $_POST) == true){
             
             body {
                 margin: 10px;
-                background-color: #eee;
+                background-color: <?=$backgroundColor;?>;
             }
             
             .well {
@@ -257,9 +308,11 @@ if(array_key_exists('category-0', $_POST) == true){
             
                 if(($keyname == "general")) {
                     
-                    echo"<div id=\"general\" class=\"collapse\">";
+                    echo "<div id=\"general\" class=\"collapse\">";
+                    echo "<div class=\"form-group clearfix well well-sm\" style=\"padding-bottom: 0px;p adding-top: 10px; margin-bottom: 5px; background-color: $versionColor\"><span class=\"btn btn-inactive \" type=\"button\"><span class=\"fa fa-$versionIcon\"></span></span> Current Version:[<strong>$currentVersion</strong>] - GitHub Version: [<strong>" . $githubVersion . "</strong>] - <strong>$versionText</strong></div>  <br>";
                     echo "<div class=\"form-group clearfix well well-sm\" style=\"padding-bottom: 0px; padding-top: 10px; margin-bottom: 5px;\">";
                     echo "<input type=\"hidden\" name=\"category-0\" class=\"form-control\" value=\"general\">";
+                    echo "<input type=\"hidden\" name=\"version-0\" class=\"form-control\" value=\"1.00\">";
                     echo "<span class=\"btn btn-inactive \" type=\"button\"><span class=\"fa fa-cog\"></span></span> ";
                     echo "<div style=\"margin-bottom: 8px\" class=\"input-group\"><div class=\"input-group-addon\">Title</div>";
                     echo "<input style=\"margin-bottom: 0px\" type=\"text\" name=\"title-0\" class=\"form-control\" value=\"" . $section["title"] ."\"></div> ";

+ 1 - 1
swap.php

@@ -38,7 +38,7 @@
 
             <div>
 
-                <p>You can click Swap Group again to go the next Group or back to the pervious group id you only have 2 groups.</p>
+                <p>You can click Swap Group again to go the next Group or back to the pervious group if you only have 2 groups.</p>
 
                 <p>&mdash; CauseFX</p>