<?php
define('EmpireCMSAdmin','1');
require("../class/connect.php");
require("../class/db_sql.php");
require("../class/functions.php");
require("../data/dbcache/class.php");
require LoadLang("pub/fun.php");
$link=db_connect();
$empire=new mysqlquery();
$enews=$_POST['enews'];
if(empty($enews))
{
	$enews=$_GET['enews'];
}
//驗證用戶
$lur=is_login();
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
hCheckEcmsRHash();

@set_time_limit(0);

require("../class/moddofun.php");
//設置訪問端
$moreportpid=0;
if($enews=='ChangeAllModForm')
{
	$moreportpid=Moreport_hDoSetSelfPath(0);
}
//增加字段
if($enews=="AddF")
{
	$add=$_POST;
	AddF($add,$logininid,$loginin);
}
//修改字段
elseif($enews=="EditF")
{
	$add=$_POST;
	EditF($add,$logininid,$loginin);
}
//修改系統字段
elseif($enews=="EditSysF")
{
	EditSysF($_POST,$logininid,$loginin);
}
//刪除字段
elseif($enews=="DelF")
{
	$fid=$_GET['fid'];
	$tid=$_GET['tid'];
	$tbname=$_GET['tbname'];
	DelF($fid,$tid,$tbname,$logininid,$loginin);
}
//修改字段順序
elseif($enews=="EditFOrder")
{
	$fid=$_POST['fid'];
	$tid=$_POST['tid'];
	$tbname=$_POST['tbname'];
	$myorder=$_POST['myorder'];
	EditFOrder($fid,$myorder,$tid,$tbname,$logininid,$loginin);
}
elseif($enews=='ChangeDataTableF')//轉移字段
{
	ChangeDataTableF($_GET,$logininid,$loginin);
}
elseif($enews=='ChangeDocDataTableF')//轉移字段(歸檔)
{
	ChangeDocDataTableF($_GET,$logininid,$loginin);
}
//增加模型
elseif($enews=="AddM")
{
	$add=$_POST['add'];
	$cname=$_POST['cname'];
	$cchange=$_POST['cchange'];
	$schange=$_POST['schange'];
	$center=$_POST['center'];
	$cqenter=$_POST['cqenter'];
	$menter=$_POST['menter'];
	AddM($add,$cname,$cchange,$schange,$center,$cqenter,$menter,$_POST['listand'],$_POST['ltempf'],$_POST['ptempf'],$_POST['canadd'],$_POST['canedit'],$_POST['listorder'],$logininid,$loginin);
}
//修改模型
elseif($enews=="EditM")
{
	$add=$_POST['add'];
	$cname=$_POST['cname'];
	$cchange=$_POST['cchange'];
	$schange=$_POST['schange'];
	$center=$_POST['center'];
	$cqenter=$_POST['cqenter'];
	$menter=$_POST['menter'];
	EditM($add,$cname,$cchange,$schange,$center,$cqenter,$menter,$_POST['listand'],$_POST['ltempf'],$_POST['ptempf'],$_POST['canadd'],$_POST['canedit'],$_POST['listorder'],$logininid,$loginin);
}
//刪除模型
elseif($enews=="DelM")
{
	$mid=$_GET['mid'];
	$tid=$_GET['tid'];
	$tbname=$_GET['tbname'];
	DelM($mid,$tid,$tbname,$logininid,$loginin);
}
//默認模型
elseif($enews=="DefM")
{
	$mid=$_GET['mid'];
	$tid=$_GET['tid'];
	$tbname=$_GET['tbname'];
	DefM($mid,$tid,$tbname,$logininid,$loginin);
}
//新建數據表
elseif($enews=="AddTable")
{
	AddTable($_POST,$logininid,$loginin);
}
//複製數據表
elseif($enews=="CopyNewTable")
{
	CopyNewTable($_POST,$logininid,$loginin);
}
//修改數據表
elseif($enews=="EditTable")
{
	EditTable($_POST,$logininid,$loginin);
}
//刪除數據表
elseif($enews=="DelTable")
{
	$tid=$_GET['tid'];
	DelTable($tid,$logininid,$loginin);
}
//默認數據表
elseif($enews=="DefaultTable")
{
	$tid=$_GET['tid'];
	DefaultTable($tid,$logininid,$loginin);
}
elseif($enews=="AddDataTable")//增加副表分表
{
	AddDataTable($_POST,$logininid,$loginin);
}
elseif($enews=="DefDataTable")//默認副表分表
{
	DefDataTable($_GET,$logininid,$loginin);
}
elseif($enews=="DelDataTable")//刪除副表分表
{
	DelDataTable($_GET,$logininid,$loginin);
}
//導入模型
elseif($enews=="LoadInMod")
{
	$file=$_FILES['file']['tmp_name'];
    $file_name=$_FILES['file']['name'];
    $file_type=$_FILES['file']['type'];
    $file_size=$_FILES['file']['size'];
	LoadInMod($_POST,$file,$file_name,$file_type,$file_size,$logininid,$loginin);
}
elseif($enews=='ChangeAllModForm')//批量更新模型表單
{
	ChangeAllModForm($_GET,$logininid,$loginin);
}
else
{printerror("ErrorUrl","history.go(-1)");}
db_close();
$empire=null;
?>