chengkun
2025-04-27 a0402d122fee696e2b7684ef7edfc504ade12640
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
<?php
 
!defined('P_W') && exit('Forbidden');
//api mode 7
 
class UserApp {
 
    var $base;
    var $db;
 
    function UserApp($base) {
        $this->base = $base;
        $this->db = $base->db;
    }
 
    function isInstall($uid) {
        $appid = array();
        $query = $this->db->query("SELECT appid FROM pw_userapp WHERE uid=" . pwEscape($uid));
        while ($rt = $this->db->fetch_array($query)) {
            $appid[] = $rt['appid'];
        }
        return new ApiResponse($appid);
    }
 
    function add($uid, $appid, $appname, $allowfeed ,$descrip) {
        global $timestamp;
 
        $this->db->update("REPLACE INTO pw_userapp SET " . pwSqlSingle(array(
            'uid'        => $uid,
            'appid'        => $appid,
            'appname'    => $appname,
            'allowfeed'    => $allowfeed
        )));
 
        if ($allowfeed) {
            $descrip = Char_cv($descrip);
            $this->db->update("INSERT INTO pw_feed SET " . pwSqlSingle(array(
                'uid'        => $uid,
                'type'        => 'app',
                'descrip'    => $descrip,
                'timestamp'    => $timestamp
            ),false));
        }
 
        return new ApiResponse(true);
    }
 
    function appsUpdateCache($apps) {
        if ($apps && is_array($apps)) {
 
            require_once(R_P.'admin/cache.php');
            setConfig('db_apps_list',$apps);
            updatecache_c();
            return new ApiResponse(true);
        } else {
            return new ApiResponse(false);
        }
    }
}
?>