forked from CryptoPartyATX/site
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtweets.php
More file actions
executable file
·100 lines (72 loc) · 2.62 KB
/
tweets.php
File metadata and controls
executable file
·100 lines (72 loc) · 2.62 KB
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
<?php
/*
TODO List
link @'s and #'s
*/
// Why are we reading from a file?
// Because we don't want our visitors to have to connect to Twitter directly!
$filename = "recent.txt";
$initTweets = @file($filename);
// add follow div
echo "<div class=\"follow\"><a target=\"_blank\" href=\"https://twitter.com/atxcrypto\">@ATXCrypto</a> Recent Tweets <span id=\"twitterShrink\">_</span></div>\n";
if($initTweets !== FALSE){
$outTweets = array();
$numTweets = 16; // how many tweets to load, max about 16
if(count($initTweets)<$numTweets)$numTweets=count($initTweets);
// from last 5 of input array, trim metadata and send to output array
for($i=count($initTweets)-1; $i>=count($initTweets)-$numTweets; $i--){
// init temp var
$curTweet = $initTweets[$i];
// clean up the data
$curTweet = htmlspecialchars(trim(substr($curTweet,strpos($curTweet,">")+1)));
// add to output array
if(strlen($curTweet)>0){array_push($outTweets,$curTweet);}
}
// box in for scroll
echo "<div class=\"tweetbox\">\n";
// format and print tweets
foreach ($outTweets as $tweet) {
echo "<div class=\"tweetitem\">";
// retweet icon
$RTicon = "<img class=\"rticon\" src=\"images/rticon.png\" />";
$isRT = substr($tweet,0,2)=="RT";
if($isRT){
//$tweet = substr($tweet,3);
echo $RTicon;
}
echo "<span class=\"atxcrypto\"><a target=\"_blank\" href=\"https://twitter.com/atxcrypto\">@ATXCrypto</a>:</span> "; // account name
$linklist = "<br>";
// extract links
while(strpos($tweet,"http:")!==FALSE||strpos($tweet,"https:")!==FALSE){
$firstHTTP = strpos($tweet,"http");
$extracted = "";
$url="";
$isHTTPS = false;
if(strpos($tweet,"http:")===$firstHTTP || strpos($tweet,"https:")===$firstHTTP && $firstHTTP !== FALSE){
$isHTTPS = strpos($tweet,"https:")===$firstHTTP;
$url = substr($tweet,$firstHTTP,strpos("$tweet "," ",$firstHTTP));
$tweet = substr($tweet,0,$firstHTTP) . substr($tweet,strpos($tweet." "," ",$firstHTTP));
if($isHTTPS){
$linklist .= "<a target=\"_blank\" class=\"tweetHTTPS\" href=\"$url\">[ HTTPS Link ]</a> \n";
}
else {
$linklist .= "<a target=\"_blank\" class=\"tweetHTTP\" href=\"$url\">[ HTTP Link ]</a> \n";
}
}
}
$tweet = str_replace("\\n","<br>",$tweet);
if(trim($tweet) === ""){ $tweet = " [Link only] "; }
echo "<span class=\"tweet\">$tweet</span>\n"; // actual text (minus links)
// include links after tweet
echo $linklist;
echo "</div>\n";
}
echo "</div>\n";
}
else{
// box in for scroll
echo "<div class=\"tweetbox\">\n";
echo "<div class=\"tweetitem\">An error occured. Tweets were not loaded.</div>\n";
echo "</div>\n";
}
?>