www.gusucode.com > 08CMS空白站群系统 3.3 繁体 UTF-8 > upload/admina/pms.inc.php

    <?php
(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
load_cache('grouptypes');
aheader();
if($action == 'batchpms'){
	!checkapermission(103) && amessage(lang('no_apermission'));
	if($sid && $sid_self) amessage(lang('msite admin item !'));
	if(!submitcheck('bbatchpms')){
		a_guide('pmsbatch');
		tabheader(lang('accept member filter0'),'batchpms','?entry=pms&action=batchpms');
		trbasic(lang('pmtoids'),'pmnew[toids]');
		trbasic(lang('pmtonames'),'pmnew[tonames]');
		$limitarr = array('0' => lang('nolimit usergroup'),'1' => lang('handwork choose'));
		foreach($grouptypes as $gtid => $grouptype){
			sourcemodule($grouptype['cname'].lang('limited'),
						"pmnew[limit$gtid]",
						$limitarr,
						'0',
						'1',
						"pmnew[ugids$gtid][]",
						ugidsarr($gtid),
						array()
						);
		}
		tabfooter();
		tabheader(lang('pm content setting'));
		trbasic(lang('pm title'),'pmnew[title]');
		trbasic(lang('pm content'),'pmnew[content]','','textarea');
		tabfooter('bbatchpms');
	}else{
		if(empty($pmnew['title']) || empty($pmnew['content'])){
			amessage(lang('pm data missing'),'?entry=pms&action=batchpms');
		}
		$wheresql = '';
		if(!empty($pmnew['toids'])){
			$toids = array_filter(explode(',',$pmnew['toids']));
			$toids = mimplode($toids);
			$wheresql = empty($toids) ? "" : "mid IN ($toids)";
		}
		if(!empty($pmnew['tonames'])){
			$tonames = array_filter(explode(',',$pmnew['tonames']));
			$tonames = mimplode($tonames);
			$wheresql .= empty($tonames) ? "" : ((empty($wheresql) ? "" : " OR ")."mname IN ($tonames)");
		}
		!empty($wheresql) && ($wheresql = "(".$wheresql.")");
		foreach($grouptypes as $gtid => $grouptype){
			if(!empty($pmnew['limit'.$gtid]) && !empty($pmnew['ugids'.$gtid])){
				$ugids = mimplode($pmnew['ugids'.$gtid]);
				$fieldname = 'grouptype'.$gtid;
				$wheresql .= empty($ugids) ? "" : ((empty($wheresql) ? "" : " AND ")."$fieldname IN ($ugids)");
			}
		}
		$wheresql = empty($wheresql) ? "" : "WHERE $wheresql";
		$query = $db->query("SELECT mid FROM {$tblprefix}members $wheresql ORDER BY mid");
		while($user = $db->fetch_array($query)){
			//收信数量限制分析
			$db->query("INSERT INTO {$tblprefix}pms SET
						title = '$pmnew[title]',
						content = '$pmnew[content]',
						toid = '$user[mid]',
						fromid = '$memberid',
						fromuser = '".$curuser->infos['mname']."',
						pmdate = '$timestamp'
						");
		}
		amessage(lang('pm send finish'),'?entry=pms&action=batchpms');
	}
}elseif($action == 'clearpms'){
	!checkapermission(104) && amessage(lang('no_apermission'));
	if($sid && $sid_self) amessage(lang('msite admin item !'));
	if(!submitcheck('bclearpms')){
		a_guide('pmsclear');
		tabheader(lang('pm clear filter0'),'clearpms','?entry=pms&action=clearpms');
		trbasic(lang('pmfromids'),'pmnew[fromids]');
		trbasic(lang('mnamestxt'),'pmnew[fromnames]');
		trbasic(lang('only clear read pm'),'pmnew[viewed]','0','radio');
		trbasic(lang('indays'),'pmnew[days]');
		tabfooter('bclearpms');
	}else{
		$wheresql = '';
		if(!empty($pmnew['fromids'])){
			$fromids = array_filter(explode(',',$pmnew['fromids']));
			$fromids = mimplode($fromids);
			$wheresql = empty($fromids) ? "" : "fromid IN ($fromids)";
		}
		if(!empty($pmnew['fromnames'])){
			$fromnames = array_filter(explode(',',$pmnew['fromnames']));
			$fromnames = mimplode($fromnames);
			$wheresql .= empty($fromnames) ? "" : ((empty($wheresql) ? "" : " OR ")."fromuser IN ($fromnames)");
		}
		!empty($wheresql) && ($wheresql = "(".$wheresql.")");
		if(!empty($pmnew['viewed'])){
			$wheresql .= (empty($wheresql) ? "" : " AND ")."viewed='1'";
		}
		if(!empty($pmnew['days'])){
			$wheresql .= (empty($wheresql) ? "" : " AND ")."pmdate<".($timestamp-86400*$pmnew['days']);
		}
		$wheresql = empty($wheresql) ? "" : "WHERE $wheresql";
		$db->query("DELETE FROM {$tblprefix}pms $wheresql",'UNBUFFERED');
		amessage(lang('pm clear finish'),'?entry=pms&action=clearpms');
	}
}
?>