<?php
/**
 *	Generated by miceCMS
 *	http://www.miceCMS.com/
 */
class database_indexAction extends security_login {
	function action(){
		ModuleLimit(__CLASS__);

		include_once MICE_DIR.'/includes/filelist.php';
		
		if(isset($_POST['FileExtName'])){
			include_once MICE_DIR.'/includes/backup.php';
			set_time_limit(0);

			$backup=new DbBackup();
			$backup->Backup($_POST['FileExtName'],MICE_DB);
		}

		$table_data=read_dir(MICE_DIR.MICE_PRIVATE.'backup/',"file",true, array('php','sql', 'gz'));

		foreach ($table_data as $key => $row)
		{
			$cerateat[$key] = $row['created'];
		}
		
		if(sizeof($cerateat))	array_multisort($cerateat,SORT_DESC,$table_data);

		foreach ($table_data as $key => $row)
		{
			$filename[$key] = $row['id'];
		}
		$j=0;
		for($i=0;$i<sizeof($filename);$i++){
			if($files[0]['name']==''){
				$files[0]['name']=substr($filename[$i],0,21);
				$files[0]['filename']=$filename[$i];
			}else{
				if($files[$j]['name']!=substr($filename[$i],0,21)){
					$files[++$j]['name']=substr($filename[$i],0,21);
					$files[$j]['filename']=$filename[$i];
				}
			}
		}

		$smarty = new Smarty();
		$smarty->load_filter('pre','micePreCompileAdmin');		
		$smarty->assign('table_data',$table_data);
		$smarty->assign('files',$files);
		$smarty->assign('url',MICE_URL.'admin.php/database/');
		$smarty->assign('sql',MICE_URL.'admin.php/database/sql');
		$smarty->assign('testurl',MICE_URL.MICE_PRIVATE.'backup/index.html');

		$filename = new getTPLFileName(__CLASS__);
		$smarty->display($filename->TPLFileName);
	}
}
?>