-
Notifications
You must be signed in to change notification settings - Fork 7
/
user.php
218 lines (205 loc) · 7.77 KB
/
user.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
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
210
211
212
213
214
215
216
217
218
<?php
include ('lib/twitese.php');
$title = "{$_GET['id']}";
include ('inc/header.php');
include ('lib/timeline_format.php');
?>
<script src="js/user.js"></script>
<div id="statuses" class="column round-left">
<?php
if (!loginStatus() || !isset($_GET['id'])) {
header('location: error.php?code='.$t->http_code);exit();
}
$t = getTwitter();
$userid = $_GET['id'];
$since_id = isset($_GET['since_id']) ? $_GET['since_id'] : false;
$max_id = isset($_GET['max_id']) ? $_GET['max_id'] : false;
if (isset($_GET['fav'])) {
$statuses = $t->getFavorites($userid, $since_id, $max_id);
} else {
$statuses = $t->userTimeline($userid, $since_id, $max_id);
}
if ($statuses === false) {
header('location: error.php?code='.$t->http_code);exit;
}
if ($t->http_code == 429) {
$apiout = true;
} else {
$aptout = false;
}
$user = $t->showUser($userid);
if (strcasecmp($userid,$t->username) == 0) {header('location: profile.php');exit();}
$isProtected = $statuses->error == 'Not authorized.';
$r = getRelationship($user->screen_name);
$isFriend = ($r & 1) != 0;
$isFollower = ($r & 2) != 0;
$isBlocked = ($r & 4) != 0;
$isMuted = ($r & 8) != 0;
if (!$isProtected) {
$userinfo = array();
$userinfo['name'] = $user->name;
$userinfo['screen_name'] = $user->screen_name;
$userinfo['friends_count'] = $user->friends_count;
$userinfo['statuses_count'] = $user->statuses_count;
$userinfo['followers_count'] = $user->followers_count;
$userinfo['url'] = $user->entities->url->urls[0]->expanded_url ? $user->entities->url->urls[0]->expanded_url : $user->url;
$userinfo['description'] = formatText($user->description);
$userinfo['location'] = $user->location;
$userinfo['date_joined'] = date('Y-m-d', format_time($user->created_at)); //from dabr
$userinfo['protected'] = $user->url;
$userinfo['id'] = $user->id;
$userinfo['image_url'] = getAvatar($user->profile_image_url);
?>
<div id="info_head" class="round">
<a href="https://twitter.com/<?php echo $userid ?>"><img id="info_headimg" src="<?php echo $userinfo['image_url'] ?>" /></a>
<div id="info_name" style="display:inline-block"><?php echo $userid ?></div>
<?php if ($isFollower) {?>
<span id="following_me" style="display:inline!important">
<span class="fa fa-check is-following"></span>
<span>Following me</span>
</span>
<?php
}
?>
<div id="info_relation">
<?php if ($isFriend) {?>
<a id="info_block_btn" class="btn btn-red" href="#">Unfollow</a>
<?php } else { ?>
<a id="info_follow_btn" class="btn btn-green" href="#">Follow</a>
<?php } ?>
<?php if ($isFollower) {?>
<a class="btn" id="info_send_btn" href="message.php?id=<?php echo $userid ?>">DM</a>
<?php } ?>
<?php if($isBlocked){ ?>
<a class='btn' id='unblock_btn' href='#'>Unblock</a>
<?php }else{ ?>
<a class='btn' id='block_btn' href='#'>Block</a>
<?php } ?>
<?php if($isMuted){ ?>
<a class='btn' id='unmute_btn' href='#'>Unmute</a>
<?php }else{ ?>
<a class='btn' id='mute_btn' href='#'>Mute</a>
<?php } ?>
<a class="btn" id="info_reply_btn" href="#">Reply</a>
<a class="btn" id="info_hide_btn" href="#">Hide @</a>
<a class="btn" id="report_btn" href="#" style="color:#a22">Report Spam</a>
</div>
</div>
<div class="clear"></div>
<?php
$empty = count($statuses) == 0? true: false;
if ($empty) {
echo "<div id=\"empty\">No tweet to display.</div>";
} else if ($apiout) {
echo "<div id=\"empty\">API quota is used out, please wait for a moment before next refresh.</div>";
} else {
$output = '<ol class="timeline" id="allTimeline">';
$firstid = false;
$lastid = false;
foreach ($statuses as $status) {
if (isset($status->retweeted_status)) {
$output .= format_retweet($status);
} else {
$output .= format_timeline($status,$t->username);
}
if(!$firstid)
$firstid = $status->id_str;
$lastid = $status->id_str;
}
$lastid = bcsub($lastid, "1");
$output .= "</ol><div id=\"pagination\">";
if ($_GET['fav'] == true) {
$output .= "<a id=\"less\" class=\"btn btn-white\" style=\"float: left;\" href=\"user.php?id=$userid&fav=true&since_id={$firstid}\">Back</a>";
$output .= "<a id=\"more\" class=\"btn btn-white\" style=\"float: right;\" href=\"user.php?id=$userid&fav=true&max_id={$lastid}\">Next</a>";
} else {
$output .= "<a id=\"less\" class=\"btn btn-white\" style=\"float: left;\" href=\"user.php?id=$userid&since_id={$firstid}\">Back</a>";
$output .= "<a id=\"more\" class=\"btn btn-white\" style=\"float: right;\" href=\"user.php?id=$userid&max_id={$lastid}\">Next</a>";
}
$output .= "</div>";
echo $output;
}
}//end of if(!$isProtected)
else {
?>
<div id="info_head" class="round">
<div id="info_name"><?php echo $userid ?></div>
<div id="info_relation">
<?php if ($isFriend) {?>
<a id="info_block_btn" class="btn" href="#">Unfollow</a>
<?php } else { ?>
<a id="info_follow_btn" class="btn" href="#">Follow</a>
<?php } ?>
<?php if ($isFollower) {?>
<a class="btn" id="info_send_btn" href="message.php?id=<?php echo $userid ?>">Send DM</a>
<?php } ?>
<?php if($isBlocked){ ?>
<a class='btn' id='unblock_btn' href='#'>Unblock</a>
<?php }else{ ?>
<a class='btn' id='block_btn' href='#'>Block</a>
<?php } ?>
<?php if($isMuted){ ?>
<a class='btn' id='unmute_btn' href='#'>Unmute</a>
<?php }else{ ?>
<a class='btn' id='mute_btn' href='#'>Mute</a>
<?php } ?>
<a class="btn" id="info_reply_btn" href="#">Reply</a>
<a class="btn" id="info_hide_btn" href="#">Hide @</a>
</div>
</div>
<div class="clear"></div>
<div id="empty">This user has been protected. You ought to follow before viewing this page.</div>
<?php
}
?>
</div>
<?php if (!$isProtected) {?>
<td class="column round-right" id="side_base">
<table>
<tr>
<td>
<div id="side" class="round-right">
<ul id="user_info">
<li><span>Name</span> <?php echo $userinfo['name']?></li>
<?php if ($userinfo['location']) echo '<li><span>Location</span> ' . $userinfo['location'] . '</li>'; ?>
<?php if (($userinfo['url']) and (strlen($userinfo['url'])>20)) echo '<li><span>Web</span> <a href="' .$userinfo['url']. '" target="_blank">' .substr($userinfo['url'], 0, 20). '...</a></li>'; else if (($userinfo['url']) and (strlen($userinfo['url'])<=20)) echo '<li><span>Web</span> <a href="' .$userinfo['url']. '" target="_blank">' .$userinfo['url']. '</a></li>';?>
<?php if ($userinfo['description']) echo "<li><span>Bio</span> " . $userinfo['description'] . "</li>"; ?>
<?php echo "<li><span>Joined at</span> " . $userinfo['date_joined'] . "</li>"; ?>
</ul>
<ul id="user_stats" style="margin:0 0 10px;">
<li>
<a href="friends.php?id=<?php echo $userid ?>">
<span class="count"><?php echo $userinfo['friends_count'] ?></span>
<span class="label">Following</span>
</a>
</li>
<li>
<a href="followers.php?id=<?php echo $userid ?>">
<span class="count"><?php echo $userinfo['followers_count'] ?></span>
<span class="label">Followers</span>
</a>
</li>
<li>
<a href="user.php?id=<?php echo $userid ?>">
<span class="count"><?php echo $userinfo['statuses_count'] ?></span>
<span class="label">Tweets</span>
</a>
</li>
</ul>
<div class="clear"></div>
<ul id="primary_nav" class="sidebar-menu">
<li id="tweets_tab"><a class="in-page-link" href="user.php?id=<?php echo $userid ?>"><span>Tweets</span></a></li>
<li id="@_tab"><a class="in-page-link" href="search.php?q=@<?php echo $userid ?>"><span>@<?php echo $userid ?></span></a></li>
<li id="favs_tab"><a class="in-page-link" href="user.php?id=<?php echo $userid ?>&fav=true"><span>Favorites</span></a></li>
<li id="lists_tab"><a class="in-page-link" href="lists.php?id=<?php echo $userid ?>"><span>Lists</span></a></li>
</ul>
<div class="clear"></div>
<?php include ('inc/sidepost.php') ?>
</div>
</td>
</tr>
</table>
<?php } else {
include ('inc/sidebar.php');
}
include ('inc/footer.php');
?>