⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memcp.php

📁 Discuz功能源码(开源)
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php

/*
	[Discuz!] (C)2001-2009 Comsenz Inc.
	This is NOT a freeware, use is subject to license terms

	$Id: memcp.php 17268 2008-12-11 08:27:13Z liuqiang $
*/
define('CURSCRIPT', 'memcp');
define('NOROBOT', TRUE);

require_once './include/common.inc.php';

$discuz_action = 7;

if(!$discuz_uid) {
	showmessage('not_loggedin', NULL, 'HALTED');
}

$action = !empty($action) ? $action : '';
$operation = !empty($operation) ? $operation : '';

$maxbiosize = $maxbiosize ? $maxbiosize : 200;

if($regverify == 2 && $groupid == 8 && ($action != 'profile' || $action == 'validating')) {
	$validating = array();
	if($regverify == 2 && $groupid == 8) {
		if($validating = $db->fetch_first("SELECT * FROM {$tablepre}validating WHERE uid='$discuz_uid'")) {
			$validating['moddate'] = $validating['moddate'] ? dgmdate("$dateformat $timeformat", $validating['moddate'] + $timeoffset * 3600) : 0;
			$validating['adminenc'] = rawurlencode($validating['admin']);
		}
	}
	include template('memcp_validating');
	dexit();
}

if(!$action || $action == 'profile') {

	$typeid = empty($typeid) || !in_array($typeid, array(1, 2, 3, 4, 5, 6)) ? 2 : $typeid;
	require_once DISCUZ_ROOT.'./forumdata/cache/cache_profilefields.php';

	$member = $db->fetch_first("SELECT * FROM {$tablepre}members m
		LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
		WHERE m.uid='$discuz_uid'");

	$seccodecheck = ($seccodestatus & 8) && (!$seccodedata['minposts'] || $posts < $seccodedata['minposts']);
	$secqaacheck = false;
	$member['msn']= explode("\t", $member['msn']);

	if(!submitcheck('editsubmit', 0, $seccodecheck)) {

		if($typeid == 1) {

			if($seccodecheck) {
				$seccode = random(6, 1) + $seccode{0} * 1000000;
			}

		} elseif($typeid == 2) {

			require_once DISCUZ_ROOT.'./include/editor.func.php';
			require_once DISCUZ_ROOT.'/uc_client/client.php';

			$gendercheck = array($member['gender'] => 'selected="selected"');
			$uc_avatarflash = uc_avatar($discuz_uid, '', 0);
			$member['bio'] = preg_replace("/<imme>(.+)<\/imme>/is", '[imme]', $member['bio']);
			$member['sightml'] = preg_replace("/<imme>(.+)<\/imme>/is", '[imme]', $member['sightml']);
			$member['bio'] = html2bbcode($member['bio']);
			$member['signature'] = html2bbcode($member['sightml']);

		} elseif($typeid == 5) {

			$invisiblechecked = $member['invisible'] ? 'checked="checked"' : '';
			$emailchecked = $member['showemail'] ? 'checked="checked"' : '';
			$newschecked = $member['newsletter'] ? 'checked="checked"' : '';
			$tppchecked = array($member['tpp'] => 'checked="checked"');
			$pppchecked = array($member['ppp'] => 'checked="checked"');
			$toselect = array(strval((float)$member['timeoffset']) => 'selected="selected"');
			$pscheck = array(intval($member['pmsound']) => 'checked="checked"');
			$emcheck = array($member['editormode'] => 'checked="checked"');
			$tfcheck = array($member['timeformat'] => 'checked="checked"');
			$dfcheck = array($member['dateformat'] => 'checked="checked"');
			$styleselect = '';
			$query = $db->query("SELECT styleid, name FROM {$tablepre}styles WHERE available='1'");
			while($style = $db->fetch_array($query)) {
				$styleselect .= "<option value=\"$style[styleid]\" ".
					($style['styleid'] == $member['styleid'] ? 'selected="selected"' : NULL).
					">$style[name]</option>\n";
			}

			$customshow = str_pad(base_convert($member['customshow'], 10, 3), 4, '0', STR_PAD_LEFT);
			$dateconvertchecked = array($customshow{0} => 'checked="checked"');
			$sschecked = array($customshow{1} => 'checked="checked"');
			$sachecked = array($customshow{2} => 'checked="checked"');
			$sichecked = array($customshow{3} => 'checked="checked"');

			$creditnoticechecked = array(empty($_COOKIE['discuz_creditnoticedisable']) => 'checked="checked"');

			$dateformatlist = array();
			if(!empty($userdateformat) && ($count = count($userdateformat))) {
				for($num =1; $num <= $count; $num ++) {
					$dateformatlist[$num] = str_replace(array('n', 'j', 'y', 'Y'), array('mm', 'dd', 'yy', 'yyyy'), $userdateformat[$num-1]);
				}
			}

			$feedchecks = array();
			$customaddfeed = intval($member['customaddfeed']);
			if($customaddfeed > 0) {
				$customaddfeed = sprintf('%03b', $customaddfeed);
				for($i = 1; $i <= 3; $i++) {
					$feedchecks[$i] = $customaddfeed[3 - $i] ? 'checked="checked"' : '';
				}
			}

			$defaultcheck = $customaddfeed == 0 ? 'checked="checked"' : '';
			$customcheck = $feedchecks ? 'checked="checked"' : '';
			$showfeedcheck = $customaddfeed == 0 ? 'none' : '';

		}

		include template('memcp_profile');

	} else {

		require_once DISCUZ_ROOT.'./include/discuzcode.func.php';

		$membersql = $memberfieldsql = $authstradd1 = $authstradd2 = $newpasswdadd = '';
		if($typeid == 1) {

			$emailnew = dhtmlspecialchars($emailnew);
			if($questionidnew === '') {
				$secquesnew = $discuz_secques;
				$questionidnew = $answernew = '';
			} else {
				$secquesnew = $questionidnew > 0 ? random(8) : '';
			}

			if(($adminid == 1 || $adminid == 2 || $adminid == 3) && !$secquesnew && $admincp['forcesecques']) {
				showmessage('profile_admin_security_invalid');
			}

			if(!empty($newpassword) && $newpassword != $newpassword2) {
				showmessage('profile_passwd_notmatch');
			}

			require_once DISCUZ_ROOT.'./uc_client/client.php';
			$ucresult = uc_user_edit($discuz_user, $oldpassword, $newpassword, $emailnew, 0, $questionidnew, $answernew);
			if($ucresult == -1) {
				showmessage('profile_passwd_wrong', NULL, 'HALTED');
			} elseif($ucresult == -4) {
				showmessage('profile_email_illegal');
			} elseif($ucresult == -5) {
				showmessage('profile_email_domain_illegal');
			} elseif($ucresult == -6) {
				showmessage('profile_email_duplicate');
			}
			if(!empty($newpassword)) {
				$newpasswdadd = ", password='".md5(random(10))."'";
			}

			if($regverify == 1 && $adminid == 0 && $emailnew != $email && (($grouptype == 'member' && $adminid == 0) || $groupid == 8)) {
				$idstring = random(6);
				$groupid = 8;

				require_once DISCUZ_ROOT.'./forumdata/cache/usergroup_8.php';

				$authstradd1 = ", groupid='8'";
				$authstradd2 = "authstr='$timestamp\t2\t$idstring'";
				sendmail("$discuz_userss <$emailnew>", 'email_verify_subject', 'email_verify_message');
			}

			$membersql = "secques='$secquesnew', email='$emailnew' $newpasswdadd $authstradd1";
			$memberfieldsql = $authstradd2;

		} elseif($typeid == 2) {

			$censorexp = '/^('.str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote(($censoruser = trim($censoruser)), '/')).')$/i';
			if($censoruser && (@preg_match($censorexp, $nicknamenew) || @preg_match($censorexp, $cstatusnew))) {
				showmessage('profile_nickname_cstatus_illegal');
			}

			if($msnnew && !isemail($msnnew)) {
				showmessage('profile_alipay_msn');
			}

			if($alipaynew && !isemail($alipaynew)) {
				showmessage('profile_alipay_illegal');
			}

			$sitenew = !preg_match("/^http:\/\/$/i", $sitenew) ? (dhtmlspecialchars(trim(preg_match("/^https?:\/\/.+/i", $sitenew) ? $sitenew : ($sitenew ? 'http://'.$sitenew : '')))) : '';

			$icqnew = preg_match ("/^([0-9]+)$/", $icqnew) && strlen($icqnew) >= 5 && strlen($icqnew) <= 12 ? $icqnew : '';
			$qqnew = preg_match ("/^([0-9]+)$/", $qqnew) && strlen($qqnew) >= 5 && strlen($qqnew) <= 12 ? $qqnew : '';
			$bdaynew = datecheck($bdaynew) ? $bdaynew : '0000-00-00';
			$yahoonew = dhtmlspecialchars($yahoonew);
			$msnnew = dhtmlspecialchars($msnnew);
			$msnnew = "$msnnew\t{$member[msn][1]}";
			$taobaonew = dhtmlspecialchars($taobaonew);
			$alipaynew = dhtmlspecialchars($alipaynew);
			$nicknamenew = $allownickname ? cutstr(censor(dhtmlspecialchars($nicknamenew)), 30) : '';
			$cstatusadd = $allowcstatus ? ', customstatus=\''.cutstr(censor(dhtmlspecialchars($cstatusnew)), 30).'\'' : '';
			$gendernew = empty($gendernew) ? 0 : intval($gendernew);
			$locationnew = cutstr(censor(dhtmlspecialchars($locationnew)), 30);

			if($maxsigsize) {
				if(strlen($signaturenew) > $maxsigsize) {
					showmessage('profile_sig_toolong');
				}
			} else {
				$signaturenew = '';
			}

			$signaturenew = censor($signaturenew);
			$sigstatusnew = $signaturenew ? 1 : 0;
			$bionew = censor(dhtmlspecialchars($bionew));

			$sightmlnew = discuzcode(stripslashes($signaturenew), 1, 0, 0, 0, $allowsigbbcode, $allowsigimgcode, 0, 0, 1);
			$biohtmlnew = discuzcode(stripslashes($bionew), 1, 0, 0, 0, $allowbiobbcode, $allowbioimgcode, 0, 0, 1);
			if($member['msn'][1]) {
				if(strpos(strtolower($sightmlnew), '[imme]') !== FALSE) {
					$sightmlnew = str_replace('[imme]', "<imme><a target='_blank' href='http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=".$member['msn'][1]."@apps.messenger.live.com&mkt=zh-cn' title='MSN'><img style='vertical-align:middle' src='http://messenger.services.live.com/users/".$member['msn'][1]."@apps.messenger.live.com/presenceimage?mkt=zh-cn' width='16' height='16' /></a></imme>", $sightmlnew);
				}
				if(strpos(strtolower($biohtmlnew), '[imme]') !== FALSE) {
					$biohtmlnew = str_replace('[imme]', "<imme><a target='_blank' href='http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=".$member['msn'][1]."@apps.messenger.live.com&mkt=zh-cn' title='MSN'><img style='vertical-align:middle' src='http://messenger.services.live.com/users/".$member['msn'][1]."@apps.messenger.live.com/presenceimage?mkt=zh-cn' width='16' height='16' /></a></imme>", $biohtmlnew);
				}
			}
			$sightmlnew = addslashes($sightmlnew);
			$biohtmlnew = addslashes($biohtmlnew);

			$membersql = "gender='$gendernew', bday='$bdaynew', sigstatus='$sigstatusnew'";
			$memberfieldsql = "nickname='$nicknamenew', site='$sitenew', location='$locationnew', icq='$icqnew', qq='$qqnew', yahoo='$yahoonew', msn='$msnnew', taobao='$taobaonew', alipay='$alipaynew', bio='$biohtmlnew', sightml='$sightmlnew' $cstatusadd";

			if($_DCACHE['fields_required'] || $_DCACHE['fields_optional']) {
				$fieldadd = array();
				foreach(array_merge($_DCACHE['fields_required'], $_DCACHE['fields_optional']) as $field) {
					$field_key = 'field_'.$field['fieldid'];
					$field_val = trim(${'field_'.$field['fieldid'].'new'});
					if($field['required'] && $field_val == '' && !($field['unchangeable'] && $member[$field_key])) {
						showmessage('profile_required_info_invalid');
					} elseif($field['selective'] && $field_val != '' && !isset($field['choices'][$field_val])) {
						showmessage('undefined_action', NULL, 'HALTED');
					} elseif(!$field['unchangeable'] || !$member[$field_key]) {
						$fieldadd[] = "$field_key='".dhtmlspecialchars($field_val)."'";
					}
				}

				if(!empty($fieldadd)) {
					$memberfieldsql .= ', '.implode(', ', $fieldadd);
				}
			}

		} else {

			$tppnew = in_array($tppnew, array(10, 20, 30)) ? $tppnew : 0;
			$pppnew = in_array($pppnew, array(5, 10, 15)) ? $pppnew : 0;
			$editormodenew = in_array($editormodenew, array(0, 1, 2)) ? $editormodenew : 2;
			$ssnew = in_array($ssnew, array(0, 1)) ? $ssnew : 2;
			$sanew = in_array($sanew, array(0, 1)) ? $sanew : 2;
			$sinew = in_array($sinew, array(0, 1)) ? $sinew : 2;
			$dateconvertnew = $dateconvertnew ? 1 : 0;
			$customshownew = base_convert($dateconvertnew.$ssnew.$sanew.$sinew, 3, 10);
			$dateformatnew = ($dateformatnew = intval($dateformatnew)) && !empty($userdateformat[$dateformatnew -1]) ? $dateformatnew : 0;
			$invisiblenew = $allowinvisible && $invisiblenew ? 1 : 0;
			$showemailnew = empty($showemailnew) ? 0 : 1;
			$styleid = empty($styleidnew) ? $styleid : $styleidnew;
			if($customaddfeednew) {
				$customaddfeednew = $addfeed[1] || $addfeed[2] ||$addfeed[3] ? bindec(intval($addfeed[3]).intval($addfeed[2]).intval($addfeed[1])) : '-1';
			}
			if($creditnoticenew) {
				dsetcookie('discuz_creditnoticedisable', '', -31536000, '');
			}

			$membersql = "styleid='$styleidnew', showemail='$showemailnew', timeoffset='$timeoffsetnew', tpp='$tppnew', ppp='$pppnew', editormode='$editormodenew', customshow='$customshownew', newsletter='$newsletternew', invisible='$invisiblenew', timeformat='$timeformatnew', dateformat='$dateformatnew', pmsound='$pmsoundnew', customaddfeed='$customaddfeednew'";

		}

		if($membersql) {
			$db->query("UPDATE {$tablepre}members SET $membersql WHERE uid='$discuz_uid'");
		}

		$query = $db->query("SELECT uid FROM {$tablepre}memberfields WHERE uid='$discuz_uid'");
		if(!$db->num_rows($query)) {
			$db->query("REPLACE INTO {$tablepre}memberfields (uid) VALUES ('$discuz_uid')");
		}

		if($memberfieldsql) {
			$db->query("UPDATE {$tablepre}memberfields SET $memberfieldsql WHERE uid='$discuz_uid'");
		}

		if($type == 1 && !empty($authstradd1) && !empty($authstradd2)) {
			showmessage('profile_email_verify');
		} else {
			showmessage('profile_succeed', 'memcp.php?action=profile&typeid='.$typeid);
		}
	}

} elseif($action == 'credits') {

	$taxpercent = sprintf('%1.2f', $creditstax * 100).'%';

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -