chengkun
2025-05-22 1a8aea45ebb1582c9f65d9e8dcd520002f83ae12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
 
!defined('P_W') && exit('Forbidden');
//api mode 1
 
define('API_USER_USERNAME_NOT_UNIQUE', 100);
 
class User {
 
    var $base;
    var $db;
 
    function User($base) {
        $this->base = $base;
        $this->db = $base->db;
    }
 
    function getInfo($uids, $fields = array()) {
        if (!$uids) {
            return new ApiResponse(false);
        }
        require_once(R_P.'require/showimg.php');
 
        $uids = is_numeric($uids) ? array($uids) : explode(",",$uids);
 
        if (!$fields) $fields = array('uid', 'username', 'icon', 'gender', 'location', 'bday');
 
        $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */
        $users = array();
        foreach ($userService->getByUserIds($uids) as $rt) {
            list($rt['icon']) = showfacedesign($rt['icon'], 1, 'm');
            $rt_a = array();
            foreach ($fields as $field) {
                if (isset($rt[$field])) {
                    $rt_a[$field] = $rt[$field];
                }
            }
            $users[$rt['uid']] = $rt_a;
        }
        return new ApiResponse($users);
    }
 
    function alterName($uid, $newname) {
        $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */
        $userName = $userService->getUserNameByUserId($uid);
        if (!$userName || $userName == $newname) {
            return new ApiResponse(1);
        }
        $existUserId = $userService->getUserIdByUserName($newname);
        if ($existUserId) {
            return new ApiResponse(API_USER_USERNAME_NOT_UNIQUE);
        }
        $userService->update($uid, array('username' => $newname));
 
        $user = L::loadClass('ucuser', 'user');
        $user->alterName($uid, $userName, $newname);
 
        return new ApiResponse(1);
    }
 
    function deluser($uids) {
        $user = L::loadClass('ucuser', 'user');
        $user->delUserByIds($uids);
 
        return new ApiResponse(1);
    }
 
    function synlogin($user){
 
        global $timestamp,$uc_key;
        list($winduid, $windid, $windpwd) = explode("\t", $this->base->strcode($user, false));
 
        header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
 
        require_once ("../../config/db.config.php");
        require_once ("../../app/include/mysql.class.php");
        require_once ("../../app/include/public.function.php");
        require_once ("../../data/plus/config.php");
        $ip = fun_ip_get();
        $time = time();
        if($config[sy_pw_type]=="pw_center"){
            $db = new mysql($db_config['dbhost'], $db_config['dbuser'], $db_config['dbpass'], $db_config['dbname'], ALL_PS, $db_config['charset']);
            $user_query = $db->query("SELECT * FROM $db_config[def]member WHERE `username`='$windid'");
            while($userrs = $db->fetch_array($user_query))
            {
                $userinfo = $userrs;
            }
            //判断是否是重名用户
            if($userinfo["uid"]>0)
            {
                if($userinfo["pw_repeat"]!="1")
                {
                    //判断账户名密码是否一致
                    if($userinfo["password"]==md5($windpwd.$userinfo[salt]))
                    {
                        $db->query("UPDATE $db_config[def]member SET `pwuid`='$winduid' WHERE `uid`='$userinfo[uid]'");
                        $this->unset_cookie();
                        $this->add_cookie($userinfo[uid],$userinfo[username],$userinfo[salt],$userinfo[email],$userinfo[password]);
 
                    }else{
 
                        //不一致标注为重名用户
                        $db->query("UPDATE $db_config[def]member SET `pw_repeat`='1' WHERE `uid`='$userinfo[uid]'");
                    }
                }
            }else{
                //用户不存在 新建一个用户
                $salt = substr(uniqid(rand()), -6);
                $pass = md5($windpwd.$salt);
                $db->query("INSERT INTO $db_config[def]member SET `username`='$windid',`password`='$pass',`salt`='$salt',`usertype`='1',`reg_ip`='$ip',`reg_date`='$time',`pwuid`='$winduid'");
                $uid = $db->insert_id();
                $db->query("INSERT INTO $db_config[def]resume SET `uid`='".$uid."'");
                $db->query("INSERT INTO $db_config[def]member_statis SET `uid`='".$uid."'");
                $this->unset_cookie();
                $this->add_cookie($winduid,$windid,$salt,"",$pass);
            }
 
 
        }
 
    }
    function add_cookie($uid,$username,$salt,$email,$pass,$usertype="1")
    {
        SetCookie("uid",$uid,time() + 86400, "/");
        SetCookie("username",$username,time() + 86400, "/");
        SetCookie("salt",$salt,time() + 86400, "/");
        SetCookie("email",$email,time() + 86400, "/");
        SetCookie("usertype",$usertype,time() + 86400, "/");
        SetCookie("shell",md5($username.$pass.$salt), time() + 86400, "/");
    }
    function unset_cookie()
    {
 
        SetCookie("uid", "", time() - 604800, "/");
        SetCookie("username", "", time() - 604800, "/");
        SetCookie("salt", "", time() - 604800, "/");
        SetCookie("email", "", time() - 604800, "/");
        SetCookie("shell", "", time() - 604800, "/");
        SetCookie("usertype", "", time() - 604800, "/");
 
        SetCookie("friend1","",time() - 3600, "/");
        SetCookie("friend2","",time() - 3600, "/");
        SetCookie("friend3","",time() - 3600, "/");
        SetCookie("friend_message1","",time() - 3600, "/");
        SetCookie("friend_message2","",time() - 3600, "/");
        SetCookie("friend_message3","",time() - 3600, "/");
        SetCookie("message1","",time() - 3600, "/");
        SetCookie("message2","",time() - 3600, "/");
        SetCookie("message3","",time() - 3600, "/");
        SetCookie("userid_msg","",time() - 3600, "/");
        SetCookie("usermsg","",time() - 3600, "/");
        SetCookie("userid_job","",time() - 3600, "/");
        SetCookie("commsg","",time() - 3600, "/");
        SetCookie("userid_job3","",time() - 3600, "/");
        SetCookie("entrust","",time() - 3600, "/");
        SetCookie("commsg3","",time() - 3600, "/");
        SetCookie("remind_num","",time() - 3600, "/");
    }
    function synlogout() {
 
        header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
           require_once ("../../data/plus/config.php");
        if($config[sy_pw_type]=="pw_center")
        {
            $this->unset_cookie();
        }
    }
    function getusergroup() {
        $usergroup = array();
        $query = $this->db->query("SELECT gid,gptype,grouptitle FROM pw_usergroups ");
        while($rt= $this->db->fetch_array($query)) {
            $usergroup[$rt['gid']] = $rt;
        }
        return new ApiResponse($usergroup);
    }
    function getphpyun(){
 
    }
}
?>