www.gusucode.com > 08CMS空白站群系统 3.3 繁体 UTF-8 > upload/admina/cotypes.inc.php
<? (!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission'); aheader(); !checkapermission(59) && amessage(lang('no_apermission')); if($sid && $sid_self) amessage(lang('msite admin item !')); load_cache('cotypes,channels,mtpls,fieldwords,rprojects,ccfields,aaltypes'); $altypes = &$aaltypes; include_once M_ROOT."./include/upload.cls.php"; include_once M_ROOT."./include/fields.fun.php"; include_once M_ROOT."./include/fields.cls.php"; if($action=='cotypesedit') { if(!submitcheck('bcotypesedit') && !submitcheck('bcotypesadd')) { a_guide('cotypesedit'); tabheader(lang('cotypem manager'),'cotypesedit','?entry=cotypes&action=cotypesedit','10'); trcategory(array(lang('id'),lang('cotype cname'),lang('order'),lang('self_reg'),lang('admin_self'),lang('cnode leaguer'),lang('mainline leaguer'),lang('delete'),lang('detail'),lang('coclass'))); foreach($cotypes as $k => $cotype){ echo "<tr>\n". "<td class=\"item1\" width=\"35\" align=\"center\">$k</td>\n". "<td class=\"item2\"><input type=\"text\" size=\"30\" maxlength=\"30\" name=\"cotypesnew[$k][cname]\" value=\"$cotype[cname]\"></td>\n". "<td class=\"item1\" align=\"center\" width=\"40\"><input type=\"text\" size=\"4\" maxlength=\"4\" name=\"cotypesnew[$k][vieworder]\" value=\"$cotype[vieworder]\"></td>\n". "<td class=\"item2\" align=\"center\" width=\"60\">".($cotype['self_reg'] ? 'Y' : '-')."</td>\n". "<td class=\"item1\" width=\"60\" align=\"center\"><input class=\"checkbox\" type=\"checkbox\" name=\"cotypesnew[$k][ctype]\" value=\"1\"".($cotype['ctype'] ? " checked" : "")."></td>\n". "<td class=\"item2\" width=\"60\" align=\"center\"><input class=\"checkbox\" type=\"checkbox\" name=\"cotypesnew[$k][sortable]\" value=\"1\"".($cotype['sortable'] ? " checked" : "")."></td>\n". "<td class=\"item1\" width=\"60\" align=\"center\"><input class=\"checkbox\" type=\"checkbox\" name=\"cotypesnew[$k][mainline]\" value=\"1\"".($cotype['mainline'] ? " checked" : "")."></td>\n". "<td class=\"item2\" width=\"40\" align=\"center\"><a href=\"?entry=cotypes&action=cotypesdelete&coid=$k\">".lang('delete')."</a></td>\n". "<td class=\"item1\" width=\"40\" align=\"center\"><a href=\"?entry=cotypes&action=cotypedetail&coid=$k\">".lang('setting')."</a></td>\n". "<td class=\"item2\" width=\"40\" align=\"center\"><a href=\"?entry=coclass&action=coclassedit&coid=$k\">".lang('admin')."</a></td>\n". "</tr>"; } tabfooter('bcotypesedit',lang('modify')); tabheader(lang('add cotypem'),'cotypesadd','?entry=cotypes&action=cotypesedit',2,0,1); trbasic(lang('cotype cname'),'cotypeadd[cname]'); trbasic(lang('weather self_reg'),'cotypeadd[self_reg]',0,'radio'); tabfooter('bcotypesadd',lang('add')); $submitstr = ''; $submitstr .= makesubmitstr('cotypeadd[cname]',1,0,0,30); check_submit_func($submitstr); }elseif(submitcheck('bcotypesedit')){ if(!empty($cotypesnew)){ foreach($cotypesnew as $k => $cotype) { $cotype['vieworder'] = max(0,intval($cotype['vieworder'])); $cotype['ctype'] = empty($cotype['ctype']) ? 0 : 1; $cotype['notblank'] = empty($cotype['notblank']) ? 0 : 1; $cotype['sortable'] = empty($cotype['sortable']) ? 0 : 1; $cotype['mainline'] = empty($cotype['sortable']) || empty($cotype['mainline']) ? 0 : 1; $cotype['cname'] = trim(strip_tags($cotype['cname'])); $cotype['cname'] = $cotype['cname'] ? $cotype['cname'] : $cotypes[$k]['cname']; $db->query("UPDATE {$tblprefix}cotypes SET cname='$cotype[cname]', vieworder='$cotype[vieworder]', ctype='$cotype[ctype]', notblank='$cotype[notblank]', sortable='$cotype[sortable]', mainline='$cotype[mainline]' WHERE coid='$k' "); } adminlog(lang('edit cotype manager list')); updatecache('cotypes'); amessage(lang('cotype edit finish'),"?entry=cotypes&action=cotypesedit"); } } elseif(submitcheck('bcotypesadd')) { empty($cotypeadd['cname']) && amessage(lang('cotype cname missing'), '?entry=cotypes&action=cotypesedit'); $db->query("INSERT INTO {$tblprefix}cotypes SET cname='$cotypeadd[cname]', self_reg='$cotypeadd[self_reg]' "); if($coid = $db->insert_id()){ $addfield = "cotype$coid"; $db->query("ALTER TABLE {$tblprefix}archives ADD $addfield smallint(6) unsigned NOT NULL default 0",'SILENT'); adminlog(lang('add cotype')); updatecache('cotypes'); updatecache('btagnames'); amessage(lang('cotype add finish'),"?entry=cotypes&action=cotypesedit"); }else{ amessage(lang('cotype add failed'),"?entry=cotypes&action=cotypesedit"); } } }elseif($action == 'cotypedetail' && $coid){ $forward = empty($forward) ? M_REFERER : $forward; !($cotype = $cotypes[$coid]) && amessage(lang('confirmchoose cotype'),$forward); if(!submitcheck('bcotypedetail')){ a_guide('cotypedetail'); tabheader(lang('cotypem detail0 edit'),'cotypedetail',"?entry=cotypes&action=cotypedetail&coid=$coid&forward=".rawurlencode($forward)); trbasic(lang('cotype cname'),'',$cotype['cname'],''); trbasic(lang('weather self_reg'),'',lang($cotype['self_reg'] ? 'yes' : 'no'),''); trbasic(lang('weather admin_self'),'cotypenew[ctype]',$cotype['ctype'],'radio'); trbasic(lang('weather notblank catas'),'cotypenew[notblank]',$cotype['notblank'],'radio'); trbasic(lang('cnode leaguer cotype'),'cotypenew[sortable]',$cotype['sortable'],'radio'); trbasic(lang('mainline leaguer cotype'),'cotypenew[mainline]',$cotype['mainline'],'radio'); empty($cotype['self_reg']) && trbasic(lang('below channel archive forbid use'),'',makecheckbox('cotypenew[chids][]',chidsarr(1),!empty($cotype['chids']) ? explode(',',$cotype['chids']) : array(),5),''); empty($cotype['self_reg']) && trbasic(lang('below type album forbid use'),'',makecheckbox('cotypenew[atids][]',atidsarr(),!empty($cotype['atids']) ? explode(',',$cotype['atids']) : array(),5),''); tabfooter('bcotypedetail'); }else{ $cotypenew['chids'] = !empty($cotypenew['chids']) ? implode(',',$cotypenew['chids']) : ''; $cotypenew['atids'] = !empty($cotypenew['atids']) ? implode(',',$cotypenew['atids']) : ''; $db->query("UPDATE {$tblprefix}cotypes SET ctype='$cotypenew[ctype]', notblank='$cotypenew[notblank]', sortable='$cotypenew[sortable]', chids='$cotypenew[chids]', atids='$cotypenew[atids]', mainline='$cotypenew[mainline]' WHERE coid='$coid'"); adminlog(lang('detail0 modify cotype')); updatecache('cotypes'); amessage(lang('cotypem setting finish'),$forward); } }elseif($action == 'cotypesdelete' && $coid) { if(!isset($confirm) || $confirm != 'ok'){ $message = lang('del_alert')."<br><br>"; $message .= lang('confirm click')."[<a href=?entry=cotypes&action=cotypesdelete&coid=$coid&confirm=ok>".lang('delete')."</a>]<br>"; $message .= lang('giveup click')."[<a href=?entry=cotypes&action=cotypesedit>".lang('goback')."</a>]"; amessage($message); } $deletefield = "cotype$coid"; $db->query("DELETE FROM {$tblprefix}cotypes WHERE coid='$coid'"); $db-> query("ALTER TABLE {$tblprefix}archives DROP $deletefield"); $db->query("DELETE FROM {$tblprefix}coclass WHERE coid='$coid'"); updatecache('cotypes'); @unlink(M_ROOT."./dynamic/cache/coclasses".$coid.".cac.php"); adminlog(lang('delete cotype')); updatecache('btagnames'); amessage(lang('cotype delete finish'),"?entry=cotypes&action=cotypesedit"); }elseif($action == 'ccfieldadd'){ if(!submitcheck('bccfieldadd')){ a_guide('ccfieldadd'); tabheader(lang('add coclass message field'),'ccfieldadd',"?entry=cotypes&action=ccfieldadd",2,0,1); $submitstr = ''; if(empty($fieldnew['datatype'])){ trbasic(lang('field type'),'fieldnew[datatype]',makeoption($datatypearr),'select'); tabfooter('bccfieldaddpre',lang('continue')); }else{ list($fmode,$fnew,$fsave) = array('cn',true,false); include_once M_ROOT."./include/fields/$fieldnew[datatype].php"; tabfooter('bccfieldadd',lang('add')); } check_submit_func($submitstr); }else{ $enamearr = $usednames['ccfields']; $fconfigarr = array( 'errorurl' => '?entry=cotypes&action=ccfieldsedit', 'enamearr' => $enamearr, 'altertable' => $tblprefix.'coclass', 'fieldtable' => $tblprefix.'cnfields', 'sqlstr' => "iscc='1'", ); list($fmode,$fnew,$fsave) = array('cn',true,true); include_once M_ROOT."./include/fields/$fieldnew[datatype].php"; adminlog(lang('add cotype message field')); updatecache('ccfields'); updatecache('btagnames'); updatecache('usednames','ccfields'); amessage(lang('field add finish'),'?entry=cotypes&action=ccfieldsedit'); } }elseif($action == 'ccfieldsedit'){ if(!submitcheck('bccfieldsedit')){ a_guide('ccfieldsedit'); tabheader(lang('coclass message field manager')." >><a href=\"?entry=cotypes&action=ccfieldadd\">".lang('add field')."</a>",'ccfieldsedit','?entry=cotypes&action=ccfieldsedit','5'); trcategory(array(lang('delete'),lang('field cname'),lang('order'),lang('field ename'),lang('field type'),lang('edit'))); foreach($ccfields as $k => $ccfield) { fieldlist($k,$ccfield,'cc'); } tabfooter('bccfieldsedit'); }else{ if(!empty($delete)){ foreach($delete as $id){ $fieldename = $ccfields[$id]['ename']; $db->query("ALTER TABLE {$tblprefix}coclass DROP $fieldename"); $db->query("DELETE FROM {$tblprefix}cnfields WHERE iscc=1 AND ename='$id'"); unset($ccfields[$id]); unset($fieldsnew[$id]); } } foreach($ccfields as $id => $field){ $fieldsnew[$id]['cname'] = trim(strip_tags($fieldsnew[$id]['cname'])); $field['cname'] = $fieldsnew[$id]['cname'] ? $fieldsnew[$id]['cname'] : $field['cname']; $field['vieworder'] = max(0,intval($fieldsnew[$id]['vieworder'])); $db->query("UPDATE {$tblprefix}cnfields SET vieworder='$field[vieworder]', cname='$field[cname]' WHERE iscc=1 AND ename='$id'"); } adminlog(lang('edit cotype message field')); updatecache('ccfields'); updatecache('btagnames'); updatecache('usednames','ccfields'); amessage(lang('field modify finish'),'?entry=cotypes&action=ccfieldsedit'); } }elseif($action == 'ccfielddetail' && $fieldename){ !isset($ccfields[$fieldename]) && amessage(lang('confirmchoose field'), '?entry=cotypes&action=ccfieldsedit'); $field = $ccfields[$fieldename]; if(!submitcheck('bccfielddetail')){ $submitstr = ''; a_guide('ccfielddetail'); tabheader(lang('field edit')." [$field[cname]]",'ccfielddetail',"?entry=cotypes&action=ccfielddetail&fieldename=$fieldename",2,0,1); list($fmode,$fnew,$fsave) = array('cn',false,false); include_once M_ROOT."./include/fields/$field[datatype].php"; tabfooter('bccfielddetail'); check_submit_func($submitstr); }else{ $fconfigarr = array( 'altertable' => $tblprefix.'coclass', 'fieldtable' => $tblprefix.'cnfields', 'wherestr' => "WHERE ename='$fieldename' AND iscc=1", ); list($fmode,$fnew,$fsave) = array('cn',false,true); include_once M_ROOT."./include/fields/$field[datatype].php"; adminlog(lang('detail0 modify cotype message field')); updatecache('ccfields'); amessage(lang('field modify finish'),'?entry=cotypes&action=ccfieldsedit'); } } ?>