(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
aheader();
backallow('cfcommu') || amessage('您没有当前项目的管理权限。');
include_once M_ROOT."./include/fields.fun.php";
$typearr = array('文档','会员');
if($action == 'abrelsedit'){
backnav('exconfig','abrel');
$abrels = fetch_arr();
if(!submitcheck('babrelsedit')){
tabheader("合辑项目管理 >>".'添加'."",'abrelsedit',"?entry=$entry&action=$action",'7');
trcategory(array('ID','启用',array('项目名称','txtL'),array('备注','txtL'),array('数据表','txtL'),'项目类型','删除','字段','编辑'));
foreach($abrels as $k => $v){
echo "
"."
$k\n"."
\n"."
\n"."
\n"."
".($v['tbl'] ? $v['tbl'] : ($v['source'] ? 'members' : 'archives'))."\n"."
".$typearr[$v['source']].'=>'.$typearr[$v['target']]."\n"."
删除\n"."
字段\n"."
详情\n";}
tabfooter('babrelsedit','修改');
a_guide('abrelsedit');
}else{
if(!empty($abrelsnew)){
foreach($abrelsnew as $k => $v){
$v['cname'] = empty($v['cname']) ? $abrels[$k]['cname'] : $v['cname'];
$v['remark'] = empty($v['remark']) ? $abrels[$k]['remark'] : $v['remark'];
$v['available'] = empty($v['available']) ? 0 : 1;
$db->query("UPDATE {
$tblprefix
}abrels SET cname='$v[cname]',remark='$v[remark]',available='$v[available]' WHERE arid='$k'");
}
}
updatecache('abrels');
adminlog('编辑合辑项目列表');
amessage('合辑项目编辑完成', "?entry=$entry&action=$action");
}
}elseif($action == 'abreldel' && $arid) {
backnav('exconfig','abrel');
deep_allow($no_deepmode);
if(!($abrel = fetch_one($arid))) amessage('请指定正确的项目');
if(empty($confirm)){
$message = "删除不能恢复,确定删除所选项目?
";
$message .= "确认请点击>>删除 ";
$message .= "放弃请点击>>返回";
amessage($message);
}
if($abrel['tbl']){
$db->query("DELETE FROM {
$tblprefix
}$abrel[tbl] WHERE arid='$arid'",'SILENT');
}else{
$tbl = empty($abrel['source']) ? 'archives' : 'members';
$db->query("ALTER TABLE {
$tblprefix
}$tbl DROP pid$arid",'SILENT');
$db->query("ALTER TABLE {
$tblprefix
}$tbl DROP inorder$arid",'SILENT');
$db->query("ALTER TABLE {
$tblprefix
}$tbl DROP incheck$arid",'SILENT');
}
$db->query("DELETE FROM {
$tblprefix
}afields WHERE type='ab' AND tpid='$arid'",'SILENT');
$db->query("DELETE FROM {
$tblprefix
}abrels WHERE arid='$arid'",'SILENT');
del_cache('abfields',$arid);
adminlog('删除合辑项目'.$abrel['cname']);
updatecache('abrels');
amessage('合辑删除完成',"?entry=$entry&action=abrelsedit");
}elseif($action == 'abreladd'){
deep_allow($no_deepmode);
if(!submitcheck('babreladd')){
tabheader('添加合辑项目','abreladd',"?entry=$entry&action=abreladd");
trbasic('项目名称','abrelnew[cname]');
trbasic('备注','abrelnew[remark]','','text',array('w'=>50));
trbasic('归辑来源类型','',makeradio('abrelnew[source]',$typearr),'',array('guide'=>'输入后不可更改'));
trbasic('归辑目标类型','',makeradio('abrelnew[target]',$typearr),'',array('guide'=>'输入后不可更改'));
trbasic('合辑记录数据表','abrelnew[tbl]','','text',array('guide'=>'输入后不可更改,留空则根据合辑类型自动设为archives或members,指定的表要手动添加'));
tabfooter('babreladd');
a_guide('abreladd');
}else{
$abrelnew['cname'] = empty($abrelnew['cname']) ? '' : trim(strip_tags($abrelnew['cname']));
empty($abrelnew['cname']) && amessage('请输入项目名称',M_REFERER);
$abrelnew['remark'] = empty($abrelnew['remark']) ? '' : trim(strip_tags($abrelnew['remark']));
$abrelnew['tbl'] = empty($abrelnew['tbl']) ? '' : trim(strip_tags($abrelnew['tbl']));
$db->query("INSERT INTO {
$tblprefix
}abrels SET arid=".auto_insert_id('abrels').",cname='$abrelnew[cname]',remark='$abrelnew[remark]',source='$abrelnew[source]',target='$abrelnew[target]',tbl='$abrelnew[tbl]'");
$arid = $db->insert_id();
if(!$abrelnew['tbl']){
$tbl = empty($abrelnew['source']) ? 'archives' : 'members';
$db->query("ALTER TABLE {
$tblprefix
}$tbl ADD pid$arid mediumint(8) unsigned NOT NULL default '0'");
$db->query("ALTER TABLE {
$tblprefix
}$tbl ADD inorder$arid smallint(6) unsigned NOT NULL default '0'");
$db->query("ALTER TABLE {
$tblprefix
}$tbl ADD incheck$arid tinyint(1) unsigned NOT NULL default '0'");
}
updatecache('abrels');
adminlog('添加合辑项目');
amessage('合辑项目添加成功,请详细配置。',"?entry=$entry&action=abreldetail&arid=$arid");
}
}elseif($action == 'abreldetail' && $arid){
if(!($abrel = fetch_one($arid))) amessage('请指定正确的合辑项目。');
if(@!include("exconfig/abrel_$arid.php")){
if(!submitcheck('babreldetail')) {
tabheader('合辑项目设置-'.$abrel['cname'],'abreldetail',"?entry=$entry&action=$action&arid=$arid");
trbasic('备注','abrelnew[remark]',$abrel['remark'],'text',array('w'=>50));
trbasic('设置参数数组'.($abrel['cfgs0'] && !$abrel['cfgs'] ? '输入格式错误,请修正!' : ''),'abrelnew[cfgs0]',empty($abrel['cfgs']) ? (empty($abrel['cfgs0']) ? '' : $abrel['cfgs0']) : var_export($abrel['cfgs'],1),'textarea',array('w' => 500,'h' => 300,'guide'=>'以array()输入,数组内容需要是php规范'));
trbasic('附加说明','abrelnew[content]',$abrel['content'],'textarea',array('w' => 500,'h' => 300,));
tabfooter('babreldetail','修改');
a_guide('abreldetail');
}else{
$abrelnew['cfgs0'] = empty($abrelnew['cfgs0']) ? '' : trim($abrelnew['cfgs0']);
$abrelnew['cfgs'] = varexp2arr($abrelnew['cfgs0']);
$abrelnew['remark'] = empty($abrelnew['remark']) ? '' : trim(strip_tags($abrelnew['remark']));
$abrelnew['content'] = empty($abrelnew['content']) ? '' : trim($abrelnew['content']);
$abrelnew['cfgs'] = !empty($abrelnew['cfgs']) ? addslashes(serialize($abrelnew['cfgs'])) : '';
$db->query("UPDATE {
$tblprefix
}abrels SET
remark='$abrelnew[remark]',
content='$abrelnew[content]',
cfgs0='$abrelnew[cfgs0]',
cfgs='$abrelnew[cfgs]'
WHERE arid='$arid'");
updatecache('abrels');
adminlog('编辑合辑项目'.$abrel['cname']);
amessage('合辑项目设置完成。',"?entry=$entry&action=$action&arid=$arid");
}
}
}elseif($action == 'abrelfields' && $arid){
if(!($abrel = fetch_one($arid))) amessage('指定的合辑项目不存在。');
$fields = fetch_farr($arid);
if(!submitcheck('babreldetail')){
tabheader($abrel['cname']."-字段管理 >>添加字段",'abreldetail',"?entry=$entry&action=$action&arid=$arid");
trcategory(array('有效',array('字段名称','txtL'),'排序','字段标识','字段类型','数据表','删除','编辑'));
foreach($fields as $k => $v){
echo "
\n"."
\n"."
\n"."
\n"."
".mhtmlspecialchars($k)."\n"."
".$datatypearr[$v['datatype']]."\n"."
$v[tbl]\n"."
\n"."
详情\n"."
";}
tabfooter('babreldetail');
}else{
if(!empty($delete) && deep_allow($no_deepmode)){
foreach($delete as $k){
tbl_dropfield($abrel['tbl'] ? $abrel['tbl'] : ($abrel['source'] ? 'members' : 'archives'),$k,$fields[$k]['datatype']);
$db->query("DELETE FROM {
$tblprefix
}afields WHERE type='ab' AND tpid='$arid' AND ename='$k'");
unset($fields[$k],$fieldsnew[$k]);
}
}
if(!empty($fieldsnew)){
foreach($fieldsnew as $k => $v){
$v['cname'] = tr
...
...
(Please download the complete source code to view)
...
Expand> <Close