Beste Criminalspoint,
Ik heb hier een Twitter Score script kan je je twitter ID invullen en kijken wat jou score is.
Maar ik wil hem dat hij elke 24 uur automatisch checkt wat de score is dat hij up-to-date blijft.
Kan iemand mij daarbij helpen?
Script: http://www.onlinestereo.org/ma/twitterscore.php
PHP
<?php
include ('values.php');
$step=$_POST["step"];
$var=$_GET["var"];
if ($var==1) {
$step=3;
}
if ($var==2) {
$step=4;
}
if ($step=='') {
?>
<div id="contentfloat">
<div id="textbox">
<br/> <br/> <p class="caption"><b> <u>Twitter Score</u></b><br/> <br/>- See how well your score against other twitter users!<br/>
<br/>
<br/>
- Scores are based on how many friends & followers you have & how often you post an update!<br/> <br/> <br/>
- Tweet your score and rank on your twitter updates for everyone to see!<br/> <br/> <br/>
<A HREF="twitterscore.php?var=1">TOP SCORES!</a><br/>
<A HREF="twitterscore.php?var=2">How It Works!</a><br/>
</p>
<p class="caption"><br/>
</p>
</div>
<div id="formbox">
<form action="twitterscore.php" method="post">
<label>Twitter ID</label><input type="hidden" name="step" value="2" />
<input name="twitterid" type="text" size="20" /><input type="submit" class="button" value="Go" />
</form>
</div>
</div>
<?php
} elseif ($step=='2') {
function twitter_status($rss, $hyperlinks = false) {
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $rss);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$src = curl_exec($c);
curl_close($c);
preg_match('/<text>(.*)<\/text>/', $src, $m);
$status = htmlentities($m[1]);
if( $hyperlinks ) $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $status);
preg_match('/<screen_name>(.*)<\/screen_name>/', $src, $m);
$screenname = htmlentities($m[1]);
preg_match('/<created_at>(.*)<\/created_at>/', $src, $m);
$created = htmlentities($m[1]);
preg_match('/<id>(.*)<\/id>/', $src, $m);
$id = htmlentities($m[1]);
preg_match('/<name>(.*)<\/name>/', $src, $m);
$name = htmlentities($m[1]);
preg_match('/<created_at>(.*)<\/created_at>/', $src, $m);
$createdate = htmlentities($m[1]);
preg_match('/<followers_count>(.*)<\/followers_count>/', $src, $m);
$followers = htmlentities($m[1]);
preg_match('/<friends_count>(.*)<\/friends_count>/', $src, $m);
$friends = htmlentities($m[1]);
preg_match('/<statuses_count>(.*)<\/statuses_count>/', $src, $m);
$updatecount = htmlentities($m[1]);
preg_match('/<location>(.*)<\/location>/', $src, $m);
$location = htmlentities($m[1]);
preg_match('/<url>(.*)<\/url>/', $src, $m);
$website = htmlentities($m[1]);
preg_match('/<description>(.*)<\/description>/', $src, $m);
$bio = htmlentities($m[1]);
preg_match('/<profile_image_url>(.*)<\/profile_image_url>/', $src, $m);
$profile = htmlentities($m[1]);
$feedvariables=array($status, $screenname, $created, $id, $name, $createdate, $followers, $friends, $updatecount, $location, $website, $bio, $profile);
return($feedvariables);
}
$twitterid=$_POST["twitterid"];
$rss="http://twitter.com/users/show.xml?screen_name=".$twitterid;
$feedvar=twitter_status($rss);
$twitstatus=$feedvar[0];
$twitscreenname=$feedvar[1];
$twitcreated=$feedvar[2];
$twitid=$feedvar[3];
$twitname=$feedvar[4];
$createdate=$feedvar[5];
$followers=$feedvar[6];
$friends=$feedvar[7];
$updatecount=number_format($feedvar[8]);
$location=$feedvar[9];
$website=$feedvar[10];
$bio=$feedvar[11];
$profile=$feedvar[12];
if ($feedvar[3]!='') {
$twityear=substr($createdate, -4);
$temptwitdate=substr($createdate, -26);
$twitmonth=substr($temptwitdate, 0, 3);
if ($twitmonth=="Jan") { $twitmonth="January"; }
if ($twitmonth=="Feb") { $twitmonth="February"; }
if ($twitmonth=="Mar") { $twitmonth="March"; }
if ($twitmonth=="Apr") { $twitmonth="April"; }
if ($twitmonth=="May") { $twitmonth="May"; }
if ($twitmonth=="Jun") { $twitmonth="June"; }
if ($twitmonth=="Jul") { $twitmonth="July"; }
if ($twitmonth=="Aug") { $twitmonth="August"; }
if ($twitmonth=="Sep") { $twitmonth="September"; }
if ($twitmonth=="Oct") { $twitmonth="October"; }
if ($twitmonth=="Nov") { $twitmonth="November"; }
if ($twitmonth=="Dec") { $twitmonth="December"; }
$temptwitdate=substr($createdate, -22);
$twitday=substr($temptwitdate, 0, 2);
$outputtext=$twitmonth." ".$twitday.", ".$twityear;
$sql = "SELECT rank FROM data ORDER BY ABS(rank) DESC LIMIT 1";
$result = mysql_query ($sql);
while ($row = mysql_fetch_array($result)) {
$toprank=$row["rank"];
}
$rank=$friends+$followers;
if ($rank>$toprank) {
$toprank=$rank;
}
$score=($rank/$toprank)*10;
if (($score>5) && ($score<10)) {
$score=$score*.7;
}
if ($score<.01) {
$score=$score*1000;
}
if ($score<1) {
$score=$score+1.5;
}
if ($score<6) {
$score=$score*1.5;
}
$score=number_format($score, 2);
$counter=0;
$placement=0;
$sql = "SELECT rank, user FROM data ORDER BY ABS(rank) DESC";
$result = mysql_query ($sql);
while ($row = mysql_fetch_array($result)) {
$counter++;
$tempuser=$row["user"];
$temprank=$row["rank"];
if ($temprank<$rank) {
$placement=$counter;
break;
}
}
$sql = "SELECT * FROM data";
$result = mysql_query ($sql);
$totalusers=mysql_num_rows($result);
if ($placement==0) {
$placement=$totalusers;
}
$sql = "SELECT * FROM data WHERE user='".$twitscreenname."' LIMIT 1";
$result = mysql_query ($sql);
if(mysql_num_rows($result)==0){
$update = "INSERT INTO data (user, score, rank, name, site, followers, friends, location, image) VALUES ('$twitscreenname', '$score', '$rank', '$twitname', '$website', '$followers', '$friends', '$location', '$profile')";
mysql_query($update);
$didit="did it";
} else {
$update = "update data set followers='$followers' WHERE user='".$twitscreenname."'";
mysql_query($update);
$update = "update data set friends='$friends' WHERE user='".$twitscreenname."'";
mysql_query($update);
$update = "update data set score='$score' WHERE user='".$twitscreenname."'";
mysql_query($update);
$update = "update data set rank='$rank' WHERE user='".$twitscreenname."'";
mysql_query($update);
}
$twitterurl="http://twitter.com/home/?status=your message here";
echo '
<img src="'.$profile.'" height=48 width=48> '.$twitname.'\'s Twitter Score Report </p>
<b>RANK '.$placement.' OF '.$totalusers.'</b><br />
<b>Followers:</b> '.number_format($followers).'<br />
<b>Following:</b> '.number_format($friends).'<br />
<b>Tweets:</b> '.$updatecount.'<br />
<br />
<h1>Profile Data</h1>';
if ($twitname!='') {
echo '<b>Full Name:</b> '.$twitname.'<br />';
}
if ($location!='') {
echo '<b>Location:</b> '.$location.'<br />';
}
if ($website!='') {
echo '<b>Web site:</b> '.$website.'<br />';
}
if ($bio!='') {
echo '<b>Bio:</b> '.$bio.'';
}
echo '
<p class="name"><b>Last Tweet:</b> '.$twitstatus.'</p>
<p class="name"><span>Tweet This <b>I have a Twitter Score of '.$score.'!:</b></span> <a href="http://twitter.com/share" class="twitter-share-button" data-text="I have a Twitter Score of '.$score.'!" data-count="none" data-via="M4zZy">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></p>
<h1>Twitter</h1>
Score: '.$score.' of 10';
echo '<br><br>';
echo '<A HREF="twitterscore.php?var=1">TOP SCORES!</a>';
} else {
echo '
There appears to be a problem with the Twitter ID that you entered - either the ID does not exist or was typed incorrectly. Please press the back button on your browser and try again. Thank you!<br><br>
<a href="javascript:history.go(-1)" title="Return to the previous page">Go back</a>';
}
} elseif ($step=='3') {
echo '
<p class="captiontext"><u><b>Top Twitter Scores Report</b></u></p>
NAME
SCORE
FRIENDS/FOLLOWERS
LOCATION';
$sql2 = "SELECT followers FROM data ORDER BY ABS(followers) DESC LIMIT 1";
$result2 = mysql_query ($sql2);
while ($row2 = mysql_fetch_array($result2)) {
$toprank=$row2["followers"];
}
$sql = "SELECT * FROM data";
$result = mysql_query ($sql);
while ($row = mysql_fetch_array($result)) {
$dispuser=$row["user"];
$dispscore=$row["score"];
$disprank=$row["rank"];
$dispname=$row["name"];
$dispsite=$row["site"];
$dispfollowers=$row["followers"];
$dispfriends=$row["friends"];
$displocation=$row["location"];
$dispimage=$row["image"];
$rank=$dispfriends+$dispfollowers;
$score=($rank/$toprank)*10;
if (($score>5) && ($score<10)) {
$score=$score*.7;
}
if ($score<.01) {
$score=$score*1000;
}
if ($score<1) {
$score=$score+1.5;
}
if ($score<6) {
$score=$score*1.5;
}
$score=number_format($score, 2);
$update = "update data set score='$score' WHERE user='".$dispuser."'";
mysql_query($update);
$update = "update data set rank='$rank' WHERE user='".$dispuser."'";
mysql_query($update);
}
$sql = "SELECT * FROM data ORDER BY ABS(score) DESC LIMIT 50";
$result = mysql_query ($sql);
$counter=0;
while ($row = mysql_fetch_array($result)) {
$counter++;
$dispuser=$row["user"];
$dispscore=$row["score"];
$disprank=$row["rank"];
$dispname=$row["name"];
$dispsite=$row["site"];
$dispfollowers=$row["followers"];
$dispfriends=$row["friends"];
$displocation=$row["location"];
$dispimage=$row["image"];
echo '
<div class="toptablecontent">
<ul>
<li class="name"><span>'.$counter.'.</span> <a href="http://www.twitter.com/'.$dispuser.'/"target="_blank"><img border=0 src="images/twitter.png" width=32 height=32></a> <a href="http://www.twitter.com/'.$dispuser.'/"target="_blank"><img border=0 src="'.$dispimage.'" width=48 height=48></a> '.$dispname.' </li>
<li class="score"><img src="images/spacer.gif" width=1 height=48>'.$dispscore.'</li>
<li class="followers"><img src="images/spacer.gif" width=1 height=48>'.number_format($dispfriends).' / '.number_format($dispfollowers).'</li>
<li class="location"><img src="images/spacer.gif" width=1 height=48>'.$displocation.'</li>
</ul></div>';
}
echo '';
} elseif ($step=='4') {
echo '
<b><u>How It Works</u></b><br /><br />
Twitter Score bases scores of Twitter users on three factors: friends, followers and frequency of updates.<br />
Based on the quantities of all three scores, a score between 0.01 and 10.00 is produced.<br />
<br />
In order to make the scoring fair, the bottom 30% of those scored are offered a handicap, and the top 10% of those scored are weighted down to make the playing field level.<br />
How It Works<br />
<br />
Twitter Score is meant for entertainment purposes only, so while reviewing your score, remember to have fun!<br/><br/><br/>
<A HREF="twitterscore.php">Go Back!</a><br />
<A HREF="twitterscore.php?var=1">TOP SCORES!</a>';
echo '';
}
?>
Toon Meer