Attack |
signup/3600-time()/3600) + 12 <= 0) {
$dbres = mysql_query("SELECT `login`,UNIX_TIMESTAMP(`signup`) AS `signup`,`attack`,`defence`,`clicks`,`attlosses`,`attwins`,`deflosses`,`defwins`,`cash`,`type`,`clan` FROM `[users]` WHERE `login`='{$_GET['x']}' AND `activated`=1");
if($def = mysql_fetch_object($dbres)) {
if($def->login == $data->login)
print " Je slaat jezelf tegen je hoofd en valt bewusteloos neer... |
\n";
else if($def->type == 3 && $data->type == 3)
print " Agenten mogen elkaar niet aanvallen |
\n";
else if($def->clan == $data->clan && $def->clan != "")
print " Je mag niet mede-clan members aanvallen |
\n";
else if(round($def->signup/3600-time()/3600) + 12 > 0)
print " {$def->login} staat nog onder bescherming |
\n";
else {
$dbres = mysql_query("SELECT * FROM `[logs]` WHERE `login`='{$data->login}' AND `person`='{$def->login}' AND FLOOR(UNIX_TIMESTAMP(`time`)/(60*60*24))=FLOOR(UNIX_TIMESTAMP(NOW())/(60*60*24)) AND `area`='attack'");
if(($numattacks = mysql_num_rows($dbres)+1) <= 5) {
$dbres = mysql_query("SELECT * FROM `[logs]` WHERE UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`time`) < 10 AND `login`='{$data->login}' AND `area`='attack'");
if(mysql_num_rows($dbres) == 0) {
mysql_query("SELECT GET_LOCK('attack_{$def->login}',5)");
$result = (($data->attack+$data->clicks*5)*rand(90,115) >= ($def->defence+$def->clicks*5)*rand(90,115)) ? 1 : 0;
$money = ($result == 1) ? (int)($def->cash*rand(40,75)/100) : (int)($data->cash*rand(25,40)/100);
$text = ($result == 1) ? Array("je hebt gewonnen!","gewonnen") : Array("je verliest.","verloren");
$forwardedFor = ($_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['HTTP_CLIENT_IP'];
$forwardedFor = preg_replace('/, .+/','',$forwardedFor);
mysql_query("INSERT INTO `[logs]`(`time`,`IP`,`forwardedFor`,`login`,`person`,`code`,`area`) values(NOW(),'{$_SERVER['REMOTE_ADDR']}','$forwardedFor','{$data->login}','{$def->login}',($money << 1) | $result,'attack')");
if($result == 1) {
mysql_query("UPDATE `[users]` SET `cash`=". ($def->cash-$money) .",`deflosses`=". ($def->deflosses+1) ." WHERE `login`='{$def->login}'");
$data->cash += $money;
$data->attwins++;
mysql_query("UPDATE `[users]` SET `cash`={$data->cash},`attwins`={$data->attwins} WHERE `login`='{$data->login}'");
}
else {
$data->cash -= $money;
$data->attlosses++;
mysql_query("UPDATE `[users]` SET `cash`={$data->cash},`attlosses`={$data->attlosses} WHERE `login`='{$data->login}'");
mysql_query("UPDATE `[users]` SET `cash`=". ($def->cash+$money) .",`defwins`=". ($def->defwins+1) ." WHERE `login`='{$def->login}'");
}
print " Je valt {$def->login} aan en... {$text[0]} Je hebt \$$money {$text[1]}... |
\n";
mysql_query("SELECT RELEASE_LOCK('attack_{$def->login}')");
}
else {
$type = Array("","junkies","klonen","agenten");
$type = $type[$data->type];
print " Je $type zijn nog moe van de vorige aanval... |
\n";
}
}
else
print " Je hebt {$def->login} al 5x aangevallen vandaag... |
\n";
}
}
}
else
print " Je kunt niemand aanvallen wanneer je onder bescherm staat |
\n";
/* ------------------------- */ ?>