forked from bang590/twitese
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
97 lines (82 loc) · 2.23 KB
/
index.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
<?php
include ('lib/twitese.php');
if (!isLogin()) {
header('location: login.php');
exit();
}
$title = "首页";
include ('inc/header.php');
?>
<script type="text/javascript" src="js/home.js"></script>
<div id="statuses">
<?php
$t = getTwitter();
if ( isset($_POST['status']) && isset($_POST['in_reply_to']) ) {
if (!testReferer()) exit();
if (trim($_POST['status']) == '') {
setUpdateCookie('empty');
} else {
$result = $t->update($_POST['status'], $_POST['in_reply_to']);
if ($result) {
setUpdateCookie('success');
$user = $result->user;
$time = time()+3600*24*365;
if ($user) {
setcookie('friends_count', $user->friends_count, $time, '/');
setcookie('statuses_count', $user->statuses_count, $time, '/');
setcookie('followers_count', $user->followers_count, $time, '/');
setcookie('imgurl', $user->profile_image_url, $time, '/');
setcookie('name', $user->name, $time, '/');
}
}
else {
setUpdateCookie('error');
}
}
header('location: index.php');
}
if (getUpdateCookie()) {
switch (getUpdateCookie()) {
case 'success':
echo "<div id=\"sentTip\">发送消息成功</div>";
break;
case 'empty':
echo "<div id=\"sentTip\">发送失败,消息不能为空</div>";
break;
case 'error':
echo "<div id=\"sentTip\">发送消息失败,请重试</div>";
break;
default:
break;
}
}
?>
<?php include('inc/sentForm.php')?>
<?php
$p = 1;
if (isset($_GET['p'])) {
$p = (int) $_GET['p'];
if ($p <= 0) $p = 1;
}
$statuses = $t->homeTimeline($p);
testResult($statuses);
$empty = count($statuses) == 0? true: false;
if ($empty) {
tpEmpty();
} else {
tpTimeline($statuses);
$output = "<div id=\"pagination\">";
if ($p >1) $output .= "<a href=\"index.php?p=" . ($p-1) . "\">上一页</a>";
if (!$empty) $output .= "<a href=\"index.php?p=" . ($p+1) . "\">下一页</a>";
$output .= "</div>";
echo $output;
}
?>
</div>
<?php
$show_stop_refresh = true;
include ('inc/sidebar.php');
?>
<?php
include ('inc/footer.php');
?>