瀏覽代碼

Upload files to 'Video'

Yeung Alan 6 年之前
父節點
當前提交
23eb81d87f
共有 10 個文件被更改,包括 1401 次插入0 次删除
  1. 16 0
      Video/FloatWindow.php
  2. 1 0
      Video/description.txt
  3. 35 0
      Video/download.php
  4. 230 0
      Video/embedded.php
  5. 282 0
      Video/index.php
  6. 221 0
      Video/manager.js
  7. 285 0
      Video/manager.php
  8. 25 0
      Video/mover.php
  9. 13 0
      Video/new_folder.php
  10. 293 0
      Video/vidPlay.php

+ 16 - 0
Video/FloatWindow.php

@@ -0,0 +1,16 @@
+<?php
+include '../auth.php';
+?>
+<html>
+<body>
+Now Loading...
+<div id="DATA_MODULENAME"><?php echo dirname(str_replace("\\","/",__FILE__)); ?></div>
+<script src="../script/jquery.min.js"></script>
+<script src="../script/ao_module.js"></script>
+<script>
+var moduleName = $("#DATA_MODULENAME").text().trim().split("/").pop();
+var uid = (new Date()).getTime();
+ao_module_newfw( moduleName + "/index.php","ArOZ Video","film", uid,undefined,undefined,undefined,undefined,true,false);
+</script>
+</body>
+</html>

+ 1 - 0
Video/description.txt

@@ -0,0 +1 @@
+The Video function allow you to stream movies or video files directly from your host to your mobile devices through Wifi Direct or local area netwrok. Powered by ArOZ Online ALPHA.

+ 35 - 0
Video/download.php

@@ -0,0 +1,35 @@
+<?php
+include '../auth.php';
+?>
+<?php
+//Download Handler for Auto Renaming System
+if (isset($_GET['download']) && $_GET['download'] != ""){
+    if (file_exists( $_GET['download']) == false){
+        die("ERROR. File doesn't exists.");
+    }
+    $target = $_GET['download'];
+    $ext = pathinfo($target, PATHINFO_EXTENSION);
+    $filedata = explode('/',$target);
+    $fullFileName = array_pop($filedata);
+    $filename = str_replace(".mp4","",$fullFileName);
+    if (strpos($filename,"inith")!== false){
+        $decodedName = hex2bin(str_replace("inith",'',$filename));
+    }else{
+        $decodedName = $filename;
+    }
+header("Content-Type: video/mp4");
+header("Content-Length: " . filesize($target));
+header('Content-Disposition: attachment; filename="'.$decodedName . "." . $ext.'"');
+//readfile($target);
+$handle = fopen($target, 'rb'); 
+$buffer = ''; 
+while (!feof($handle)) { 
+    $buffer = fread($handle, 4096); 
+    echo $buffer; 
+    ob_flush(); 
+    flush(); 
+} 
+fclose($handle); 
+exit;
+}
+?>

File diff suppressed because it is too large
+ 230 - 0
Video/embedded.php


+ 282 - 0
Video/index.php

@@ -0,0 +1,282 @@
+<?php
+include '../auth.php';
+?>
+<!DOCTYPE html>
+<meta name="apple-mobile-web-app-capable" content="yes" />
+<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
+<html>
+<head>
+<script type='text/javascript' charset='utf-8'>
+    // Hides mobile browser's address bar when page is done loading.
+      window.addEventListener('load', function(e) {
+        setTimeout(function() { window.scrollTo(0, 1); }, 1);
+      }, false);
+</script>
+    <meta charset="UTF-8">
+	<script src="../script/jquery.min.js"></script>
+    <link rel="stylesheet" href="../script/tocas/tocas.css">
+	<script type='text/javascript' src="../script/tocas/tocas.js"></script>
+	<script src="../script/ao_module.js"></script>
+	<title>ArOZ Video</title>
+	<style>
+    	body{
+    	    background-color:#f5f5f5;
+    	}
+	    .videoborder{
+	        border-left: 5px solid #525252;
+	        padding:8px !important;
+	        margin:3px;
+			cursor:pointer;
+	    }
+	    .videoborder:hover{
+	        border-left: 5px solid #675cff;
+	        background-color:#d7d4ff;
+	    }
+	    .rightFloatAbsolute{
+			position: absolute;
+	        top:30%;
+	        right:8px;
+	    }
+	    .rightFloatAbsolute:hover{
+	        color:#1f44fc;
+	    }
+	    .limited{
+	        text-overflow: ellipsis;
+            overflow: hidden; 
+            max-width: 75%; 
+            white-space: nowrap;
+	    }
+	    .hidden{
+	        display:none;
+	    }
+	    .shortList{
+	        max-height:300px !important;
+	        overflow-y:auto;
+	        overflow-x:hidden;
+	    }
+	</style>
+</head>
+<body>
+<?php
+$uploadPath = "../Upload Manager/upload_interface.php?target=Video&filetype=mp4";
+function formatBytes($size, $precision = 2)
+			{
+				$base = log($size, 1024);
+				$suffixes = array('Byte', 'KB', 'MB', 'GB', 'TB');   
+
+				return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)];
+			}
+
+if (isset($_GET['filepath']) && $_GET['filepath'] != "" ){
+	header('Location: vidPlay.php?src='.$_GET['filepath']);
+}
+?>
+    <nav class="ts attached borderless small menu">
+            <a id="rtiBtn" href="../" class="item"><i class="angle left icon"></i></a>
+            <a href="" class="item">ArOZ Video</a>
+            <div class="right menu">
+		    	<a href="<?php echo $uploadPath;?>" class="item"><i class="upload icon"></i></a>
+			    <a href="manager.php" class="item"><i class="folder open outline icon"></i></a>
+            </div>
+    </nav>
+    
+	<!-- Main Header-->
+	<div class="ts container" style="padding-top:8px;">
+	<?php
+	$templateA = '
+	<div class="ts horizontal divider">%PlayListName%</div>
+	<div class="ts list shortList">';
+    $templateB= '<div class="item videoborder" >
+            <i class="video icon"></i>
+            <div class="content" href="%VideoPlayPath%" onClick="playVideo(this);">
+                <div class="header limited">%VideoFileName%</div>
+                <div class="description">%FileInfo%</div>
+            </div>
+            <a class="rightFloatAbsolute" href="%DownloadPath%" download><i class="download icon"></i></a>
+        </div>';
+    $templateC = '</div>
+    <a class="ts mini basic fluid button" href="%PlayPlayList%"><i class="play icon"></i>View Playlist</a>';
+	$playlists = glob('playlist/*');
+	foreach($playlists as $playlist){
+		if (is_dir($playlist)){
+			$videos = glob($playlist . '/*.mp4');
+			$playlistName = hex2bin(basename($playlist));
+			$box = str_replace("%PlayListName%",$playlistName,$templateA);
+			if (count($videos) != 0){
+				$box = str_replace("%PlayPlayList%","vidPlay.php?src=".$videos[0]."&playlist=".$playlist."",$box);
+			}else{
+				//$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);
+			}
+			echo $box;
+			foreach($videos as $video){
+				//echo $video . '<br>';
+				$filename = basename($video,".mp4");
+				if (ctype_xdigit(str_replace("inith","",$filename)) && strlen(str_replace("inith","",$filename)) % 2 == 0) {
+					$decodedName = hex2bin(str_replace("inith","",$filename));
+				}else{
+					$decodedName = $filename;
+				}
+				$box = str_replace("%VideoPlayPath%","vidPlay.php?src=".$video,$templateB);
+				$box = str_replace("%VideoFileName%",$decodedName,$box);
+				$box = str_replace("%DownloadPath%","download.php?download=".$video,$box);
+				$box = str_replace("%FileInfo%",formatBytes(filesize($video)) . " [".pathinfo($video, PATHINFO_EXTENSION)."]",$box);
+				echo $box;
+			}
+		
+			if (count($videos) != 0){
+        	    echo str_replace("%PlayPlayList%","vidPlay.php?src=".$videos[0]."&playlist=uploads",$templateC);
+        	}else{
+        	    echo str_replace("%PlayPlayList%","",$templateC);
+        	}
+			
+		}
+	}
+	
+	$unsorted = glob("uploads/*.mp4");
+	$box = str_replace("%PlayListName%","Unsorted Videos",$templateA);
+	if (count($unsorted) != 0){
+				$box = str_replace("%PlayPlayList%","vidPlay.php?src=".$unsorted[0]."&playlist=uploads",$box);
+	}else{
+				//$box = str_replace('  <a href="%PlayPlayList%"> Play playlist</a>','  <kbd>Empty playlist</kbd>',$box);
+	}
+	echo $box;
+	foreach ($unsorted as $video){
+		$filename = basename($video,".mp4");
+		if (ctype_xdigit(str_replace("inith","",$filename)) && strlen(str_replace("inith","",$filename)) % 2 == 0) {
+			$decodedName = hex2bin(str_replace("inith","",$filename));
+		}else{
+			$decodedName = $filename;
+		}
+		$box = str_replace("%VideoPlayPath%","vidPlay.php?src=".$video,$templateB);
+		$box = str_replace("%VideoFileName%",$decodedName,$box);
+		$box = str_replace("%DownloadPath%","download.php?download=".$video,$box);
+		$box = str_replace("%FileInfo%",formatBytes(filesize($video)) . " [".pathinfo($video, PATHINFO_EXTENSION)."]",$box);
+		echo $box;
+	}
+	if (count($unsorted) != 0){
+	    echo str_replace("%PlayPlayList%","vidPlay.php?src=".$unsorted[0]."&playlist=uploads",$templateC);
+	}else{
+	    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);
+	}
+	
+	
+	//Check for external storage devices
+	if (file_exists("/media/")){
+		//This system have media directory and check for mounting points
+		$extstorages = glob("/media/storage*");
+		foreach ($extstorages as $storage){
+			if (file_exists("$storage/Video/")){
+				$unsorted = glob("$storage/Video/*.mp4");
+				$box = str_replace("%PlayListName%","External Storage ($storage)",$templateA);
+				if (count($unsorted) != 0){
+							$box = str_replace("%PlayPlayList%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$unsorted[0]."&playlist=$storage/Video/&isExt=true",$box);
+				}else{
+							$box = str_replace('  <a href="%PlayPlayList%"> Play playlist</a>','  <kbd>Empty playlist / Not Plugged In</kbd>',$box);
+				}
+				echo $box;
+				foreach ($unsorted as $video){
+					$filedata = explode('/',$video);
+					$fullFileName = array_pop($filedata);
+					$filename = str_replace(".mp4","",$fullFileName);
+					//$filename = basename($video,".mp4");
+					if (strpos($filename,"inith") !== false){
+						$decodedName = hex2bin(str_replace("inith","",$filename));
+					}else{
+						$decodedName = $filename;
+					}
+					$box = str_replace("%VideoPlayPath%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$video,$templateB);
+					$box = str_replace("%VideoFileName%",$decodedName,$box);
+					$box = str_replace("%DownloadPath%","download.php?download=".$video,$box);
+					$box = str_replace("%FileInfo%",formatBytes(filesize($video)) . " [".pathinfo($video, PATHINFO_EXTENSION)."]",$box);
+					echo $box;
+				}
+					if (count($unsorted) != 0){
+                	    echo str_replace("%PlayPlayList%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$unsorted[0]."&playlist=$storage/Video/&isExt=true",$templateC);
+                	}else{
+                	    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);
+                	}
+				}
+		}
+	}
+	//scan for external playlist. This won't show if nothing is found.
+	if (file_exists("/media/")){
+		//This system have media directory and check for mounting points
+		$extstorages = glob("/media/storage*");
+		foreach ($extstorages as $storage){
+			if (file_exists("$storage/Video/")){
+				$playlists = glob( $storage . '/Video/*');
+				foreach($playlists as $playlist){
+					if (is_dir($playlist)){
+						$unsorted = glob($playlist . "/*.mp4");
+						//basename in traiditional mode to prevent utf-8 encoding error
+						$tmp_1 = explode("/",$playlist);
+						$basename = array_pop($tmp_1);
+						if (ctype_xdigit($basename) && strlen($basename) % 2 == 0) {
+							$playlistName = hex2bin($basename);
+						} else {
+							$playlistName = $basename;
+						}
+						$box = str_replace("%PlayListName%", $playlistName . " - ($storage)",$templateA);
+						$box = str_replace('layout icon','disk outline icon',$box);
+						if (count($unsorted) != 0){
+									$box = str_replace("%PlayPlayList%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$unsorted[0]."&playlist=$storage/Video/$basename&isExt=true",$box);
+						}else{
+									//$box = str_replace('  <a href="%PlayPlayList%"> Play playlist</a>','  <kbd>Empty playlist / Not Plugged In</kbd>',$box);
+						}
+						echo $box;
+						foreach ($unsorted as $video){
+							$filedata = explode('/',$video);
+							$fullFileName = array_pop($filedata);
+							$filename = str_replace(".mp4","",$fullFileName);
+							if (strpos($filename,"inith") !== false){
+								$decodedName = hex2bin(str_replace("inith","",$filename));
+							}else{
+								$decodedName = $filename;
+							}
+							$box = str_replace("%VideoPlayPath%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$video,$templateB);
+							$box = str_replace("%VideoFileName%",$decodedName,$box);
+							$box = str_replace("%DownloadPath%","download.php?download=".$video,$box);
+							$box = str_replace("%FileInfo%",formatBytes(filesize($video)) . " [".pathinfo($video, PATHINFO_EXTENSION)."]",$box);
+							echo $box;
+						}
+						if (count($unsorted) != 0){
+                    	    echo str_replace("%PlayPlayList%","vidPlay.php?src=../SystemAOB/functions/extDiskAccess.php?file=".$unsorted[0]."&playlist=$playlist&isExt=true",$templateC);
+                    	}else{
+                    	    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);
+                    	}
+					}
+				}
+			}
+		}
+	}
+	?>
+	
+	<br><br>
+	</div>
+	<script>
+	if (ao_module_virtualDesktop){
+	    $("#rtiBtn").hide();
+	}
+	    ao_module_setWindowIcon("film");
+	    ao_module_setWindowTitle("ArOZ Video");
+	    ao_module_setGlassEffectMode();
+		
+	function playVideo(object){
+		var url = $(object).attr("href");
+		window.location.href = url;
+	}
+	
+	$( window ).resize(function() {
+	    if ($(window).width() < 425){
+	        $(".video.icon").each(function(){
+	            $(this).css("display","none");
+	        });
+	    }else{
+	        $(".video.icon").each(function(){
+	            $(this).css("display","");
+	        });
+	    }
+	});
+	</script>
+</body>
+</html>

+ 221 - 0
Video/manager.js

@@ -0,0 +1,221 @@
+//Image Manager Control Script
+//Global Variables
+var csdirectory = "";//Current Selected Directory
+var previewMode = true;
+var sendmode = 0;
+var selectedFiles = [];
+//SendMode define the mode to move files.
+// 0 - Do not sent
+// 1 - Sent only selected
+// 2 - Sent All
+// 3 - Delete Selected
+$( document ).ready(function() {
+	//Hide the notification bar
+    $('#nfb').hide();
+	//Hide the confirm box
+	$('#confirmbox').hide();
+	//Enable Preview mode as default
+	$("#btn1").attr('class','ts button active');
+	//Unselect all checkbox to prevent browser memory.
+	toggleFalse();
+});
+
+//Check if the foldername contain illegal characters
+$('#fileNameInput').on('input',function(e){
+	//$('#fileNameInput').val($('#fileNameInput').val().replace(/[^A-Za-z0-9]/g, ""));
+});
+
+//Check if the user confirm folder creation
+$("#fileNameInput").on('keyup', function (e) {
+    if (e.keyCode == 13) {
+		if ($('#fileNameInput').val() != ""){
+        $.ajax({
+			data: 'name=' + $('#fileNameInput').val(),
+			url: 'new_folder.php',
+			method: 'POST', // or GET
+			success: function(msg) {
+				console.log(msg);
+				if (msg == "DONE"){
+					location.reload(); 
+				}else{
+					showNotifiy("Something went wrong on the server side :(");
+				}
+			}
+		});
+		}else{
+			$('#filenamer').fadeOut('fast');
+		}
+    }
+});
+
+
+
+//Management finished
+function done(){
+	$("body").fadeOut(1000,function(){
+       window.location.href = "index.php";
+    })
+}
+
+//Starting a new folder
+function newfolder(){
+	$('#filenamer').show();
+	$('#fileNameInput').focus();
+	showNotifiy('Enter the folder name and press Enter to create new folder.');
+}
+
+//Check all checkbox
+function toggle() {
+  checkboxes = document.getElementsByName('box2check');
+  for(var i=0, n=checkboxes.length;i<n;i++) {
+    checkboxes[i].checked = true;
+  }
+}
+
+//Uncheck all checkbox
+function toggleFalse() {
+  checkboxes = document.getElementsByName('box2check');
+  for(var i=0, n=checkboxes.length;i<n;i++) {
+    checkboxes[i].checked = false;
+  }
+}
+
+function ConfirmAction(){
+	$('#confirmbox').fadeOut('slow');
+	if (selectedFiles.length != 0 && sendmode != 0){
+		//There are action and files prepared to be sent
+		$.ajax({
+			data: 'files=' + selectedFiles + '&opr=' + sendmode + '&dir=' + csdirectory,
+			url: 'mover.php',
+			method: 'POST', // or GET
+			success: function(msg) {
+				console.log(msg);
+				if (msg == "DONE"){
+					location.reload(); 
+				}else{
+					showNotifiy("Something went wrong on the server side :(");
+				}
+			}
+		});
+		
+		
+	}
+	
+}
+
+function MoveFile(mode){
+	$('#confirmbox').css('background', 'rgba(0,0,0,0.7)');
+	if (csdirectory == "" && mode != 3){
+		//No selected folder target 
+		showNotifiy("No target folder selected.");
+	}else{
+		$('#confirmbox').fadeIn('slow');
+		var msg = "Error. Please refresh this page."
+		sendmode = mode;
+		if (mode == 1){
+			//Get all the checked ids
+			var all, checked, notChecked;
+			all = $("input:checkbox");
+			checked = all.filter(":checked");
+			notChecked = all.not(":checked");
+			var checkedIds = checked.map(function() {
+				return this.id;
+			});
+			msg = "Are you sure that you want to sent the these files to '" + csdirectory +"' ? <br> This process cannot be undo. List of files to be moved:<br>";
+			selectedFiles = [];
+			for (var i = 0, len = checkedIds.length; i < len; i++){
+				//console.log(GetFileNameFromID(checkedIds[i]));
+				var filename = GetFileNameFromID(checkedIds[i]);
+				msg += filename + " -> " + filename.replace("uploads/",csdirectory + "/") + "<br>";
+				selectedFiles.push(filename);
+			}
+			console.log(selectedFiles);
+		}else if (mode == 2){
+			var all, checked, notChecked;
+			all = $("input:checkbox");
+			var Ids = all.map(function() {
+				return this.id;
+			});
+			msg = "All files under 'Unsorted' will be moved to '" + csdirectory + "'. Are you sure?<br> This process cannot be undo. List of files to be moved:<br>";
+			selectedFiles = [];
+			for (var i = 0, len = Ids.length; i < len; i++){
+				//console.log(GetFileNameFromID(checkedIds[i]));
+				var filename = GetFileNameFromID(Ids[i]);
+				msg += filename + " -> " + filename.replace("uploads/",csdirectory + "/") + "<br>";
+				selectedFiles.push(filename);
+			}
+			
+		} else if (mode == 3){
+			$('#confirmbox').css('background', 'rgba(124,66,70,0.8)'); //DARKER:rgba(84,44,47,0.7)
+			var all, checked, notChecked;
+			all = $("input:checkbox");
+			checked = all.filter(":checked");
+			notChecked = all.not(":checked");
+			var checkedIds = checked.map(function() {
+				return this.id;
+			});
+			msg = "All selected files will be DELETED. Are you sure?<br> This process cannot be undo. List of files TO BE DELETED:<br>";
+			selectedFiles = [];
+			for (var i = 0, len = checkedIds.length; i < len; i++){
+				//console.log(GetFileNameFromID(checkedIds[i]));
+				var filename = GetFileNameFromID(checkedIds[i]);
+				msg += "[REMOVE] " + filename + "<br>";
+				selectedFiles.push(filename);
+			}
+			
+		}
+		$('#confirminfo').html(msg);
+	}
+}
+
+
+function GetFileNameFromID(divid){
+	return $("#" + divid + "-rfp").html();
+}
+
+function TogglePreview(){
+	if (previewMode == true){
+		$("#btn1").attr('class','ts button');
+		showNotifiy("Preview Mode Disabled.");
+		previewMode = false;
+		$("#previewWindow").attr("src","img/function_icon.png");
+	}else{
+		$("#btn1").attr('class','ts button active');
+		showNotifiy("Preview Mode Enabled.");
+		previewMode = true;
+	}
+}
+
+//Show preview if clicked
+function showPreview(divid){
+	if (previewMode == true){
+		var src = $("#" + divid + "-rfp").html();
+		//$("#previewWindow").attr("src",src);
+		if($("#" + divid + "-rfp").length == 0) {
+		  console.log('DIV NOT FOUND');
+		}
+		
+	}
+	//Update other information
+	$('#ImageName').html($("#" + divid + "-ofn").html() + "." + $("#" + divid + "-ext").html());
+	$('#fileext').html($("#" + divid + "-ext").html());
+	$('#storagename').html($("#" + divid + "-rfp").html());
+	$('#imgsize').html($("#" + divid + "-size").html());
+	//$('#targetdir').html($("#" + divid + "-rfp").html());
+}
+
+//Change active focus of folder
+function selectFolder(foldername){
+	$("#" + foldername).attr('class','item active');
+	if (csdirectory != ""){
+		$("#" + csdirectory).attr('class','item');
+	}
+	csdirectory = foldername;
+	$('#targetdir').html(foldername);
+}
+
+//Simple function for poping out the notification bar
+function showNotifiy(text){
+	$('#nfbtxt').html(text);
+	$('#nfb').stop().fadeIn('slow').delay(2000).fadeOut('slow');
+}

+ 285 - 0
Video/manager.php

@@ -0,0 +1,285 @@
+<?php
+include '../auth.php';
+if(isset($_GET["bkend"])){
+	if(isset($_GET["query"])){
+		if($_GET["query"] == "playlist"){
+			$intdirs = array_filter(glob("playlist/" . "*"), 'is_dir');
+			$IntDirWInfo = [];
+			foreach ($intdirs as &$intdir) {
+				preg_match('/playlist\/([^\/]*)/', $intdir, $out_playlist);
+				$tmp = [];
+				$tmp["name"] = "Internal - ".hex2bin($out_playlist[1]);
+				$tmp["dir"] = $intdir;
+				$tmp["drive"] = "internal";
+				$tmp["playlist"] = $out_playlist[1];
+				array_push($IntDirWInfo,$tmp);
+			}
+			if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+				$ExtDirWInfo = []; //TODO: add ext support
+			}else{
+				if (file_exists("/media/")){
+					$extdirs = array_filter(glob("/media/*/Video/*"), 'is_dir');
+					$ExtDirWInfo = [];
+					foreach ($extdirs as &$extdir) {
+						preg_match('/\/media\/([^\/]*)\//', $extdir, $out_storage);
+						preg_match('/Video\/([^\/]*)/', $extdir, $out_playlist);
+						$tmp = [];
+						$tmp["name"] = $out_storage[1]." - ".hex2bin($out_playlist[1]);
+						$tmp["dir"] = $extdir;
+						$tmp["drive"] = $out_storage[1];
+						$tmp["playlist"] = $out_playlist[1];
+						array_push($ExtDirWInfo,$tmp);
+					}
+				}
+			}
+			$dirs = array_merge($IntDirWInfo,$ExtDirWInfo);
+			echo json_encode($dirs);
+		}else if($_GET["query"] == "storage"){
+			$extdirs = array_filter(glob("/media/*"), 'is_dir');
+			$dirs = array_merge($extdirs,["internal"]);
+			echo json_encode($dirs);
+		}else if($_GET["query"] == "unsort"){
+			$intdirs = glob('uploads/*.mp4', GLOB_BRACE);
+			$IntDirWInfo = [];
+			foreach ($intdirs as &$intdir) {
+				$tmp = [];
+				$tmp["dir"] = $intdir;
+				$tmp["drive"] = "internal";
+				array_push($IntDirWInfo,$tmp);
+			}
+			if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+				$ExtDirWInfo = []; //TODO: add ext support
+			}else{
+				if (file_exists("/media/")){
+					$extdirs = glob("/media/*/Video/*.mp4");
+					$ExtDirWInfo = [];
+					foreach ($extdirs as &$extdir) {
+						preg_match('/\/media\/([^\/]*)\//', $extdir, $out_storage);
+						$tmp = [];
+						$tmp["dir"] = $extdir;
+						$tmp["drive"] = $out_storage[1];
+						array_push($ExtDirWInfo,$tmp);
+					}
+				}
+			}
+			$dirs = array_merge($IntDirWInfo,$ExtDirWInfo);
+			echo json_encode($dirs);
+		}
+	}
+	die();
+}
+?>
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="UTF-8">
+	<script src="../script/jquery.min.js"></script>
+    <link rel="stylesheet" href="../script/tocas/tocas.css">
+	<script type='text/javascript' src="../script/tocas/tocas.js"></script>
+	<script type='text/javascript' src="../script/ao_module.js"></script>
+	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+	<title>ArOZ Onlineβ</title>
+	<style>
+		@media (max-width: 767px){
+			.ts.bottom.right.snackbar.active{
+				width: 100% !important;
+				bottom: 0px !important;
+				right: 0px !important;
+			}
+		}
+	</style>
+</head>
+<body>
+<nav class="ts attached borderless small menu">
+            <a id="rtiBtn" href="index.php" class="item"><i class="angle left icon"></i></a>
+            <a href="" class="item">ArOZ Video</a>
+            <div class="right menu">
+				<a onclick="ts('#AddPlaylistModal').modal('show')" class="item"><i class="add outline icon"></i></a>
+		    	<a href="../Upload Manager/upload_interface.php?target=Video&filetype=mp4" class="item"><i class="upload icon"></i></a>
+			    <a href="manager.php" class="item"><i class="folder open outline icon"></i></a>
+            </div>
+</nav>
+<br>
+<div class="ts container">
+<div class="ts inverted info segment">
+	<p>Batch moving :
+	<select class="ts basic dropdown" name="batchfolderdropdown">
+		<option>Select</option>
+	</select>
+	</p>
+</div>
+
+	<div class="ts segmented list" id="unsortlist">
+
+	</div>
+</div>
+
+<div class="ts modals dimmer">
+	<dialog id="AddPlaylistModal" class="ts fullscreen modal" open>
+		<div class="header">
+			Create new playlist
+		</div>
+		<div class="content">
+			<div class="ts form">
+			    <div class="field">
+					<label>Storage</label>
+					<select name="storagedropdown">
+						<option>Select</option>
+					</select>
+				</div>
+				<div class="field">
+					<label>New playlist name</label>
+					<input type="text" id="playlistname">
+					<small></small>
+				</div>
+			</div>
+		</div>
+		<div class="actions">
+			<button class="ts deny button">
+				Cancel
+			</button>
+			<button class="ts positive button" onclick="submit()">
+				Confirm
+			</button>
+		</div>
+	</dialog>
+</div>
+<div class="ts bottom right snackbar">
+    <div class="content"></div>
+</div>
+<script>
+//first script to run
+$.ajax({url: "manager.php?bkend=true&query=unsort", success: function(result){
+	var resultArr = JSON.parse(result);
+	var allfile = "";
+	$.each(resultArr, function( index, value ) {
+		if(value["drive"] !== "internal"){
+			var drivename = '<div class="ts horizontal right floated label"><i class="usb icon"></i>' + value["drive"] + '</div>';
+		}else{
+			var drivename = '';
+		}
+		$("#unsortlist").append('<details class="ts accordion item" id="' + value["dir"] + '"><summary><i class="dropdown icon"></i>' + ao_module_codec.decodeUmFilename(value["dir"].replace(/^.*[\\\/]/, '')) + drivename + '</summary><div class="content"><div class="ts segmented list" style="padding: 10px;"><div class="ts item"><p><i class="move icon"></i>Move to&nbsp;&nbsp;<select class="ts basic dropdown" name="folderdropdown" file="' + value["dir"] + '" storage="' + value["drive"] + '"><option>Select</option></select></p></div><div class="ts item"><button name="deletefile"  file="' + value["dir"] + '" class="ts mini very compact negative button"><i class="delete icon"></i>Delete</button></div></div></div></details>');
+		allfile += value["dir"] + ",";
+	});
+	$("select[name='batchfolderdropdown']").attr("file",allfile.substr(0,allfile.length -1));
+	step2();
+}});
+
+function step2(){
+	$.ajax({url: "manager.php?bkend=true&query=playlist", success: function(result){
+		var resultArr = JSON.parse(result);
+		$("select[name='folderdropdown']").html("");
+		$("select[name='folderdropdown']").append(new Option("Select",""));
+		
+		$("select[name='batchfolderdropdown']").html("");
+		$("select[name='batchfolderdropdown']").append(new Option("Select",""));		
+		$.each(resultArr, function( index, value ) {
+			$("select[name='folderdropdown'][storage='" + value["drive"] + "']").append(new Option(value["name"],value["dir"]));
+			$("select[name='batchfolderdropdown']").append(new Option(value["name"],value["dir"]));
+		});
+		
+		step3();
+	}});
+}
+
+function step3(){
+	$.ajax({url: "manager.php?bkend=true&query=storage", success: function(result){
+		var resultArr = JSON.parse(result);
+		$("select[name='storagedropdown']").html("");
+		$("select[name='storagedropdown']").append(new Option("Select",""));
+		$.each(resultArr, function( index, value ) {
+			$("select[name='storagedropdown']").append(new Option(value,value));
+		});
+	}});
+	
+	step4();
+}
+
+function step4(){
+	$( "select[name='batchfolderdropdown']" ).change(function() {
+		var DOM = $(this);
+		$.post( "mover.php", { opr: 1, files: $(this).attr("file"), dir: $(this).val() },function( data ) {
+			if(data == "DONE"){
+				$("#unsortlist").html('<div class="ts slate accordion item"><i class="notice circle icon"></i><span class="header">No file unsorted</span><span class="description">Upload some files to here :)</span></div>');
+				msgbox("Finished.");
+			}else{
+				msgbox("Error.");
+			}
+		});
+	});
+	
+	$( "select[name='folderdropdown']" ).change(function() {
+		if($(this).val()!==""){
+			var DOM = $(this);
+			$.post( "mover.php", { opr: 1, files: $(this).attr("file"), dir: $(this).val() },function( data ) {
+				if(data == "DONE"){
+					$(DOM).parent().parent().parent().parent().parent().fadeOut( "slow", function() {
+						$(DOM).parent().parent().parent().parent().parent().remove();
+						if($.trim($("#unsortlist").html()) == ""){
+							$("#unsortlist").html('<div class="ts slate accordion item"><i class="notice circle icon"></i><span class="header">No file unsorted</span><span class="description">Upload some files to here :)</span></div>');
+						}
+					});
+					msgbox("Finished.");
+				}else{
+					msgbox("Error.");
+				}
+			});
+		}
+	});
+
+	$( "button[name='deletefile']" ).click(function() {
+		var DOM = $(this);
+		$.post( "mover.php", { opr: 3, files: $(this).attr("file")},function( data ) {
+			if(data == "DONE"){
+				$(DOM).parent().parent().parent().parent().parent().fadeOut( "slow", function() {
+					$(DOM).parent().parent().parent().parent().parent().remove();
+					if($.trim($("#unsortlist").html()) == ""){
+						$("#unsortlist").html('<div class="ts slate accordion item"><i class="notice circle icon"></i><span class="header">No file unsorted</span><span class="description">Upload some files to here :)</span></div>');
+					}
+				});
+				msgbox("Finished.");
+			}else{
+				msgbox("Error.");
+			}
+		});
+	});
+
+	$( "details" ).click(function() {
+		$("details[open='']").not(this).removeAttr('open');
+	});
+
+	$( ".ts.accordion.item" ).hover(function() {
+		$(".ts.accordion.item").not(this).removeAttr('style');
+		$(this).attr('style',"background-color:#f7f7f7");
+	});
+	
+	if($.trim($("#unsortlist").html()) == ""){
+		$("#unsortlist").html('<div class="ts slate accordion item"><i class="notice circle icon"></i><span class="header">No file unsorted</span><span class="description">Upload some files to here :)</span></div>');
+	}
+}
+
+function submit(){
+	var storage = $("select[name='storagedropdown']").val() + "/";
+	if(storage == "internal/"){
+		storage = "playlist/";
+	}
+	$.post( "new_folder.php", { storage: storage, name : $("#playlistname").val() },function( data ) {
+		if(data == "DONE"){
+			msgbox("Finished.");
+			location.reload();
+		}
+	});
+}
+
+function msgbox(content,bgcolor,fontcolor){
+	$(".snackbar").attr("style",'background-color: ' + bgcolor + ';color:' + fontcolor);
+	ts('.snackbar').snackbar({
+		content: content,
+		onAction: () => {
+			$(".snackbar").removeAttr("style");
+		}
+	});
+}
+</script>
+</body>
+</html>

+ 25 - 0
Video/mover.php

@@ -0,0 +1,25 @@
+<?php
+include '../auth.php';
+?>
+<?php
+/*
+In 2019/8/18 21:36PDT, opr == 2 has been deprecated and reduced to 2 opr only
+keeping opr == 2 only for unexpected
+1 = move
+3 = delete
+*/
+//Video Processing System
+$files = explode(",",$_POST['files']);
+$target = $_POST['dir'];
+$opr = $_POST['opr'];
+foreach ($files as $file){
+	if ($opr == 1 || $opr == 2){
+	//No idea why php rename does the moving job =w=
+		rename($file, str_replace(pathinfo($file)['dirname'],$target,$file));	
+	}
+	if ($opr == 3){
+		unlink($file);
+	}
+}
+echo 'DONE';
+?>

+ 13 - 0
Video/new_folder.php

@@ -0,0 +1,13 @@
+<?php
+include '../auth.php';
+?>
+<?php
+//New Folder Creation PHP
+$foldername = $_POST['name'];
+$storage = $_POST['storage'];
+
+if (file_exists($storage . $foldername . "/") == false){
+	mkdir($storage . bin2hex($foldername) . "/");
+	echo 'DONE';
+}
+?>

File diff suppressed because it is too large
+ 293 - 0
Video/vidPlay.php


Some files were not shown because too many files changed in this diff