<?php

/*
*	Copyright VeryIDE,2007-2010
*	http://www.veryide.com/
*
*	$Id: veryide_welcome.php,v2 19:47 2008-2-18 Lay $
*/

require '../../include/loader.php';
html_start("数据结构 - VeryIDE");
?>

<!--body start-->

	<?php
    
    //loader
    require('include/naver.stats.php');
	
	$action = getgpc('action');
	
	$data = VI_ROOT.$_G['project']['cache']."/system/files.tables.php";
	
	if( $action == "save" ){
		
		$cache='<?php'.chr(13);
		$cache.=' /*'.date("Y-m-t H:i:s").'*/ '.chr(13);
		
		/*
		$cache.='$_CACHE["sys.tables"]=array('.chr(13);
		
		$table = $_POST["table"];
													
		foreach ($table as $key => $value) {
			
			$cache.='	"'.$key.'" => "'. str_replace('$','\$',addslashes($value)) .'", '.chr(13);			
			
		}
		
		$cache.=");".chr(13).chr(13);
		
		$cache.="?>";
		
		//exit( $cache );
		
		//写入缓存
		create_file( $data ,$cache);
		*/
		
		
	}	

	//载入缓存
	//include( $data );
	
	
    //连接数据库
        System :: connect();	
	
    ?>

    <table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
    <tr class="title">
        <td width="40"></td>
        <td width="160">表名</td>
        <td width="100">引擎</td>
        <td width="120">字符集</td>
        <td>行数</td>
        <td>数据长度</td>
        <td>索引长度</td>
        <td>描述</td>
    </tr>
    <tr class="item">
        <td colspan="8"><?php echo loader_image("icon/gear.png");?> 系统数据（表前辍：<em><?php echo VI_DBMANPRE;?></em>）</td>
    </tr>
    
    <?php		

    $result = mysql_list_tables( VI_DBNAME );
	
	$i = 1;

    while ($row = mysql_fetch_row($result)) {
        
        $table = $row[0];
        
        if( strpos( $table , VI_DBMANPRE ) !== false ){
            
            //$count = System :: $db -> getValue("SELECT count(*) from `$table`");
            
            $schema = System :: $db -> getOne("SELECT ENGINE,TABLE_COLLATION,TABLE_ROWS,DATA_LENGTH,INDEX_LENGTH,TABLE_COMMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = '".VI_DBNAME."' AND TABLE_NAME = '$table'");
            
            //<td> <input name="table['.$table.']" type="text" class="text" value="'.$_CACHE["sys.tables"][$table].'" /> </td>
        
            echo '
            <tr class="'.( $i % 2 == 0 ? 'line' : 'band' ).'">
                <td>'.$i.'</td>
                <td><strong class="text-yes">'.str_replace( VI_DBMANPRE , '' , $table ).'</strong></td>
                <td>'.$schema["ENGINE"].'</td>
                <td>'.$schema["TABLE_COLLATION"].'</td>
                <td>'.$schema["TABLE_ROWS"].'</td>
                <td>'.$schema["DATA_LENGTH"].'</td>
                <td>'.$schema["INDEX_LENGTH"].'</td>
                <td>'.$schema["TABLE_COMMENT"].'</td>
            </tr>
            ';
			
			$i++;
        
        }
        
    }
    
    ?>
    <tr class="item">
        <td colspan="8"><?php echo loader_image("icon/box.png");?> 模块数据（表前辍：<em><?php echo VI_DBMODPRE;?></em>）</td>
    </tr>
    
    <?php
    
    $result = mysql_list_tables( VI_DBNAME );
    
    while ($row = mysql_fetch_row($result)) {
        
        $table = $row[0];
        
        if( strpos( $table , VI_DBMANPRE ) === false ){
            
            //$count = System :: $db -> getValue("SELECT count(*) from `$table`");				
            
            $schema = System :: $db -> getOne("SELECT ENGINE,TABLE_COLLATION,TABLE_ROWS,DATA_LENGTH,INDEX_LENGTH,TABLE_COMMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = '".VI_DBNAME."' AND TABLE_NAME = '$table'");
            
            //<td> <input name="table['.$table.']" type="text" class="text" value="'.$_CACHE["sys.tables"][$table].'" /> </td>
        
            echo '
            <tr class="'.( $i % 2 == 0 ? 'line' : 'band' ).'">
                <td>'.$i.'</td>
                <td><strong class="text-yes">'.str_replace( VI_DBMODPRE , '' , $table ).'</strong></td>
                <td>'.$schema["ENGINE"].'</td>
                <td>'.$schema["TABLE_COLLATION"].'</td>
                <td>'.$schema["TABLE_ROWS"].'</td>
                <td>'.$schema["DATA_LENGTH"].'</td>
                <td>'.$schema["INDEX_LENGTH"].'</td>
                <td>'.$schema["TABLE_COMMENT"].'</td>
            </tr>
            ';
			
			$i++;
        
        }
        
    }
    
    ?>
    
    <?php
    
	//关闭数据库
	System :: connect();
        
    ?>
    
    </table>        
    
<!--body end-->

<?php html_close();?>