function PostMember() { global $zbp; if (!isset($_POST['ID'])) { return; } if (!$zbp->CheckRights('MemberAll')) { unset($_POST['Level']); unset($_POST['Name']); } if (isset($_POST['Password'])) { if ($_POST['Password'] == '') { unset($_POST['Password']); } else { if (strlen($_POST['Password']) < $zbp->option['ZC_PASSWORD_MIN'] || strlen($_POST['Password']) > $zbp->option['ZC_PASSWORD_MAX']) { $zbp->ShowError(54); } if (!CheckRegExp($_POST['Password'], '[password]')) { $zbp->ShowError(54); } $_POST['Password'] = Member::GetPassWordByGuid($_POST['Password'], $_POST['Guid']); } } if (isset($_POST['Name'])) { if (isset($zbp->membersbyname[$_POST['Name']])) { if ($zbp->membersbyname[$_POST['Name']]->ID != $_POST['ID']) { $zbp->ShowError(62); } } } if (isset($_POST['Alias'])) { $_POST['Alias'] = TransferHTML($_POST['Alias'], '[noscript]'); } $mem = new Member(); if (GetVars('ID', 'POST') == 0) { if (isset($_POST['Password']) == false || $_POST['Password'] == '') { $zbp->ShowError(73); } $_POST['IP'] = GetGuestIP(); } else { $mem->LoadInfoByID(GetVars('ID', 'POST')); } foreach ($zbp->datainfo['Member'] as $key => $value) { if ($key == 'ID') { continue; } if ($key == 'Meta') { continue; } if (isset($_POST[$key])) { $mem->{$key} = GetVars($key, 'POST'); } } foreach ($GLOBALS['Filter_Plugin_PostMember_Core'] as $fpname => &$fpsignal) { $fpname($mem); } FilterMember($mem); FilterMeta($mem); CountMember($mem); $mem->Save(); foreach ($GLOBALS['Filter_Plugin_PostMember_Succeed'] as $fpname => &$fpsignal) { $fpname($mem); } if (isset($_POST['Password'])) { if ($mem->ID == $zbp->user->ID) { Redirect($zbp->host . 'zb_system/cmd.php?act=login'); } } return true; }
/** * 提交用户数据 * @return bool */ function PostMember() { global $zbp; $mem = new Member(); $data = array(); if (!isset($_POST['ID'])) { return false; } //检测密码 if (trim($_POST["Password"]) == '' || trim($_POST["PasswordRe"]) == '' || $_POST["Password"] != $_POST["PasswordRe"]) { unset($_POST["Password"]); unset($_POST["PasswordRe"]); } $data['ID'] = $_POST['ID']; $editableField = array('Password', 'Email', 'HomePage', 'Alias', 'Intro', 'Template'); // 如果是管理员,则再允许改动别的字段 if ($zbp->CheckRights('MemberAll')) { array_push($editableField, 'Level', 'Status', 'Name', 'IP'); } else { $data['ID'] = $zbp->user->ID; } // 复制一个新数组 foreach ($editableField as $value) { if (isset($_POST[$value])) { $data[$value] = GetVars($value, 'POST'); } } if (isset($data['Name'])) { // 检测同名 if (isset($zbp->membersbyname[$data['Name']])) { if ($zbp->membersbyname[$data['Name']]->ID != $data['ID']) { $zbp->ShowError(62, __FILE__, __LINE__); } } } if (isset($data['Alias'])) { $data['Alias'] = TransferHTML($data['Alias'], '[noscript]'); } if ($data['ID'] == 0) { if (!isset($data['Password']) || $data['Password'] == '') { $zbp->ShowError(73, __FILE__, __LINE__); } $data['IP'] = GetGuestIP(); } else { $mem->LoadInfoByID($data['ID']); } foreach ($zbp->datainfo['Member'] as $key => $value) { if ($key == 'ID' || $key == 'Meta') { continue; } if (isset($data[$key])) { $mem->{$key} = $data[$key]; } } // 然后,读入密码 // 密码需要单独处理,因为拿不到用户Guid if (isset($data['Password'])) { if ($data['Password'] != '') { if (strlen($data['Password']) < $zbp->option['ZC_PASSWORD_MIN'] || strlen($data['Password']) > $zbp->option['ZC_PASSWORD_MAX']) { $zbp->ShowError(54, __FILE__, __LINE__); } if (!CheckRegExp($data['Password'], '[password]')) { $zbp->ShowError(54, __FILE__, __LINE__); } $mem->Password = Member::GetPassWordByGuid($data['Password'], $mem->Guid); } } FilterMeta($mem); foreach ($GLOBALS['hooks']['Filter_Plugin_PostMember_Core'] as $fpname => &$fpsignal) { $fpname($mem); } FilterMember($mem); CountMember($mem); // 查询同名 if (isset($data['Name'])) { if ($data['ID'] == 0) { if ($zbp->CheckMemberNameExist($data['Name'])) { $zbp->ShowError(62, __FILE__, __LINE__); } } } $mem->Save(); foreach ($GLOBALS['hooks']['Filter_Plugin_PostMember_Succeed'] as $fpname => &$fpsignal) { $fpname($mem); } $zbp->AddBuildModule('authors'); if (isset($data['Password'])) { if ($mem->ID == $zbp->user->ID) { Redirect($zbp->host . 'zb_system/cmd.php?act=login'); } } return true; }