vidPlay.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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. if(ctype_xdigit($_GET['playlist'])){
  126. $playListName = hex2bin($_GET['playlist']);
  127. }else{
  128. $playListName = $_GET['playlist'];
  129. }
  130. }
  131. $playlistDir = $_GET['playlist'];
  132. echo '<div class="ts segment">';
  133. echo '<div class="ts grid">
  134. <div class="ten wide column"><div class="ts segment"><p>Playlist <i class="angle double right icon"></i> '.$playListName.'</p></div></div>
  135. <div class="six wide column"><div class="ts segment">
  136. <div class="ts toggle checkbox">
  137. <input type="checkbox" id="toggle">
  138. <label for="toggle">Auto Play</label>
  139. </div>
  140. </div></div>
  141. </div>';
  142. $template = '<div class="ts grid">
  143. <div class="ten wide column"><div class="ts fluid segment">%Video Attrubute Name%</div></div>
  144. <div class="six wide column"><div class="ts fluid segment playable" align="center">%Operations%</div></div>
  145. </div>';
  146. $playlist = $_GET['playlist'];
  147. if($playlist == "uploads"){ //actually that will had bug if playlist is named "uploads", but well anyway Toby won't care
  148. $files = glob($playlist . '/*.mp4');
  149. }else if(strpos($playlist,"/media/") !== false){
  150. $files = glob($playlist . '/*.mp4');
  151. }else{
  152. $files = glob("./playlist/".$playlist . '/*.mp4');
  153. }
  154. if (isset($_GET['isExt']) && $_GET['isExt'] == "true"){
  155. $extAccess = true;
  156. }else{
  157. $extAccess = false;
  158. }
  159. foreach ($files as $file){
  160. array_push($playlistItem,$file);
  161. //$thisfilename = basename($file,'.mp4');
  162. $filedata = explode('/',$file);
  163. $fullFileName = array_pop($filedata);
  164. $thisfilename = str_replace(".mp4","",$fullFileName);
  165. if (ctype_xdigit(str_replace("inith","",$thisfilename)) && strlen(str_replace("inith","",$thisfilename)) % 2 == 0) {
  166. $thisdecodedName = hex2bin(str_replace("inith","",$thisfilename));
  167. }else{
  168. $thisdecodedName = $thisfilename;
  169. }
  170. //$thisdecodedName = hex2bin(str_replace("inith","",$thisfilename));
  171. $thisitem = str_replace('%Video Attrubute Name%',$thisdecodedName,$template);
  172. if ($thisdecodedName == $decodedName){
  173. //If the looping loop back to the playing file, make it blue
  174. $thisitem = str_replace('ts fluid segment','ts inverted info segment',$thisitem);
  175. $thisitem = str_replace('%Operations%','PLAYING',$thisitem);
  176. }else{
  177. if ($extAccess == true){
  178. $viewPath = "vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=$file&playlist=$playlist&isExt=true";
  179. $thisitem = str_replace('%Operations%','<a href="'.$viewPath.'"><i class="play icon"></i>Play Video</a>',$thisitem);
  180. }else{
  181. $viewPath = "vidPlay.php?src=$file&playlist=$playlist";
  182. $thisitem = str_replace('%Operations%','<a href="'.$viewPath.'"><i class="play icon"></i>Play Video</a>',$thisitem);
  183. }
  184. }
  185. echo $thisitem;
  186. }
  187. echo '</div>';
  188. }
  189. ?>
  190. <!-- Bottom Bar -->
  191. <br><br><br>
  192. <div id="btmbar"style=" position: fixed;
  193. z-index: 100;
  194. bottom: 0;
  195. left: 0;
  196. width: 100%;">
  197. <div class="ts tiny menu">
  198. <a id="backbtn" class="item" href="index.php"><i class="angle left icon"></i></a>
  199. <a class="item" onClick="volDown();"><i class="volume down icon"></i>Vol-</a>
  200. <a class="item" onClick="volUp();"><i class="volume up icon"></i>Vol+</a>
  201. <?php
  202. //Check if QuickSend system exists for sharing function
  203. if (file_exists("../QuickSend/")){
  204. echo '<a class="item" onClick="share();"><i class="share alternate icon"></i>Share</a>';
  205. }else{
  206. echo '<a class="disabled item"><i class="share alternate icon"></i>Share</a>';
  207. }
  208. ?>
  209. <a class="item" onClick="downlaod();"><i class="download icon"></i>Download</a>
  210. </div>
  211. </div>
  212. </div>
  213. <script>
  214. //These function is for ArOZ Online System quick storage data processing
  215. function CheckStorage(id){
  216. if (typeof(Storage) !== "undefined") {
  217. return true;
  218. } else {
  219. return false;
  220. }
  221. }
  222. function GetStorage(id){
  223. //All data get are string
  224. return localStorage.getItem(id);
  225. }
  226. function SaveStorage(id,value){
  227. localStorage.setItem(id, value);
  228. return true;
  229. }
  230. //Declare global variables
  231. var globVol;
  232. var video = document.getElementById('player');
  233. var playlist = <?php echo json_encode($playlistItem); ?>;
  234. var thisVidName = <?php echo json_encode($_GET['src']); ?>;
  235. var playlistName = <?php echo json_encode($playlistDir); ?>;
  236. var extAccess = <?php echo $extAccess? 'true' : 'false';?>; //1 = Accessing files outside of the web root, 0 = within web root
  237. video.onvolumechange = function() {
  238. UpdateGlobalVol(video.volume);
  239. };
  240. video.onended = function() {
  241. console.log("Video ended!");
  242. if (GetStorage('VidAutoPlay') == 'true'){
  243. //Play next item in the playlist
  244. for(var i = 0;i<playlist.length;i++){
  245. console.log(thisVidName,playlist[i]);
  246. thisVidName = thisVidName.replace("\\","/");
  247. console.log(thisVidName);
  248. playlist[i] = playlist[i].replace("\\","/").replace("./","");
  249. console.log(playlist[i]);
  250. if (thisVidName.includes(playlist[i])){
  251. if (i + 1 == playlist.length){
  252. //if reaching the end of the playlist
  253. if (extAccess == 1){
  254. //Reading from external storage
  255. if (playlistName == ""){
  256. window.location.href="vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=" + playlist[0] ;
  257. }else if (playlistName != ""){
  258. window.location.href="vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=" + playlist[0] + "&playlist=" + playlistName + "&isExt=true";
  259. }
  260. }else{
  261. //Reading from web root
  262. if (playlistName == ""){
  263. window.location.href="vidPlay.php?src=" + playlist[0] ;
  264. }else if (playlistName != ""){
  265. window.location.href="vidPlay.php?src=" + playlist[0] + "&playlist=" + playlistName;
  266. }
  267. }
  268. }else{
  269. if (extAccess == 1){
  270. //Reading from exteranl storage
  271. if (playlistName == ""){
  272. window.location.href="vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=" + playlist[i+1] ;
  273. }else if (playlistName != ""){
  274. window.location.href="vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=" + playlist[i+1] + "&playlist=" + playlistName + "&isExt=true";
  275. }
  276. }else{
  277. //Reading from web root
  278. //If it is not the last video in the play list
  279. if (playlistName == ""){
  280. window.location.href="vidPlay.php?src=" + playlist[i+1];
  281. }else if (playlistName != ""){
  282. window.location.href="vidPlay.php?src=" + playlist[i+1] + "&playlist=" + playlistName;
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }else{
  289. console.log("Playlist Finished.");
  290. }
  291. };
  292. function MobileCheck(){
  293. var check = false;
  294. (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);
  295. return check;
  296. }
  297. function SetTitle(){
  298. $(document).attr("title",$('#videoName').html());
  299. }
  300. function CheckHorizontal(){
  301. screenHeight = $(window).height();
  302. screenWidth = $(window).width();
  303. if (screenWidth > screenHeight){
  304. return true;
  305. }else{
  306. return false;
  307. }
  308. }
  309. window.onresize = function(event) {
  310. if (MobileCheck() == true && CheckHorizontal() == true){
  311. $('#btmbar').hide();
  312. }
  313. if (MobileCheck() == true && CheckHorizontal() == false){
  314. $('#btmbar').show();
  315. }
  316. };
  317. function UpdateGlobalVol(value){
  318. //value = Math.round(value / 0.1) * 10;
  319. //value = value / 100;
  320. globVol = value;
  321. //To fix the terrible Javascript rounding problem
  322. var displayVol = (globVol * 100).toString();
  323. if (displayVol.includes(".")){
  324. displayVol = displayVol.split(".");
  325. displayVol.pop();
  326. }
  327. $('#globVol').html('Global Volume: ' + displayVol + '%');
  328. SaveStorage('global_volume',value);
  329. }
  330. //On System ready
  331. $( document ).ready(function() {
  332. var lastvol = GetStorage('global_volume');
  333. if (lastvol != null){
  334. globVol = parseFloat(GetStorage('global_volume'));
  335. video.volume = globVol;
  336. }else{
  337. //no previous volume info
  338. globVol = 0.6;
  339. video.volume = globVol;
  340. SaveStorage('global_volume',0.6);
  341. }
  342. $('#globVol').html('Global Volume: ' + globVol*100 + '%');
  343. if (GetStorage('VidAutoPlay') == 'true'){
  344. $('#toggle').prop("checked",true);
  345. }else{
  346. $('#toggle').prop("checked",false);
  347. }
  348. if (MobileCheck() == false){
  349. //This is a desktop / laptop PC, make the player size smaller!
  350. $('#player').css('width', '70%');
  351. $('#desktopMode').css('display',''); //Show display setting
  352. }
  353. //Set the video attribute to previous page size
  354. if (GetStorage('VidAttrScale') != null){
  355. $('#player').css('width', GetStorage('VidAttrScale')+ '%');
  356. if (GetStorage('VidAttrScale') == "100"){
  357. $("#topnavbar").hide();
  358. }
  359. }
  360. //Check if it is in mobile horizontal mode.
  361. if (MobileCheck() == true && CheckHorizontal() == true){
  362. $('#btmbar').hide();
  363. }
  364. if (MobileCheck() == true && CheckHorizontal() == false){
  365. $('#btmbar').show();
  366. }
  367. SetTitle();
  368. });
  369. $('#toggle').change(function() {
  370. if(this.checked) {
  371. SaveStorage('VidAutoPlay','true');
  372. }else{
  373. SaveStorage('VidAutoPlay','false');
  374. }
  375. });
  376. function share(){
  377. var url = window.location.href.replace("&","<and>");
  378. window.location.href = "../QuickSend/index.php?share=" + url;
  379. }
  380. function Resize(percentage){
  381. $('#player').css('width', percentage + '%');
  382. SaveStorage('VidAttrScale',percentage);
  383. if (percentage == 100){
  384. $("#topnavbar").slideUp();
  385. }else{
  386. $("#topnavbar").slideDown();
  387. }
  388. }
  389. function downlaod(){
  390. window.location.href = "download.php?download=" + thisVidName;
  391. }
  392. function volDown(){
  393. if (globVol >= 0.1){
  394. UpdateGlobalVol(globVol - 0.05);
  395. video.volume = globVol;
  396. }
  397. }
  398. function volUp(){
  399. if (globVol <= 0.9){
  400. UpdateGlobalVol(globVol + 0.05);
  401. video.volume = globVol;
  402. }
  403. }
  404. if (ao_module_virtualDesktop){
  405. $("body").addClass("vdi");
  406. }
  407. </script>
  408. </body>
  409. </html>