\n"; $query = $db->query("SELECT fid, name, type, fup FROM {$tablepre}forums WHERE type<>'sub' ORDER BY displayorder"); while($fup = $db->fetch_array($query)) { $fups[] = $fup; } if(is_array($fups)) { foreach($fups as $forum1) { if($forum1['type'] == 'group') { if(isset($fupid) && $fupid == $forum1['fid']) { $fupselected = 'selected'; $addforumtype = $forum1['type']; } else { $fupselected = ''; } $groupselect .= "$forum1[name]\n"; $forumselect .= "\n"; foreach($fups as $forum2) { if($forum2['type'] == 'forum' && $forum2['fup'] == $forum1['fid']) { if(isset($fupid) && $fupid == $forum2['fid']) { $fupselected = 'selected'; $addforumtype = $forum2['type']; } else { $fupselected = ''; } $forumselect .= " > $forum2[name]\n"; } } } } foreach($fups as $forum0) { if($forum0['type'] == 'forum' && $forum0['fup'] == 0) { if(isset($fupid) && $fupid == $forum0['fid']) { $fupselected = 'selected'; $addforumtype = $forum0['type']; } else { $fupselected = ''; } if($forum0['type'] == 'group') { $groupselect .= "$forum0[name]\n"; } else { $forumselect .= "$forum0[name]\n"; } } } } $groupselect .= ''; $forumselect .= ''; $projectselect = "".$lang['none'].""; $query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='forum'"); while($project = $db->fetch_array($query)) { $projectselect .= "$project[name]\n"; } $projectselect .= ''; shownav('menu_forums_add'); showtips('forums_add_tips'); if(empty($addforumtype)) { ?> =$lang['forums_add_category']?> =$lang['name']?>: } if(empty($addforumtype) || $addforumtype == 'group') { ?> =$lang['forums_add_forum']?> =$lang['forums_edit_board_name']?> =$lang['name']?>: =$lang['forums_add_parent_category']?>: =$groupselect?> =$lang['forums_scheme']?> =$projectselect?> } if(empty($addforumtype) || $addforumtype == 'forum') { ?> =$lang['forums_add_sub']?> =$lang['forums_edit_board_name']?> =$lang['name']?>: =$lang['forums_add_parent_forum']?>: =$forumselect?> =$lang['forums_scheme']?> =$projectselect?> } } elseif(submitcheck('catsubmit')) { if(strlen($newcat) > 50) { cpmsg('forums_name_toolong'); } $db->query("INSERT INTO {$tablepre}forums (type, name, status) VALUES ('group', '$newcat', '1')"); $fid = $db->insert_id(); $db->query("INSERT INTO {$tablepre}forumfields (fid) VALUES ('$fid')"); updatecache('forums'); updatecache('new_forums'); cpmsg('forums_add_category_succeed', 'admincp.php?action=forumsedit'); } elseif(submitcheck('forumsubmit')) { if(strlen($newforum) > 50) { cpmsg('forums_name_toolong'); } if(!$fup) { cpmsg('forums_noparent'); } $modarray = $forumfields = array(); $table_forum_columns = array('fup', 'type', 'name', 'status', 'idx_push','styleid', 'allowsmilies', 'allowhtml', 'allowbbcode', 'allowimgcode', 'allowanonymous', 'allowshare', 'allowpostspecial', 'alloweditrules', 'allowpaytoauthor', 'alloweditpost', 'modnewposts', 'recyclebin', 'jammer', 'forumcolumns', 'threadcaches', 'disablewatermark', 'autoclose', 'simple','board_name'); $table_forumfield_columns = array('fid', 'attachextensions', 'threadtypes', 'postcredits', 'replycredits', 'digestcredits', 'postattachcredits', 'getattachcredits', 'viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm'); $query = $db->query("SELECT * FROM {$tablepre}forums WHERE fid='$fup'"); $forum = $db->fetch_array($query); if(!empty($projectid)) { $query = $db->query("SELECT value FROM {$tablepre}projects WHERE id='$projectid'"); $project = unserialize($db->result($query, 0)); foreach($table_forum_columns as $field) { $forumfields[$field] = $project[$field]; } foreach($table_forumfield_columns as $field) { $forumfields[$field] = $project[$field]; } } else { $forumfields['allowsmilies'] = $forumfields['allowbbcode'] = $forumfields['allowimgcode'] = $forumfields['allowshare'] = 1; $forumfields['allowpostspecial'] = 15; } $forumfields['fup'] = $forum ? $fup : 0; $forumfields['type'] = $forum['type'] == 'forum' ? 'sub' : 'forum'; $forumfields['name'] = $newforum; $forumfields['board_name'] = $new_board_name; $forumfields['status'] = 1; $sql1 = $sql2 = $comma = ''; foreach($table_forum_columns as $field) { if(isset($forumfields[$field])) { $sql1 .= "$comma$field"; $sql2 .= "$comma'{$forumfields[$field]}'"; $comma = ', '; } } $db->query("INSERT INTO {$tablepre}forums ($sql1) VALUES ($sql2)"); $forumfields['fid'] = $fid = $db->insert_id(); $sql1 = $sql2 = $comma = ''; foreach($table_forumfield_columns as $field) { if(isset($forumfields[$field])) { $sql1 .= "$comma$field"; $sql2 .= "$comma'{$forumfields[$field]}'"; $comma = ', '; } } $db->query("INSERT INTO {$tablepre}forumfields ($sql1) VALUES ($sql2)"); $query = $db->query("SELECT uid, inherited FROM {$tablepre}moderators WHERE fid='$fup'"); while($mod = $db->fetch_array($query)) { if($mod['inherited'] || $forum['inheritedmod']) { $db->query("REPLACE INTO {$tablepre}moderators (uid, fid, inherited) VALUES ('$mod[uid]', '$fid', '1')"); } } updatecache('forums'); updatecache('new_forums'); cpmsg('forums_add_forum_succeed', 'admincp.php?action=forumsedit'); } } elseif($action == 'forumsedit') { if(!submitcheck('editsubmit')) { shownav('menu_forums_edit'); showtips('forums_tips'); ?> =$lang['forums_edit']?> $forums = $showedforums = array(); $query = $db->query("SELECT f.fid, f.type, f.status, f.name, f.fup, f.displayorder, f.inheritedmod, ff.moderators FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff USING(fid) ORDER BY f.type<>'group', f.displayorder"); while($forum = $db->fetch_array($query)) { $forums[] = $forum; } for($i = 0; $i < count($forums); $i++) { if($forums[$i]['type'] == 'group') { echo ''.showforum($i, 'group'); for($j = 0; $j < count($forums); $j++) { if($forums[$j]['fup'] == $forums[$i]['fid'] && $forums[$j]['type'] == 'forum') { echo ''.showforum($j); for($k = 0; $k < count($forums); $k++) { if($forums[$k]['fup'] == $forums[$j]['fid'] && $forums[$k]['type'] == 'sub') { echo ''.showforum($k, 'sub').''; } } echo ''; } } echo ''; } elseif(!$forums[$i]['fup'] && $forums[$i]['type'] == 'forum') { echo ''.showforum($i); for($j = 0; $j < count($forums); $j++) { if($forums[$j]['fup'] == $forums[$i]['fid'] && $forums[$j]['type'] == 'sub') { echo ''.showforum($j, 'sub').''; } } echo ''; } } foreach($forums as $key => $forum) { if(!in_array($key, $showedforums)) { $db->query("UPDATE {$tablepre}forums SET fup='0', type='forum' WHERE fid='$forum[fid]'"); echo ''.showforum($key).''; } } echo "\n"; } else { // read from groups $usergroups = array(); $query = $db->query("SELECT groupid, type, creditshigher, creditslower FROM {$tablepre}usergroups"); while($group = $db->fetch_array($query)) { $usergroups[$group['groupid']] = $group; } if(is_array($order)) { foreach($order as $fid => $value) { $db->query("UPDATE {$tablepre}forums SET displayorder='$order[$fid]' WHERE fid='$fid'"); } } updatecache('forums'); updatecache('new_forums'); cpmsg('forums_update_succeed', 'admincp.php?action=forumsedit'); } } elseif($action == 'moderators' && $fid) { if(!submitcheck('modsubmit')) { $moderators = ''; $query = $db->query("SELECT m.username, mo.* FROM {$tablepre}members m, {$tablepre}moderators mo WHERE mo.fid='$fid' AND m.uid=mo.uid ORDER BY mo.inherited, mo.displayorder"); while($mod = $db->fetch_array($query)) { $moderators .= "\n". "$mod[username]\n". "\n". "".($mod['inherited'] ? ''.$lang['yes'].'' : $lang['no'])."\n"; } if($forum['type'] == 'group' || $forum['type'] == 'sub') { $checked = $forum['type'] == 'group' ? 'checked' : ''; $disabled = 'disabled'; } else { $checked = $forum['inheritedmod'] ? 'checked' : ''; $disabled = ''; } shownav('forums_moderators_edit'); showtips('forums_moderators_tips'); ?> =$lang['forums_moderators_edit']?> - =$forum['name']?> =$lang['del']?>=$lang['username']?>=$lang['display_order']?>=$lang['forums_moderators_inherited']?> =$moderators?> =$lang['add_new']?> =$disabled?>> =$lang['forums_moderators_inherit']?> } else { if($forum['type'] == 'group') { $inheritedmodnew = 1; } elseif($forum['type'] == 'sub') { $inheritedmodnew = 0; } if(!empty($delete) || $newmoderator || (bool)$forum['inheritedmod'] != (bool)$inheritedmodnew) { $fidarray = $newmodarray = $origmodarray = array(); if($forum['type'] == 'group') { $query = $db->query("SELECT fid FROM {$tablepre}forums WHERE type='forum' AND fup='$fid'"); while($sub = $db->fetch_array($query)) { $fidarray[] = $sub['fid']; } $query = $db->query("SELECT fid FROM {$tablepre}forums WHERE type='sub' AND fup IN ('".implode('\',\'', $fidarray)."')"); while($sub = $db->fetch_array($query)) { $fidarray[] = $sub['fid']; } } elseif($forum['type'] == 'forum') { $query = $db->query("SELECT fid FROM {$tablepre}forums WHERE type='sub' AND fup='$fid'"); while($sub = $db->fetch_array($query)) { $fidarray[] = $sub['fid']; } } if(is_array($delete)) { foreach($delete as $uid) { $db->query("DELETE FROM {$tablepre}moderators WHERE uid='$uid' AND ((fid='$fid' AND inherited='0') OR (fid IN ('".implode('\',\'', $fidarray)."') AND inherited='1'))"); } $excludeuids = 0; $deleteuids = '\''.implode('\',\'', $delete).'\''; $query = $db->query("SELECT uid FROM {$tablepre}moderators WHERE uid IN ($deleteuids)"); while($mod = $db->fetch_array($query)) { $excludeuids .= ','.$mod['uid']; } $usergroups = array(); $query = $db->query("SELECT groupid, type, radminid, creditshigher, creditslower FROM {$tablepre}usergroups"); while($group = $db->fetch_array($query)) { $usergroups[$group['groupid']] = $group; } $query = $db->query("SELECT uid, groupid, credits FROM {$tablepre}members WHERE uid IN ($deleteuids) AND uid NOT IN ($excludeuids) AND adminid NOT IN (1,2)"); while($member = $db->fetch_array($query)) { if($usergroups[$member['groupid']]['type'] == 'special' && $usergroups[$member['groupid']]['radminid'] != 3) { $adminidnew = -1; $groupidnew = $member['groupid']; } else { $adminidnew = 0; foreach($usergroups as $group) { if($group['type'] == 'member' && $member['credits'] >= $group['creditshigher'] && $member['credits'] < $group['creditslower']) { $groupidnew = $group['groupid']; break; } } } $db->query("UPDATE {$tablepre}members SET adminid='$adminidnew', groupid='$groupidnew' WHERE uid='$member[uid]'"); } } if((bool)$forum['inheritedmod'] != (bool)$inheritedmodnew) { $query = $db->query("SELECT uid FROM {$tablepre}moderators WHERE fid='$fid' AND inherited='0'"); while($mod = $db->fetch_array($query)) { $origmodarray[] = $mod['uid']; if(!$forum['inheritedmod'] && $inheritedmodnew) { $newmodarray[] = $mod['uid']; } } if($forum['inheritedmod'] && !$inheritedmodnew) { $db->query("DELETE FROM {$tablepre}moderators WHERE uid IN ('".implode('\',\'', $origmodarray)."') AND fid IN ('".implode('\',\'', $fidarray)."') AND inherited='1'"); } } if($newmoderator) { $query = $db->query("SELECT uid FROM {$tablepre}members WHERE username='$newmoderator'"); if(!$member = $db->fetch_array($query)) { cpmsg('members_edit_nonexistence'); } else { $newmodarray[] = $member['uid']; $db->query("UPDATE {$tablepre}members SET groupid='3' WHERE uid='$member[uid]' AND adminid NOT IN (1,2,3,4,5,6,7,8,-1)"); $db->query("UPDATE {$tablepre}members SET adminid='3' WHERE uid='$member[uid]' AND adminid NOT IN (1,2)"); $db->query("REPLACE INTO {$tablepre}moderators (uid, fid, displayorder, inherited) VALUES ('$member[uid]', '$fid', '$newdisplayorder', '0')"); } } foreach($newmodarray as $uid) { $db->query("REPLACE INTO {$tablepre}moderators (uid, fid, displayorder, inherited) VALUES ('$uid', '$fid', '$newdisplayorder', '0')"); if($inheritedmodnew) { foreach($fidarray as $ifid) { $db->query("REPLACE INTO {$tablepre}moderators (uid, fid, inherited) VALUES ('$uid', '$ifid', '1')"); } } } if($forum['type'] == 'group') { $inheritedmodnew = 1; } elseif($forum['type'] == 'sub') { $inheritedmodnew = 0; } $db->query("UPDATE {$tablepre}forums SET inheritedmod='$inheritedmodnew' WHERE fid='$fid'"); } if(is_array($displayordernew)) { foreach($displayordernew as $uid => $order) { $db->query("UPDATE {$tablepre}moderators SET displayorder='$order' WHERE fid='$fid' AND uid='$uid'"); } } $moderators = $tab = ''; $query = $db->query("SELECT m.username FROM {$tablepre}members m, {$tablepre}moderators mo WHERE mo.fid='$fid' AND mo.inherited='0' AND m.uid=mo.uid ORDER BY mo.displayorder"); while($mod = $db->fetch_array($query)) { $moderators .= $tab.addslashes($mod['username']); $tab = "\t"; } $db->query("UPDATE {$tablepre}forumfields SET moderators='$moderators' WHERE fid='$fid'"); cpmsg('forums_moderators_update_succeed', "admincp.php?action=moderators&fid=$fid"); } } elseif($action == 'forumsmerge') { if(!submitcheck('mergesubmit') || $source == $target) { require_once DISCUZ_ROOT.'./include/forum.func.php'; require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php'; $forumselect = "\n > $lang[select] ".str_replace('%', '%%', forumselect()).''; shownav('menu_forums_merge'); ?> =$lang['forums_merge']?> =$lang['forums_merge_source']?>: =sprintf($forumselect, "source")?> =$lang['forums_merge_target']?>: =sprintf($forumselect, "target")?> } else { $query = $db->query("SELECT COUNT(*) FROM {$tablepre}forums WHERE fid IN ('$source', '$target') AND type<>'group'"); if(($db->result($query, 0)) != 2) { cpmsg('forums_nonexistence'); } $query = $db->query("SELECT COUNT(*) FROM {$tablepre}forums WHERE fup='$source'"); if($db->result($query, 0)) { cpmsg('forums_merge_source_sub_notnull'); } $db->query("UPDATE {$tablepre}threads SET fid='$target' WHERE fid='$source'"); $db->query("UPDATE {$tablepre}posts SET fid='$target' WHERE fid='$source'"); $query = $db->query("SELECT threads, posts FROM {$tablepre}forums WHERE fid='$source'"); $sourceforum = $db->fetch_array($query); $db->query("UPDATE {$tablepre}forums SET threads=threads+$sourceforum[threads], posts=posts+$sourceforum[posts] WHERE fid='$target'"); $db->query("DELETE FROM {$tablepre}forums WHERE fid='$source'"); $db->query("DELETE FROM {$tablepre}forumfields WHERE fid='$source'"); $db->query("DELETE FROM {$tablepre}moderators WHERE fid='$source'"); $query = $db->query("SELECT * FROM {$tablepre}access WHERE fid='$source'"); while($access = $db->fetch_array($query)) { $db->query("INSERT INTO {$tablepre}access (uid, fid, allowview, allowpost, allowreply, allowgetattach) VALUES ('$access[uid]', '$target', '$access[allowview]', '$access[allowpost]', '$access[allowreply]', '$access[allowgetattach]')", 'SILENT'); } $db->query("DELETE FROM {$tablepre}access WHERE fid='$source'"); updatecache('forums'); updatecache('new_forums'); cpmsg('forums_merge_succeed', 'admincp.php?action=forumsedit'); } } elseif($action == 'forumdetail') { $perms = array('viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm'); $query = $db->query("SELECT *, f.fid AS fid FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff USING (fid) WHERE f.fid='$fid'"); if(!$forum = $db->fetch_array($query)) { cpmsg('forums_nonexistence'); } $query = $db->query("SELECT disabledactions FROM {$tablepre}adminactions WHERE admingid='$groupid'"); $dactionarray = ($dactionarray = unserialize($db->result($query, 0))) ? $dactionarray : array(); $allowthreadtypes = !in_array('threadtypes', $dactionarray); if(!empty($projectid)) { $query = $db->query("SELECT value FROM {$tablepre}projects WHERE id='$projectid'"); $forum = @array_merge($forum, unserialize($db->result($query, 0))); } if(!submitcheck('detailsubmit') && !submitcheck('saveconfigsubmit')) { shownav('menu_forums_detail'); ?> if($forum['type'] == 'group') { showtype("$lang[forums_cat_detail] - $forum[name]", 'top'); showsetting('forums_cat_name', 'namenew', $forum['name'], 'text'); showsetting('forums_sub_horizontal', 'forumcolumnsnew', $forum['forumcolumns'], 'text'); showtype('', 'bottom'); } else { showtips('forums_edit_tips'); $projectselect = "".$lang['none'].""; $query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='forum'"); while($project = $db->fetch_array($query)) { $projectselect .= "$project[name]\n"; } $projectselect .= ''; $fupselect = "\n"; $query = $db->query("SELECT fid, type, name, fup FROM {$tablepre}forums WHERE fid<>'$fid' AND type<>'sub' ORDER BY displayorder"); while($fup = $db->fetch_array($query)) { $fups[] = $fup; } if(is_array($fups)) { foreach($fups as $forum1) { if($forum1['type'] == 'group') { $selected = $forum1['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL; $fupselect .= "$forum1[name]\n"; foreach($fups as $forum2) { if($forum2['type'] == 'forum' && $forum2['fup'] == $forum1['fid']) { $selected = $forum2['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL; $fupselect .= " > $forum2[name]\n"; } } } } foreach($fups as $forum0) { if($forum0['type'] == 'forum' && $forum0['fup'] == 0) { $selected = $forum0['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL; $fupselect .= "$forum0[name]\n"; } } } $fupselect .= ''; $groups = array(); $query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups"); while($group = $db->fetch_array($query)) { $groups[] = $group; } $styleselect = "$lang[use_default]"; $query = $db->query("SELECT styleid, name FROM {$tablepre}styles"); while($style = $db->fetch_array($query)) { $styleselect .= "$style[name]\n"; } $styleselect .= ''; if($forum['autoclose']) { $acoption = $forum['autoclose'] / abs($forum['autoclose']); $forum['autoclose'] = abs($forum['autoclose']); } else { $acoption = 0; } $checkac = array($acoption => 'checked'); $checkpostspecial = array(); $forum['allowpostspecial'] = sprintf('%04b', $forum['allowpostspecial']); for($i = 1; $i <= 4; $i++) { $checkpostspecial[$i] = $forum['allowpostspecial'][4 - $i] ? 'checked' : ''; } $checkmod = array($forum['modnewposts'] => 'checked'); $checkrules = array($forum['alloweditrules'] => 'checked'); $viewaccess = $postaccess = $replyaccess = $getattachaccess = $postattachaccess = ''; $query = $db->query("SELECT m.username, a.* FROM {$tablepre}access a LEFT JOIN {$tablepre}members m USING (uid) WHERE fid='$fid'"); while($access = $db->fetch_array($query)) { $member = ", $access[username]"; $viewaccess .= $access['allowview'] ? $member : NULL; $postaccess .= $access['allowpost'] ? $member : NULL; $replyaccess .= $access['allowreply'] ? $member : NULL; $getattachaccess .= $access['allowgetattach'] ? $member : NULL; $postattachaccess .= $access['allowpostattach'] ? $member : NULL; } unset($member); if($forum['status'] != 2) { $typeids = $comma = ''; if($forum['threadtypes']) { $forum['threadtypes'] = unserialize($forum['threadtypes']); $forum['threadtypes']['status'] = 1; $flatarray = is_array($forum['threadtypes']['flat']) ? $forum['threadtypes']['flat'] : array(); $selectboxarray = is_array($forum['threadtypes']['selectbox']) ? $forum['threadtypes']['selectbox'] : array(); $typearray = array_merge($flatarray, $selectboxarray); if(is_array($forum['threadtypes'][types]) && $forum['threadtypes'][types]) { foreach($forum['threadtypes'][types] AS $typeid => $typename) { $typeids .= $comma.$typeid; $comma = ','; } } } else { $forum['threadtypes'] = array('status' => 0, 'required' => 0, 'listable' => 0, 'prefix' => 0, 'options' => array()); } $typeselect = ''; $query = $db->query("SELECT * FROM {$tablepre}threadtypes ORDER BY displayorder"); while($type = $db->fetch_array($query)) { $typeselected = array(); if(isset($forum['threadtypes']['flat'][$type['typeid']])) { $typeselected[1] = 'checked'; } elseif(isset($forum['threadtypes']['selectbox'][$type['typeid']])) { $typeselected[2] = 'checked'; } else { $typeselected[0] = 'checked'; } $typeselect .= "$type[name]". "$type[description]". "". "". "". ""; } $typeselect = $typeselect ? $typeselect : ''.$lang['forums_edit_threadtypes_options_null'].''; } $forum['postcredits'] = $forum['postcredits']? unserialize($forum['postcredits']) : array(); $forum['replycredits'] = $forum['replycredits']? unserialize($forum['replycredits']) : array(); $forum['digestcredits'] = $forum['digestcredits']? unserialize($forum['digestcredits']) : array(); $forum['postattachcredits'] = $forum['postattachcredits']? unserialize($forum['postattachcredits']) : array(); $forum['getattachcredits'] = $forum['getattachcredits']? unserialize($forum['getattachcredits']) : array(); $forum['circle'] = $forum['status'] == 2 ? 1 : 0; showtype('menu_forums_detail', 'top'); showsetting('forums_scheme', '', '', $projectselect); showtype("forums_basic_settings"); showsetting('forums_edit_board_name', 'board_namenew', $forum['board_name'], 'text'); showsetting('forums_edit_name', 'namenew', $forum['name'], 'text'); showsetting('forums_edit_display', 'statusnew', $forum['status'], 'radio'); /*S: Show Forum*/ showsetting('forums_edit_show', 'idx_push', $forum['idx_push'], 'radio'); /*E: Show Forum*/ showsetting('forums_edit_perm_passwd', 'passwordnew', $forum['password'], 'text'); showsetting('forums_edit_up', '', '', $fupselect); showsetting('forums_edit_redirect', 'redirectnew', $forum['redirect'], 'text'); showsetting('forums_edit_icon', 'iconnew', $forum['icon'], 'text'); showsetting('forums_edit_description', 'descriptionnew', $forum['description'], 'textarea'); showsetting('forums_edit_rules', 'rulesnew', $forum['rules'], 'textarea'); showtype('forums_extend_conf'); showsetting('forums_edit_style', '', '', $styleselect); showsetting('forums_sub_horizontal', 'forumcolumnsnew', $forum['forumcolumns'], 'text'); showsetting('forums_threadcache', 'threadcachesnew', $forum['threadcaches'], 'text'); showsetting('forums_edit_simple', 'simplenew', $forum['simple'], 'radio'); showsetting('forums_edit_edit_rules', '', '', ' '.$lang['forums_edit_edit_rules_html_none'].' '.$lang['forums_edit_edit_rules_html_no'].' '.$lang['forums_edit_edit_rules_html_yes']); if($supe['status']) { if($supe['circlestatus']) { showsetting('circle_forum', 'circlenew', $forum['circle'], 'radio'); } $forum['supe_pushsetting'] = unserialize($forum['supe_pushsetting']); $forum['supe_pushsetting']['status'] = intval($forum['supe_pushsetting']['status']); $forum['supe_pushsetting']['filter']['digest'] = intval($forum['supe_pushsetting']['filter']['digest']); $forum['supe_pushsetting']['filter']['displayorder'] = intval($forum['supe_pushsetting']['filter']['displayorder']); $supe_pushsetchecked = array($forum['supe_pushsetting']['status'] => ' checked'); $supe_pushsetdigestselected = array($forum['supe_pushsetting']['filter']['digest'] => ' selected'); $supe_pushsetdisplayorderselected = array($forum['supe_pushsetting']['filter']['displayorder'] => ' selected'); echo ''.$lang['supe_collection_mode'].''.$lang['supe_collection_mode_comment'].''; echo ''.$lang['supe_pushsetting_status_0'].''.$lang['supe_pushsetting_status_1'].''.$lang['supe_pushsetting_status_2'].''.$lang['supe_pushsetting_status_3']; echo ''; echo ''.$lang['supe_pushsetting_views'].' >= '; echo ''.$lang['supe_pushsetting_replys'].' >= '; echo ''.$lang['supe_pushsetting_digest'].' >= '.$lang['forums_digest_one'].''.$lang['forums_digest_two'].''.$lang['forums_digest_three'].''; echo ''.$lang['supe_pushsetting_stick'].' >= '.$lang['forums_stick_one'].''.$lang['forums_stick_two'].''.$lang['forums_stick_three'].''; echo ''; unset($supe_pushsetchecked, $supe_pushsetdigestselected, $supe_pushsetdisplayorderselected); } showtype('forums_edit_options'); showsetting('forums_edit_modposts', '', '', ' '.$lang['none'].' '.$lang['forums_edit_modposts_threads'].' '.$lang['forums_edit_modposts_posts']); showsetting('forums_edit_alloweditpost', 'alloweditpostnew', $forum['alloweditpost'], 'radio'); showsetting('forums_edit_recyclebin', 'recyclebinnew', $forum['recyclebin'], 'radio'); showsetting('forums_edit_share', 'allowsharenew', $forum['allowshare'], 'radio'); showsetting('forums_edit_html', 'allowhtmlnew', $forum['allowhtml'], 'radio'); showsetting('forums_edit_bbcode', 'allowbbcodenew', $forum['allowbbcode'], 'radio'); showsetting('forums_edit_imgcode', 'allowimgcodenew', $forum['allowimgcode'], 'radio'); showsetting('forums_edit_smilies', 'allowsmiliesnew', $forum['allowsmilies'], 'radio'); showsetting('forums_edit_jammer', 'jammernew', $forum['jammer'], 'radio'); showsetting('forums_edit_anonymous', 'allowanonymousnew', $forum['allowanonymous'], 'radio'); showsetting('forums_edit_disablewatermark', 'disablewatermarknew', $forum['disablewatermark'], 'radio'); showsetting('forums_edit_trade_payto', 'allowpaytoauthornew', $forum['allowpaytoauthor'], 'radio'); showsetting('forums_edit_allowpostspecial', '', '', ''.$lang['forums_thread_poll'].''.$lang['forums_thread_trade'].''.$lang['forums_thread_reward'].''.$lang['forums_thread_activity']); showsetting('forums_edit_allowspecialonly', 'allowspecialonlynew', $forum['allowspecialonly'], 'radio'); showsetting('forums_edit_autoclose', '', '', ' '.$lang['forums_edit_autoclose_none'].' '.$lang['forums_edit_autoclose_dateline'].' '.$lang['forums_edit_autoclose_lastpost']); showsetting('forums_edit_autoclose_time', '', '', ''); showsetting('forums_edit_attach_ext', 'attachextensionsnew', $forum['attachextensions'], 'text'); showtype('forums_edit_credits'); showsetting('forums_edit_postcredits', 'postcreditsstatus', $forum['postcredits'], 'radio'); showsetting('forums_edit_replycredits', 'replycreditsstatus', $forum['replycredits'], 'radio'); showsetting('settings_digest_add_credits', 'digestcreditsstatus', $forum['digestcredits'], 'radio'); showsetting('settings_postattachment_add_cridits', 'postattachcreditsstatus', $forum['postattachcredits'], 'radio'); showsetting('settings_digest_cut_credits', 'getattachcreditsstatus', $forum['getattachcredits'], 'radio'); echo ''. ''.$lang['credits_id'].''.$lang['credits_title'].''.$lang['forums_edit_postcredits_add'].''.$lang['forums_edit_replycredits_add'].''.$lang['settings_credits_policy_digest'].''.$lang['settings_credits_policy_post_attach'].''.$lang['settings_credits_policy_get_attach'].''; for($i = 1; $i <= 8; $i++) { echo "extcredits$i". "{$extcredits[$i]['title']}". "". "". "". "". ""; } if($allowthreadtypes && $forum['status'] != 2) { showtype('forums_edit_threadtypes'); showsetting('forums_edit_threadtypes_status', 'threadtypesnew[status]', $forum['threadtypes']['status'], 'radio'); showsetting('forums_edit_threadtypes_required', 'threadtypesnew[required]', $forum['threadtypes']['required'], 'radio'); showsetting('forums_edit_threadtypes_listable', 'threadtypesnew[listable]', $forum['threadtypes']['listable'], 'radio'); showsetting('forums_edit_threadtypes_prefix', 'threadtypesnew[prefix]', $forum['threadtypes']['prefix'], 'radio'); echo ''. ''.$lang['forums_edit_cat_name'].''.$lang['forums_sort_note'].''.$lang['not_use'].''.$lang['forums_threadtypes_use_cols'].''.$lang['forums_threadtypes_use_choice'].''. $typeselect.''.$lang['add_new'].'[+]'; for($i = 1; $i < 10; $i++) { echo ''; } echo ''.$lang['settings_threadtypes_comment'].''; } echo ''. ''.$lang['forums_edit_perm'].''. ' '.$lang['forums_edit_perm_view'].''. ' '.$lang['forums_edit_perm_post'].''. ' '.$lang['forums_edit_perm_reply'].''. ' '.$lang['forums_edit_perm_get_attach'].''. ' '.$lang['forums_edit_perm_post_attach'].''; foreach($groups as $group) { echo ' '.$group[grouptitle].''; $altbgthis = 'altbg1'; foreach($perms as $perm) { $checked = strstr($forum[$perm], "\t$group[groupid]\t") ? 'checked' : NULL; $altbgthis = $altbgthis == 'altbg2' ? 'altbg1' : 'altbg2'; echo ''; } echo ''; } echo ''.$lang['forums_edit_perm_comment'].''; echo ''.$lang['forums_edit_access_mask'].''; echo ''.$lang['forums_edit_perm_view'].':'.substr($viewaccess, 2).''; echo ''.$lang['forums_edit_perm_post'].':'.substr($postaccess, 2).''; echo ''.$lang['forums_edit_perm_reply'].':'.substr($replyaccess, 2).''; echo ''.$lang['forums_edit_perm_get_attach'].':'.substr($getattachaccess, 2).''; echo ''.$lang['forums_edit_perm_post_attach'].':'.substr($postattachaccess, 2).''; showtype('', 'bottom'); } echo ""; if($forum['type'] != 'group') { echo " "; } } else { if(strlen($namenew) > 50) { cpmsg('forums_name_toolong'); } if($type == 'group') { if($namenew) { $db->query("UPDATE {$tablepre}forums SET name='$namenew',forumcolumns='".intval($forumcolumnsnew)."' WHERE fid='$fid'"); updatecache('forums'); cpmsg('forums_edit_succeed', 'admincp.php?action=forumsedit'); } else { cpmsg('forums_edit_name_invalid'); } } else { $extensionarray = array(); foreach(explode(',', $attachextensionsnew) as $extension) { if($extension = trim($extension)) { $extensionarray[] = $extension; } } $attachextensionsnew = implode(', ', $extensionarray); foreach($perms as $perm) { ${$perm.'new'} = is_array($$perm) && !empty($$perm) ? "\t".implode("\t", $$perm)."\t" : ''; } $fupadd = ''; if($fupnew != $forum['fup']) { $query = $db->query("SELECT fid FROM {$tablepre}forums WHERE fup='$fid'"); if($db->num_rows($query)) { cpmsg('forums_edit_sub_notnull'); } $query = $db->query("SELECT fid, type, inheritedmod FROM {$tablepre}forums WHERE fid='$fupnew'"); $fup = $db->fetch_array($query); $fupadd = ", type='".($fup['type'] == 'forum' ? 'sub' : 'forum')."', fup='$fup[fid]'"; $db->query("DELETE FROM {$tablepre}moderators WHERE fid='$fid' AND inherited='1'"); $query = $db->query("SELECT * FROM {$tablepre}moderators WHERE fid='$fupnew' ".($fup['inheritedmod'] ? '' : "AND inherited='1'")); while($mod = $db->fetch_array($query)) { $db->query("REPLACE INTO {$tablepre}moderators (uid, fid, displayorder, inherited) VALUES ('$mod[uid]', '$fid', '0', '1')"); } $moderators = $tab = ''; $query = $db->query("SELECT m.username FROM {$tablepre}members m, {$tablepre}moderators mo WHERE mo.fid='$fid' AND mo.inherited='0' AND m.uid=mo.uid ORDER BY mo.displayorder"); while($mod = $db->fetch_array($query)) { $moderators .= $tab.addslashes($mod['username']); $tab = "\t"; } $db->query("UPDATE {$tablepre}forumfields SET moderators='$moderators' WHERE fid='$fid'"); } $statusnew = $supe['status'] && $supe['circlestatus'] && $circlenew ? 2 : $statusnew; $supe_pushsetting[status] = $statusnew == 2 && !$supe_pushsetting[status] ? 1 : $supe_pushsetting[status]; $supe_pushsettingadd = $supe['status'] ? ", supe_pushsetting='".serialize($supe_pushsetting)."'" : ''; if(!$allowsharenew && (bool)$allowsharenew != (bool)$forum['allowshare']) { $db->query("UPDATE {$tablepre}threads SET blog='0' WHERE fid='$fid'"); } $allowpostspecialnew = bindec(intval($allowpostspecialnew[4]).intval($allowpostspecialnew[3]).intval($allowpostspecialnew[2]).intval($allowpostspecialnew[1])); $allowspecialonlynew = $allowpostspecialnew ? $allowspecialonlynew : 0; $forumcolumnsnew = intval($forumcolumnsnew); $threadcachesnew = max(0, min(100, intval($threadcachesnew))); $db->query("UPDATE {$tablepre}forums SET status='$statusnew', name='$namenew', idx_push='".$idx_push."', board_name='".$board_namenew."', styleid='$styleidnew', allowshare='$allowsharenew', alloweditpost='$alloweditpostnew', allowpostspecial='$allowpostspecialnew', allowspecialonly='$allowspecialonlynew', allowpaytoauthor='$allowpaytoauthornew', allowhtml='$allowhtmlnew', allowbbcode='$allowbbcodenew', allowimgcode='$allowimgcodenew', allowsmilies='$allowsmiliesnew', alloweditrules='$alloweditrulesnew', modnewposts='$modnewpostsnew', recyclebin='$recyclebinnew', jammer='$jammernew', allowanonymous='$allowanonymousnew', forumcolumns='$forumcolumnsnew', threadcaches='$threadcachesnew', simple='$simplenew', disablewatermark='$disablewatermarknew', autoclose='".intval($autoclosenew * $autoclosetimenew)."' $fupadd WHERE fid='$fid'"); $query = $db->query("SELECT fid FROM {$tablepre}forumfields WHERE fid='$fid'"); if(!($db->num_rows($query))) { $db->query("INSERT INTO {$tablepre}forumfields (fid) VALUES ('$fid')"); } $postcreditsarray = $replycreditsarray = array(); if($postcreditsstatus) { for($i = 1; $i <= 8; $i++) { if(isset($extcredits[$i]) && isset($postcreditsnew[$i])) { $postcreditsnew[$i] = $postcreditsnew[$i] < -99 ? -99 : $postcreditsnew[$i]; $postcreditsnew[$i] = $postcreditsnew[$i] > 99 ? 99 : $postcreditsnew[$i]; $postcreditsarray[$i] = intval($postcreditsnew[$i]); } } } if($replycreditsstatus) { for($i = 1; $i <= 8; $i++) { if(isset($extcredits[$i]) && isset($replycreditsnew[$i])) { $replycreditsnew[$i] = $replycreditsnew[$i] < -99 ? -99 : $replycreditsnew[$i]; $replycreditsnew[$i] = $replycreditsnew[$i] > 99 ? 99 : $replycreditsnew[$i]; $replycreditsarray[$i] = intval($replycreditsnew[$i]); } } } if($digestcreditsstatus) { for($i = 1; $i <= 8; $i++) { if(isset($extcredits[$i]) && isset($digestcreditsnew[$i])) { $digestcreditsnew[$i] = $digestcreditsnew[$i] < -99 ? -99 : $digestcreditsnew[$i]; $digestcreditsnew[$i] = $digestcreditsnew[$i] > 99 ? 99 : $digestcreditsnew[$i]; $digestcreditsarray[$i] = intval($digestcreditsnew[$i]); } } } if($postattachcreditsstatus) { for($i = 1; $i <= 8; $i++) { if(isset($extcredits[$i]) && isset($postattachcreditsnew[$i])) { $postattachcreditsnew[$i] = $postattachcreditsnew[$i] < -99 ? -99 : $postattachcreditsnew[$i]; $postattachcreditsnew[$i] = $postattachcreditsnew[$i] > 99 ? 99 : $postattachcreditsnew[$i]; $postattachcreditsarray[$i] = intval($postattachcreditsnew[$i]); } } } if($getattachcreditsstatus) { for($i = 1; $i <= 8; $i++) { if(isset($extcredits[$i]) && isset($getattachcreditsnew[$i])) { $getattachcreditsnew[$i] = $getattachcreditsnew[$i] < -99 ? -99 : $getattachcreditsnew[$i]; $getattachcreditsnew[$i] = $getattachcreditsnew[$i] > 99 ? 99 : $getattachcreditsnew[$i]; $getattachcreditsarray[$i] = intval($getattachcreditsnew[$i]); } } } $postcreditsnew = $postcreditsarray ? addslashes(serialize($postcreditsarray)) : ''; $replycreditsnew = $replycreditsarray ? addslashes(serialize($replycreditsarray)) : ''; $digestcreditsnew = $digestcreditsarray ? addslashes(serialize($digestcreditsarray)) : ''; $postattachcreditsnew = $postattachcreditsarray ? addslashes(serialize($postattachcreditsarray)) : ''; $getattachcreditsnew = $getattachcreditsarray ? addslashes(serialize($getattachcreditsarray)) : ''; $threadtypesnew['types'] = $threadtypesnew['flat'] = $threadtypes['selectbox'] = array(); if($allowthreadtypes && $forum['status'] != 2) { if(is_array($newname) && $newname) { $newname = array_unique($newname); if($newname) { foreach($newname AS $key => $val) { $val = trim($val); if($val) { $query = $db->query("SELECT typeid FROM {$tablepre}threadtypes WHERE name='$val'"); $newtypeid = $db->result($query, 0); if(!$newtypeid) { $db->query("INSERT INTO {$tablepre}threadtypes (name, description) VALUES ('$val', '".dhtmlspecialchars(trim($newdescription[$key]))."')"); $newtypeid = $db->insert_id(); } if($newoptions[$key] == 1) { $threadtypesnew['types'][$newtypeid] = $threadtypesnew['flat'][$newtypeid] = $val; } elseif($newoptions[$key] == 2) { $threadtypesnew['types'][$newtypeid] = $threadtypesnew['selectbox'][$newtypeid] = $val; } } } } $threadtypesnew['status'] = 1; } else { $newname = array(); } if($threadtypesnew['status']) { if(is_array($threadtypesnew['options']) && $threadtypesnew['options']) { $typeids = '0'; foreach($threadtypesnew['options'] as $key => $val) { $typeids .= $val ? ', '.intval($key) : ''; } $query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE typeid IN ($typeids) ORDER BY displayorder"); while($type = $db->fetch_array($query)) { if($threadtypesnew['options'][$type['typeid']] == 1) { $threadtypesnew['types'][$type['typeid']] = $threadtypesnew['flat'][$type['typeid']] = $type['name']; } elseif($threadtypesnew['options'][$type['typeid']] == 2) { $threadtypesnew['types'][$type['typeid']] = $threadtypesnew['selectbox'][$type['typeid']] = $type['name']; } } } $threadtypesnew = $threadtypesnew['types'] ? addslashes(serialize(array ( 'required' => (bool)$threadtypesnew['required'], 'listable' => (bool)$threadtypesnew['listable'], 'prefix' => (bool)$threadtypesnew['prefix'], 'types' => $threadtypesnew['types'], 'selectbox' => $threadtypesnew['selectbox'], 'flat' => $threadtypesnew['flat'], ))) : ''; } else { $threadtypesnew = ''; } $threadtypesadd = "threadtypes='$threadtypesnew',"; } else { $threadtypesadd = ''; } $db->query("UPDATE {$tablepre}forumfields SET description='$descriptionnew', icon='$iconnew', password='$passwordnew', redirect='$redirectnew', rules='$rulesnew', attachextensions='$attachextensionsnew', $threadtypesadd postcredits='$postcreditsnew', replycredits='$replycreditsnew', digestcredits='$digestcreditsnew', postattachcredits='$postattachcreditsnew', getattachcredits='$getattachcreditsnew', viewperm='$viewpermnew', postperm='$postpermnew', replyperm='$replypermnew', getattachperm='$getattachpermnew', postattachperm='$postattachpermnew'$supe_pushsettingadd WHERE fid='$fid'"); if($statusnew == 0) { $db->query("UPDATE {$tablepre}forums SET status='$statusnew' WHERE fup='$fid'", 'UNBUFFERED'); } updatecache('forums'); updatecache('new_forums'); if(submitcheck('saveconfigsubmit') && $type != 'group') { $projectid = intval($projectid); dheader("Location: {$boardurl}admincp.php?action=projectadd&id=$fid&type=forum&projectid=$projectid"); } else { cpmsg('forums_edit_succeed', 'admincp.php?action=forumsedit'); } } } } elseif($action == 'forumdelete') { if($ajax) { ob_end_clean(); require_once DISCUZ_ROOT.'./include/post.func.php'; $tids = 0; $total = intval($total); $pp = intval($pp); $currow = intval($currow); $query = $db->query("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' LIMIT $pp"); while($thread = $db->fetch_array($query)) { $tids .= ','.$thread['tid']; } if($tids) { $query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($tids)"); while($attach = $db->fetch_array($query)) { dunlink($attach['attachment'], $attach['thumb'], $attach['remote']); } foreach(array('threads', 'threadsmod', 'relatedthreads', 'posts', 'polls', 'polloptions', 'trades', 'activities', 'activityapplies', 'attachments', 'favorites', 'mythreads', 'myposts', 'subscriptions') as $value) { $db->query("DELETE FROM {$tablepre}$value WHERE tid IN ($tids)", 'UNBUFFERED'); } } if($currow + $pp > $total) { $db->query("DELETE FROM {$tablepre}forums WHERE fid='$fid'"); $db->query("DELETE FROM {$tablepre}forumfields WHERE fid='$fid'"); $db->query("DELETE FROM {$tablepre}moderators WHERE fid='$fid'"); $db->query("DELETE FROM {$tablepre}access WHERE fid='$fid'"); echo 'TRUE'; exit; } updatecache('forums'); updatecache('new_forums'); echo 'GO'; exit; } else { if($finished) { cpmsg('forums_delete_succeed', 'admincp.php?action=forumsedit'); } $query = $db->query("SELECT COUNT(*) FROM {$tablepre}forums WHERE fup='$fid'"); if($db->result($query, 0)) { cpmsg('forums_delete_sub_notnull'); } if(!$confirmed) { cpmsg('forums_delete_confirm', "admincp.php?action=forumdelete&fid=$fid", 'form'); } else { $query = $db->query("SELECT COUNT(*) FROM {$tablepre}threads WHERE fid='$fid'"); $threads = $db->result($query, 0); echo " ".$lang['discuz_message']." ".$lang['forums_delete_alarm']." 0% "; echo ""; echo ""; echo " "; } } } elseif($action == 'threadtypes') { if(!submitcheck('typesubmit')) { $forumsarray = $fidsarray = array(); $query = $db->query("SELECT f.fid, f.name, ff.threadtypes FROM {$tablepre}forums f , {$tablepre}forumfields ff WHERE ff.threadtypes<>'' AND f.fid=ff.fid"); while($forum = $db->fetch_array($query)) { $forum['threadtypes'] = unserialize($forum['threadtypes']); if(is_array($forum['threadtypes']['types'])) { foreach($forum['threadtypes']['types'] as $typeid => $name) { $forumsarray[$typeid][] = ''.$forum['name'].' ['.$lang['edit'].']'; $fidsarray[$typeid][] = $forum['fid']; } } } $threadtypes = ''; $query = $db->query("SELECT * FROM {$tablepre}threadtypes ORDER BY displayorder"); while($type = $db->fetch_array($query)) { $threadtypes .= "\n". "\n". "\n". "\n". "".(is_array($forumsarray[$type['typeid']]) ? implode(', ', $forumsarray[$type['typeid']])."" : '')."\n"; } shownav('menu_forums_threadtypes'); showtips('forums_threadtypes_tips'); ?> =$lang['forums_threadtypes']?> =$lang['del']?>=$lang['forums_threadtypes']?>=$lang['display_order']?>=$lang['description']?>=$lang['forums_threadtypes_forums']?> =$threadtypes?> =$lang['add_new']?> } else { $modifiedtypes = array(); if(is_array($delete)) { $modifiedtypes = $delete; $deleteids = '\''.implode('\',\'', $delete).'\''; $db->query("DELETE FROM {$tablepre}threadtypes WHERE typeid IN ($deleteids)"); if($db->affected_rows()) { $db->query("UPDATE {$tablepre}threads SET typeid='0' WHERE typeid IN ($deleteids)"); foreach($delete AS $id) { if(!empty($fids[$id])) { $query = $db->query("SELECT fid, threadtypes FROM {$tablepre}forumfields WHERE fid IN ($fids[$id])"); while($forum = $db->fetch_array($query)) { $forum['threadtypes'] = unserialize($forum['threadtypes']); unset($forum['threadtypes']['types'][$id], $forum['threadtypes']['flat'][$id], $forum['threadtypes']['selectbox'][$id]); $threadtypesnew = addslashes(serialize(array ( 'required' => (bool)$forum['threadtypes']['required'], 'listable' => (bool)$forum['threadtypes']['listable'], 'prefix' => (bool)$forum['threadtypes']['prefix'], 'types' => $forum['threadtypes']['types'], 'selectbox' => $forum['threadtypes']['selectbox'], 'flat' => $forum['threadtypes']['flat'], ))); $db->query("UPDATE {$tablepre}forumfields SET threadtypes='$threadtypesnew' WHERE fid='$forum[fid]'"); } } } } } if(is_array($namenew)) { foreach($namenew as $typeid => $val) { $db->query("UPDATE {$tablepre}threadtypes SET name='".trim($namenew[$typeid])."', description='".dhtmlspecialchars(trim($descriptionnew[$typeid]))."', displayorder='$displayordernew[$typeid]' WHERE typeid='$typeid'"); if($db->affected_rows()) { $modifiedtypes[] = $typeid; } } if($modifiedtypes = array_unique($modifiedtypes)) { $query = $db->query("SELECT f.fid, ff.threadtypes FROM {$tablepre}forums f, {$tablepre}forumfields ff WHERE ff.threadtypes<>'' AND f.fid=ff.fid"); while($forum = $db->fetch_array($query)) { $forum['threadtypes'] = unserialize($forum['threadtypes']); foreach($modifiedtypes as $typeid) { if(isset($forum['threadtypes']['types'][$typeid])) { $db->query("SELECT * FROM {$tablepre}threadtypes WHERE typeid IN (".implode(',', array_keys($forum['threadtypes']['types'])).") ORDER BY displayorder"); $forum['threadtypes']['types'] = array(); while($type = $db->fetch_array($query)) { $forum['threadtypes']['types'][$type['typeid']] = $type['name']; } $db->query("UPDATE {$tablepre}forumfields SET threadtypes='".addslashes(serialize($forum['threadtypes']))."' WHERE fid='$fid'"); break; } } } } } if($newname != '') { $newname = trim($newname); $query = $db->query("SELECT typeid FROM {$tablepre}threadtypes WHERE name='$newname'"); if($db->num_rows($query)) { cpmsg('forums_threadtypes_duplicate'); } $db->query("INSERT INTO {$tablepre}threadtypes (name, description, displayorder) VALUES ('$newname', '".dhtmlspecialchars(trim($newdescription))."', '$newdisplayorder')"); } cpmsg('forums_threadtypes_succeed', 'admincp.php?action=threadtypes'); } } elseif($action == 'forumrules') { if(empty($fid)) { $forums = ''; if($adminid == 2) { $query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE alloweditrules>'0' AND type IN ('forum', 'sub')"); } else { $query = $db->query("SELECT f.fid, f.name, m.uid FROM {$tablepre}forums f LEFT JOIN {$tablepre}moderators m ON m.uid='$discuz_uid' AND m.fid=f.fid WHERE alloweditrules>'0' AND f.type IN ('forum', 'sub')"); } while($forum = $db->fetch_array($query)) { if($forum['uid'] || $adminid == 2) { $forums .= "".strip_tags($forum['name']).""; } } if($forums) { $forums = ''.$forums.''; } else { cpmsg('forums_rules_nopermission'); } shownav('menu_forums_rules'); ?> =$lang['forums_edit']?> =$lang['forum']?>:=$forums?> } else { $access = 0; if($adminid == 2) { $access = 1; } elseif($adminid == 3) { $query = $db->query("SELECT uid FROM {$tablepre}moderators WHERE uid='$discuz_uid' AND fid='$fid'"); $access = $db->num_rows($query) ? 1 : 0; } $query = $db->query("SELECT f.fid, f.name, f.alloweditrules, ff.rules FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff USING (fid) WHERE f.fid='$fid' AND alloweditrules>'0' AND type IN ('forum', 'sub')"); if(!$access || !($forum = $db->fetch_array($query))) { cpmsg('forums_rules_nopermission'); } if(!submitcheck('rulessubmit')) { $comment = $lang[($forum['alloweditrules'] == 1 ? 'forums_edit_edit_rules_html_no' : 'forums_edit_edit_rules_html_yes')]; ?> =$lang['forums_edit']?> - =$forum['name']?> =$lang['forums_edit_rules']?>=$comment?> =dhtmlspecialchars($forum['rules'])?> } else { if($forum['alloweditrules'] != 2) { $rulesnew = dhtmlspecialchars($rulesnew); } $db->query("UPDATE {$tablepre}forumfields SET rules='$rulesnew' WHERE fid='$fid'"); cpmsg('forums_rules_succeed'); } } } elseif($action == 'forumcopy') { require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php'; $source = intval($source); $sourceforum = $_DCACHE['forums'][$source]; if(empty($sourceforum) || $sourceforum['type'] == 'group') { cpmsg('forums_copy_source_invalid'); } $optgroups = array ( 'normal' => array('modnewposts', 'recyclebin', 'allowshare', 'allowhtml', 'allowbbcode', 'allowimgcode', 'allowsmilies', 'jammer', 'allowanonymous' ,'disablewatermark' ,'allowpostspecial'), 'credits' => array('postcredits', 'replycredits'), 'access' => array('password', 'viewperm', 'postperm', 'replyperm', 'getattachperm' ,'postattachperm'), 'misc' => array('threadtypes', 'attachextensions') ); if(!submitcheck('copysubmit')) { require_once DISCUZ_ROOT.'./include/forum.func.php'; $forumselect = ''.forumselect().''; $optselect = ''; foreach($optgroups as $optgroup => $options) { $optselect .= '\n"; foreach($options as $option) { $optselect .= "".$lang['forums_copy_options_'.$option]."\n"; } } $optselect .= ''; showtips('forums_copy_tips'); ?> showtype($lang['forums_copy'].' - '.$lang['forums_copy_source'].' - '.$sourceforum['name'], 'top'); showsetting('forums_copy_target', '', '', $forumselect); showsetting('forums_copy_options', '', '', $optselect); showtype('', 'bottom'); echo ""; } else { $fids = $comma = ''; if(is_array($target) && count($target)) { foreach($target as $fid) { if(($fid = intval($fid)) && $fid != $source ) { $fids .= $comma.$fid; $comma = ','; } } } if(empty($fids)) { cpmsg('forums_copy_target_invalid'); } $forumoptions = array(); if(is_array($options) && !empty($options)) { foreach($options as $option) { if($option = trim($option)) { if(in_array($option, $optgroups['normal'])) { $forumoptions['forums'][] = $option; } elseif(in_array($option, $optgroups['misc']) || in_array($option, $optgroups['credits']) || in_array($option, $optgroups['access'])) { $forumoptions['forumfields'][] = $option; } } } } if(empty($forumoptions)) { cpmsg('forums_copy_options_invalid'); } foreach(array('forums', 'forumfields') as $table) { if(is_array($forumoptions[$table]) && !empty($forumoptions[$table])) { $query = $db->query("SELECT ".implode($forumoptions[$table],',')." FROM {$tablepre}$table WHERE fid='$source'"); if(!$sourceforum = $db->fetch_array($query)) { cpmsg('forums_copy_source_invalid'); } $updatequery = 'fid=fid'; foreach($sourceforum as $key => $val) { $updatequery .= ", $key='".addslashes($val)."'"; } $db->query("UPDATE {$tablepre}$table SET $updatequery WHERE fid IN ($fids)"); } } updatecache('forums'); cpmsg('forums_copy_succeed', 'admincp.php?action=forumsedit'); } } ?>