OSDN Git Service

embr
[embrj/master.git] / user.php
index 002d64d..3e9b6cb 100644 (file)
--- a/user.php
+++ b/user.php
-<?php \r
-       include ('lib/twitese.php');\r
-       $title = "{$_GET['id']}";\r
-       include ('inc/header.php');\r
-\r
-?>\r
-\r
-<script type="text/javascript" src="js/user.js?ver=2010031301"></script>\r
-\r
-<div id="statuses" class="column round-left">\r
-<?php \r
-       if (!loginStatus() || !isset($_GET['id'])) {\r
-               header('location: error.php');\r
-       }\r
-\r
-       $p = 1;\r
-       if (isset($_GET['p'])) {\r
-               $p = (int) $_GET['p'];\r
-               if ($p <= 0) $p = 1;\r
-       }\r
-\r
-       $t = getTwitter();\r
-       $userid = $_GET['id'];\r
-       $statuses = $t->userTimeline($p, $userid);\r
-\r
-       if ($statuses === false) {\r
-               header('location: error.php');\r
-       }\r
-       $isProtected = $statuses == 'protected';\r
-       $isFriend = $t->isFriend($t->username, $userid);\r
-       $isFollower = $t->isFriend($userid, $t->username);\r
-       $block_error = $t->isBlocked($userid)->error;\r
-       $isBlocked = !$block_error;\r
-\r
-       if (!$isProtected) {\r
-               $userinfo = array();\r
-               $userinfo['name'] = $statuses[0]->user->name;\r
-               $userinfo['screen_name'] = $statuses[0]->user->screen_name;\r
-               $userinfo['friends_count'] = $statuses[0]->user->friends_count;\r
-               $userinfo['statuses_count'] = $statuses[0]->user->statuses_count;\r
-               $userinfo['followers_count'] = $statuses[0]->user->followers_count;\r
-               $userinfo['url'] = $statuses[0]->user->url;\r
-               $userinfo['description'] = $statuses[0]->user->description;\r
-               $userinfo['location'] = $statuses[0]->user->location;\r
-               $userinfo['protected'] = $statuses[0]->user->url;\r
-               $userinfo['id'] = $statuses[0]->user->id;\r
-               $userinfo['image_url'] = getAvatar($statuses[0]->user->profile_image_url);\r
-\r
-\r
-?>\r
-       <div id="info_head" class="round">\r
-               <a href="https://twitter.com/<?php echo $userid ?>"><img id="info_headimg" src="<?php echo $userinfo['image_url'] ?>" /></a>\r
-               <div id="info_name"><?php echo $userid ?></div>\r
-               <?php if ($t->isFriend($userid, $t->username)) {?>\r
-               <span style="position: absolute; margin-left: 8px; font-size: 11px; margin-top: 10px;"><img style="margin: 0pt 5px 3px 0pt; vertical-align: middle;" src="img/yes.gif" alt="" class="icon"/><span>Following me</span></span>\r
-<?php \r
-               }\r
-               if($userid != $t->username){\r
-?>\r
-               <div id="info_relation">\r
-               <?php if ($isFriend) {?>\r
-                       <a id="info_block_btn" class="btn btn-red" href="a_relation.php?action=destory&id=<?php echo $userid ?>">Unfollow</a>\r
-               <?php } else { ?>\r
-                       <a id="info_follow_btn" class="btn btn-green" href="a_relation.php?action=create&id=<?php echo $userid ?>">Follow</a>\r
-               <?php } ?>\r
-               <?php if ($isFollowerr) {?>\r
-                       <a class="btn" id="info_send_btn" href="message.php?id=<?php echo $userid ?>">Send DM</a>\r
-               <?php } ?>\r
-<?php if($isBlocked){ ?>\r
-               <a class='btn' id='unblock_btn' href='javascript:void(0)'>Unblock</a>\r
-<?php }else{ ?>\r
-               <a class='btn' id='block_btn' href='javascript:void(0)'>Block</a>\r
-<?php } ?>\r
-                       <a class="btn" id="info_reply_btn" href="javascript:void(0)">Reply</a>\r
-                       <a class="btn" id="info_hide_btn" href="javascript:void(0)">Hide @</a>\r
-                       <a class="btn btn-mint" id="nexus_btn" href="nexus.php?target=<?php echo $userid ?>&source=<?php echo getEncryptCookie('twitese_name')?>">Nexus</a>\r
-               </div>\r
-<?php } ?>\r
-       </div>\r
-       <div class="clear"></div>\r
-<?php \r
-\r
-               $empty = count($statuses) == 0? true: false;\r
-               if ($empty) {\r
-                       echo "<div id=\"empty\">No tweet to display.</div>";\r
-               } else {\r
-                       $output = '<ol class="timeline" id="allTimeline">';\r
-\r
-                       foreach ($statuses as $status) {\r
-                               $user = $status->user;\r
-                               $date = formatDate($status->created_at);\r
-                               $text = formatText($status->text);\r
-\r
-                               $output .= "\r
-                                       <li>\r
-                                       <span class=\"info_status_body\">\r
-                                       <span class=\"status_id\">$status->id</span>\r
-                                       <span class=\"status_word\"><span class=\"tweet\"> $text </span></span>";\r
-                               if ($shorturl = unshortUrl($text)) $output .= "<span class=\"unshorturl\"><p>URL</p><a href=\"$shorturl\" target=\"_blank\" rel=\"noreferrer\">$shorturl</a></span>";\r
-                               $output .= "<span class=\"actions\">\r
-                                       <a class=\"replie_btn\" href=\"a_reply.php?id=$status->id\">Reply</a>\r
-                                       <a class=\"rt_btn\" href=\"a_rt.php?id=$status->id\">Retweet</a>\r
-                                       <a class=\"retw_btn\" title=\"New Retweet\" href=\"javascript:void(0);\">New Retweet</a>\r
-                                       <a class=\"favor_btn\" href=\"a_favor.php?id=$status->id\">Favorite</a>\r
-                                       <a class=\"trans_btn\" title=\"Translate\" href=\"javascript:void(0);\">Translate</a>\r
-                                       </span><span class=\"status_info\">\r
-                                       ";\r
-                               if ($status->in_reply_to_status_id) $output .= "<span class=\"in_reply_to\"> <a class=\"ajax_reply\" href=\"ajax/status.php?id=$status->in_reply_to_status_id&uid=$user->id \">in reply to $status->in_reply_to_screen_name</a></span>";\r
-\r
-                               $output .= "    \r
-                                       <span class=\"source\">from $status->source</span><span class=\"date\"><a href=\"/status.php?id=$status->id\">$date</a></span></span>\r
-                                       </span>\r
-                                       </li>\r
-                                       ";\r
-                       }\r
-\r
-                       $output .= "</ol><div id=\"pagination\">";\r
-\r
-                       if ($p >1) $output .= "<a id=\"more\" class=\"round more\" style=\"float: left;\" href=\"user.php?id=$userid&p=" . ($p-1) . "\">Back</a>";\r
-                       if (!$empty) $output .= "<a id=\"more\" class=\"round more\" style=\"float: right;\" href=\"user.php?id=$userid&p=" . ($p+1) . "\">Next</a>";\r
-\r
-\r
-                       $output .= "</div>";\r
-\r
-                       echo $output;\r
-               }\r
-       }//end of if(!$isProtected)\r
-       else {\r
-?>\r
-               <div id="info_head" class="round">\r
-                       <div id="info_name"><?php echo $userid ?></div>\r
-                       <div id="info_relation">\r
-                       <?php if ($isFriend) {?>\r
-                               <a id="info_block_btn" class="btn_hover" href="a_relation.php?action=destory&id=<?php echo $userid ?>">Unfollow</a>\r
-                       <?php } else { ?>\r
-                               <a id="info_follow_btn" class="btn" href="a_relation.php?action=create&id=<?php echo $userid ?>">Follow</a>\r
-                       <?php } ?>\r
-                       <?php if ($isFollower) {?>\r
-                               <a class="btn" id="info_send_btn" href="message.php?id=<?php echo $userid ?>">Send DM</a>\r
-                       <?php } ?>\r
-<?php if($isBlocked){ ?>\r
-               <a class='btn_hover' id='unblock_btn' href='javascript:void(0)'>Unblock</a>\r
-<?php }else{ ?>\r
-               <a class='btn' id='block_btn' href='javascript:void(0)'>Block</a>\r
-<?php } ?>\r
-                               <a class="btn" id="info_reply_btn" href="javascript:void(0)">Reply</a>\r
-                               <a class="btn" id="info_hide_btn" href="javascript:void(0)">Hide @</a>\r
-                       </div>\r
-               </div>\r
-               <div class="clear"></div>\r
-               <div id="empty">This user has been protected. You ought to follow before viewing this page.</div>\r
-<?php \r
-       }\r
-?>\r
-</div>\r
-\r
-<?php if (!$isProtected) {?>\r
-<td class="column round-right" id="side_base">\r
-<table>\r
-<tr>\r
-<td>\r
-<div id="side" class="round-right">\r
-       <ul id="user_info">\r
-               <li><span>Name</span> <?php echo $userinfo['name']?></li>\r
-               <?php if ($userinfo['location']) echo '<li><span>Location</span> ' . $userinfo['location'] . '</li>'; ?>\r
-               <?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>';?>\r
-               <?php  if ($userinfo['description']) echo "<li><span>Bio</span> " . $userinfo['description'] . "</li>"; ?>\r
-       </ul>\r
-       <ul id="user_stats" style="margin:0 0 10px;">\r
-               <li>\r
-                       <a href="friends.php?id=<?php echo $userid ?>">\r
-                               <span class="count"><?php echo $userinfo['friends_count'] ?></span>\r
-                               <span class="label">Following</span>\r
-                       </a>\r
-               </li>\r
-               <li>\r
-                       <a href="followers.php?id=<?php echo $userid ?>">\r
-                               <span class="count"><?php echo $userinfo['followers_count'] ?></span>\r
-                               <span class="label">Followers</span>\r
-                       </a>\r
-               </li>\r
-               <li>\r
-                       <a href="user.php?id=<?php echo $userid ?>">\r
-                               <span class="count"><?php echo $userinfo['statuses_count'] ?></span>\r
-                               <span class="label">Tweets</span>\r
-                       </a>\r
-               </li>\r
-       </ul>\r
-       <div class="clear"></div>\r
-       <ul id="primary_nav" class="sidebar-menu">\r
-       <li id="tweets_tab"><a class="in-page-link" href="user.php?id=<?php echo $userid ?>"><span>Tweets</span></a></li>\r
-       <li id="lists_tab"><a class="in-page-link" href="lists.php?id=<?php echo $userid ?>"><span>Lists</span></a></li>\r
-       </ul>\r
-       <div class="clear"></div>\r
-       <?php include ('inc/sidepost.php') ?>\r
-</div>\r
-</td>\r
-</tr>\r
-</table>\r
-<?php } else { \r
-               include ('inc/sidebar.php');\r
-}\r
-?>\r
-\r
-<?php \r
-       include ('inc/footer.php');\r
-?>\r
+<?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');exit();
+       }
+
+       $p = 1;
+       if (isset($_GET['p'])) {
+               $p = (int) $_GET['p'];
+               if ($p <= 0) $p = 1;
+       }
+
+       $t = getTwitter();
+       $userid = $_GET['id'];
+       if (isset($_GET['fav'])) {
+               $statuses = $t->getFavorites($p, $userid);
+       } else {
+               $statuses = $t->userTimeline($p, $userid);
+       }
+       
+       if ($statuses === false) {
+               header('location: error.php');exit;
+       }
+       $user = $t->showUser($userid);
+       if (strcasecmp($userid,$t->username) == 0) {header('location: profile.php');exit();}
+
+       $isProtected = ($statuses == 'protected') || ($statuses->error == 'Not authorized');
+       $r = getRelationship($user->screen_name);
+       $isFriend = $r == 2 || $r == 1;
+       $isFollower = $r == 3 || $r == 1;
+       $isBlocked = $r == 4;
+
+       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->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"><img style="" src="img/yes.gif" alt="" class="icon"/><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 } ?>
+                       <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 {
+                       $output = '<ol class="timeline" id="allTimeline">';
+                       foreach ($statuses as $status) {
+                               if (isset($status->retweeted_status)) {
+                                       $output .= format_retweet($status);
+                               } else { 
+                               $output .= format_timeline($status,$t->username);
+                               }
+                       }
+                       $output .= "</ol><div id=\"pagination\">";
+                       if ($_GET['fav'] == true) {
+                               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>";
+                               if (!$empty) $output .= "<a id=\"more\" class=\"round more\" style=\"float: right;\" href=\"user.php?id=$userid&fav=true&p=" . ($p+1) . "\">Next</a>";
+                       } else {
+                               if ($p >1) $output .= "<a id=\"more\" class=\"round more\" style=\"float: left;\" href=\"user.php?id=$userid&p=" . ($p-1) . "\">Back</a>";
+                               if (!$empty) $output .= "<a id=\"more\" class=\"round more\" style=\"float: right;\" href=\"user.php?id=$userid&p=" . ($p+1) . "\">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_hover" 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_hover' id='unblock_btn' href='#'>Unblock</a>
+<?php }else{ ?>
+               <a class='btn' id='block_btn' href='#'>Block</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');
+?>