OSDN Git Service

3e9b6cb72d0e9a4056e78730c16b5ca8f4e6cd2d
[embrj/master.git] / user.php
1 <?php 
2         include ('lib/twitese.php');
3         $title = "{$_GET['id']}";
4         include ('inc/header.php');
5         include ('lib/timeline_format.php');
6
7 ?>
8
9 <script src="js/user.js"></script>
10
11 <div id="statuses" class="column round-left">
12 <?php 
13         if (!loginStatus() || !isset($_GET['id'])) {
14                 header('location: error.php');exit();
15         }
16
17         $p = 1;
18         if (isset($_GET['p'])) {
19                 $p = (int) $_GET['p'];
20                 if ($p <= 0) $p = 1;
21         }
22
23         $t = getTwitter();
24         $userid = $_GET['id'];
25         if (isset($_GET['fav'])) {
26                 $statuses = $t->getFavorites($p, $userid);
27         } else {
28                 $statuses = $t->userTimeline($p, $userid);
29         }
30         
31         if ($statuses === false) {
32                 header('location: error.php');exit;
33         }
34         $user = $t->showUser($userid);
35         if (strcasecmp($userid,$t->username) == 0) {header('location: profile.php');exit();}
36
37         $isProtected = ($statuses == 'protected') || ($statuses->error == 'Not authorized');
38         $r = getRelationship($user->screen_name);
39         $isFriend = $r == 2 || $r == 1;
40         $isFollower = $r == 3 || $r == 1;
41         $isBlocked = $r == 4;
42
43         if (!$isProtected) {
44
45                 $userinfo = array();
46                 $userinfo['name'] = $user->name;
47                 $userinfo['screen_name'] = $user->screen_name;
48                 $userinfo['friends_count'] = $user->friends_count;
49                 $userinfo['statuses_count'] = $user->statuses_count;
50                 $userinfo['followers_count'] = $user->followers_count;
51                 $userinfo['url'] = $user->url;
52                 $userinfo['description'] = formatText($user->description);
53                 $userinfo['location'] = $user->location;
54                 $userinfo['date_joined'] = date('Y-m-d', format_time($user->created_at)); //from dabr
55                 $userinfo['protected'] = $user->url;
56                 $userinfo['id'] = $user->id;
57                 $userinfo['image_url'] = getAvatar($user->profile_image_url);
58
59 ?>
60         <div id="info_head" class="round">
61                 <a href="https://twitter.com/<?php echo $userid ?>"><img id="info_headimg" src="<?php echo $userinfo['image_url'] ?>" /></a>
62                 <div id="info_name" style="display:inline-block"><?php echo $userid ?></div>
63                 <?php if ($isFollower) {?>
64                 <span id="following_me" style="display:inline!important"><img style="" src="img/yes.gif" alt="" class="icon"/><span>Following me</span></span>
65 <?php 
66                 }
67 ?>
68                 <div id="info_relation">
69                 <?php if ($isFriend) {?>
70                         <a id="info_block_btn" class="btn btn-red" href="#">Unfollow</a>
71                 <?php } else { ?>
72                         <a id="info_follow_btn" class="btn btn-green" href="#">Follow</a>
73                 <?php } ?>
74                 <?php if ($isFollower) {?>
75                         <a class="btn" id="info_send_btn" href="message.php?id=<?php echo $userid ?>">DM</a>
76                 <?php } ?>
77 <?php if($isBlocked){ ?>
78                 <a class='btn' id='unblock_btn' href='#'>Unblock</a>
79 <?php }else{ ?>
80                 <a class='btn' id='block_btn' href='#'>Block</a>
81 <?php } ?>
82                         <a class="btn" id="info_reply_btn" href="#">Reply</a>
83                         <a class="btn" id="info_hide_btn" href="#">Hide @</a>
84                         <a class="btn " id="report_btn" href="#" style="color:#a22">Report Spam</a>
85                 </div>
86         </div>
87         <div class="clear"></div>
88 <?php 
89                 $empty = count($statuses) == 0? true: false;
90                 if ($empty) {
91                         echo "<div id=\"empty\">No tweet to display.</div>";
92                 } else {
93                         $output = '<ol class="timeline" id="allTimeline">';
94                         foreach ($statuses as $status) {
95                                 if (isset($status->retweeted_status)) {
96                                         $output .= format_retweet($status);
97                                 } else { 
98                                 $output .= format_timeline($status,$t->username);
99                                 }
100                         }
101                         $output .= "</ol><div id=\"pagination\">";
102                         if ($_GET['fav'] == true) {
103                                 if ($p >1) $output .= "<a id=\"more\" class=\"round more\" style=\"float: left;\" href=\"user.php?id=$userid&fav=true&p=" . ($p-1) . "\">Back</a>";
104                                 if (!$empty) $output .= "<a id=\"more\" class=\"round more\" style=\"float: right;\" href=\"user.php?id=$userid&fav=true&p=" . ($p+1) . "\">Next</a>";
105                         } else {
106                                 if ($p >1) $output .= "<a id=\"more\" class=\"round more\" style=\"float: left;\" href=\"user.php?id=$userid&p=" . ($p-1) . "\">Back</a>";
107                                 if (!$empty) $output .= "<a id=\"more\" class=\"round more\" style=\"float: right;\" href=\"user.php?id=$userid&p=" . ($p+1) . "\">Next</a>";
108                         }
109                         $output .= "</div>";
110                         echo $output;
111                 }
112         }//end of if(!$isProtected)
113         else {
114 ?>
115                 <div id="info_head" class="round">
116                         <div id="info_name"><?php echo $userid ?></div>
117                         <div id="info_relation">
118                         <?php if ($isFriend) {?>
119                                 <a id="info_block_btn" class="btn_hover" href="#">Unfollow</a>
120                         <?php } else { ?>
121                                 <a id="info_follow_btn" class="btn" href="#">Follow</a>
122                         <?php } ?>
123                         <?php if ($isFollower) {?>
124                                 <a class="btn" id="info_send_btn" href="message.php?id=<?php echo $userid ?>">Send DM</a>
125                         <?php } ?>
126 <?php if($isBlocked){ ?>
127                 <a class='btn_hover' id='unblock_btn' href='#'>Unblock</a>
128 <?php }else{ ?>
129                 <a class='btn' id='block_btn' href='#'>Block</a>
130 <?php } ?>
131                                 <a class="btn" id="info_reply_btn" href="#">Reply</a>
132                                 <a class="btn" id="info_hide_btn" href="#">Hide @</a>
133                         </div>
134                 </div>
135                 <div class="clear"></div>
136                 <div id="empty">This user has been protected. You ought to follow before viewing this page.</div>
137 <?php 
138         }
139 ?>
140 </div>
141
142 <?php if (!$isProtected) {?>
143 <td class="column round-right" id="side_base">
144 <table>
145 <tr>
146 <td>
147 <div id="side" class="round-right">
148         <ul id="user_info">
149                 <li><span>Name</span> <?php echo $userinfo['name']?></li>
150                 <?php if ($userinfo['location']) echo '<li><span>Location</span> ' . $userinfo['location'] . '</li>'; ?>
151                 <?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>';?>
152                 <?php  if ($userinfo['description']) echo "<li><span>Bio</span> " . $userinfo['description'] . "</li>"; ?>
153                 <?php  echo "<li><span>Joined at</span> " . $userinfo['date_joined'] . "</li>"; ?>
154         </ul>
155         <ul id="user_stats" style="margin:0 0 10px;">
156                 <li>
157                         <a href="friends.php?id=<?php echo $userid ?>">
158                                 <span class="count"><?php echo $userinfo['friends_count'] ?></span>
159                                 <span class="label">Following</span>
160                         </a>
161                 </li>
162                 <li>
163                         <a href="followers.php?id=<?php echo $userid ?>">
164                                 <span class="count"><?php echo $userinfo['followers_count'] ?></span>
165                                 <span class="label">Followers</span>
166                         </a>
167                 </li>
168                 <li>
169                         <a href="user.php?id=<?php echo $userid ?>">
170                                 <span class="count"><?php echo $userinfo['statuses_count'] ?></span>
171                                 <span class="label">Tweets</span>
172                         </a>
173                 </li>
174         </ul>
175         <div class="clear"></div>
176         <ul id="primary_nav" class="sidebar-menu">
177         <li id="tweets_tab"><a class="in-page-link" href="user.php?id=<?php echo $userid ?>"><span>Tweets</span></a></li>
178         <li id="@_tab"><a class="in-page-link" href="search.php?q=@<?php echo $userid ?>"><span>@<?php echo $userid ?></span></a></li>
179         <li id="favs_tab"><a class="in-page-link" href="user.php?id=<?php echo $userid ?>&fav=true"><span>Favorites</span></a></li>
180         <li id="lists_tab"><a class="in-page-link" href="lists.php?id=<?php echo $userid ?>"><span>Lists</span></a></li>
181         </ul>
182         <div class="clear"></div>
183         <?php include ('inc/sidepost.php') ?>
184 </div>
185 </td>
186 </tr>
187 </table>
188 <?php } else { 
189                 include ('inc/sidebar.php');
190 }
191
192         include ('inc/footer.php');
193 ?>