OSDN Git Service

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