Blagovest Petrov
8 years ago
1 changed files with 0 additions and 66 deletions
@ -1,66 +0,0 @@ |
|||
<?php |
|||
|
|||
|
|||
function read_tweets(){ |
|||
|
|||
$fpServer = fsockopen("spitfire.initlab.org", 8124, $errno, $errstr, 30); |
|||
$fpLocal = @fopen("tweets.txt", "w"); |
|||
$tweet_contents = array(); |
|||
|
|||
if (!$fpServer) { |
|||
echo "$errstr ($errno)\n"; |
|||
} |
|||
else { |
|||
$out = "QUIT\r\n\r\n"; |
|||
fwrite($fpServer, $out); |
|||
$i=0; |
|||
while (!feof($fpServer)) { |
|||
// echo fgets($fpServer, 128); |
|||
$tweet_contents[$i] = fgets($fpServer, 128); |
|||
$i++; |
|||
} |
|||
fclose($fpServer); |
|||
} |
|||
|
|||
for($i=0; $i<2; $i++){ |
|||
array_pop($tweet_contents); |
|||
} |
|||
array_shift($tweet_contents); |
|||
|
|||
if($fpLocal) { |
|||
for ($i=0; $i<count($tweet_contents); $i++){ |
|||
fwrite($fpLocal, $tweet_contents[$i]); |
|||
} |
|||
} |
|||
fclose($fpLocal); |
|||
} |
|||
|
|||
function send_tweet() { |
|||
if(file_exists("FOR_SEND.TXT")) { |
|||
$fpServer = fsockopen("spitfire.initlab.org", 8124, $errno, $errstr, 30); |
|||
$tweet = file_get_contents("FOR_SEND.TXT"); |
|||
|
|||
if (!$fpServer) { |
|||
echo "$errstr ($errno)\n"; |
|||
} |
|||
else { |
|||
usleep(1500000); |
|||
$out = "SEND " . $tweet . "\r\n"; |
|||
// $out .= "QUIT\r\n\r\n"; |
|||
fwrite($fpServer, $out); |
|||
usleep(1500000); |
|||
fclose($fpServer); |
|||
} |
|||
unlink("FOR_SEND.TXT"); |
|||
} |
|||
} |
|||
|
|||
while(42){ |
|||
read_tweets(); |
|||
usleep(1); |
|||
send_tweet(); |
|||
sleep(30); |
|||
} |
|||
|
|||
|
|||
?> |
Loading…
Reference in new issue