index.php 11 KB

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