Bladeren bron

Upload files to 'Photo'

Yeung Alan 6 jaren geleden
bovenliggende
commit
0664750009
2 gewijzigde bestanden met toevoegingen van 635 en 256 verwijderingen
  1. 237 256
      Photo/index.php
  2. 398 0
      Photo/manager.php

+ 237 - 256
Photo/index.php

@@ -3,10 +3,9 @@ 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=0.6, maximum-scale=0.6"/>
+<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
 <html>
 <head>
-<link rel="manifest" href="manifest.json">
 <script type='text/javascript' charset='utf-8'>
     // Hides mobile browser's address bar when page is done loading.
       window.addEventListener('load', function(e) {
@@ -17,285 +16,267 @@ include '../auth.php';
 	<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>
-	<title>ArOZ Onlineβ</title>
+	<script src="../script/ao_module.js"></script>
+	<title>ArOZ Video</title>
 	<style>
-		body{
-			background-color: #f7f7f7;
-		}
+    	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>
-    <nav id="topMenu" class="ts attached inverted borderless normal menu">
-        <div class="ts narrow container">
-            <a href="../" class="item">ArOZ Onlineβ</a>
-        </div>
-    </nav>
+<?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
-	//random image selector
-	if (isset($_GET['folder']) && $_GET['folder'] != ""){
-		$folder = $_GET['folder'];
-		$imagesDir = 'storage/' . $folder ."/";
-	}else{
-		$imagesDir = 'uploads/';
+	$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);
+        	}
+			
+		}
 	}
-	if (isset($_GET['filepath']) && $_GET['filename']){
-		header("Location: embedded.php?filename=" . $_GET['filename'] . "&filepath=" . $_GET['filepath']);
+	
+	$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);
 	}
-	$images = glob($imagesDir . '*.{jpg,jpeg,png}', GLOB_BRACE);
-	if (sizeof($images) == 0){
-		array_push($images,'img/std_background.png');
+	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;
 	}
-	$randomImage = $images[array_rand($images)];
-	//Handle pwa request
-	$pwa = "false";
-	if (isset($_GET['pwa']) && $_GET['pwa'] == "enabled"){
-		$pwa = "true";
+	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);
 	}
-	?>
-    <div class="ts center aligned borderless attached very padded segment" style="background-image:url(<?php echo $randomImage;?>);background-size: cover; background-position: center; ">
-        <div class="ts narrow container">
-            <br>
-			<div style="background:rgba(0,0,0,0.5);border-radius: 25px;">
-            <div class="ts massive header" style="color:white">
-                Photo Station
-                <div class="sub header" style="color:white">
-                Share your photo with your friends and family
-                </div>
-            </div>
-			</div>
-            <br>
-            <a onClick="uploadImage();" class="ts labeled icon button">
-				<i class="upload icon"></i>
-				Upload
-			</a>
-			<a onClick="openImageManager();" class="ts right labeled icon button">
-				Manage
-				<i class="folder open icon"></i>
-			</a>
-            <br>
-            <br>
-        </div>
-    </div>
-	<div class="ts attached pointing secondary menu">
-		
-		<!-- Dropdown Menu -->
-		<div class="ts dropdown labeled icon button" style="width:200px">
-			<i class="folder icon"></i>
-			<span id="folderdir" class="text">Loading...</span>
-			<div class="menu">
-			<div class="header">
-				<i class="folder open icon"></i> uploads/
-			</div>
-			<?php
-				$dirs = array_filter(glob('storage/*'), 'is_dir');
-				//check if defined folder path
-				if (isset($_GET['folder']) && $_GET['folder'] != ""){
-					$folderpath = $_GET['folder'];
+	
+	
+	//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{
-					$folderpath = "";
+							$box = str_replace('  <a href="%PlayPlayList%"> Play playlist</a>','  <kbd>Empty playlist / Not Plugged In</kbd>',$box);
 				}
-				
-				//Check if defined search keyword
-				if (isset($_GET['search']) && $_GET['search'] != ""){
-					$keyword = $_GET['search'];
-				}else{
-					$keyword = "";
+				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 ($folderpath == ""){
-					echo '<a class="active item" Onclick="changeFolderView(0)">Unsorted</a>';
-				}else{
-					echo '<a class="item" Onclick="changeFolderView(0)">Unsorted</a>';
+					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);
+                	}
 				}
-				echo '<div class="divider"></div>';
-				echo '<div class="header">
-				<i class="folder open icon"></i> storage/
-				</div>';
-				foreach ($dirs as $folder){
-						$folder = str_replace("storage/","",$folder);
-						if ($folderpath == $folder){
-							echo "<a class='active item' Onclick='changeFolderView(".'"' . $folder . '"'.")'>".$folder.'</a>';	
+		}
+	}
+	//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{
-							echo "<a class='item' Onclick='changeFolderView(".'"' . $folder . '"'.")'>".$folder.'</a>';
+									//$box = str_replace('  <a href="%PlayPlayList%"> Play playlist</a>','  <kbd>Empty playlist / Not Plugged In</kbd>',$box);
 						}
-				}
-			?>
-			</div>
-		</div>
-		<div class="ts icon buttons">
-			<button id="sort1" class="ts button active" Onclick="changeSortMethod(1);"><i class="sort alphabet ascending icon"></i></button>
-			<button id="sort2" class="ts button" Onclick="changeSortMethod(2);"><i class="sort alphabet descending icon"></i></button>
-			<button id="dlbtn" class="ts button" onClick="downloadmode();"><i class="download icon"></i></button>
-			<?php 
-			if (file_exists("../QuickSend/")){
-				echo '<button class="ts button" onClick="shareThis();"><i class="share alternate icon"></i></button>';
-			}else{
-				echo '<button class="ts disabled button"><i class="share alternate icon"></i></button>';
-			}
-			?>
-			<!-- <button class="ts button" onClick="shareThis();"><i class="share alternate icon"></i></button> -->
-		</div>
-		<div class="right fitted item">
-			<div class="ts borderless right icon input">
-				<input id="searchbar" type="text" placeholder="Search...">
-				<i class="search icon"></i>
-			</div>
-		</div>
-    </div>
-
-    <div id="contentFrame" class="ts center aligned attached vertically very padded secondary segment">
-
-        <div class="ts narrow container">
-
-            <div class="ts stackable five flatted cards">
-
-				<?php
-                $template = '<div class="ts card">
-                    <div class="image">
-                        <img src="genthumb.php?src=%FILE_PATH%&size=%3C480" OnClick="TogglePreview('."'".'%IMGAGE_PATH%'."'".')">
-                    </div>
-                    <div class="left aligned content">
-                        <div class="description">%UPLOAD_DATA%</div>
-                    </div>
-                </div>';
-				//Scan all image within dir
-				if (isset($_GET['folder']) && $_GET['folder'] != ""){
-					$files = glob("storage/".$_GET['folder'].'/*.{jpg,jpeg,png,gif}', GLOB_BRACE);
-				}else{
-					$files = glob('uploads/*.{jpg,jpeg,png,gif}', GLOB_BRACE);
-				}
-				
-				//Sort the file accordingly
-				if (isset($_GET['sort']) && $_GET['sort'] != ""){
-					$sortmode = $_GET['sort'];
-					if ($_GET['sort'] = 'reverse'){
-						rsort($files);
-					}
-				}else{
-					$sortmode = "";
-					sort($files);
-				}
-				$count = 0;
-				$path2name = [];
-				foreach($files as $file) {
-					if ($keyword != ""){
-						//There are set keyword for search
-						$ext = pathinfo($file, PATHINFO_EXTENSION);
-						$filename = str_replace("." . $ext,"",str_replace("inith","",basename($file)));
-						$filename = hex2bin($filename);
-						if (strpos(strtolower($filename),strtolower($keyword)) !== False){
-							//echo $file . "<br>";
-							$box = str_replace("%FILE_PATH%",$file,$template);
-							$box = str_replace("%UPLOAD_DATA%",$filename,$box);
-							$box = str_replace("%IMGAGE_PATH%",$file,$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;
-							$count += 1;
-							array_push($path2name,[$file,$filename . "." .$ext]);
 						}
-						
-					}else{
-						$ext = pathinfo($file, PATHINFO_EXTENSION);
-						$filename = str_replace("." . $ext,"",str_replace("inith","",basename($file)));
-						$filename = hex2bin($filename);
-						//echo $file . "<br>";
-						$box = str_replace("%FILE_PATH%",$file,$template);
-						$box = str_replace("%UPLOAD_DATA%",$filename,$box);
-						$box = str_replace("%IMGAGE_PATH%",$file,$box);
-						echo $box;
-						$count += 1;
-						array_push($path2name,[$file,$filename. "." .$ext]);
+						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);
+                    	}
 					}
 				}
-				
-				if ($count == 0){
-					//No result found.
-					$box = str_replace("%FILE_PATH%","img/no_img_found.png",$template);
-					$uploadmsg = "<div align='center'><a class='ts button' onClick='uploadImage();'>Upload</a></div>";
-					$box = str_replace("%IMGAGE_PATH%","img/no_img_found.png",$box);
-					$box = str_replace("%UPLOAD_DATA%",$uploadmsg,$box);
-					echo $box;
-				}
-				?>
-               
-            </div>
-
-        </div>
-
-    </div>
-	
-    <!--Notification Bar -->
-	<div id="nbar" class="ts bottom right active snackbar" style="display:none;">
-		<div id="nbartxt" class="content">
-			Download Mode Enabled.
-		</div>
-		<a class="primary action" Onclick="downloadmode()">Toggle</a>
-	</div>
-	
-	<!-- Image Preview Window -->
-	<div id="imagePreview" align="center" style="z-index: 99; display:none;">
-	<div style="position:fixed;
-    top:0;
-    left:0 !important;;
-    height:100%;
-	width:100%;
-    z-index: 100;
-	background:rgba(0,0,0,0.3);
-	boarder:0px;" OnClick="TogglePreview()">
-	<div class="ts active dimmer"></div>	
-	</div>
-	<!-- Close Button -->
-	<div style="position:fixed;
-	z-index: 101;
-	top:100px;
-	background-color:#383838;
-	top:0;left:0;
-	">
-	<button OnClick="TogglePreview(0);" class="ts big close button"></button>
-	</div>
+			}
+		}
+	}
+	?>
 	
-	<!-- Preview Image -->
-	<div id="previewImageDiv" align="center" style="position:fixed;
-	z-index: 101;
-	top:70px;
-	left:0;
-	color:white;
-	max-height:100%;
-	//background:rgba(0,0,0,0.5);
-	">
-	<img id="previewingImage" class="ts massive image" src="img/std_background.png"><br>
-	<div id="previewImagetxt" align="center"><i class="image icon"></i>Loading...</div>
-	</div>
+	<br><br>
 	</div>
-	
-	<!-- Bottom Bar -->
-    <div class="ts bottom attached segment">
-        <div class="ts narrow container">
-            <br>
-            <div class="ts large header">
-                ArOZ Online Beta Photo Station
-                <div class="smaller sub header">
-                    CopyRight IMUS Laboratory, 2016-2017
-                </div>
-            </div>
-            <br>
-        </div>
-    </div>
-	<div id="DATA_PIPELINE_pwa" style="display:none;"><?php echo $pwa;?></div>
-	<div id="DATA_PIPELINE_folder_path" style="display:none;"><?php echo $folderpath;?></div>
-	<div id="DATA_PIPELINE_search_keyword" style="display:none;"><?php echo $keyword;?></div>
-	<div id="DATA_PIPELINE_sort_mode" style="display:none;"><?php echo $sortmode;?></div>
-	<div id="DATA_PIPELINE_path2name" style="display:none;"><?php echo json_encode($path2name); ?></div>
 	<script>
-				
-	</script>
-	<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>
-	<script src="index.js"></script>
 </body>
 </html>

+ 398 - 0
Photo/manager.php

@@ -0,0 +1,398 @@
+<?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"] = "../../../Video/".$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"] = "../../../Video/".$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>
+		body{
+			background:rgba(245,245,245,0.8);
+		}
+		@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 segment">
+	<p>Batch moving :
+	<select class="ts basic dropdown" name="batchfolderdropdown">
+		<option>Select</option>
+	</select>
+	<button name="batchfolderbutton" class="ts button"><i class="move icon"></i>Move</button>
+	</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>
+<br><br><br><br>
+<div class="ts bottom right snackbar">
+    <div class="content"></div>
+</div>
+<script>
+//Bind enter key to the input bar
+$("#playlistname").on("keydown",function(e){
+	if (e.keyCode == 13){
+		submit();
+	}
+});
+
+//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  <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(){
+	$( "button[name='batchfolderbutton']" ).click(function() {
+		var Arr = $("select[name='batchfolderdropdown']").attr("file").split(",");
+		var DOM = $("select[name='batchfolderdropdown']");
+		
+		var length = Arr.length;
+		var success = 0;
+		var failed = 0;
+		
+		$.each(Arr, function( index, value ) {
+			if(value!== ""){
+				$(DOM).parent().parent().parent().append('<div class="ts active inverted dimmer"><div class="ts text loader" id="processingtext">Processing...</div></div>');
+				$.get( "../SystemAOB/functions/file_system/fsexec.php?opr=move&from=" + value + "&target=" + $(DOM).val() + value.replace(/^.*[\\\/]/, ''), function(UUID) {
+					//Return an UUID, can call fsexec.php?listen={uuid} to see the file moving progress
+					if(!UUID.includes("ERROR")){
+						var timer = setInterval(function(){ 
+							$.get( '../SystemAOB/functions/file_system/fsexec.php?listen=["' + UUID + '"]', function(data) {
+								if(data[0][1] == "done"){
+									success += 1;
+									if(success == length){
+										$("#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>');
+										$(DOM).parent().parent().parent().find(".ts.active.inverted.dimmer").remove();
+									}
+									if((success + failed) == length){
+										location.reload();
+									}
+									msgbox("Moved " + value.replace(/^.*[\\\/]/, ''));
+									clearInterval(timer);
+								}else if(data[0][1] == "error"){
+									failed += 1;
+									if((success + failed) == length){
+										location.reload();
+									}
+									msgbox("Error moving " + value.replace(/^.*[\\\/]/, ''));
+									clearInterval(timer);
+								}
+							});
+						}, 3000);
+					}else{
+						failed += 1;
+						if((success + failed) == length){
+							location.reload();
+						}
+						msgbox(UUID);
+					}
+				});
+			}
+		});
+	});
+	
+	$( "select[name='folderdropdown']" ).change(function() {
+		if($(this).val()!==""){
+			var DOM = $(this);
+			$(DOM).parent().parent().parent().append('<div class="ts active inverted dimmer"><div class="ts text loader">Processing...</div></div>');
+			$.get( "../SystemAOB/functions/file_system/fsexec.php?opr=move&from=" + $(this).attr("file") + "&target=" + $(this).val() + $(this).attr("file").replace(/^.*[\\\/]/, ''), function(UUID) {
+				//Return an UUID, can call fsexec.php?listen={uuid} to see the file moving progress
+				if(!UUID.includes("ERROR")){
+					var timer = setInterval(function(){ 
+						$.get( '../SystemAOB/functions/file_system/fsexec.php?listen=["' + UUID + '"]', function(data) {
+							if(data[0][1] == "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>');
+									}
+								});
+								$(DOM).parent().parent().parent().find(".ts.active.inverted.dimmer").remove();
+								msgbox("Success moving " + value.replace(/^.*[\\\/]/, ''));
+								clearInterval(timer);
+							}else if(data[0][1] == "error"){
+								$(DOM).parent().parent().parent().find(".ts.active.inverted.dimmer").remove();
+								msgbox("Error moving " + value.replace(/^.*[\\\/]/, ''));
+								clearInterval(timer);
+							}
+						});
+					}, 3000);
+				}else{
+					$(DOM).parent().parent().parent().find(".ts.active.inverted.dimmer").remove();
+					msgbox(UUID);
+				}
+			});
+			
+			/*
+			$.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>');
+	}
+}
+
+/*
+    var OldArr = [];
+    var firstInitOldArr = true;
+	setInterval(function(){ 
+		var notmatch = false;
+		$.ajax({url: "manager.php?bkend=true&query=unsort", success: function(result){
+			var resultArr = JSON.parse(result);
+    		if(resultArr.length !== OldArr.length){
+    			 notmatch = true;
+    		}else{
+        		for (var i = 0; resultArr.length < i; i++) {
+        			if (resultArr[i] !== oldArr[i]){
+        				notmatch = true;
+        			}
+        		}
+    		}
+    		if(firstInitOldArr){
+    		    firstInitOldArr = false;
+    		    notmatch = false;
+    		}
+    		if(notmatch){
+    		   	location.reload();
+    		 }
+    		 OldArr = resultArr;
+		}
+		});
+	}, 3000);
+*/
+	
+function submit(){
+	if(storage = $("select[name='storagedropdown']").val() !== ""){
+		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();
+			}
+		});
+	}else{
+		msgbox("You must select the directory.");
+	}
+}
+
+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>