0

so i'm not very familiar with either javascript or php but what i want to do is create an automated voter for a certain site. its very simple. I have a url which increases the vote count by one. I have verified that entering this url counts as a vote. however the site cookie must be deleted before another vote can take place.This is what i have tried so far (ps: hoping to make this work in chrome. if anyone has an alternative browser to make it work in thats fine to.):

<html>
<body>
<script Type="text/javascript">
function clearCookies()
{
chrome.cookies.getAll({domain: "Domain.com"}, function(cookies) {
for(var i=0; i<cookies.length;i++) {
chrome.cookies.remove({url: "Domain.com" + cookies[i].path, name: cookies[i].name});
}
});
}
</script>
<?php
set_time_limit(0);
while(true){ 
echo "<script Type=\"text/javascript\"> clearCookies(); </script>";
$useragent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "Specific_URL_To_Vote"); 
curl_exec ($ch) ;
curl_close($ch);
sleep(6);
}
?>
</body>
</html>

so obviously i replace "Domain.com" with the actual domain and "Specific_URL_To_Vote" with the actual URL. can anyone help me with this? i've really only worked with java and basic html before so I'm not even entirely sure how I would troubleshoot this on my own.

2 Answers2

0

You're trying to send a request to a server using PHP Curl and clear cookies, so you can re-vote.

The problem is that PHP makes the request.

If you want your browser to do requests, look into AJAX.

0

If jquery is allowed then use below solution

 <span class='vote' >Vote</span>
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script>
    $(".vote").click(
                 function()
                 {                  
                        var rquest = $.ajax({
                                    type: "POST",
                                    url: "url_to_vote",
                                    data: {voted_user_id: 'id of user who is voting'}
                                  });
                                  rquest.done(function( msg ) {
                                     if(msg == true)
                                     {
                                        alert('Voted successfully');
                                     }
                                     else
                                     {
                                        alert('already voted');
                                     }
                                  });
                                  request.fail(function(jqXHR, textStatus) {
                                        alert( "Error: " + textStatus );
                                    });
                        }
                 );
    </script>

Now in url_to_vote write below pseudo code without error

id = voted_user_id
query = select 1 from voting_table where user_id =id
result = execute(query)
if (result == 1)
    print false
else
{
    add code to insert voting data
    print true
}
Notepad
  • 1,659
  • 1
  • 12
  • 14