<?
defined('ROOT_PHPLEFT') or exit('phpleft: Not page');
/*
	phpleftDms Copyright (c) 2011 phpleft.COM
	商业授权：QQ45150208
	
*/
$rs = new admin;
$docache = new allcache;
$path = PL_ROOT.$PL_CFG['cache']."/";
$file = 'table_'.$menuid.'.inc.php';
$menuid = $table?$table:$menuid;
if ($post<>''){
switch($post) {
	case 'del':
    $db->query("DELETE FROM ".$PL_CFG['tb_pre']."table WHERE id='".$deltab."'");
	$db->query("ALTER TABLE ".$PL_CFG['tb_pre'].$menuid." DROP COLUMN ".$keys);
	$docache->menu_cache(4);
    msg('删除成功', 'phpleft.php?file=user&in=menukey&table='.$menuid.'&show=key');
	break;
	case 'paixu':
	if ($inid<>''){
    foreach($inid as $id=>$t) { 
     $query=$db->query("update 	".$PL_CFG['tb_pre']."table set keylist=".$keylist[$id]." where id='".$t."'");
    }
    $docache->menu_cache(4);
    msg('更新排序成功', 'phpleft.php?file=menukey&menuid='.$menuid.'&show=key');
   }else{
    msg('没有数据，无任何操作！', 'phpleft.php?file=user&in=menukey&table='.$menuid.'&show=key');	
    }
   break;
   case 'add':
   $do->into($alladd,'table');
   $docache->menu_cache(4);
   $length = $alladd[length] ? "(".$alladd[length].")" : '';
   $db->query("ALTER TABLE ".$PL_CFG['tb_pre'].$alladd[moduleid]." ADD ".$alladd[thiskeys]." ".$alladd[keystype].$length);
   msg('添加字段成功', 'phpleft.php?file=user&in=menukey&table='.$alladd[moduleid].'&show=key');
   break;
   case 'bj':
   $do->update($alladd,'table','id',$id);
   $docache->menu_cache(4);
   msg('修改字段成功', 'phpleft.php?file=user&in=menukey&table='.$alladd[moduleid].'&show=key');
   break;
}
}else{
switch($show) {
	case 'key':
	$tablelist = cache_read('table_'.$menuid.'.inc.php',$path);
	break;
	case 'bj':
	$alladds=cache_read('table_'.$menuid.'.inc.php',$path);
    foreach($alladds as $id=>$allad) {
	 if ($allad[id]==$thisid){
		 $alladd =$allad;
	 }
      }
	break;
	}
$menu = array (
	array('','phpleft.php?file=user&in=set','模块设置',0),
    array('key','phpleft.php?file=user&in=menukey&table='.$table.'&show=key&show=key', '字段管理',0),
	array('add','phpleft.php?file=user&in=menukey&table='.$table.'&show=key&show=add', '添加字段',0),
	);
include 't/'.$in.'.php';
}

?>