vidPlay.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <?php
  2. include_once '../auth.php';
  3. ?>
  4. <!DOCTYPE html>
  5. <meta name="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/ao_module.js"></script>
  19. <script type='text/javascript' src="../script/tocas/tocas.js"></script>
  20. <title>ArOZ Onlineβ</title>
  21. <style>
  22. body{
  23. background-color:#f5f5f5;
  24. }
  25. .vdi{
  26. padding-bottom:30px;
  27. }
  28. .segment{
  29. padding: 4px !important;
  30. padding-left: 10px !important;
  31. padding-right: 10px !important;
  32. }
  33. .playable{
  34. border: 1px solid transparent !important;
  35. height:100% !important;
  36. }
  37. .playable:hover{
  38. border: 1px solid #0469d4 !important;
  39. }
  40. .info.segment{
  41. background-color: #0469d4 !important;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <nav id="topnavbar" class="ts attached borderless small menu">
  47. <a href="index.php" class="item"><i class="angle left icon"></i></a>
  48. <a href="#" class="item">ArOZ Video</a>
  49. </nav>
  50. <div id="innerWrapper" style="width:100%" align="center">
  51. <?php
  52. $infoTemplate = '<details class="ts small accordion">
  53. <summary>
  54. <i class="bookmark icon"></i>Video file details
  55. </summary>
  56. <div class="content" style="background-color:#ffffff;padding:8px;">
  57. <p><i class="folder open icon"></i>File access path: %FILEPATH%</p>
  58. <p><i class="file icon"></i>File storage size: %FILESIZE%</p>
  59. </div>
  60. </details>';
  61. if (isset($_GET['src']) && $_GET['src'] != ""){
  62. //There are given src for video attribute
  63. if (file_exists($_GET['src'])|| strpos($_GET['src'],"extDiskAccess.php")){
  64. echo '<video id="player" style="width:100%" src="'.$_GET['src'].'" autoplay controls></video>';
  65. //$filename = basename($_GET['src'], ".mp4");
  66. $filedata = explode('/',$_GET['src']);
  67. $fullFileName = array_pop($filedata);
  68. $filename = str_replace(".mp4","",$fullFileName);
  69. if (ctype_xdigit(str_replace("inith","",$filename)) && strlen(str_replace("inith","",$filename)) % 2 == 0) {
  70. $decodedName = hex2bin(str_replace("inith","",$filename));
  71. }else{
  72. $decodedName = $filename;
  73. }
  74. }else{
  75. die('<i class="remove icon"></i>API call error: 404 File not found.');
  76. }
  77. }else{
  78. die('<i class="remove icon"></i>API call error: src value not found.');
  79. }
  80. ?>
  81. </div>
  82. <div class="ts attached message">
  83. <?php
  84. function formatBytes($size, $precision = 2)
  85. {
  86. $base = log($size, 1024);
  87. $suffixes = array('Byte', 'KB', 'MB', 'GB', 'TB');
  88. return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)];
  89. }
  90. echo '<div class="header" id="videoName">' . $decodedName . '</div>';
  91. $box = $infoTemplate;
  92. $box = str_replace("%FILEPATH%",$_GET['src'],$box);
  93. if (strpos($_GET['src'],"extDiskAccess.php") !== false){
  94. $extFile = explode("=",$_GET['src'])[1];
  95. $filesize = formatBytes(filesize($extFile));
  96. }else{
  97. $filesize = formatBytes(filesize($_GET['src']));
  98. }
  99. $box = str_replace("%FILESIZE%",$filesize,$box);
  100. echo $box;
  101. ?>
  102. <details class="ts small accordion">
  103. <summary>
  104. <i class="dropdown icon"></i>Display Setting
  105. </summary>
  106. <div class="content" style="background-color:#ffffff;padding:15px;">
  107. <div id="desktopMode"class="ts icon stackable fluid tiny buttons" style="display:none;">
  108. <button class="ts basic button" onClick="Resize(50);">Small</button>
  109. <button class="ts basic button" onClick="Resize(70);"><i class="expand icon"></i>Medium</button>
  110. <button class="ts basic button" onClick="Resize(80);"><i class="maximize icon"></i>Large</button>
  111. <button class="ts basic button" onClick="Resize(100);"><i class="resize horizontal icon"></i>Max Width</button>
  112. </div>
  113. </div>
  114. </details>
  115. <div id="globVol">Global Volume: 100%</div>
  116. </div>
  117. <?php
  118. $playlistDir = "";
  119. $playlistItem = [];
  120. $extAccess = false;
  121. if (isset($_GET['playlist']) && $_GET['playlist'] != ""){
  122. if ($_GET['playlist'] == "uploads"){
  123. $playListName = "Unsorted";
  124. }else{
  125. $playListName = "";
  126. }
  127. $playlistDir = $_GET['playlist'];
  128. echo '<div class="ts segment">';
  129. echo '<div class="ts grid">
  130. <div class="ten wide column"><div class="ts segment"><p>Playlist <i class="angle double right icon"></i> '.$playListName.'</p></div></div>
  131. <div class="six wide column"><div class="ts segment">
  132. <div class="ts toggle checkbox">
  133. <input type="checkbox" id="toggle">
  134. <label for="toggle">Auto Play</label>
  135. </div>
  136. </div></div>
  137. </div>';
  138. $template = '<div class="ts grid">
  139. <div class="ten wide column"><div class="ts fluid segment">%Video Attrubute Name%</div></div>
  140. <div class="six wide column"><div class="ts fluid segment playable" align="center">%Operations%</div></div>
  141. </div>';
  142. $playlist = $_GET['playlist'];
  143. $files = glob($playlist . '/*.mp4');
  144. if (isset($_GET['isExt']) && $_GET['isExt'] == "true"){
  145. $extAccess = true;
  146. }else{
  147. $extAccess = false;
  148. }
  149. foreach ($files as $file){
  150. array_push($playlistItem,$file);
  151. //$thisfilename = basename($file,'.mp4');
  152. $filedata = explode('/',$file);
  153. $fullFileName = array_pop($filedata);
  154. $thisfilename = str_replace(".mp4","",$fullFileName);
  155. if (ctype_xdigit(str_replace("inith","",$thisfilename)) && strlen(str_replace("inith","",$thisfilename)) % 2 == 0) {
  156. $thisdecodedName = hex2bin(str_replace("inith","",$thisfilename));
  157. }else{
  158. $thisdecodedName = $thisfilename;
  159. }
  160. //$thisdecodedName = hex2bin(str_replace("inith","",$thisfilename));
  161. $thisitem = str_replace('%Video Attrubute Name%',$thisdecodedName,$template);
  162. if ($thisdecodedName == $decodedName){
  163. //If the looping loop back to the playing file, make it blue
  164. $thisitem = str_replace('ts fluid segment','ts inverted info segment',$thisitem);
  165. $thisitem = str_replace('%Operations%','PLAYING',$thisitem);
  166. }else{
  167. if ($extAccess == true){
  168. $viewPath = "vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=$file&playlist=$playlist&isExt=true";
  169. $thisitem = str_replace('%Operations%','<a href="'.$viewPath.'"><i class="play icon"></i>Play Video</a>',$thisitem);
  170. }else{
  171. $viewPath = "vidPlay.php?src=$file&playlist=$playlist";
  172. $thisitem = str_replace('%Operations%','<a href="'.$viewPath.'"><i class="play icon"></i>Play Video</a>',$thisitem);
  173. }
  174. }
  175. echo $thisitem;
  176. }
  177. echo '</div>';
  178. }
  179. ?>
  180. <!-- Bottom Bar -->
  181. <br><br><br>
  182. <div id="btmbar"style=" position: fixed;
  183. z-index: 100;
  184. bottom: 0;
  185. left: 0;
  186. width: 100%;">
  187. <div class="ts tiny menu">
  188. <a id="backbtn" class="item" href="index.php"><i class="angle left icon"></i></a>
  189. <a class="item" onClick="volDown();"><i class="volume down icon"></i>Vol-</a>
  190. <a class="item" onClick="volUp();"><i class="volume up icon"></i>Vol+</a>
  191. <?php
  192. //Check if QuickSend system exists for sharing function
  193. if (file_exists("../QuickSend/")){
  194. echo '<a class="item" onClick="share();"><i class="share alternate icon"></i>Share</a>';
  195. }else{
  196. echo '<a class="disabled item"><i class="share alternate icon"></i>Share</a>';
  197. }
  198. ?>
  199. <a class="item" onClick="downlaod();"><i class="download icon"></i>Download</a>
  200. </div>
  201. </div>
  202. </div>
  203. <script>
  204. //These function is for ArOZ Online System quick storage data processing
  205. function CheckStorage(id){
  206. if (typeof(Storage) !== "undefined") {
  207. return true;
  208. } else {
  209. return false;
  210. }
  211. }
  212. function GetStorage(id){
  213. //All data get are string
  214. return localStorage.getItem(id);
  215. }
  216. function SaveStorage(id,value){
  217. localStorage.setItem(id, value);
  218. return true;
  219. }
  220. //Declare global variables
  221. var globVol;
  222. var video = document.getElementById('player');
  223. var playlist = <?php echo json_encode($playlistItem); ?>;
  224. var thisVidName = <?php echo json_encode($_GET['src']); ?>;
  225. var playlistName = <?php echo json_encode($playlistDir); ?>;
  226. var extAccess = <?php echo $extAccess? 'true' : 'false';?>; //1 = Accessing files outside of the web root, 0 = within web root
  227. video.onvolumechange = function() {
  228. UpdateGlobalVol(video.volume);
  229. };
  230. video.onended = function() {
  231. console.log("Video ended!");
  232. if (GetStorage('VidAutoPlay') == 'true'){
  233. //Play next item in the playlist
  234. for(var i = 0;i<playlist.length;i++){
  235. //console.log(thisVidName,playlist[i]);
  236. thisVidName = thisVidName.replace("\\","/");
  237. //console.log(thisVidName);
  238. playlist[i] = playlist[i].replace("\\","/");
  239. //console.log(playlist[i]);
  240. if (thisVidName.includes(playlist[i])){
  241. if (i + 1 == playlist.length){
  242. //if reaching the end of the playlist
  243. if (extAccess == 1){
  244. //Reading from external storage
  245. if (playlistName == ""){
  246. window.location.href="vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=" + playlist[0] ;
  247. }else if (playlistName != ""){
  248. window.location.href="vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=" + playlist[0] + "&playlist=" + playlistName + "&isExt=true";
  249. }
  250. }else{
  251. //Reading from web root
  252. if (playlistName == ""){
  253. window.location.href="vidPlay.php?src=" + playlist[0] ;
  254. }else if (playlistName != ""){
  255. window.location.href="vidPlay.php?src=" + playlist[0] + "&playlist=" + playlistName;
  256. }
  257. }
  258. }else{
  259. if (extAccess == 1){
  260. //Reading from exteranl storage
  261. if (playlistName == ""){
  262. window.location.href="vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=" + playlist[i+1] ;
  263. }else if (playlistName != ""){
  264. window.location.href="vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=" + playlist[i+1] + "&playlist=" + playlistName + "&isExt=true";
  265. }
  266. }else{
  267. //Reading from web root
  268. //If it is not the last video in the play list
  269. if (playlistName == ""){
  270. window.location.href="vidPlay.php?src=" + playlist[i+1];
  271. }else if (playlistName != ""){
  272. window.location.href="vidPlay.php?src=" + playlist[i+1] + "&playlist=" + playlistName;
  273. }
  274. }
  275. }
  276. }
  277. }
  278. }else{
  279. console.log("Playlist Finished.");
  280. }
  281. };
  282. function MobileCheck(){
  283. var check = false;
  284. (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
  285. return check;
  286. }
  287. function SetTitle(){
  288. $(document).attr("title",$('#videoName').html());
  289. }
  290. function CheckHorizontal(){
  291. screenHeight = $(window).height();
  292. screenWidth = $(window).width();
  293. if (screenWidth > screenHeight){
  294. return true;
  295. }else{
  296. return false;
  297. }
  298. }
  299. window.onresize = function(event) {
  300. if (MobileCheck() == true && CheckHorizontal() == true){
  301. $('#btmbar').hide();
  302. }
  303. if (MobileCheck() == true && CheckHorizontal() == false){
  304. $('#btmbar').show();
  305. }
  306. };
  307. function UpdateGlobalVol(value){
  308. //value = Math.round(value / 0.1) * 10;
  309. //value = value / 100;
  310. globVol = value;
  311. //To fix the terrible Javascript rounding problem
  312. var displayVol = (globVol * 100).toString();
  313. if (displayVol.includes(".")){
  314. displayVol = displayVol.split(".");
  315. displayVol.pop();
  316. }
  317. $('#globVol').html('Global Volume: ' + displayVol + '%');
  318. SaveStorage('global_volume',value);
  319. }
  320. //On System ready
  321. $( document ).ready(function() {
  322. var lastvol = GetStorage('global_volume');
  323. if (lastvol != null){
  324. globVol = parseFloat(GetStorage('global_volume'));
  325. video.volume = globVol;
  326. }else{
  327. //no previous volume info
  328. globVol = 0.6;
  329. video.volume = globVol;
  330. SaveStorage('global_volume',0.6);
  331. }
  332. $('#globVol').html('Global Volume: ' + globVol*100 + '%');
  333. if (GetStorage('VidAutoPlay') == 'true'){
  334. $('#toggle').prop("checked",true);
  335. }else{
  336. $('#toggle').prop("checked",false);
  337. }
  338. if (MobileCheck() == false){
  339. //This is a desktop / laptop PC, make the player size smaller!
  340. $('#player').css('width', '70%');
  341. $('#desktopMode').css('display',''); //Show display setting
  342. }
  343. //Set the video attribute to previous page size
  344. if (GetStorage('VidAttrScale') != null){
  345. $('#player').css('width', GetStorage('VidAttrScale')+ '%');
  346. if (GetStorage('VidAttrScale') == "100"){
  347. $("#topnavbar").hide();
  348. }
  349. }
  350. //Check if it is in mobile horizontal mode.
  351. if (MobileCheck() == true && CheckHorizontal() == true){
  352. $('#btmbar').hide();
  353. }
  354. if (MobileCheck() == true && CheckHorizontal() == false){
  355. $('#btmbar').show();
  356. }
  357. SetTitle();
  358. });
  359. $('#toggle').change(function() {
  360. if(this.checked) {
  361. SaveStorage('VidAutoPlay','true');
  362. }else{
  363. SaveStorage('VidAutoPlay','false');
  364. }
  365. });
  366. function share(){
  367. var url = window.location.href.replace("&","<and>");
  368. window.location.href = "../QuickSend/index.php?share=" + url;
  369. }
  370. function Resize(percentage){
  371. $('#player').css('width', percentage + '%');
  372. SaveStorage('VidAttrScale',percentage);
  373. if (percentage == 100){
  374. $("#topnavbar").slideUp();
  375. }else{
  376. $("#topnavbar").slideDown();
  377. }
  378. }
  379. function downlaod(){
  380. window.location.href = "download.php?download=" + thisVidName;
  381. }
  382. function volDown(){
  383. if (globVol >= 0.1){
  384. UpdateGlobalVol(globVol - 0.05);
  385. video.volume = globVol;
  386. }
  387. }
  388. function volUp(){
  389. if (globVol <= 0.9){
  390. UpdateGlobalVol(globVol + 0.05);
  391. video.volume = globVol;
  392. }
  393. }
  394. if (ao_module_virtualDesktop){
  395. $("body").addClass("vdi");
  396. }
  397. </script>
  398. </body>
  399. </html>