-
Notifications
You must be signed in to change notification settings - Fork 1
/
friend.php
61 lines (54 loc) · 2.23 KB
/
friend.php
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
<?php
require_once './include/common.inc.php';
$action = gp('action');
$fuid = gp('fuid', 0);
switch ($action) {
case 'refresh':
$db->query("DELETE FROM game_friends WHERE uid = $uid");
$fuids = $my->api_client->friend_getAppUsers();
foreach ($fuids as $fuid) {
$db->query("INSERT INTO game_friends (uid, fuid) VALUES ('{$uid}', '{$fuid}')");
}
$query = $db->query("SELECT f.fuid, u.username FROM game_friends f LEFT JOIN game_users u ON u.fuid = u.uid WHERE f.uid = '{$uid}'");
while ($friend = $db->fetch_array($query)) {
echo '<li><a href="friend.php?fuid='.$friend['fuid'].'">'.$friend['username'].'</a></li>';
}
break;
default:
$userInfo = $db->fetch_first("SELECT u.*,u_p.*,u_pl.empiric AS uEmpiric FROM game_users u ".
"LEFT JOIN game_userproperty u_p ON u.uid = u_p.uid ".
"LEFT JOIN game_userlevel u_pl ON u_p.level = u_pl.level ".
"WHERE u.uid = $fuid");
$smarty->assign('userInfo', $userInfo);
$makeQuery = $db->query("SELECT m.*,p.productname,p.pic FROM game_makeprocess m ".
"LEFT JOIN game_products p ON m.pid = p.pid ".
"WHERE m.uid = $fuid");
if($makeQuery)
{
while($makeItem = $db->fetch_array($makeQuery)) {
$makeList[] = array(
'id' => $makeItem['id'],
'uid' => $makeItem['uid'],
'productname' => $makeItem['productname'],
'pic' => $makeItem['pic'],
);
}
$smarty->assign('makeList', $makeList);
}
$friendInfo = $db->fetch_first("SELECT COUNT(*) AS fCount FROM game_friends WHERE uid = $uid");
if($friendInfo['fCount'] == 0)
{
$friendList = $my->api_client->friend_getAppUsers();
foreach($friendList as $friendUid) {
$db->query("INSERT INTO game_friends(uid,fuid) VALUES ($uid,$friendUid)");
}
$smarty->assign('updated', '1');
}
$friendQuery = $db->query("SELECT f.uid,f.fuid,u.username FROM game_friends f ".
"LEFT JOIN game_users u ON f.fuid = u.uid ".
"WHERE f.uid = $uid");
while($friend = $db->fetch_array($friendQuery)) {
$friend_list[] = array('userid' => $friend['fuid'], 'username' => $friend['username']);
}
$smarty->assign('friend_list', $friend_list);
$smarty->display('friend.html');