Index: /pro-bachkim-filespace/sourcecode/application/modules/ajax/controllers/privatecontent.php
===================================================================
--- /pro-bachkim-filespace/sourcecode/application/modules/ajax/controllers/privatecontent.php	(revision 10)
+++ /pro-bachkim-filespace/sourcecode/application/modules/ajax/controllers/privatecontent.php	(revision 11)
@@ -9,11 +9,5 @@
 class PrivateContent extends MX_Controller 
 {
-	
-	public function __construct() {
-		parent::__construct();
-	}
-	
-	public function getContent () {
-		$aryDir = array(
+	/* private $_aryDir = array(
 				0 => array ('id' => 1, 'name' => 'Dir 1', 'parentID' => 0),
 				1 => array ('id' => 2, 'name' => 'Dir 2', 'parentID' => 0),
@@ -25,6 +19,6 @@
 				7 => array ('id' => 8, 'name' => 'Dir 3.1', 'parentID' => 7)
 		);
-		
-		$aryFile = array(
+	
+	private $_aryFile = array(
 				0 => array('id' => 1, 'name' => 'File 1', 'minetype' => 'text', 'size' => '1.5MB', 'parentID' => 1),
 				1 => array('id' => 2, 'name' => 'File 2', 'minetype' => 'text', 'size' => '1.6MB', 'parentID' => 1),
@@ -34,17 +28,36 @@
 				5 => array('id' => 6, 'name' => 'File 6', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 3),
 				5 => array('id' => 7, 'name' => 'File 7', 'minetype' => 'text', 'size' => '1.8MB', 'parentID' => 5)
-		);
-		
-		$aryData = array('DIRECTORIES' => $aryDir, 'FILES' => $aryFile);
-		
+		); */
+	
+	public function __construct() {
+		parent::__construct();
+		$this->load->model('Directory_model', 'objDirectory', TRUE);
+	}
+	
+	public function getContent () {
+		$aryData = array('DIRECTORIES' =>  $this->objDirectory->getAllDirectory() , 'FILES' => $this->objDirectory->getAllFile());
 		echo json_encode($aryData);
 	}
 
 	public function createDir () {
+		$parentDir =  $this->input->post('parentID',TRUE);
+		$name =  $this->input->post('name',TRUE);
 		
+		if (!is_null($parentDir) && !is_null($name)) {
+			
+			$maxID = $this->objDirectory->getMaxID (true);
+			$aryDir = array('id' => (int)$maxID + 1, 'name' => $name, 'parentID' => $parentDir, 'maxID' => $maxID);
+			
+			$result = $this->objDirectory->createDir($aryDir);
+			echo json_encode($aryDir);
+		}
 	}
 	
 	public function deleteDir () {
+		$dirID =  $this->input->post('id',TRUE);
+		$delAllChild = $this->input->post('delallchild',TRUE);
 		
+		$aryChild = $this->objDirectory->getAllChild($dirID);
+		echo json_encode($aryChild);
 	}
 
Index: /pro-bachkim-filespace/sourcecode/application/modules/ajax/models/directory_model.php
===================================================================
--- /pro-bachkim-filespace/sourcecode/application/modules/ajax/models/directory_model.php	(revision 10)
+++ /pro-bachkim-filespace/sourcecode/application/modules/ajax/models/directory_model.php	(revision 11)
@@ -9,8 +9,166 @@
 {
 
-	function __construct()
+	public function __construct()
 	{
 		// Call the Model constructor
 		parent::__construct();
 	}
+	
+	public function getAllDirectory () {
+		$dbFile = 'directory.db';
+		$h = fopen($dbFile, 'r');
+		$line = '';
+		$aryDir = array();
+		$aryField = array ('id', 'name', 'parentID');
+		
+		while (($line = fgets($h, 4096)) !== false) {
+			$aryTmp = explode(',', trim($line));
+			$aryDir[] = array_combine($aryField, $aryTmp);
+		}
+		if (!feof($h)) {
+			echo "Error: unexpected fgets() fail\n";
+		}
+		fclose($h);
+		
+		return $aryDir;
+	}
+	
+	public function getAllFile () {
+		$dbFile = 'file.db';
+		$h = fopen($dbFile, 'r');
+		$line = '';
+		$aryFile = array();
+		$aryField = array ('id', 'name', 'minetype', 'size', 'parentID');
+	
+		while (($line = fgets($h, 4096)) !== false) {
+			$aryTmp = explode(',', trim($line));
+			$aryFile[] = array_combine($aryField, $aryTmp);
+		}
+		if (!feof($h)) {
+			echo "Error: unexpected fgets() fail\n";
+		}
+		fclose($h);
+	
+		return $aryFile;
+	}
+	
+	public function createDir($aryDir) {
+		$dbFile = 'directory.db';
+		$aryField = array ('id', 'name', 'parentID');
+		$aryTmp = array();
+		$h = fopen($dbFile, 'a');
+		$line = '';
+		foreach ($aryField as $key => $field) {
+			$aryTmp[$field] = $aryDir[$field];
+		}
+		$line = implode(',',$aryTmp);
+		fwrite($h, $line."\n");
+		fclose($h);
+		return true;
+	}
+	
+	public function createFile($aryFile) {
+		$dbFile = 'file.db';
+		$aryField = array ('id', 'name', 'minetype', 'size', 'parentID');
+		$aryTmp = array();
+		$h = fopen($dbFile, 'a+');
+		$line = '';
+		foreach ($aryField as $key => $field) {
+			$aryTmp[$field] = $aryFile[$field];
+		}
+		$line = implode(',',$aryTmp);
+		fwrite($line."\n", $h);
+		fclose($h);
+		return true;
+	}
+	
+	public function deleteDir ($dirID, $delAllChild = FALSE) {
+		$dbFile = 'directory.db';
+		$dirList = $this->getAllDirectory();
+		
+		$lineNumber = 0;
+		
+		foreach ($dirList as $key => $dir) {
+			if ($dir[0] == $dirID) {
+				$lineNumber = $key;
+			}
+		}	
+		
+		//$aryChildDir =  
+		
+		if ($delAllChild) {
+			
+		}
+		
+		unset($dirList[$lineNumber]);
+		return $this->writeDB ($dbFile, $dirList);
+	}
+	
+	public function deleteFile ($fileID) {
+		$dbFile = 'file.db';
+		$fileList = $this->getAllFile();
+		
+		$lineNumber = 0;
+		
+		foreach ($fileList as $key => $file) {
+			if ($dir[0] == $dirID) {
+				$lineNumber = $key;
+			}
+		}
+		
+		unset($fileList[$lineNumber]);
+		return $this->writeDB ($dbFile, $fileList);
+	}
+	
+	public function getAllFileChild ($dirID) {
+		$fileList = $this->getAllFile();
+		$aryChild = array();
+		
+		$aryDirChild = $this->getAllDirChild($dirID);
+		
+	}
+	
+	public function getAllDirChild ($dirID) {
+		$dirList = $this->getAllDirectory();
+		$aryChild = array();
+		
+		foreach ($dirList as $key => $dir) {
+			if ($dir['parentID'] == $dirID) {
+				$aryChild[$dir['id']] = $dir;
+				
+				$aryChild[$dir['id']]['child'] = $this->getAllDirChild($dir['id']);
+				if (count($aryChild[$dir['id']]['child']) == 0) unset($aryChild[$dir['id']]['child']);
+			}
+		}
+		
+		return $aryChild;
+	}
+	
+	private function writeDB ($file, $aryDataSet, $flag = '') {
+		$flag = ($flag == 'append') ? 'a' : 'w';
+		
+		if (file_exists($file) && count($aryDataSet) > 0) {
+			$h = fopen ($file, $flag);
+			foreach ($aryDataSet as $key => $line) {
+				$line = implode(',',$aryTmp);
+				fwrite($line."\n", $h);
+			}
+			fclose ($h);
+			
+			return true;
+		}else {
+			return false;
+		}
+	}
+	
+	public function getMaxID($isDir) {
+		$list = $isDir = true ? $this->getAllDirectory() : $this->getAllFile();
+		$maxID = 0;
+		foreach ($list as $key => $e) {
+			if ($e['id'] > $maxID) $maxID = $e['id'];
+		}
+		
+		return $maxID;
+	}
+	
 }
Index: /pro-bachkim-filespace/sourcecode/assets/js/filemanager/filemanager.js
===================================================================
--- /pro-bachkim-filespace/sourcecode/assets/js/filemanager/filemanager.js	(revision 10)
+++ /pro-bachkim-filespace/sourcecode/assets/js/filemanager/filemanager.js	(revision 11)
@@ -52,5 +52,4 @@
 
 		var privateTree =  $('#treeview-container').violetTree({
-			script:'http://localhost/ajax/privatecontent/getcontent',
 			expandEasing: 'easeOutBounce', 
 			collapseEasing: 'easeOutBounce',
Index: /pro-bachkim-filespace/sourcecode/assets/js/vsfilemanager.js
===================================================================
--- /pro-bachkim-filespace/sourcecode/assets/js/vsfilemanager.js	(revision 10)
+++ /pro-bachkim-filespace/sourcecode/assets/js/vsfilemanager.js	(revision 11)
@@ -6,5 +6,6 @@
 			if( o.user == undefined ) o.user = null;
 			if( o.homeDirNameDisplay == undefined ) o.homeDirNameDisplay = 'Home';
-			if( o.script == undefined ) o.script = null;
+			if( o.host == undefined ) o.host = 'http://localhost/';
+			if( o.script == undefined ) o.script = 'ajax/privatecontent/getcontent';
 			if( o.container == undefined ) o.container = $(this);
 			if( o.dirIDprefix == undefined ) o.dirIDprefix = 'vsdir_';
@@ -21,4 +22,5 @@
 			var sendCommand = function (p) {
 				if( p.postdata == undefined ) p.postdata = null;
+				if( p.script == undefined ) p.script = o.script;
 				if( p.callbackSuccess == undefined ) p.callbackSuccess = null;
 				if( p.callbackDone == undefined ) p.callbackDone = null;
@@ -26,6 +28,6 @@
 				if( p.callbackAlways == undefined ) p.callbackAlways = null;
 
-				if (o.script != null) {
-					$.post(o.script, p.postdata, function (data){
+				if (p.script != null) {
+					$.post(o.host + p.script, p.postdata, function (data){
 						if (data) {
 							parseData = $.parseJSON(data);
@@ -181,7 +183,8 @@
 
 				var dirName = prompt("Please enter new directory name", "");
-
+				var script = 'ajax/privatecontent/createdir';
 				sendCommand({
-					postdata:{action:"create_dir",parentID:pid,name:dirName},
+					script: script,
+					postdata:{parentID:pid,name:dirName},
 					callbackSuccess: function (parsedData) {createNode({
 										id: parsedData.id,
@@ -210,10 +213,11 @@
 
 				if (confirmDel && confirmChild) {
-					var postdata = {action:"delete_dir",id:pid}
+					var postdata = {id:pid,delallchild:true}
 					sendCommand({
+						script:'ajax/privatecontent/deletedir',
 						postdata:postdata,
 						callbackSuccess: function (parsedData) {deleteNode(parsedData)}
 					});
-				}	
+				}
 			}
 
Index: /pro-bachkim-filespace/sourcecode/directory.db
===================================================================
--- /pro-bachkim-filespace/sourcecode/directory.db	(revision 11)
+++ /pro-bachkim-filespace/sourcecode/directory.db	(revision 11)
@@ -0,0 +1,16 @@
+1,Dir 1,0
+2,Dir 2,0
+3,Dir 1.1,1
+4,Dir 1.1.1,3
+5,Dir 1.1.1.1,4
+6,Dir 1.1.2,3
+7,Dir 3,0
+8,Dir 3.1,7
+9,Dir 4,0
+10,Dir 5,0
+11,Dir 4.1,9
+12,Dir 4.2,9
+13,Dir 3.2,7
+14,Dir 2.1,2
+15,Dir 2.1.1,14
+16,Dir 1.1.1.2,4
Index: /pro-bachkim-filespace/sourcecode/file.db
===================================================================
--- /pro-bachkim-filespace/sourcecode/file.db	(revision 11)
+++ /pro-bachkim-filespace/sourcecode/file.db	(revision 11)
@@ -0,0 +1,7 @@
+1,File 1,text,1.5MB,1
+2,File 2,text,1.6MB,1
+3,File 3,text,1.7MB,2
+4,File 4,text,1.8MB,2
+5,File 5,text,1.8MB,0
+6,File 6,text,1.8MB,3
+7,File 7,text,1.8MB,5
