forked from tylerhall/Shine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtweets.php
122 lines (109 loc) · 5.2 KB
/
tweets.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?PHP
require 'includes/master.inc.php';
$Auth->requireAdmin('login.php');
$nav = 'tweets';
$applications = DBObject::glob('Application', 'SELECT * FROM shine_applications ORDER BY name');
if(isset($_GET['refresh']))
include 'tweet-cron.php';
if(isset($_GET['delete']))
{
$t = new Tweet($_GET['delete']);
$t->deleted = 1;
$t->new = 0;
$t->update();
}
if(isset($_GET['reply']))
{
$t = new Tweet($_GET['reply']);
$t->replied_to = 1;
$t->reply_date = dater();
$t->new = 0;
$t->update();
redirect("http://twitter.com/home?status=@{$t->username}%20&in_reply_to={$t->tweet_id}");
}
$sql = ''; $app_id = '';
if(isset($_GET['id']))
{
$sql = 'AND app_id = ' . intval($_GET['id']);
$app_id = intval($_GET['id']);
}
if(isset($_GET['read']))
{
$db = Database::getDatabase();
$db->query("UPDATE shine_tweets SET new = 0 WHERE 1 = 1 $sql");
redirect("tweets.php?id=$app_id");
}
$tweets = DBObject::glob('Tweet', "SELECT * FROM shine_tweets WHERE deleted = 0 $sql ORDER BY dt DESC LIMIT 100");
function twitterfy($str)
{
// Via http://www.snipe.net/2009/09/php-twitter-clickable-links/
$str = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $str);
$str = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $str);
$str = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $str);
$str = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $str);
return $str;
}
?>
<?PHP include('inc/header.inc.php'); ?>
<div id="bd">
<div id="yui-main">
<div class="yui-b"><div class="yui-g">
<div class="block tabs spaces">
<div class="hd">
<h2>Orders</h2>
<ul>
<li class="<?PHP if(!isset($_GET['id'])) echo 'active'; ?>"><a href="tweets.php">All Apps</a></li>
<?PHP foreach($applications as $a) : ?>
<li class="<?PHP if(@$_GET['id'] == $a->id) echo 'active'; ?>"><a href="tweets.php?id=<?PHP echo $a->id; ?>"><?PHP echo $a->name; ?></a></li>
<?PHP endforeach; ?>
</ul>
<div class="clear"></div>
</div>
<div class="bd">
<table>
<tbody>
<?PHP foreach($tweets as $t) : ?>
<?PHP if($t->new) : ?>
<tr class="highlight">
<?PHP else : ?>
<tr>
<?PHP endif; ?>
<td><img src="<?PHP echo $t->profile_img; ?>" style="width:48px;height:48px;"></td>
<td>
<strong><a href="http://twitter.com/<?PHP echo $t->username; ?>"><?PHP echo $t->username; ?></a></strong>
<br>
<a style="font-size:80%;" href="http://twitter.com/<?PHP echo $t->username; ?>/status/<?PHP echo $t->tweet_id; ?>"><?PHP echo time2str($t->dt); ?></a>
</td>
<td>
<?PHP echo twitterfy($t->body); ?><br>
<span style="font-size:80%;">
<?PHP if($t->replied_to) : ?>
Replied to <?PHP echo time2str($t->reply_date); ?>
<?PHP else : ?>
<a href="tweets.php?id=<?PHP echo $app_id; ?>&reply=<?PHP echo $t->id; ?>">Reply</a>
<?PHP endif; ?>
</span>
</td>
<td><a href="tweets.php?id=<?PHP echo $app_id; ?>&delete=<?PHP echo $t->id; ?>">Delete</a></td>
</tr>
<?PHP endforeach; ?>
</tbody>
</table>
</div>
</div>
</div></div>
</div>
<div id="sidebar" class="yui-b">
<div class="block">
<div class="hd">
<h3>Summary</h3>
</div>
<div class="bd">
<p><?PHP echo count($tweets); ?> tweets</p>
<p><a href="tweets.php?id=<?PHP echo $app_id; ?>&read=1">Mark all as read</a></p>
<p><a href="tweets.php?id=<?PHP echo $app_id; ?>&refresh=1">Refresh All</a></p>
</div>
</div>
</div>
</div>
<?PHP include('inc/footer.inc.php'); ?>