bgworker.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. include '../auth.php';
  3. ?>
  4. <!DOCTYPE html>
  5. <br>
  6. <?php
  7. function formatSizeUnits($bytes)
  8. {
  9. if ($bytes >= 1073741824)
  10. {
  11. $bytes = number_format($bytes / 1073741824, 2) . ' GB';
  12. }
  13. elseif ($bytes >= 1048576)
  14. {
  15. $bytes = number_format($bytes / 1048576, 2) . ' MB';
  16. }
  17. elseif ($bytes >= 1024)
  18. {
  19. $bytes = number_format($bytes / 1024, 2) . ' KB';
  20. }
  21. elseif ($bytes > 1)
  22. {
  23. $bytes = $bytes . ' bytes';
  24. }
  25. elseif ($bytes == 1)
  26. {
  27. $bytes = $bytes . ' byte';
  28. }
  29. else
  30. {
  31. $bytes = '0 bytes';
  32. }
  33. return $bytes;
  34. }
  35. ?>
  36. <div class="ts small attached segmented single line selection items">
  37. <?php if(isset($_GET['share']) && $_GET['share'] != "" && isset($_GET['display']) && $_GET['display'] != "" & isset($_GET['id']) && $_GET['id'] != ""){
  38. $shareMode = true;
  39. }else{
  40. $shareMode = false;
  41. }
  42. ?>
  43. <script>
  44. <?php
  45. if ($shareMode){
  46. echo 'var ShareMode = true;';
  47. echo 'var ShareSong = ["'.$_GET['share'].'","'.$_GET['display'].'",'. $_GET['id'] .']';
  48. }else{
  49. echo 'var ShareMode = false;';
  50. }
  51. ?>
  52. </script>
  53. <!-- Audio Control System with no HTML5 Audio Attribute-->
  54. <div class="ts fluid container" style="cursor: pointer;">
  55. <div id="audio_attr"style="display:none;">
  56. <audio id="player" controls autoplay style="display:none;">
  57. <source src="" type="audio/mpeg">
  58. Your browser does not support the audio element.
  59. </audio>
  60. </div>
  61. <div id="YamiPlayer" class="content">
  62. <div id="songname" class="ts top attached segment">
  63. NOW PLAYING ||
  64. </div>
  65. <div id="progressbardiv" class="ts attached progress">
  66. <div id="audioprogress" class="bar" style="width: 0%"></div>
  67. </div>
  68. <div class="ts bottom attached segment">
  69. <div class="ts icon buttons">
  70. <button class="ts mini button" onclick="PreviousSong()"><i class="step backward icon"></i></button>
  71. <button class="ts mini button" onclick="playbtn()"><i id='playbtn' class="pause icon"></i></button>
  72. <button class="ts mini button" onclick="NextSong()"><i class="step forward icon"></i></button>
  73. <button class="ts mini button" onclick="stopbtn()"><i class="stop icon"></i></button>
  74. <button class="ts mini button" onclick="volDown()"><i class="volume down icon"></i></button>
  75. <button class="ts mini button" onclick="volUp()"><i class="volume up icon"></i></button>
  76. <button class="ts mini button" onclick="repeatmode()"><i class="repeat icon"></i></button>
  77. </div>
  78. <span>
  79. <i id="voldis" class="volume off icon"> 100%</i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  80. <i id="timecode" class="time icon"> 0:00/0:00</i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  81. <i id="repmode" class="repeat icon"> Single</i>
  82. </span>
  83. </div>
  84. <!-- <button class="ts button" onclick="Show_Audio_Attrubute()">Show HTML5 Attrubute</button> -->
  85. </div>
  86. </div>
  87. <?php
  88. $template = '<div href="" id="%ID%" class="ts item" onclick="PlaySong('."'".'%RAW_FILENAME%'."','" .'%AUDIO_FILE_NAME%'."','".'%ID%'."'".')">
  89. <div>
  90. <i class="big file audio outline icon"></i>
  91. </div>
  92. <div class="content">
  93. <div class="header">%AUDIO_FILE_NAME%</div>
  94. <div class="middoted meta">
  95. <div>%FILE_SIZE%</div>
  96. </div>
  97. </div>
  98. </div>';
  99. $files = array();
  100. $filepath = "uploads/";
  101. foreach (glob($filepath . "*.mp3") as $file) {
  102. if(strpos($file,'inith') !== false){
  103. $files[] = $file;
  104. }
  105. }
  106. $count = 0;
  107. $songlist = [];
  108. $keyword = "";
  109. if(isset($_GET['search']) == true && $_GET['search'] != ""){
  110. $keyword = $_GET['search'];
  111. $loweredkeyword = mb_strtolower($keyword);
  112. foreach($files as $file) {
  113. $ext = pathinfo($file, PATHINFO_EXTENSION);
  114. $filename = str_replace("." . $ext,"",str_replace("inith","",basename($file)));
  115. $filename = hex2bin($filename);
  116. if (strpos(mb_strtolower($filename),$loweredkeyword) !== false){
  117. array_push($songlist,[$file,$filename,$count]);
  118. $box = str_replace("%AUDIO_FILE_NAME%",$filename,$template);
  119. $box = str_replace("%FILE_SIZE%",formatSizeUnits(filesize($file)),$box);
  120. $box = str_replace("%RAW_FILENAME%",$file,$box);
  121. $box = str_replace("%ID%","AudioID" + (string)$count,$box);
  122. echo $box;
  123. $count += 1;
  124. }
  125. }
  126. if ($count == 0){
  127. //No Search Results
  128. echo '<div class="ts item">
  129. <div>
  130. <i class="big plus square outline icon"></i>
  131. </div>
  132. <div class="content">
  133. <div class="header">No matched search results.</div>
  134. <div class="middoted meta">
  135. <div>Maybe you can try upload some new audio files?<br>
  136. <a href="../Upload Manager/upload_interface.php?target=Audio&reminder=This module only allow mp3 or mp4 uploads.&filetype=mp3,mp4&finishing=ffmpeg_converter.php">Upload</a>
  137. </div>
  138. </div>
  139. </div>
  140. </div>';
  141. }
  142. }else{
  143. foreach($files as $file) {
  144. $ext = pathinfo($file, PATHINFO_EXTENSION);
  145. $filename = str_replace("." . $ext,"",str_replace("inith","",basename($file)));
  146. $filename = hex2bin($filename);
  147. array_push($songlist,[$file,$filename,$count]);
  148. $box = str_replace("%AUDIO_FILE_NAME%",$filename,$template);
  149. $box = str_replace("%FILE_SIZE%",formatSizeUnits(filesize($file)),$box);
  150. $box = str_replace("%RAW_FILENAME%",$file,$box);
  151. $box = str_replace("%ID%","AudioID" + (string)$count,$box);
  152. echo $box;
  153. $count += 1;
  154. }
  155. }
  156. ?>
  157. <div class="ts fluid container">
  158. <br><br><br><br><br>
  159. </div>
  160. <script type="text/javascript">
  161. var songlist = <?php echo json_encode($songlist); ?>;
  162. var search_keyword = "<?php echo $keyword;?>";
  163. </script>
  164. </div>
  165. <div class="ts top left attached label" style="background-color:#444444;color:white;">Audio Module / Background Worker Unit</div>
  166. </html>