index.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <?php
  2. error_reporting (E_ALL ^ E_NOTICE);
  3. try {
  4. $config = parse_ini_file('settings.ini.php', true);
  5. } catch(Exception $e) {
  6. die('<b>Unable to read config.ini.php. Did you rename it from config.ini.php-example?</b><br><br>Error message: ' .$e->getMessage());
  7. }
  8. $i = 0;
  9. $ii = 0;
  10. foreach ($config as $keyname => $section) {
  11. if(($keyname == "groups")){
  12. if(isset($section['groups'])){
  13. $groupCount = $section['groups'];
  14. }else{
  15. $groupCount = "1";
  16. }
  17. }
  18. }
  19. foreach ($config as $keyname => $section) {
  20. if(($keyname !== "general" && $section["enabled"]=="true")){
  21. $i++;
  22. if(!empty($section["default"]) && $section["default"]=="true"){
  23. $defaulttabuser = "tab$i";
  24. }
  25. }
  26. if(!empty($section["useicons"]) && ($section["useicons"]=="true")){
  27. $icons = "active";
  28. $guesticons = "<span><i class=\"fa fa-toggle-on\"></i></span>";
  29. $adminicons = "<span><i class=\"fa fa-toggle-on\"></i></span>";
  30. $swapicons = "<span><i class=\"fa fa-arrows-h\"></i></span>";
  31. $refreshicons = "<span><i class=\"fa fa-refresh\"></i></span>";
  32. }
  33. if(!empty($section["usemargins"]) && ($section["usemargins"]=="true")){
  34. $margins = "active";
  35. }
  36. if($icons == "active"){
  37. $px = "62px";//80
  38. $pxmobile = "-30px";
  39. }else{
  40. $px = "34px";//50
  41. $pxmobile = "0px";
  42. }
  43. if($margins == "active"){
  44. $marginpx = "10px";
  45. $marginborderpx = "0px";
  46. }else{
  47. $marginpx = "0px";
  48. $marginborderpx = "0px";
  49. }
  50. //Guest
  51. if($_COOKIE["logged"] !== $cookiepass && !empty($section["enabled"]) && ($section["enabled"]=="true") && !empty($section["guest"]) && ($section["guest"]=="true") ) {
  52. if($icons == "active"){ $listicons = "<span><i class=\"fa ". $section["icon"] ."\"></i></span>"; }
  53. $loadedlist .= "<li id=\"". $section["url"] ."x\"><a>" . $keyname . " " . $listicons ."</a></li>\n";
  54. $loadedurls .= "<div class=\"z-nopadding\" data-content-url=\"". $section["url"] ."\" data-content-type=\"iframe\"></div>\n";
  55. if(($keyname !== "general" && !empty($section["enabled"]) && $section["enabled"]=="true" && !empty($section["guest"]) && $section["guest"]=="true")){
  56. $ii++;
  57. if(!empty($section["default"]) && $section["default"]=="true"){
  58. $defaulttabguest = "tab$ii";
  59. }
  60. }
  61. }
  62. if(isset($groupCount)) {
  63. if($icons == "active"){ $listicons = "<span><i class=\"fa ". $section["icon"] ."\"></i></span>"; }
  64. if($_COOKIE["logged"] == $cookiepass){
  65. foreach(range(1,$groupCount) as $index) {
  66. if(!empty($section["enabled"]) && $section["enabled"]=="true" && $section["group"]==$index) {
  67. if($index == 1){
  68. //$loadedlist .= "<variable id=\"$index\">";
  69. $loadedlist .= "<li style=\"display: block\" class=\"" . $section["group"] . "\" id=\"". $section["url"] ."x\"><a>" . $keyname . " " . $listicons ."</a></li>\n";
  70. }elseif($index !== 1 && $index == $index){
  71. $loadedlist .= "<li style=\"display: none\" class=\"" . $section["group"] . "\" id=\"". $section["url"] ."x\"><a>" . $keyname . " " . $listicons ."</a></li>\n";
  72. }
  73. $loadedurls .= "<div class=\"z-nopadding\" data-content-url=\"". $section["url"] ."\" data-content-type=\"iframe\"></div>\n";
  74. //echo "2nd . Name is $keyname Group Count is $groupCount and index is $index\n";
  75. }
  76. }
  77. }
  78. }else{
  79. //Full Access - Now with groups!
  80. if($_COOKIE["logged"] == $cookiepass && !empty($section["enabled"]) && ($section["enabled"]=="true")) {
  81. if($icons == "active"){ $listicons = "<span><i class=\"fa ". $section["icon"] ."\"></i></span>"; }
  82. $loadedlist .= "<li group=\"" . $section["group"] . "\" id=\"". $section["url"] ."x\"><a>" . $keyname . " " . $listicons ."</a></li>\n";
  83. $loadedurls .= "<div group=\"" . $section["group"] . "\" class=\"z-nopadding\" data-content-url=\"". $section["url"] ."\" data-content-type=\"iframe\"></div>\n";
  84. }
  85. }
  86. //General
  87. if (empty($title)) $title = 'Manage My HTPC';
  88. if(($keyname == "general")) {
  89. $title = $section["title"];
  90. $tabcoloractive = $section["tabcoloractive"];
  91. $fontcoloractive = $section["fontcoloractive"];
  92. $tabcolor = $section["tabcolor"];
  93. $fontcolor = $section["fontcolor"];
  94. $tabshadowactive = $section["tabshadowactive"];
  95. $tabshadow = $section["tabshadow"];
  96. $cookiepass = $section["password"];
  97. $bg = $section["bg"];
  98. $tabborder = $section["tabborder"];
  99. $tabhighlight = $section["tabhighlight"];
  100. }
  101. }
  102. if($_COOKIE["logged"] !== $cookiepass){
  103. $lasttablist .= "<li><a>Login" . $guesticons . "</a></li>\n";
  104. $lasttaburl .= "<div class=\"z-nopadding\" data-content-url=\"setup.php\" data-content-type=\"iframe\"></div>\n";
  105. $defaulttab = $defaulttabguest;
  106. }
  107. if($_COOKIE["logged"] == $cookiepass){
  108. if($groupCount > 1){
  109. $lasttablist .= "<li class=\"donthide\"><a>Settings" . $adminicons . "</a></li><li class=\"donthide\"><a class=\"swapGroup\">Swap Group" . $swapicons . "</a></li>\n";
  110. $lasttaburl .= "<div class=\"z-nopadding\" data-content-url=\"setup.php\" data-content-type=\"iframe\"></div>\n";
  111. $lasttaburl .= "<div class=\"z-nopadding\" data-content-url=\"swap.php\" data-content-type=\"iframe\"></div>\n";
  112. }elseif(!isset($groupCount) || $groupCount == 1){
  113. $lasttablist .= "<li class=\"donthide\"><a>Settings" . $adminicons . "</a></li>\n";
  114. $lasttaburl .= "<div class=\"z-nopadding\" data-content-url=\"setup.php\" data-content-type=\"iframe\"></div>\n";
  115. }
  116. $defaulttab = $defaulttabuser;
  117. }
  118. if(!file_exists('settings.ini.php')){
  119. $lasttablist = "<li><a>Setup<span><i class=\"fa fa-spinner\"></i></span></a></li>\n";
  120. $lasttaburl = "<div class=\"z-nopadding\" data-content-url=\"setup.php\" data-content-type=\"iframe\"></div>\n";
  121. }
  122. if(empty($defaulttab)){ $defaulttab = "tab1";}
  123. ?>
  124. <!doctype html>
  125. <html class="z-white z-width1200">
  126. <head>
  127. <title><?=$title;?></title>
  128. <meta charset="utf-8">
  129. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  130. <meta name="apple-mobile-web-app-capable" content="yes" />
  131. <meta name="mobile-web-app-capable" content="yes" />
  132. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  133. <meta name="msapplication-tap-highlight" content="no" />
  134. <link rel="apple-touch-icon" sizes="180x180" href="fav/apple-touch-icon.png">
  135. <link rel="icon" type="image/png" href="fav/favicon-32x32.png" sizes="32x32">
  136. <link rel="icon" type="image/png" href="fav/favicon-16x16.png" sizes="16x16">
  137. <link rel="manifest" href="fav/manifest.json">
  138. <link rel="mask-icon" href="fav/safari-pinned-tab.svg" color="#369c15">
  139. <link rel="shortcut icon" href="fav/favicon.ico">
  140. <meta name="msapplication-config" content="fav/browserconfig.xml">
  141. <meta name="theme-color" content="#ffffff">
  142. <link href="css/min.css" rel="stylesheet" />
  143. <link href="css/tabs.min.css" rel="stylesheet" />
  144. <script src="js/jquery.min.js"></script>
  145. <script src="js/tabs.min.js"></script>
  146. <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'>
  147. <style>
  148. .z-tabs.white.z-bordered > ul > li.z-active > a {color: <?=$fontcoloractive;?>; background-color: <?=$tabcoloractive;?>; text-shadow: 0 1px <?=$tabshadowactive;?>;}
  149. .z-tabs.horizontal.responsive > ul > li > a, .z-tabs.horizontal.top-compact > ul > li > a, .z-tabs.horizontal.bottom-compact > ul > li > a, .z-tabs.horizontal.top-center > ul > li > a, .z-tabs.horizontal.bottom-center > ul > li > a { color: <?=$fontcolor;?>; background-color: <?=$tabcolor;?>; text-shadow: 0 1px <?=$tabshadow;?>;}
  150. .z-tabs.mobile {position: absolute;top: 0;bottom: 0;left: 0;right: 0;overflow: overlay;}
  151. .z-tabs.white > ul, .z-tabs.white > ul > li > a, .z-tabs.white > .z-container {border-color: <?=$tabborder;?>;}
  152. .z-tabs.horizontal.top.white.z-bordered > ul > li.z-active > a { border-top: 2px solid <?=$tabhighlight;?>; }
  153. </style>
  154. <script>
  155. sessionStorage.currentGroup = 1;
  156. $(document).ready(function(){
  157. $("li").dblclick(function(){
  158. var frame = this.id.slice(0, -1);
  159. var f = document.getElementById(frame);
  160. f.src = f.src;
  161. });
  162. });
  163. </script>
  164. </head>
  165. <body style="position: fixed; top: 0; right: 0; bottom: 0; left: 0; background-color: <?=$bg;?>; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; overflow: hidden;">
  166. <!--<span>&nbsp;</span>-->
  167. <div id="page" style="margin: <?=$marginpx;?>; position: absolute; overflow: hidden;">
  168. <!--Tabs Start-->
  169. <div id="tabbed-nav">
  170. <ul id="grouping">
  171. <?=$loadedlist;?>
  172. <?=$lasttablist;?>
  173. </ul>
  174. <!-- Content container -->
  175. <style>
  176. .z-container { position: absolute; top: 50px; right: 0px; bottom: 0px; left: 0px; margin: <?=$marginpx;?>; }
  177. </style>
  178. <style>
  179. .z-tabs .z-container{ margin: <?=$marginpx;?>; border-width: <?=$marginborderpx;?>; }
  180. </style>
  181. <style>
  182. .z-tabs.mobile.top > .z-container {margin-top: <?=$pxmobile;?>;}
  183. </style>
  184. <style>
  185. .z-video{position: absolute; height: 100%; width: 100%;-webkit-overflow-scrolling: touch; overflow: auto;}
  186. </style>
  187. <style>
  188. .z-content-inner{overflow: hidden;}
  189. </style>
  190. <style>
  191. .z-nopadding.z-content{overflow: hidden}
  192. </style>
  193. <div style="top: <?=$px;?>; overflow: hidden;">
  194. <?=$loadedurls;?>
  195. <?=$lasttaburl;?>
  196. </div>
  197. </div>
  198. <!--Tabs End-->
  199. </div>
  200. <script>
  201. jQuery(document).ready(function ($) {
  202. /* jQuery activation and setting options for the tabs*/
  203. $("#tabbed-nav").zozoTabs({
  204. defaultTab: "<?=$defaulttab;?>",
  205. multiline: true,
  206. theme: "white",
  207. position: "top-compact",
  208. size: "mini",
  209. animation: {
  210. easing: "easeInOutExpo",
  211. duration: 450,
  212. effects: "fade"
  213. }
  214. });
  215. <?php if(!isset($groupCount)): ?>
  216. $(window).resize(function () {
  217. if (/*_base.lastWindowHeight !== $(window).height() ||*/ _base.lastWindowWidth !== $(window).width()) {
  218. clearInterval(_base.resizeWindowIntervalId);
  219. _base.resizeWindowIntervalId = setTimeout(function () {
  220. _base.lastWindowHeight = $(window).height();
  221. _base.lastWindowWidth = $(window).width();
  222. methods.checkWidth(_base);
  223. }, _base.settings.responsiveDelay);
  224. }
  225. });
  226. <?php endif;?>
  227. });
  228. </script>
  229. <script>
  230. $('.swapGroup').on('click touchstart', function(){
  231. if (typeof sessionStorage.getItem("currentGroup") === 'undefined' || sessionStorage.getItem("currentGroup") === null) {
  232. sessionStorage.currentGroup = 1
  233. currentGroup = 1
  234. }
  235. var currentGroup = sessionStorage.getItem("currentGroup")
  236. if(currentGroup === "<?=$groupCount;?>"){
  237. currentGroup = 0
  238. }
  239. currentGroup ++
  240. $("#grouping li").show()
  241. $("#grouping li").not('.' + currentGroup + ', .donthide').hide();
  242. if($(window).width() > 737){
  243. var countTabs = $("ul").find("." + currentGroup + ", .donthide").length;
  244. var countTabsPercent = 100 / countTabs + '%';
  245. $("ul").find("." + currentGroup + ", .donthide").css({"width": countTabsPercent});
  246. }
  247. sessionStorage.currentGroup = currentGroup
  248. });
  249. </script>
  250. <?php if(isset($groupCount)): ?>
  251. <script>
  252. $(window).ready(function(){
  253. if($(window).width() > 737){
  254. var countTabs = $("ul").find(".1, .donthide").length;
  255. var countTabsPercent = 100 / countTabs + '%';
  256. $("ul").find(".1, .donthide").css({"width": countTabsPercent});
  257. }
  258. });
  259. $(document).ready(function(){
  260. $(window).resize(function(){
  261. var countTabs = $("ul").find(".1, .donthide").length;
  262. var countTabsPercent = 100 / countTabs + '%';
  263. $("ul").find(".1, .donthide").css({"width": countTabsPercent});
  264. });
  265. });
  266. </script>
  267. <?php endif;?>
  268. </body>
  269. </html>