<?php
$dirname = "/var/www/html/SIPP311/resources/template/new_template/";
function count_files($dirname) {if(is_dir($dirname)) $dir_handle = opendir($dirname); if(!$dir_handle) return false; $files = 0; while($file = readdir($dir_handle)) {if($file != "." and $file != "..") {if(!is_dir($dirname . "/" . $file)) $files++; else $files += count_files($dirname . "/" . $file); } } closedir($dir_handle); return $files; }
?>
<div name="table_pihak1" class="cssTable">
<?php echo $this->encrypt->decode(base64_decode($enc));?>
		<table class="cssTable" style="margin:0px;padding:0px;">
			<col width="5%">
			<col width="20%">
			<col width="50%">
			<tbody>
				<tr>
					<td>No</td>
					<td>Folder</td>
					<td>File Template</td>
				</tr>
				<tr><td colspan="3"><b>Total Kwabeh: <?php echo count_files($dirname); ?> Bijik</td></tr>
				 <?php
						$no=0;
						function print_dir($in,$path) {
						    $buff = '';
						    foreach ($in as $k => $v){
						        $no++;
						    	if ($no==1){
						    		$tr="<tr style='background:#007640'><td colspan='3'><font color='white'>Folder : ".strtoupper($path)."</b>--------------</td></tr>";
						    	}else{
						    		$tr="";
						    	}
						        if (!is_array($v)){
						        	$nama_file=base64_encode($path.$v);
						            $buff .= $tr."<tr onclick='popup(".'"'.$nama_file.'"'.")'><td>".$z.$no."</td><td>".$path."</td><td>".$v."</td></tr>";
						    		
						        }else{
						            $buff .= "".print_dir($v,$path.$k.DIRECTORY_SEPARATOR);
						        }
						    }
						    return $buff;
						}
						echo print_dir($map,'');
                        ?>
                  </tr>
			</tbody>
		</table>
	</div>
	<script type="text/javascript">
		function popup(kode) {
			closeLoading();
			popup_form("<?php echo base_url('c_new_template').'/popup/';?>"+kode,"_parent");
		}
	</script>
