index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <?php
  2. include '../auth.php';
  3. //Patch for uploads folder not found exception during upload with Upload Manager
  4. if (!file_exists("uploads/")){
  5. mkdir("uploads",0777,true);
  6. }
  7. ?>
  8. <!DOCTYPE html>
  9. <meta name="apple-mobile-web-app-capable" content="yes" />
  10. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  11. <html>
  12. <head>
  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. <meta charset="UTF-8">
  20. <script src="../script/jquery.min.js"></script>
  21. <link rel="stylesheet" href="../script/tocas/tocas.css">
  22. <script type='text/javascript' src="../script/tocas/tocas.js"></script>
  23. <script src="../script/ao_module.js"></script>
  24. <title>ArOZ Video</title>
  25. <style>
  26. body{
  27. background-color:#f5f5f5;
  28. }
  29. .videoborder{
  30. border-left: 5px solid #525252;
  31. padding:8px !important;
  32. margin:3px;
  33. cursor:pointer;
  34. }
  35. .videoborder:hover{
  36. border-left: 5px solid #675cff;
  37. background-color:#d7d4ff;
  38. }
  39. .rightFloatAbsolute{
  40. position: absolute;
  41. top:30%;
  42. right:8px;
  43. }
  44. .rightFloatAbsolute:hover{
  45. color:#1f44fc;
  46. }
  47. .limited{
  48. text-overflow: ellipsis;
  49. overflow: hidden;
  50. max-width: 75%;
  51. white-space: nowrap;
  52. }
  53. .hidden{
  54. display:none;
  55. }
  56. .shortList{
  57. max-height:300px !important;
  58. overflow-y:auto;
  59. overflow-x:hidden;
  60. }
  61. </style>
  62. </head>
  63. <body>
  64. <?php
  65. $uploadPath = "../Upload Manager/upload_interface.php?target=Video&filetype=mp4";
  66. function formatBytes($size, $precision = 2)
  67. {
  68. $base = log($size, 1024);
  69. $suffixes = array('Byte', 'KB', 'MB', 'GB', 'TB');
  70. return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)];
  71. }
  72. if (isset($_GET['filepath']) && $_GET['filepath'] != "" ){
  73. header('Location: vidPlay.php?src='.$_GET['filepath']);
  74. }
  75. ?>
  76. <nav class="ts attached borderless small menu">
  77. <a id="rtiBtn" href="../" class="item"><i class="angle left icon"></i></a>
  78. <a href="" class="item">ArOZ Video</a>
  79. <div class="right menu">
  80. <a href="<?php echo $uploadPath;?>" class="item"><i class="upload icon"></i></a>
  81. <a href="manager.php" class="item"><i class="folder open outline icon"></i></a>
  82. </div>
  83. </nav>
  84. <!-- Main Header-->
  85. <div class="ts container" style="padding-top:8px;">
  86. <?php
  87. $templateA = '
  88. <div class="ts horizontal divider">%PlayListName%</div>
  89. <div class="ts list shortList">';
  90. $templateB= '<div class="item videoborder" >
  91. <i class="video icon"></i>
  92. <div class="content" href="%VideoPlayPath%" onClick="playVideo(this);">
  93. <div class="header limited">%VideoFileName%</div>
  94. <div class="description">%FileInfo%</div>
  95. </div>
  96. <a class="rightFloatAbsolute" href="%DownloadPath%" download><i class="download icon"></i></a>
  97. </div>';
  98. $templateC = '</div>
  99. <a class="ts mini basic fluid button" href="%PlayPlayList%"><i class="play icon"></i>View Playlist</a>';
  100. $playlists = glob('playlist/*');
  101. foreach($playlists as $playlist){
  102. if (is_dir($playlist)){
  103. $videos = glob($playlist . '/*.mp4');
  104. //check if PHP was higher than 7.4, if true then not using inith filename
  105. if(ctype_xdigit(basename($playlist))){
  106. $playlistName = hex2bin(basename($playlist));
  107. }else{
  108. $playlistName = basename($playlist);
  109. }
  110. $box = str_replace("%PlayListName%",$playlistName,$templateA);
  111. if (count($videos) != 0){
  112. $box = str_replace("%PlayPlayList%","vidPlay.php?src=".$videos[0]."&playlist=".$playlist."",$box);
  113. }else{
  114. //$box = str_replace('<a class="ts mini basic fluid button" href="%PlayPlayList%"><i class="play icon"></i>View Playlist</a>','  <kbd>Empty playlist</kbd>',$box);
  115. }
  116. echo $box;
  117. foreach($videos as $video){
  118. //echo $video . '<br>';
  119. $filename = basename($video,".mp4");
  120. if (ctype_xdigit(str_replace("inith","",$filename)) && strlen(str_replace("inith","",$filename)) % 2 == 0) {
  121. $decodedName = hex2bin(str_replace("inith","",$filename));
  122. }else{
  123. $decodedName = $filename;
  124. }
  125. $box = str_replace("%VideoPlayPath%","vidPlay.php?src=".$video,$templateB);
  126. $box = str_replace("%VideoFileName%",$decodedName,$box);
  127. $box = str_replace("%DownloadPath%","download.php?download=".$video,$box);
  128. $box = str_replace("%FileInfo%",formatBytes(filesize($video)) . " [".pathinfo($video, PATHINFO_EXTENSION)."]",$box);
  129. echo $box;
  130. }
  131. if (count($videos) != 0){
  132. echo str_replace("%PlayPlayList%","vidPlay.php?src=".$videos[0]."&playlist=".basename($playlist),$templateC);
  133. }else{
  134. echo str_replace("%PlayPlayList%","",$templateC);
  135. }
  136. }
  137. }
  138. $unsorted = glob("uploads/*.mp4");
  139. $box = str_replace("%PlayListName%","Unsorted Videos",$templateA);
  140. if (count($unsorted) != 0){
  141. $box = str_replace("%PlayPlayList%","vidPlay.php?src=".$unsorted[0]."&playlist=uploads",$box);
  142. }else{
  143. //$box = str_replace('  <a href="%PlayPlayList%"> Play playlist</a>','  <kbd>Empty playlist</kbd>',$box);
  144. }
  145. echo $box;
  146. foreach ($unsorted as $video){
  147. $filename = basename($video,".mp4");
  148. if (ctype_xdigit(str_replace("inith","",$filename)) && strlen(str_replace("inith","",$filename)) % 2 == 0) {
  149. $decodedName = hex2bin(str_replace("inith","",$filename));
  150. }else{
  151. $decodedName = $filename;
  152. }
  153. $box = str_replace("%VideoPlayPath%","vidPlay.php?src=".$video,$templateB);
  154. $box = str_replace("%VideoFileName%",$decodedName,$box);
  155. $box = str_replace("%DownloadPath%","download.php?download=".$video,$box);
  156. $box = str_replace("%FileInfo%",formatBytes(filesize($video)) . " [".pathinfo($video, PATHINFO_EXTENSION)."]",$box);
  157. echo $box;
  158. }
  159. if (count($unsorted) != 0){
  160. echo str_replace("%PlayPlayList%","vidPlay.php?src=".$unsorted[0]."&playlist=uploads",$templateC);
  161. }else{
  162. echo str_replace('<a class="ts mini basic fluid button" href="%PlayPlayList%"><i class="play icon"></i>View Playlist</a>',"<p style='width:100%;' align='center'>/// Empty Playlist ///</p>",$templateC);
  163. }
  164. //Check for external storage devices
  165. if (file_exists("/media/")){
  166. //This system have media directory and check for mounting points
  167. $extstorages = glob("/media/storage*");
  168. foreach ($extstorages as $storage){
  169. if (file_exists("$storage/Video/")){
  170. $unsorted = glob("$storage/Video/*.mp4");
  171. $box = str_replace("%PlayListName%","External Storage ($storage)",$templateA);
  172. if (count($unsorted) != 0){
  173. $box = str_replace("%PlayPlayList%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$unsorted[0]."&playlist=$storage/Video/&isExt=true",$box);
  174. }else{
  175. $box = str_replace('  <a href="%PlayPlayList%"> Play playlist</a>','  <kbd>Empty playlist / Not Plugged In</kbd>',$box);
  176. }
  177. echo $box;
  178. foreach ($unsorted as $video){
  179. $filedata = explode('/',$video);
  180. $fullFileName = array_pop($filedata);
  181. $filename = str_replace(".mp4","",$fullFileName);
  182. //$filename = basename($video,".mp4");
  183. if (strpos($filename,"inith") !== false){
  184. $decodedName = hex2bin(str_replace("inith","",$filename));
  185. }else{
  186. $decodedName = $filename;
  187. }
  188. $box = str_replace("%VideoPlayPath%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$video,$templateB);
  189. $box = str_replace("%VideoFileName%",$decodedName,$box);
  190. $box = str_replace("%DownloadPath%","download.php?download=".$video,$box);
  191. $box = str_replace("%FileInfo%",formatBytes(filesize($video)) . " [".pathinfo($video, PATHINFO_EXTENSION)."]",$box);
  192. echo $box;
  193. }
  194. if (count($unsorted) != 0){
  195. echo str_replace("%PlayPlayList%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$unsorted[0]."&playlist=$storage/Video/&isExt=true",$templateC);
  196. }else{
  197. echo str_replace('<a class="ts mini basic fluid button" href="%PlayPlayList%"><i class="play icon"></i>View Playlist</a>',"<p style='width:100%;' align='center'>/// Empty Playlist ///</p>",$templateC);
  198. }
  199. }
  200. }
  201. }
  202. //scan for external playlist. This won't show if nothing is found.
  203. if (file_exists("/media/")){
  204. //This system have media directory and check for mounting points
  205. $extstorages = glob("/media/storage*");
  206. foreach ($extstorages as $storage){
  207. if (file_exists("$storage/Video/")){
  208. $playlists = glob( $storage . '/Video/*');
  209. foreach($playlists as $playlist){
  210. if (is_dir($playlist)){
  211. $unsorted = glob($playlist . "/*.mp4");
  212. //basename in traiditional mode to prevent utf-8 encoding error
  213. $tmp_1 = explode("/",$playlist);
  214. $basename = array_pop($tmp_1);
  215. if (ctype_xdigit($basename) && strlen($basename) % 2 == 0) {
  216. $playlistName = hex2bin($basename);
  217. } else {
  218. $playlistName = $basename;
  219. }
  220. $box = str_replace("%PlayListName%", $playlistName . " - ($storage)",$templateA);
  221. $box = str_replace('layout icon','disk outline icon',$box);
  222. if (count($unsorted) != 0){
  223. $box = str_replace("%PlayPlayList%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$unsorted[0]."&playlist=$storage/Video/$basename&isExt=true",$box);
  224. }else{
  225. //$box = str_replace('  <a href="%PlayPlayList%"> Play playlist</a>','  <kbd>Empty playlist / Not Plugged In</kbd>',$box);
  226. }
  227. echo $box;
  228. foreach ($unsorted as $video){
  229. $filedata = explode('/',$video);
  230. $fullFileName = array_pop($filedata);
  231. $filename = str_replace(".mp4","",$fullFileName);
  232. if (strpos($filename,"inith") !== false){
  233. $decodedName = hex2bin(str_replace("inith","",$filename));
  234. }else{
  235. $decodedName = $filename;
  236. }
  237. $box = str_replace("%VideoPlayPath%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$video,$templateB);
  238. $box = str_replace("%VideoFileName%",$decodedName,$box);
  239. $box = str_replace("%DownloadPath%","download.php?download=".$video,$box);
  240. $box = str_replace("%FileInfo%",formatBytes(filesize($video)) . " [".pathinfo($video, PATHINFO_EXTENSION)."]",$box);
  241. echo $box;
  242. }
  243. if (count($unsorted) != 0){
  244. echo str_replace("%PlayPlayList%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$unsorted[0]."&playlist=$playlist&isExt=true",$templateC);
  245. }else{
  246. echo str_replace('<a class="ts mini basic fluid button" href="%PlayPlayList%"><i class="play icon"></i>View Playlist</a>',"<p style='width:100%;' align='center'>/// Empty Playlist ///</p>",$templateC);
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. ?>
  254. <br><br>
  255. </div>
  256. <script>
  257. if (ao_module_virtualDesktop){
  258. $("#rtiBtn").hide();
  259. }
  260. ao_module_setWindowIcon("film");
  261. ao_module_setWindowTitle("ArOZ Video");
  262. ao_module_setGlassEffectMode();
  263. function playVideo(object){
  264. var url = $(object).attr("href");
  265. window.location.href = url;
  266. }
  267. $( window ).resize(function() {
  268. if ($(window).width() < 425){
  269. $(".video.icon").each(function(){
  270. $(this).css("display","none");
  271. });
  272. }else{
  273. $(".video.icon").each(function(){
  274. $(this).css("display","");
  275. });
  276. }
  277. });
  278. </script>
  279. </body>
  280. </html>