Jump to content

Using file_get_contents for vote incentives


DayCoder

Recommended Posts

Hi, I run a top site which has incentives. Originally when a voter came and voted, the script in the background would run file() but I noticed that it sometimes lagged and caused the voter to wait a few secs before the page loads.

 

I was then told by a developer to use file_get_contents(), but I was getting the same results. It occasionally lagged, even on my own websites that are voting on it.

 

I decided to log the incentives now, and get a cron to check and process any incentives instead of the user lagging, but now it's starting to kill my server as you can see below

 

xxxxx.com 1.05 0.49 0.1

Top Process %CPU 77.2 php -q process_incentives.php

Top Process %CPU 24.0 php -q process_incentives.php

Top Process %CPU 8.0 php -q timers/5mins.php

xxxxx.com 0.99 0.13 0.0

Top Process %CPU 9.0 php -q timers/30mins.php

Top Process %CPU 7.0 php -q timers/5mins.php

 

Code in process_incentives.php

 

//REWARD VOTERS
$get = mysql_query("SELECT id,url FROM incentives ORDER BY id DESC limit 50;");
while ($game = mysql_fetch_array($get)){

  file_get_contents("$game[url]");
  mysql_query("DELETE from incentives WHERE id='$game[id]'");

}

Link to comment
Share on other sites

Yea, I'm not trying to get any content. I'm just trying to hit reward files, that webmasters set on their own servers to reward their voters when they vote.

 

Top site, websites come and submit their website.

They sometimes set a reward file in their account on my topsite, for my server to hit, when they send a voter over to vote.

 

if($vote){

$ip = $_SERVER['REMOTE_ADDR'];

        if(!fetch("SELECT id FROM $tab[vote] WHERE game='$id' AND ip='$ip';")){
           mysql_query("INSERT INTO $tab[vote] (game,ip) VALUES ('$id','$ip');");
           mysql_query("UPDATE $tab[game] SET votes=votes+1, totalvotes=totalvotes+1 WHERE id='$id';");

           if(($game[rewardscript]) && (!$no)){
             mysql_query("INSERT INTO incentives (url) VALUES ('$game[rewardscript]$REQUEST_URI');"); 
           }
          }
    elseif(($game['alwaysreward'] == 1) && ($game['rewardscript']) && (!$no)){
           mysql_query("INSERT INTO incentives (url) VALUES ('$game[rewardscript]$REQUEST_URI');"); 
          }
       header("Location: vote.php?id=$id&voted=1"); 
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.