HosipLan

Untitled

Apr 20th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1.  private function culturePoints() {
  2.         global $database;
  3.   $ourFileHandle = @fopen("GameEngine/Prevention/culturepoints.txt", 'w');
  4.         @fclose($ourFileHandle);
  5.         $time = time()-60;
  6.         $array = array();
  7.         $q = "SELECT id, lastupdate FROM ".TB_PREFIX."users where lastupdate < $time";
  8.         $array = $database->query_return($q);
  9.        
  10.         foreach($array as $indi) {
  11.             if($indi['lastupdate'] < $time){
  12.                 $dif = $time-$indi['lastupdate'];
  13.                 $cp = $database->getVSumField($indi['id'], 'cp');
  14.                 $cp = $cp/86400;
  15.                 $cp = $cp*$dif;
  16.                 $newupdate = time();
  17.                 $q = "UPDATE ".TB_PREFIX."users set cp = cp + $cp, lastupdate = $newupdate where id = '".$indi['id']."'";
  18.                 $database->query($q);
  19.             }
  20.            
  21.         }
  22.   if(file_exists("GameEngine/Prevention/culturepoints.txt")) {
  23.             @unlink("GameEngine/Prevention/culturepoints.txt");
  24.         }
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment