Example #1
0
function uc_user_register($username, $password, $email, $nickname, $questionid = '', $answer = '', $regip = '', $addorg = 1)
{
    if ($nickname && ($status = uc_user_checkname($nickname)) < 0) {
        return $status;
    }
    if (($status = uc_user_checkusername($username)) < 0) {
        return $status;
    }
    if (($status = uc_user_checkemail($email)) < 0) {
        return $status;
    }
    $uid = uc_add_user($username, $password, $email, $nickname, 0, $questionid, $answer, $regip);
    //加入默认机构
    if ($addorg && is_array($uid) && getglobal('setting/defaultdepartment') && DB::fetch_first("select orgid from %t where orgid=%d ", array('organization', getglobal('setting/defaultdepartment')))) {
        C::t('organization_user')->insert($uid['uid'], getglobal('setting/defaultdepartment'));
    }
    return $uid;
}
Example #2
0
                 runlog('sendmail', "{$email} sendmail failed.");
             }
         }
     }
 } else {
     //新添用户
     if (!check_username($_GET['username'])) {
         exit(json_encode(array('error' => '用户姓名含有敏感字符')));
     }
     if ($_GET['nickname']) {
         if (check_username($_GET['nickname']) && !C::t('user')->fetch_by_nickname($_GET['nickname'])) {
         } else {
             $_GET['nickname'] = '';
         }
     }
     $user = uc_add_user($_GET['username'], $_GET['password'], $email, $_GET['nickname']);
     $uid = $user['uid'];
     if ($uid < 1) {
         exit(json_encode(array('error' => '导入不成功')));
     }
     $base = array('uid' => $uid, 'adminid' => 0, 'groupid' => 9, 'regdate' => TIMESTAMP, 'emailstatus' => 1);
     if ($_GET['mobile']) {
         if (!preg_match("/^\\d+\$/", $_GET['mobile'])) {
         } elseif (C::t('user')->fetch_by_phone($_GET['mobile'])) {
         } else {
             $base['phone'] = $_GET['mobile'];
         }
     }
     if ($_GET['weixinid']) {
         if (!preg_match("/^[A-Za-z][\\w|-]+\$/i", $_GET['weixinid'])) {
         } elseif (C::t('user')->fetch_by_weixinid($_GET['weixinid'])) {