OSDN Git Service

embrj
[embrj/master.git] / replies.php
1 <?php
2         include ('lib/twitese.php');
3         $title = "Replies";
4         include ('inc/header.php');
5         if (!loginStatus()) header('location: login.php');
6 ?>
7
8 <script src="js/btns.js"></script>
9
10 <div id="statuses" class="column round-left">
11 <?php 
12         include('inc/sentForm.php');
13         include('lib/timeline_format.php');
14                 $t = getTwitter();
15                 $since_id = isset($_GET['since_id']) ? $_GET['since_id'] : false;
16                 $max_id = isset($_GET['max_id']) ? $_GET['max_id'] : false;
17         
18                 $statuses = $t->replies($since_id, $max_id);
19                 if ($statuses === false) {
20                         header('location: error.php');exit();
21                 } 
22
23                 $count_t = count($statuses);
24                 if ($count_t > 1) {
25                         $empty = 0; // 0 for not empty
26                 } else if ($count_t < 1) {
27                         $empty = 1; // 1 for no tweets to display
28                 } else {
29                         $empty = $t->http_code == 429 ? 2 : 0; // 2 for API outage
30                 }
31                 if ($empty == 1) {
32                         echo "<div id=\"empty\">No tweet to display.</div>";
33                 } else if ($empty == 2) {
34                         echo "<div id=\"empty\">API quota is used out, please wait for a moment before next refresh.</div>";
35                 } else {
36                         $output = '<ol class="timeline" id="allTimeline">';
37                         
38                         $firstid = false;
39                         $lastid = false;
40                         foreach ($statuses as $status) {
41                                 if (!$firstid) $firstid = $status->id_str;
42                                 $lastid = $status->id_str;
43                                 $output .= format_timeline($status,$t->username);
44                         }
45                         $lastid = bcsub($lastid, "1");
46                         
47                         $output .= "</ol><div id=\"pagination\">";
48                         
49                         $output .= "<a id=\"less\" class=\"round more\" style=\"float: left;\" href=\"replies.php?since_id=" . $firstid . "\">Back</a>";
50                         $output .= "<a id=\"more\" class=\"round more\" style=\"float: right;\" href=\"replies.php?max_id=" . $lastid . "\">Next</a>";
51                         
52                         $output .= "</div>";
53                         
54                         echo $output;
55                 }
56         ?>
57 </div>
58
59 <?php 
60         include ('inc/sidebar.php');
61         include ('inc/footer.php');
62 ?>