index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <?php
  2. include '../auth.php';
  3. if (!file_exists("uploads/")){
  4. mkdir("uploads/");
  5. }
  6. ?>
  7. <!DOCTYPE html>
  8. <meta name="apple-mobile-web-app-capable" content="yes" />
  9. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=0.8, maximum-scale=0.8"/>
  10. <html>
  11. <head>
  12. <meta charset="UTF-8">
  13. <script type='text/javascript' charset='utf-8'>
  14. // Hides mobile browser's address bar when page is done loading.
  15. window.addEventListener('load', function(e) {
  16. setTimeout(function() { window.scrollTo(0, 1); }, 1);
  17. }, false);
  18. </script>
  19. <title>ArOZ Onlineβ</title>
  20. <link rel="manifest" href="manifest.json">
  21. <link rel="stylesheet" href="../script/tocas/tocas.css">
  22. <script src="../script/tocas/tocas.js"></script>
  23. <script src="../script/jquery.min.js"></script>
  24. <script src="../script/ao_module.js"></script>
  25. <style>
  26. body {
  27. background: rgba(255,255,255,0.7);
  28. }
  29. </style>
  30. </head>
  31. <body><?php
  32. function formatSizeUnits($bytes)
  33. {
  34. if ($bytes >= 1073741824)
  35. {
  36. $bytes = number_format($bytes / 1073741824, 2) . ' GB';
  37. }
  38. elseif ($bytes >= 1048576)
  39. {
  40. $bytes = number_format($bytes / 1048576, 2) . ' MB';
  41. }
  42. elseif ($bytes >= 1024)
  43. {
  44. $bytes = number_format($bytes / 1024, 2) . ' KB';
  45. }
  46. elseif ($bytes > 1)
  47. {
  48. $bytes = $bytes . ' bytes';
  49. }
  50. elseif ($bytes == 1)
  51. {
  52. $bytes = $bytes . ' byte';
  53. }
  54. else
  55. {
  56. $bytes = '0 bytes';
  57. }
  58. return $bytes;
  59. }
  60. ?><div class="ts borderless basic fluid menu">
  61. <?php
  62. $pwa = "false";
  63. if (isset($_GET['mode']) == true && $_GET['mode'] == "fw"){
  64. //Entering float window mode, remove back to index function
  65. echo '<a id="backBtn" href="" class="item">ArOZβ</a>';
  66. }else if (isset($_GET['mode']) == true && $_GET['mode'] == "pwa"){
  67. $pwa = "true";
  68. echo '<a id="backBtn" href="" class="item">ArOZβ</a>';
  69. }else{
  70. echo '<a id="backBtn" href="../index.php" class="item">ArOZβ</a>';
  71. }?>
  72. <div class="header stretched center aligned item">Music Bank</div>
  73. <?php
  74. if (file_exists("../QuickSend/")){
  75. echo '<a class="pwahide item" onClick="share();">
  76. <i class="share alternate icon"></i>
  77. </a>';
  78. }
  79. ?>
  80. </div>
  81. <div class="ts small attached segmented single line selection items">
  82. <?php if(isset($_GET['share']) && $_GET['share'] != "" && isset($_GET['display']) && $_GET['display'] != "" & isset($_GET['id']) && $_GET['id'] != ""){
  83. $shareMode = true;
  84. $externalPlayMode = false;
  85. }else{
  86. $shareMode = false;
  87. }
  88. //Standard ArOZ Online File System calling variable
  89. if(isset($_GET['filepath']) && $_GET['filepath'] != "" && isset($_GET['filename']) && $_GET['filename'] != ""){
  90. $shareMode = true;
  91. $externalPlayMode = true;
  92. }else{
  93. $shareMode = false;
  94. }
  95. ?>
  96. <?php
  97. $SongS = "";
  98. if ($shareMode && $externalPlayMode == false){
  99. $ModeS = "true";
  100. $SongS = json_encode([$_GET['share'],$_GET['display'],$_GET['id']]);
  101. }else if ($shareMode && $externalPlayMode){
  102. $ModeS = "true";
  103. $SongS = json_encode([$_GET['filepath'],$_GET['filename'],-1]);
  104. }else{
  105. $ModeS = "false";
  106. }
  107. ?>
  108. <!-- Audio Control System with no HTML5 Audio Attribute-->
  109. <div class="ts fluid container" style="cursor: pointer;">
  110. <div id="audio_attr"style="display:none;">
  111. <audio id="player" controls autoplay>
  112. <source src="" type="audio/mpeg">
  113. Your browser does not support the audio element.
  114. </audio>
  115. </div>
  116. <div id="YamiPlayer" class="content">
  117. <div id="songname" class="ts top attached segment">
  118. NOW PLAYING ||
  119. </div>
  120. <div id="progressbardiv" class="ts attached progress">
  121. <div id="audioprogress" class="bar" style="width: 0%"></div>
  122. </div>
  123. <div class="ts bottom attached segment">
  124. <div class="ts icon buttons">
  125. <button class="ts button" onclick="PreviousSong()"><i class="step backward icon"></i></button>
  126. <button class="ts button" onclick="playbtn()"><i id='playbtn' class="pause icon"></i></button>
  127. <button class="ts button" onclick="NextSong()"><i class="step forward icon"></i></button>
  128. <button class="ts button" onclick="stopbtn()"><i class="stop icon"></i></button>
  129. <button class="ts button" onclick="volDown()"><i class="volume down icon"></i></button>
  130. <button class="ts button" onclick="volUp()"><i class="volume up icon"></i></button>
  131. <button class="ts button" onclick="repeatmode()"><i class="repeat icon"></i></button>
  132. </div>
  133. <span>
  134. <i id="voldis" class="volume off icon"> 100%</i>      
  135. <i id="timecode" class="time icon"> 0:00/0:00</i>                  
  136. <i id="repmode" class="repeat icon"> Single</i>
  137. </span>
  138. </div>
  139. <!-- <button class="ts button" onclick="Show_Audio_Attrubute()">Show HTML5 Attrubute</button> -->
  140. </div>
  141. </div>
  142. <select id="basedirPath" class="ts fluid tiny basic dropdown">
  143. <option>Internal Storage</option>
  144. <?php
  145. $folders = glob("/media/storage*");
  146. foreach ($folders as $storage){
  147. if (file_exists($storage . "/Audio")){
  148. echo '<option>'.$storage.'</option>';
  149. }
  150. }
  151. ?>
  152. </select>
  153. <!-- Search Bar -->
  154. <div id="searchbar" class="ts fluid container">
  155. <div class="ts fluid icon input">
  156. <input id="sbinput" type="text" placeholder="Search...">
  157. <i class="search icon"></i>
  158. </div>
  159. </div>
  160. <!-- end of search bar-->
  161. <?php
  162. $template = '<div href="" id="%ID%" class="ts item" onclick="PlaySong('."'".'%RAW_FILENAME%'."','" .'%AUDIO_FILE_NAME%'."','".'%ID%'."'".')">
  163. <div>
  164. <i class="big file audio outline icon"></i>
  165. </div>
  166. <div class="content">
  167. <div class="header">%AUDIO_FILE_NAME%</div>
  168. <div class="middoted meta">
  169. <div>%FILE_SIZE% / %FILE_FORMAT%</div>
  170. </div>
  171. </div>
  172. </div>';
  173. $extStorageMode = "false";
  174. $extStorageFolder = "";
  175. $files = array();
  176. $filepath = "uploads/";
  177. foreach (glob($filepath . "*.{mp3,wav,flac,aac}", GLOB_BRACE) as $file) {
  178. $files[] = $file;
  179. }
  180. $count = 0;
  181. $songlist = [];
  182. $keyword = "";
  183. if(isset($_GET['search']) == true && $_GET['search'] != ""){
  184. $keyword = $_GET['search'];
  185. $loweredkeyword = mb_strtolower($keyword);
  186. foreach($files as $file) {
  187. $ext = pathinfo($file, PATHINFO_EXTENSION);
  188. if(substr(basename($file),0,5) === "inith"){
  189. $filename = str_replace("." . $ext,"",str_replace("inith","",basename($file)));
  190. $filename = hex2bin($filename);
  191. }else{
  192. $filename = basename($file);
  193. }
  194. if (strpos(mb_strtolower($filename),$loweredkeyword) !== false){
  195. array_push($songlist,[$file,$filename,$count]);
  196. $box = str_replace("%AUDIO_FILE_NAME%",str_replace("'","",$filename),$template);
  197. $box = str_replace("%FILE_SIZE%",formatSizeUnits(filesize($file)),$box);
  198. $box = str_replace("%RAW_FILENAME%",$file,$box);
  199. $box = str_replace("%ID%","AudioID" + (string)$count,$box);
  200. $box = str_replace("%FILE_FORMAT%",$ext,$box);
  201. echo $box;
  202. $count += 1;
  203. }
  204. }
  205. if ($count == 0){
  206. //No Search Results
  207. echo '<div class="ts item">
  208. <div>
  209. <i class="big plus square outline icon"></i>
  210. </div>
  211. <div class="content">
  212. <div class="header">No matched search results.</div>
  213. <div class="middoted meta">
  214. <div>Maybe you can try upload some new audio files?<br>
  215. <a href="../Upload Manager/upload_interface.php?target=Audio&filetype=mp3,mp4,flac,wav,aac&finishing=ffmpeg_converter.php">Upload</a>
  216. </div>
  217. </div>
  218. </div>
  219. </div>';
  220. }
  221. }elseif (isset($_GET['extstorage']) && $_GET['extstorage'] != "" && !(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')){
  222. //Newly added features in 27-8-2018 for accessing audio in external storage devices
  223. $files = array();
  224. $filepath = "/media/" . $_GET['extstorage'] . "/Audio/";
  225. $extStorageMode = "true";
  226. $extStorageFolder = $_GET['extstorage'];
  227. foreach (glob($filepath . "*.{mp3,wav,flac,aac}", GLOB_BRACE) as $file) {
  228. $files[] = $file;
  229. }
  230. $count = 0;
  231. $songlist = [];
  232. foreach($files as $file) {
  233. $ext = pathinfo($file, PATHINFO_EXTENSION);
  234. if(substr(basename($file),0,5) === "inith"){
  235. $filename = str_replace("." . $ext,"",str_replace("inith","",basename($file)));
  236. $filename = hex2bin($filename);
  237. }else{
  238. $filename = basename($file);
  239. }
  240. array_push($songlist,[$file,$filename,$count]);
  241. $box = str_replace("%AUDIO_FILE_NAME%",str_replace("'","",$filename),$template);
  242. $box = str_replace("%FILE_SIZE%",formatSizeUnits(filesize($file)),$box);
  243. $box = str_replace("%RAW_FILENAME%",$file,$box);
  244. $box = str_replace("%ID%","AudioID" + (string)$count,$box);
  245. $box = str_replace("%FILE_FORMAT%",$ext,$box);
  246. echo $box;
  247. $count += 1;
  248. }
  249. }else{
  250. foreach($files as $file) {
  251. $ext = pathinfo($file, PATHINFO_EXTENSION);
  252. if(substr(basename($file),0,5) === "inith"){
  253. $filename = str_replace("." . $ext,"",str_replace("inith","",basename($file)));
  254. $filename = hex2bin($filename);
  255. }else{
  256. $filename = basename($file);
  257. }
  258. array_push($songlist,[$file,$filename,$count]);
  259. $box = str_replace("%AUDIO_FILE_NAME%",str_replace("'","",$filename),$template);
  260. $box = str_replace("%FILE_SIZE%",formatSizeUnits(filesize($file)),$box);
  261. $box = str_replace("%RAW_FILENAME%",$file,$box);
  262. $box = str_replace("%ID%","AudioID" . ((string)$count),$box);
  263. $box = str_replace("%FILE_FORMAT%",$ext,$box);
  264. echo $box;
  265. $count += 1;
  266. }
  267. }
  268. ?>
  269. <div class="ts fluid container">
  270. <br><br><br><br><br>
  271. </div>
  272. </div>
  273. <div id="fuctmenu" class="ts mini borderless bottom fixed evenly divided labeled icon menu" style="padding-bottom:8px;">
  274. <a href="../index.php" class="pwa item">
  275. <i class="chevron left icon"></i>
  276. Back
  277. </a>
  278. <a href="index.php" class="pwa item">
  279. <i class="browser icon"></i>
  280. Update List
  281. </a>
  282. <a class="item" onclick="toggleSearch()">
  283. <i class="search icon"></i>
  284. Search
  285. </a>
  286. <?php
  287. if (file_exists("../Upload Manager/upload_interface.php")){
  288. echo '<a href="../Upload Manager/upload_interface.php?target=Audio&filetype=mp3,mp4,flac,wav,aac&finishing=ffmpeg_converter.php" class="pwa item">';
  289. }else{
  290. echo '<a href="" class="pwa disabled item">';
  291. }
  292. ?>
  293. <i class="upload icon"></i>
  294. Upload
  295. </a>
  296. <a id="downloadmodeBtn" class="item" onclick="toggledownload();" style="">
  297. <i class="download icon"></i>
  298. Download
  299. </a>
  300. </div>
  301. <div id="downloadmode_reminder" class="ts active bottom right snackbar">
  302. <div id="sbtext" class="content">
  303. Download Mode Enabled.
  304. </div>
  305. <a class="primary action" onclick="toggledownload()">Disable</a>
  306. </div>
  307. <div style="display:none;">
  308. <div id="DATA_OBJECT_extStorageMode"><?php echo $extStorageMode;?></div>
  309. <div id="DATA_OBJECT_extStorageFolder"><?php echo $extStorageFolder;?></div>
  310. <div id="DATA_OBJECT_songlist"><?php echo json_encode($songlist); ?></div>
  311. <div id="DATA_OBJECT_search_keyword"><?php echo $keyword;?></div>
  312. <div id="DATA_OBJECT_shareMode"><?php echo $ModeS;?></div>
  313. <div id="DATA_OBJECT_ShareSong"><?php echo $SongS;?></div>
  314. <div id="DATA_OBJECT_pwaMode"><?php echo $pwa;?></div>
  315. </div>
  316. <script>
  317. </script>
  318. <script src="index.js"></script>
  319. </body>
  320. </html>