These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use Buddy\BuddyModel; |
||
4 | use Buddy\BuddyException; |
||
5 | |||
6 | /** |
||
7 | * buddy.php |
||
8 | * Friend system |
||
9 | * |
||
10 | * v3.0 Fully rewrote by Gorlum for http://supernova.ws |
||
11 | * [!] Full rewrote from scratch |
||
12 | * |
||
13 | * Idea from buddy.php Created by Perberos. All rights reversed (C) 2006 |
||
14 | * */ |
||
15 | |||
16 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
17 | |||
18 | /** |
||
19 | * @var array $user |
||
20 | */ |
||
21 | global $user; |
||
22 | |||
23 | lng_include('buddy'); |
||
24 | |||
25 | $result = array(); |
||
26 | sn_db_transaction_start(); |
||
27 | try { |
||
28 | $cBuddy = new \Buddy\BuddyRoutingParams(array( |
||
29 | 'gc' => classSupernova::$gc, |
||
30 | 'buddy_id' => sys_get_param_id('buddy_id'), |
||
31 | 'mode' => sys_get_param_str('mode'), |
||
32 | 'new_friend_id_safe' => sys_get_param_id('request_user_id'), |
||
33 | 'new_friend_name_unsafe' => sys_get_param_str_unsafe('request_user_name'), |
||
34 | 'new_request_text' => sys_get_param_str('request_text'), |
||
35 | 'user' => $user, |
||
36 | )); |
||
37 | |||
38 | classSupernova::$gc->buddy->route($cBuddy); |
||
0 ignored issues
–
show
|
|||
39 | } catch (BuddyException $e) { |
||
40 | $result[] = array( |
||
41 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
||
42 | 'MESSAGE' => classLocale::$lang[$e->getMessage()], |
||
43 | ); |
||
44 | $e->getCode() == ERR_NONE ? sn_db_transaction_commit() : sn_db_transaction_rollback(); |
||
45 | } |
||
46 | sn_db_transaction_rollback(); |
||
47 | unset($buddy); |
||
48 | |||
49 | empty($template_result) ? $template_result = array() : false; |
||
50 | |||
51 | foreach (BuddyModel::db_buddy_list_by_user(classSupernova::$gc->db, $user['id']) as $row) { |
||
52 | $row['BUDDY_REQUEST'] = sys_bbcodeParse($row['BUDDY_REQUEST']); |
||
53 | |||
54 | $row['BUDDY_ACTIVE'] = $row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE; |
||
55 | $row['BUDDY_DENIED'] = $row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED; |
||
56 | $row['BUDDY_INCOMING'] = $row['BUDDY_OWNER_ID'] == $user['id']; |
||
57 | $row['BUDDY_ONLINE'] = floor((SN_TIME_NOW - $row['onlinetime']) / 60); |
||
58 | |||
59 | $template_result['.']['buddy'][] = $row; |
||
60 | } |
||
61 | |||
62 | $template_result += array( |
||
63 | 'PAGE_HEADER' => classLocale::$lang['buddy_buddies'], |
||
64 | 'PAGE_HINT' => classLocale::$lang['buddy_hint'], |
||
65 | 'USER_ID' => $user['id'], |
||
66 | 'REQUEST_USER_ID' => isset($new_friend_row['id']) ? $new_friend_row['id'] : 0, |
||
67 | 'REQUEST_USER_NAME' => isset($new_friend_row['username']) ? $new_friend_row['username'] : '', |
||
68 | ); |
||
69 | |||
70 | $template_result['.']['result'] = is_array($template_result['.']['result']) ? $template_result['.']['result'] : array(); |
||
71 | $template_result['.']['result'] += $result; |
||
72 | |||
73 | $template = gettemplate('buddy', true); |
||
74 | $template->assign_recursive($template_result); |
||
75 | |||
76 | display($template); |
||
77 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.