Example #1
0
/**
 * 会员修改邮箱地址
 *
 * 编写人:陈雷
 * 编写日期:2009-6-16
 * 修改日期:
 * @param int $uid 用户uid
 * @param string $oldname 老邮箱地址
 * @param string $newname 新邮箱地址
 * @param string $password 原密码
 * @param string $validate_code 验证码
 * @param string $errorinfo 错误信息,引用
 * @return 1表示失败,0表示成功
 */
function change_email($uid, $oldname, $newname, $password, $validate_code, &$errorinfo)
{
    global $SDB, $DC, $SESSION, $MDB, $MDB_LY;
    $obj_user = $DC->get_user($uid);
    if ($obj_user->validate_email == 1) {
        $errorinfo = '您的邮箱已经通过验证,不能再次修改';
        $result = 0;
        return $result;
    }
    if (!strstr($newname, '@')) {
        $errorinfo = '新邮箱格式错误';
        $result = 0;
        return $result;
    }
    $validate_code = addslashes($validate_code);
    $code_hash = $_COOKIE['GFCH'];
    if (!verify_antispam_v2($code_hash, $validate_code)) {
        $errorinfo = '验证码错误';
        $result = 0;
        return $result;
    }
    $sql = "select uid from user where name = '{$newname}'";
    $temp_uid = $SDB->result($sql);
    if ($temp_uid > 0) {
        $errorinfo = '您要修改的新邮箱已经存在';
        $result = 0;
        return $result;
    }
    $raw_hash = 'Love21cn.com' . sha1(_strtolower($oldname)) . sha1($password);
    $login_hash = sha1($raw_hash);
    $user_obj = $DC->get_userlog_from_uidhash(md5($uid));
    if ($user_obj->login_hash == $login_hash) {
        $new_raw_hash = 'Love21cn.com' . sha1(_strtolower($newname)) . sha1($password);
        $new_login_hash = sha1($new_raw_hash);
        $arr = array('name' => $newname, 'login_hash' => $new_login_hash);
        $blogin = $DC->update_userlogin($uid, $arr);
        $buser = $DC->update_user($uid, $arr);
        v_send_email($newname, 1, $uid);
        $DC->set_cache('post_email_num_chenlei_' . $uid, 1, 3600 * 24);
        $errorinfo = '邮箱修改成功,验证邮件已发至新邮箱(' . $newname . ')请使用新邮箱地址重新登录世纪佳缘。';
        $result = 1;
        /**
         * 更新直邮推荐表
         */
        $sql = "update subscribe set email='" . $newname . "' where uid=" . $uid;
        $MDB_LY->query($sql);
        $USER = $SDB->result("SELECT * FROM user WHERE `uid`='" . $uid . "'");
        if (is_object($USER) && $USER->uid > 0) {
            write_session($USER, 0, 0, $new_login_hash);
        }
        $DC->set_cache('post_email_num_chenlei_' . $USER->uid, 0, 3600 * 24);
    } else {
        $errorinfo = '密码错误';
        $result = 0;
    }
    return $result;
}
Example #2
0
function unity_user_login()
{
    $email = func_arg(0);
    $password = func_arg(1);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Account');
    $retValid = FALSE;
    $retMessage = "Gagal login!";
    $cekada = $lilo_mongo->findOne(array("email" => $email, 'password' => md5($password)));
    if ($cekada) {
        write_session($cekada['_id'], $cekada['activation_key'], $cekada['token_key']);
        $retValid = TRUE;
        $retMessage = "Login success!";
    } else {
        $cekada2 = $lilo_mongo->findOne(array("username" => $email, 'password' => md5($password)));
        if ($cekada2) {
            write_session($cekada2['_id'], $cekada2['activation_key'], $cekada2['token_key']);
            //
            $retValid = TRUE;
            $retMessage = "Login success!";
        }
    }
    $ret = array('valid' => $retValid, 'message' => $retMessage);
    return json_encode($ret);
}