showmessage('do_success', "cp.php?ac=mtag&op=mtaginvite", 0); } showmessage('invite_mtag_cancel', "cp.php?ac=mtag&op=mtaginvite", 0); }elseif($_GET['op'] == 'apply') { $tagid = intval($_GET['tagid']); if($tagid && submitcheck('pmsubmit')) { if(empty($_POST['message'])) { showmessage('fill_out_the_grounds_for_the_application'); } $notearr = array(); $mtag = getmtag($tagid); $mtagurl = 'cp.php?ac=mtag&tagid='.$tagid.'&op=manage&subop=members&key='.$_SGLOBAL['supe_username']; $_POST['message'] = getstr($_POST['message'], 0, 1, 1, 1); $message = cplang('apply_mtag_manager', array($mtagurl, $mtag['tagname'], $_POST['message'])); $query = $_SGLOBAL['db']->query("SELECT uid FROM ".tname('tagspace')." WHERE tagid='$tagid' AND grade > 8 LIMIT 0 , 5"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $notearr[] = array( 'uid' => $value['uid'], 'type' => 'mtag', 'new' => 1, 'authorid' => $_SGLOBAL['supe_uid'], 'author' => $_SGLOBAL['supe_username'], 'note' => addslashes(sstripslashes($message)), 'dateline' => $_SGLOBAL['timestamp'] );
$db_target->query("UPDATE " . $db_target->table('common_member_count') . " SET posts=posts+1 WHERE uid='{$post['uid']}'", 'UNBUFFERED'); $db_target->query("UPDATE " . $db_target->table('forum_groupuser') . " SET replies=replies+1 WHERE fid='{$sid}' AND uid='{$post['uid']}'", 'UNBUFFERED'); } if ($lastpost) { $db_target->update('forum_thread', $lastpost, array('tid' => $tid)); } else { $lastpost['lastpost'] = $value['lastpost']; } $db_target->insert('common_member_count', array('uid' => $value['uid']), 0, false, true); $db_target->query("UPDATE " . $db_target->table('common_member_count') . " SET threads=threads+1 WHERE uid='{$value['uid']}'", 'UNBUFFERED'); $db_target->query("UPDATE " . $db_target->table('forum_groupuser') . " SET threads=threads+1 WHERE fid='{$sid}' AND uid='{$value['uid']}'", 'UNBUFFERED'); $db_target->query("UPDATE " . $db_target->table('forum_forum') . " SET lastpost='{$lastpost['lastpost']}', threads=threads+1, posts=posts+{$value['replynum']} WHERE fid='{$sid}'", 'UNBUFFERED'); } $force = false; if (!$nextid) { if (!getmtag($tagid)) { if (!getprofield($fieldid)) { $nextid = 0; } else { $force = true; } } else { $force = true; } $nextid = $force ? 1 : 0; } if ($nextid) { if ($force) { $nextid = 0; } $mtag = array();
function deleteposts($tagid, $pids) { global $_SGLOBAL; //统计 $postnums = $mpostnums = $tids = $delposts = $newids = $spaces = array(); $ismanager = $allowmanage = checkperm('managethread'); $managebatch = checkperm('managebatch'); $delnum = 0; //群主 $wheresql = ''; if (empty($allowmanage) && $tagid) { $mtag = getmtag($tagid); if ($mtag['grade'] >= 8) { $allowmanage = 1; $managebatch = 1; $wheresql = " AND p.tagid='{$tagid}'"; } } //获取积分 $reward = getreward('delcomment', 0); $query = $_SGLOBAL['db']->query("SELECT p.* FROM " . tname('post') . " p WHERE p.pid IN (" . simplode($pids) . ") {$wheresql} ORDER BY p.isthread DESC"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if ($allowmanage || $value['uid'] == $_SGLOBAL['supe_uid']) { if (!$managebatch && $value['uid'] != $_SGLOBAL['supe_uid']) { $delnum++; } $postarr[] = $value; } } if (!$managebatch && $delnum > 1) { return array(); } foreach ($postarr as $key => $value) { if ($value['isthread']) { $tids[] = $value['tid']; } else { if (!in_array($value['tid'], $tids)) { $newids[] = $value['pid']; $delposts[] = $value; $postnums[$value['tid']]++; if ($ismanager && $value['uid'] != $_SGLOBAL['supe_uid']) { //扣除积分 $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET credit=credit-{$reward['credit']}, experience=experience-{$reward['experience']} WHERE uid='{$value['uid']}'"); } } } } $delthreads = array(); if ($tids) { $delthreads = deletethreads($tagid, $tids); } if (empty($delposts)) { return $delthreads; } //整理 $nums = renum($postnums); foreach ($nums[0] as $pnum) { $_SGLOBAL['db']->query("UPDATE " . tname('thread') . " SET replynum=replynum-{$pnum} WHERE tid IN (" . simplode($nums[1][$pnum]) . ")"); } //删除 $_SGLOBAL['db']->query("DELETE FROM " . tname('post') . " WHERE pid IN (" . simplode($newids) . ")"); return $delposts; }
function ckmtagspace($tagid) { global $_SGLOBAL, $_SCONFIG, $event, $userevent; if ($event) { //活动话题单独处理 if (empty($userevent) || $userevent['status'] < 2) { showmessage('event_only_allows_member_thread'); } if ($event['tagid'] != $tagid) { showmessage('event_mtag_not_match'); } $mtag = getmtag($tagid); if ($mtag['close']) { showmessage('mtag_close'); } return $mtag; } $count = 0; $mtag = array(); if ($tagid) { $mtag = getmtag($tagid); if ($mtag) { //判断是否关闭 if ($mtag['close']) { showmessage('mtag_close'); } //是否允许浏览 if (empty($mtag['allowview'])) { showmessage('mtag_not_allow_to_do'); } //判断是否满足人数要求 if ($mtag['field']['mtagminnum'] && $mtag['membernum'] < $mtag['field']['mtagminnum']) { showmessage('mtag_minnum_erro', '', 1, array($mtag['field']['mtagminnum'])); } } } if (empty($mtag)) { showmessage('first_select_a_mtag'); } return $mtag; }
function topthreads($tagid, $tids, $v) { global $_SGLOBAL; $mtag = getmtag($tagid); if($mtag['grade']<8) { return array(); } if(empty($v)) { $wheresql = " AND t.displayorder='1'"; $v = 0; } else { $wheresql = " AND t.displayorder='0'"; $v = 1; } $newtids = $threads = array(); $query = $_SGLOBAL['db']->query("SELECT t.* FROM ".tname('thread')." t WHERE t.tagid='$tagid' AND t.tid IN (".simplode($tids).") $wheresql"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $newtids[] = $value['tid']; $threads[] = $value; } //数据 if($newtids) { $_SGLOBAL['db']->query("UPDATE ".tname('thread')." SET displayorder='$v' WHERE tid IN (".simplode($newtids).")"); } return $threads; }
function ckmtagspace($tagid) { global $_SGLOBAL, $_SCONFIG; $count = 0; $mtag = array(); if ($tagid) { $mtag = getmtag($tagid); if ($mtag) { //判断是否关闭 if ($mtag['close']) { showmessage('mtag_close'); } //是否允许浏览 if (empty($mtag['allowview'])) { showmessage('mtag_not_allow_to_do'); } //是否允许发 if (empty($mtag['allowpost'])) { showmessage('no_privilege'); } //判断是否满足人数要求 if ($mtag['field']['mtagminnum'] && $mtag['membernum'] < $mtag['field']['mtagminnum']) { showmessage('mtag_minnum_erro', '', 1, array($mtag['field']['mtagminnum'])); } } } if (empty($mtag)) { showmessage('first_select_a_mtag'); } return $mtag; }
function deleteposts($tagid, $pids) { global $_SGLOBAL; //统计 $postnums = $mpostnums = $tids = $delposts = $newids = $spaces = array(); $allowmanage = checkperm('managethread'); //群主 $wheresql = ''; if (empty($allowmanage) && $tagid) { $mtag = getmtag($tagid); if ($mtag['grade'] >= 8) { $allowmanage = 1; $wheresql = " AND p.tagid='{$tagid}'"; } } $query = $_SGLOBAL['db']->query("SELECT p.* FROM " . tname('post') . " p WHERE p.pid IN (" . simplode($pids) . ") {$wheresql} ORDER BY p.isthread DESC"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if ($allowmanage || $value['uid'] == $_SGLOBAL['supe_uid']) { if ($value['isthread']) { $tids[] = $value['tid']; } else { if (!in_array($value['tid'], $tids)) { $newids[] = $value['pid']; $delposts[] = $value; $postnums[$value['tid']]++; $spaces[$value['uid']]++; } } } } $delthreads = array(); if ($tids) { $delthreads = deletethreads($tagid, $tids); } if (empty($delposts)) { return $delthreads; } //整理 $nums = renum($postnums); foreach ($nums[0] as $pnum) { $_SGLOBAL['db']->query("UPDATE " . tname('thread') . " SET replynum=replynum-{$pnum} WHERE tid IN (" . simplode($nums[1][$pnum]) . ")"); } //删除 $_SGLOBAL['db']->query("DELETE FROM " . tname('post') . " WHERE pid IN (" . simplode($newids) . ")"); //积分 updatespaces($spaces, 'post'); return $delposts; }