index.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <html>
  2. <head>
  3. <?php
  4. //This folder is used to store all the important information needed for multiple web system booting
  5. $infoFolder = "msbinfo";
  6. if (file_exists($infoFolder . "/") == false){
  7. die("SYSTEM FOLDER NOT FOUND.");
  8. }
  9. echo '<link rel="stylesheet" href="'.$infoFolder.'/tocas.css">';
  10. ?>
  11. <meta name="apple-mobile-web-app-capable" content="yes" />
  12. <meta charset="UTF-8">
  13. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  14. <link rel="stylesheet" href="<?php echo $infoFolder; ?>/tocas.css">
  15. <script src="<?php echo $infoFolder; ?>/jquery.min.js"></script>
  16. <title>IMSB Interface</title>
  17. </head>
  18. <body>
  19. <?php
  20. $save = fopen("$infoFolder/bootinfo.txt", "w") or die("Permission denied! PHP cannot write file to this directory.");
  21. $txt = "last_act=" . time() . "\nrmt_addr=" . $_SERVER['REMOTE_ADDR'] . "\n";
  22. fwrite($save, $txt);
  23. fclose($save);
  24. ?>
  25. <div class="ts centered big menu">
  26. <div class="item">IMUS Multiple System Booting Interface</div>
  27. </div><br>
  28. <div class="ts container">
  29. <div class="ts cards">
  30. <?php
  31. $templateNormal = '<a class="ts card" href="%REDIRECT%">
  32. <div class="image">
  33. <img src="%MODULE_PIC%">
  34. <div class="header">
  35. %MODULE_NAME%
  36. <div class="sub header">%MODULE_DESC%</div>
  37. </div>
  38. </div>
  39. </a>';
  40. $templateVideo = '<a class="ts card" href="%REDIRECT%">
  41. <div class="video">
  42. <div class="ts 1:1 active embed">
  43. <video src="%VIDEO_PATH%" autoplay muted loop></video>
  44. </div>
  45. <div class="header">
  46. %MODULE_NAME%
  47. <div class="sub header">%MODULE_DESC%</div>
  48. </div>
  49. </div>
  50. </a>';
  51. //Building non-system directories list
  52. $skippingDirectory = [];
  53. array_push($skippingDirectory,$infoFolder);
  54. $skipItems = file_get_contents($infoFolder."/non-system_list.txt") or die("Missing $infoFolder/non-system_list.txt");
  55. $skipItems = explode("\n",$skipItems);
  56. foreach ($skipItems as $dir){
  57. if (substr($dir,0,2) != "//" && $dir != ""){
  58. //Not commented items
  59. array_push($skippingDirectory,trim($dir));
  60. }
  61. }
  62. //Generating System List
  63. $systems = array_filter(glob('*'), 'is_dir');
  64. foreach ($systems as $system){
  65. if (in_array($system,$skippingDirectory) == false){
  66. if (file_exists($system . "/msb/card.mp4") == false){
  67. $box = str_replace("%REDIRECT%",$system . "/",$templateNormal);
  68. if (file_exists($system . "/msb/card.png") == true){
  69. //Module msb supporting profile pic found
  70. $box = str_replace("%MODULE_PIC%",$system . "/msb/card.png",$box);
  71. }else{
  72. //Module msb supporting profile pic not found, use default
  73. $box = str_replace("%MODULE_PIC%","$infoFolder/unknown_module.png",$box);
  74. }
  75. }else{
  76. //Video found, use video as profile pic
  77. $box = str_replace("%REDIRECT%",$system . "/",$templateVideo);
  78. $box = str_replace("%VIDEO_PATH%",$system . "/msb/card.mp4",$box);
  79. }
  80. if (file_exists($system . "/msb/") == true){
  81. //This system support multiple system booting
  82. if (file_exists($system . "/msb/bootConfig.txt")){
  83. //Config exists, use config's data as template
  84. $content = file_get_contents($system . "/msb/bootConfig.txt");
  85. $content = explode("\n",$content);
  86. $btarget = "index.php";
  87. $displayName = $system;
  88. $desc = "N/A";
  89. foreach ($content as $setting){
  90. if (strpos($setting,"bootTarget=") !== false){
  91. $btarget = $system . "/" . str_replace("bootTarget=","",$setting);
  92. }else if (strpos($setting,"displayName=") !== false){
  93. $displayName = str_replace("displayName=","",$setting);
  94. }else if (strpos($setting,"description=") !== false){
  95. $desc = str_replace("description=","",$setting);
  96. }
  97. }
  98. $box = str_replace('href="'.$system.'/"','href="'.$btarget.'"',$box);
  99. $box = str_replace("%MODULE_NAME%",$displayName,$box);
  100. $box = str_replace("%MODULE_DESC%",$desc,$box);
  101. echo $box;
  102. }else{
  103. //Config not exists, use default values
  104. $box = str_replace("%MODULE_NAME%","$system",$box);
  105. $box = str_replace("%MODULE_DESC%","This module has no information readable by Multi System Booting Interface Utilities.",$box);
  106. echo $box;
  107. }
  108. }else{
  109. //This system do not support multiple system booting
  110. $box = str_replace("%REDIRECT%",$system . "/",$templateNormal);
  111. $box = str_replace("%MODULE_PIC%","$infoFolder/unknown_module.png",$box);
  112. $box = str_replace("%MODULE_NAME%","$system",$box);
  113. $box = str_replace("%MODULE_DESC%","This module has no information readable by Multi System Booting Interface Utilities.",$box);
  114. echo $box;
  115. }
  116. }
  117. }
  118. ?>
  119. </div>
  120. </div>
  121. <div style=" position: fixed;
  122. z-index: 100;
  123. bottom: 0;
  124. left: 0;
  125. width: 100%;
  126. background-color:#828282;color:white;" align="right">
  127. CopyRight IMUS Laboratory 2017-2018
  128. </div>
  129. <script>
  130. /*
  131. var AOB = <?php echo file_exists("AOB/");?>;
  132. var cancel = false;
  133. if (AOB == true){
  134. setTimeout(function() {
  135. if (cancel == false){
  136. window.location.href = "AOB/index.php";
  137. }
  138. }, 1000);
  139. }
  140. $(document).keypress(function(e) {
  141. if(e.which == 13) {
  142. cancel = true;
  143. console.log("Auto-boot canceled");
  144. }
  145. });
  146. */
  147. </script>
  148. </body>
  149. </html>