Esempio n. 1
0
 function DoModify()
 {
     $_update = false;
     $uid = (int) $this->Post['uid'];
     if ($uid < 1) {
         $this->Messager("请指定一个正确的UID");
     }
     $this->ID = $uid;
     $member_info = jsg_member_info($uid);
     if (!$member_info) {
         $this->Messager("您要编辑的用户已经不存在了");
     }
     if (!admin_check_allow($uid)) {
         $this->Messager("为安全起见,您没有编辑 <b>{$member_info['nickname']}</b> 用户信息的权限,请使用网站创始人的身份登录后再进行编辑操作。", '', 10);
     }
     if (($this->Post['role_id'] == 4 || $this->Post['role_id'] == 118) && !trim($this->Post['cause'])) {
         $this->Messager("请输入封杀理由", -1);
     }
     $password = get_param('password');
     if ($password == '') {
         unset($this->Post['password']);
     } else {
         $this->Post['password_unhash'] = $password;
         $this->Post['password'] = jsg_member_password($password, $member_info['salt']);
         $_update = true;
     }
     $rets = array('0' => '【注册失败】有可能是站点关闭了注册功能', '-1' => '不合法', '-2' => '不允许注册', '-3' => '已经存在了', '-4' => 'Email 不合法,请输入正确的Email地址。', '-5' => 'Email 不允许注册,请尝试更换一个。', '-6' => 'Email 已经存在了,请尝试更换一个。');
     $nickname = get_param('nickname');
     if ($nickname != $member_info['nickname']) {
         $ret = jsg_member_checkname($nickname, 1, 0, $uid);
         if ($ret < 1) {
             $this->Messager("帐户/昵称 " . $rets[$ret]);
         }
         unset($this->Post['nickname']);
         $_update = true;
     }
     $username = get_param('username');
     if ($username != $member_info['username']) {
         $ret = jsg_member_checkname($username, 0, 0, $uid);
         if ($ret < 1) {
             $this->Messager("个性域名/微博地址 " . $rets[$ret]);
         }
         unset($this->Post['username']);
         $_update = true;
     }
     $email_update = false;
     $email = get_param('email');
     if ($email != $member_info['email']) {
         $ret = jsg_member_checkemail($email);
         if ($ret < 1) {
             $this->Messager($rets[$ret]);
         }
         unset($this->Post['email']);
         $_update = true;
     }
     $this->Post['role_id'] = (int) $this->Post['role_id'];
     if ($this->Post['role_id'] > 0) {
         $role = DB::fetch_first("SELECT * FROM " . DB::table('role') . " WHERE `id`='{$this->Post['role_id']}'");
         if ($role) {
             if (!admin_check_allow($this->Post['role_id'], 1) || true === jsg_member_is_founder($uid) && 'admin' != $role['type']) {
                 unset($this->Post['role_id'], $this->Post['role_type']);
             } else {
                 $this->Post['role_type'] = $role['type'];
             }
             $login_enable = jconf::get('login_enable');
             if (!$role['privilege'] || $role['privilege'] == '') {
                 $login_enable[$uid] = $uid;
             } else {
                 unset($login_enable[$uid]);
             }
             jconf::set('login_enable', $login_enable);
         } else {
             $this->messager("角色已经不存在");
         }
     } else {
         unset($this->Post['role_id'], $this->Post['role_type']);
     }
     $phone = $this->Post['phone'];
     if ($phone) {
         if (!jsg_is_mobile($phone)) {
             $this->Messager("手机号 {$phone} 格式不对哦,请重新输入正确的号码。");
             $phone = '';
             unset($this->Post['phone']);
         } else {
             if (($member_phone_info = jtable('members')->info(array('phone' => $phone))) && $uid != $member_phone_info['uid']) {
                 $this->Messager("手机号 {$phone} 已经被使用在了 【{$member_phone_info['uid']}】{$member_phone_info['nickname']} 帐户上,请返回重新输入!");
             }
         }
     } else {
         $phone = '';
     }
     if (sms_init()) {
         if ($phone) {
             sms_bind($uid, $phone);
         } else {
             sms_unbind($uid);
         }
     }
     if (@is_file(ROOT_PATH . 'include/logic/cp.logic.php') && $this->Config['company_enable']) {
         $this->Post['companyid'] = max(0, (int) $this->Post['companyid']);
         if ($this->Post['companyid'] == $member_info['companyid']) {
             unset($this->Post['companyid']);
         } else {
             if ($member_info['companyid'] == 0 && $this->Post['companyid'] > 0) {
                 $this->CpLogic->update('company', $this->Post['companyid'], 1, $member_info['topic_count']);
             } elseif ($member_info['companyid'] > 0 && $this->Post['companyid'] == 0) {
                 $this->CpLogic->update('company', $member_info['companyid'], -1, -$member_info['topic_count']);
             } else {
                 $this->CpLogic->update('company', $member_info['companyid'], -1, -$member_info['topic_count']);
                 $this->CpLogic->update('company', $this->Post['companyid'], 1, $member_info['topic_count']);
             }
             $this->Post['company'] = $this->CpLogic->Getone($this->Post['companyid'], 'company', 'name');
         }
         if ($this->Config['department_enable']) {
             $this->Post['departmentid'] = max(0, (int) $this->Post['departmentid']);
             if ($this->Post['departmentid'] == $member_info['departmentid']) {
                 unset($this->Post['departmentid']);
             } else {
                 if ($member_info['departmentid'] == 0 && $this->Post['departmentid'] > 0) {
                     $this->CpLogic->update('department', $this->Post['departmentid'], 1, $member_info['topic_count']);
                 } elseif ($member_info['departmentid'] > 0 && $this->Post['departmentid'] == 0) {
                     $this->CpLogic->update('department', $member_info['departmentid'], -1, -$member_info['topic_count']);
                 } else {
                     $this->CpLogic->update('department', $member_info['departmentid'], -1, -$member_info['topic_count']);
                     $this->CpLogic->update('department', $this->Post['departmentid'], 1, $member_info['topic_count']);
                 }
                 $this->Post['department'] = $this->CpLogic->Getone($this->Post['departmentid'], 'department', 'name');
             }
         }
         if ($this->Post['jobid'] == $member_info['jobid']) {
             unset($this->Post['jobid']);
         } else {
             $this->Post['job'] = jlogic('job')->id2subject($this->Post['jobid']);
         }
         if ($this->Post['companyid']) {
             $chx_cid = $this->Post['companyid'];
             $chx_uid = $member_info['uid'];
             $chx_did = $this->Post['departmentid'] ? $this->Post['departmentid'] : 0;
             $is_cp_usered = DB::fetch_first("SELECT * FROM " . DB::table('cp_user') . " WHERE uid = '{$chx_uid}' AND companyid = '{$chx_cid}' AND departmentid = '{$chx_did}'");
             if ($is_cp_usered) {
                 DB::query("DELETE FROM " . DB::table('cp_user') . " WHERE id = '" . $is_cp_usered['id'] . "'");
             }
         }
     }
     $this->Post['province'] = trim(DB::result_first("select name from " . TABLE_PREFIX . "common_district where id = '" . (int) $this->Post['province'] . "'"));
     $this->Post['city'] = trim(DB::result_first("select name from " . TABLE_PREFIX . "common_district where id = '" . (int) $this->Post['city'] . "'"));
     if ($this->Post['area']) {
         $this->Post['area'] = trim(DB::result_first("select name from " . TABLE_PREFIX . "common_district where id = '" . (int) $this->Post['area'] . "'"));
     }
     if ($this->Post['street']) {
         $this->Post['street'] = trim(DB::result_first("select name from " . TABLE_PREFIX . "common_district where id = '" . (int) $this->Post['street'] . "'"));
     }
     $table1 = jtable('members')->update($this->Post, $uid);
     $memberfields = array('site' => $this->Post['site'], 'validate_true_name' => $this->Post['validate_true_name'], 'validate_card_type' => $this->Post['validate_card_type'], 'validate_card_id' => $this->Post['validate_card_id'], 'validate_remark' => $this->Post['validate_remark']);
     $table2 = jtable('memberfields')->update($memberfields, $uid);
     #附表2信息(members_profile)
     $arr2 = array();
     $profileField = array('constellation', 'zodiac', 'telephone', 'address', 'zipcode', 'nationality', 'education', 'birthcity', 'graduateschool', 'pcompany', 'occupation', 'position', 'revenue', 'affectivestatus', 'lookingfor', 'bloodtype', 'height', 'weight', 'alipay', 'icq', 'yahoo', 'taobao', 'site', 'interest', 'linkaddress', 'field1', 'field2', 'field3', 'field4', 'field5', 'field6', 'field7', 'field8');
     foreach ($profileField as $k => $v) {
         isset($this->Post[$v]) && ($arr2[$v] = trim(strip_tags($this->Post[$v])));
     }
     if ($arr2) {
         $this->_updateMemberProfile($arr2, $uid);
     }
     $email_checked = $this->Post['email_checked'] ? $this->Post['email_checked'] : 0;
     if ($email_checked != $member_info['email_checked']) {
         $_update = true;
     }
     if ($_update) {
         $ret = jsg_member_edit($member_info['nickname'], '', $nickname, $this->Post['password_unhash'], $email, $username, 1, 1, $email_checked);
         $rets = array('0' => '没有做任何修改', '-1' => '帐户/昵称 不合法,含有不允许注册的字符,请尝试更换一个。', '-2' => '帐户/昵称 不允许注册,含有被保留的字符,请尝试更换一个。', '-3' => '帐户/昵称 已经存在了,请尝试更换一个。', '-4' => 'Email 不合法,请输入正确的Email地址。', '-5' => 'Email 不允许注册,请尝试更换一个。', '-6' => 'Email 已经存在了,请尝试更换一个。');
         if ($ret < 1 && isset($rets[$ret])) {
             $this->Messager($rets[$ret]);
         }
     }
     load::logic('topic_manage');
     $TopicManageLogic = new TopicManageLogic();
     $role_id = get_param('role_id');
     $cause = get_param('cause');
     if ($role_id == 4 || $role_id == 118) {
         $TopicManageLogic->doForceOut((array) $nickname, $cause, $role_id);
     } elseif ($role_id != 4 && $role_id != 118 && ($member_info['role_id'] == 4 || $member_info['role_id'] == 118)) {
         $TopicManageLogic->doUserFree($uid);
     }
     if ($this->Config['extcredits_enable'] && $this->Post['validate'] && $this->Post['uid'] > 0) {
         update_credits_by_action('vip', $this->Post['uid']);
     }
     Load::logic('credits');
     $CreditsLogic = new CreditsLogic();
     $CreditsLogic->CountCredits($this->Post['uid']);
     $data = array('uid' => $uid, 'rid' => 0, 'relatedid' => MEMBER_ID, 'dateline' => time());
     foreach ($GLOBALS['_J']['config']['credits']['ext'] as $key => $value) {
         $data[$key] = $_POST[$key] - $member_info[$key];
         $remark .= $value['name'] . ' : ' . $_POST[$key . '_remark'] . ' , ';
     }
     $data['remark'] = trim($remark, ', ');
     jtable('credits_log')->insert($data);
     $this->Messager("编辑成功");
 }
Esempio n. 2
0
function jsg_member_val($key, $ret = 'nickname', $cache = 1)
{
    $key = trim($key);
    if (empty($key)) {
        return '';
    }
    $info = array();
    if (is_numeric($key)) {
        if ($GLOBALS['_J']['config']['sms_enable'] && jsg_is_mobile($key)) {
            $info = jsg_member_info($key, 'phone', '*', $cache);
        } else {
            $info = jsg_member_info($key, 'uid', '*', $cache);
        }
    } else {
        if (false !== strpos($key, '@')) {
            $info = jsg_member_info($key, 'email', '*', $cache);
        }
    }
    if (!$info) {
        $info = jsg_member_info($key, 'nickname', '*', $cache);
        if (!$info) {
            $info = jsg_member_info($key, 'username', '*', $cache);
        }
    }
    if (!$info) {
        return '';
    }
    return $info[$ret];
}