-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php.1209
More file actions
209 lines (173 loc) · 7.2 KB
/
profile.php.1209
File metadata and controls
209 lines (173 loc) · 7.2 KB
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php
/**
* profile
*
* @package Sngine
* @author Zamblek
*/
// fetch bootstrap
require('bootstrap.php');
function console_log( $data ){
echo '<script>';
echo 'Your Credit Scores('. json_encode( $data ) .')';
echo '</script>';
}
// user access
if(!$system['system_public']) {
user_access();
}
// check username
if(is_empty($_GET['username']) || !valid_username($_GET['username'])) {
_error(404);
}
try {
// [1] get main profile info
$get_profile = $db->query(sprintf("SELECT users.*, packages.name as package_name, packages.color as package_color FROM users LEFT JOIN packages ON users.user_subscribed = '1' AND users.user_package = packages.package_id WHERE users.user_name = %s", secure($_GET['username']))) or _error(SQL_ERROR_THROWEN);
if($get_profile->num_rows == 0) {
_error(404);
}
$profile = $get_profile->fetch_assoc();
//VAR_DUMP($profile);
/* check if banned by the system */
if($user->banned($profile['user_id'])) {
_error(404);
}
/* check if blocked by the viewer */
if($user->blocked($profile['user_id'])) {
_error(404);
}
/* check username case */
if(strtolower($_GET['username']) == strtolower($profile['user_name']) && $_GET['username'] != $profile['user_name']) {
redirect('/'.$profile['user_name']);
}
/* get profile picture */
$profile['user_picture_default'] = ($profile['user_picture'])? false : true;
$profile['user_picture'] = User::get_picture($profile['user_picture'], $profile['user_gender']);
/* get the connection & mutual friends */
if($user->_logged_in && $profile['user_id'] != $user->_data['user_id']) {
/* get the connection */
$profile['we_friends'] = (in_array($profile['user_id'], $user->_data['friends_ids']))? true: false;
$profile['he_request'] = (in_array($profile['user_id'], $user->_data['friend_requests_ids']))? true: false;
$profile['i_request'] = (in_array($profile['user_id'], $user->_data['friend_requests_sent_ids']))? true: false;
$profile['i_follow'] = (in_array($profile['user_id'], $user->_data['followings_ids']))? true: false;
/* get mutual friends */
$profile['mutual_friends_count'] = $user->get_mutual_friends_count($profile['user_id']);
$profile['mutual_friends'] = $user->get_mutual_friends($profile['user_id']);
}
// [2] get view content
switch ($_GET['view']) {
case '':
/* get followers count */
$profile['followers_count'] = count($user->get_followers_ids($profile['user_id']));
// get custom fields
$smarty->assign('custom_fields', $user->get_custom_fields( array("get" => "profile", "user_id" => $profile['user_id']) ));
/* get friends */
$profile['friends'] = $user->get_friends($profile['user_id']);
if(count($profile['friends']) > 0) {
$profile['friends_count'] = count($user->get_friends_ids($profile['user_id']));
}
$totals = $user->_data['user_points'] + intval($profile['followers_count'])*2 + $profile['friends_count']*2;
$user->_data['user_points'] = $totals;
/* get photos */
$profile['photos'] = $user->get_photos($profile['user_id']);
/* get pages */
$profile['pages'] = $user->get_pages( array('user_id' => $profile['user_id'], 'results' => $system['min_results_even']) );
/* get groups */
$profile['groups'] = $user->get_groups( array('user_id' => $profile['user_id'], 'results' => $system['min_results_even']) );
/* get events */
$profile['events'] = $user->get_events( array('user_id' => $profile['user_id'], 'results' => $system['min_results_even']) );
/* get pinned post */
$pinned_post = $user->get_post($profile['user_pinned_post']);
$smarty->assign('pinned_post', $pinned_post);
/* prepare publisher */
$smarty->assign('market_categories', $user->get_market_categories());
$smarty->assign('feelings', get_feelings());
$smarty->assign('feelings_types', get_feelings_types());
/* get posts */
$posts = $user->get_posts( array('get' => 'posts_profile', 'id' => $profile['user_id']) );
/* assign variables */
$smarty->assign('posts', $posts);
break;
case 'friends':
/* get friends */
$profile['friends'] = $user->get_friends($profile['user_id']);
if(count($profile['friends']) > 0) {
$profile['friends_count'] = count($user->get_friends_ids($profile['user_id']));
}
break;
case 'photos':
/* get photos */
$profile['photos'] = $user->get_photos($profile['user_id']);
break;
case 'albums':
/* get albums */
$profile['albums'] = $user->get_albums($profile['user_id']);
break;
case 'album':
/* get album */
$album = $user->get_album($_GET['id']);
if(!$album || $album['in_group'] || $album['user_type'] == "page" || ($album['user_type'] == "user" && $album['user_id'] != $profile['user_id'])) {
_error(404);
}
/* assign variables */
$smarty->assign('album', $album);
break;
case 'followers':
/* get followers count */
$profile['followers_count'] = count($user->get_followers_ids($profile['user_id']));
/* get followers */
if($profile['followers_count'] > 0) {
$profile['followers'] = $user->get_followers($profile['user_id']);
}
break;
case 'followings':
/* get followings count */
$profile['followings_count'] = count($user->get_followings_ids($profile['user_id']));
/* get followings */
if($profile['followings_count'] > 0) {
$profile['followings'] = $user->get_followings($profile['user_id']);
}
$profile['user_affiliate_balance'] = $user->_data['user_affiliate_balance'];
break;
case 'likes':
/* get pages */
$profile['pages'] = $user->get_pages( array('user_id' => $profile['user_id']) );
break;
case 'groups':
/* get groups */
$profile['groups'] = $user->get_groups( array('user_id' => $profile['user_id']) );
break;
case 'events':
/* get events */
$profile['events'] = $user->get_events( array('user_id' => $profile['user_id']) );
break;
default:
_error(404);
break;
}
// [3] profile visit notification
if($_GET['view'] == "" && $user->_logged_in && $system['profile_notification_enabled']) {
$user->post_notification( array('to_user_id'=>$profile['user_id'], 'action'=>'profile_visit') );
}
// recent rearches
if(isset($_GET['ref']) && $_GET['ref'] == "qs") {
$user->add_search_log($profile['user_id'], 'user');
}
} catch (Exception $e) {
_error(__("Error"), $e->getMessage());
}
// page header
page_header($profile['user_firstname']." ".$profile['user_lastname'], $profile['user_biography']);
// assign variables
$smarty->assign('profile', $profile);
$smarty->assign('view', $_GET['view']);
// page footer
page_footer("profile");
//popup credit scores from FBchians.
//$totals = $user->_data['user_points'] + $user->_data['user_live_messages_lastid']*2 + $user->_data['user_live_notifications_counter']*2;
$totals = $user->_data['user_points'] + intval($profile['followers_count'])*2 + $profile['friends_count']*2;
$profile['user_points'] = $totals;
$message = "FaceBlock 用户信用积分: " . $user->_data['user_points'] . "; 统计今天社交信用积分总数: " . $totals;
//echo "<script type='text/javascript'>alert('$message');</script>";
//$smarty->assign('Credits',$message);
?>