<?php
/*
　* @$Id
　* @
　* @Ver: 2.0
　* @Create: 2009-11-18 8:10
　* @Modify: 
　* @Author: CPWEB http://www.cpweb.net.cn
　* @Copyright (C) 2008 www.cpweb.net.cn. All Rights Reserved.
　* @License CPWEB is free software and use is subject to license terms
　*/
class DatabaseAction extends GlobalAction{
	public function index()
	{
		$module=M();
		$list=$module->query("show table status");
		$this->assign("list",$list);
	  	$this->display();
	}
	public function optimize(){
		@set_time_limit(0);
		$act=$_POST['action'];
		$db=$_POST['id'];
		$db = implode(',',$db);
		$module=M();
		if ($act=='repair')
		{
			$d=$module->query("REPAIR TABLE $db");
		}
		if ($act=='optimize')
		{
			$d1=$module->query("OPTIMIZE TABLE $db");
		}
		$this->assign('d',$d);
		$this->assign('d1',$d1);
		$this->display();
	}
	public function exesql(){
		$this->display();
	}
	public function executesql()
	{
		$db=M();
	    $sql=$_POST['sql'];
	    $sql = stripslashes($sql);
		$this->assign('sql',$sql); 
		$l=$db->query($sql);
	        if ($l!==false) {
	         	 $type=1;
	        }else {
	        	 $type=0;
	        }
	   $this->assign('type',$type);
	   $this->display("exesql");
	}

	public function update(){

	}
	public  function cache(){
	
		
	}
}
?>