-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
186 lines (151 loc) · 5.49 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
session_start();
require_once('clsTwitterDB.php');
require_once('twitteroauth/twitteroauth.php');
$is_logged = true;
if(@$_GET['logout'])
{
session_destroy();
$is_logged = false;
}
/* Verifying token */
if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
$is_logged = false;
}else{
/* Get session token. */
$access_token = $_SESSION['access_token'];
/* Creating OAuth object. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
/* User credentials by twitter API */
$content = $connection->get('account/verify_credentials');
/* Get followers. */
$flws = $connection->get('statuses/followers');
//return current user timeline
$timeline = $connection->get('statuses/home_timeline', array('screen_name' => $content->screen_name));
if($_POST)
{//If tweet has posted
$tw = new clsTwitterDB();
$tw->setText($_POST['tw_text']);
$tw->setAuthor($content->screen_name);
$tw->split();
$tw_text = $tw->tweet();
for($i = count($tw_text)-1 ; $i >= 0; $i--){
if($tw_text[$i] != '')
{
$connection->post('statuses/update', array('status'=>$tw_text[$i]));
}
}
//Redirect again, to display in time line the last tweet
header( 'Location: index.php' ) ;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>.:: Welcome to ltweet.com ::.</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<link rel="stylesheet" href="css/default.css" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
function count_char()
{
rs = false;
var text = new String($("#tw_text").val());
var len = 675 - text.length;
var total_tweets;
total_tweets = Math.ceil(text.length/140);
if(len >= 0)
{
$("#tw_count").html(len + ' [' + total_tweets + '/5]');
rs = true;
}
else
{
//Stop to add text
text = text.slice(0,675);
$("#tw_text").val(text);
}
return rs;
}
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-21972831-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<?php
if(!$is_logged){
//Showing login page
?>
<img id="logo-index" src="images/logo.png" />
<div id="welcome-text">
It is a fact, people do not click through to read your long posts
when you include shortened URL's in your tweets using sites like
bit.ly or tinyurl.<br /><br />
<span class="intro-text-2">
Want to write longer tweets, that people actually read? Use
ltweet.
</span><br />
<span class="intro-text-3">
Simply log in with your twitter account and start tweeting longer
messages using up to 5 tweets at once.
</span>
</div>
<div id="login-button" >
<a href="https://twitter.com/signup"><img src="images/sign-up.png" alt="Sign up on Twitter" border="0" /></a>
<a href="./redirect.php"><img src="./images/lighter.png" alt="Sign in with Twitter" border="0" /></a>
</div>
<div id="footer">
<ul>
<li><a href="how_works.php">How it works</a></li>
<li><a href="privacy.php">Privacy</a></li>
<li><a href="disclaimer.php">Disclaimer</a></li>
<li><a href="contact.php">Contacts</a></li>
</ul>
</div>
<?php
}else{
//Showing applications page
include_once('common_design.php');
$common_design = new commonDesign();
?>
<!-- Main Menu -->
<?php echo $common_design->topMenu() ?>
<div id="main-container">
<!-- Right Column -->
<?php echo $common_design->rightColumn($content, $flws, true) ?>
<div id="left">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div id="tw_tag">
What's Happening
</div>
<div id="tw_count">
675 [1/5]
</div>
<br />
<textarea name="tw_text" id="tw_text" cols="100" rows="7" maxlength="675" onkeyup="count_char();"></textarea><br />
<input type="submit" name="btn_sign" id="tweet-button" value="Tweet" />
</form>
<div id="time-line">
<span>Home timeline:</span>
<?php
foreach($timeline as $tw)
{
echo '<div><img src="'.$tw->user->profile_image_url.'" /> '.$tw->text.'</div>';
}
?>
</div>
</div>
<div style="clear:both;height:30px;"></div>
</div>
<?php } ?>
</body>
</html>