function attack($result, $village) { global $server; global $account; $url = "http://{$server}/a2b.php"; $server_hour = get_server_hour($result); // echo "Current hour : " . $server_hour . "\n"; $start = $server_hour == 0 ? 23 : $server_hour - 1; $stop = $server_hour == 23 ? 0 : $server_hour + 1; $sql = "select x, y, min_clubs, `recursive`, `seq`, `ram` from mission where account = {$account} and village = {$village} and TO_DAYS(now()) > `recursive` and `hour` in (" . $start . "," . $server_hour . "," . $stop . ") order by `recursive`"; $res = mysql_query($sql); if (!$res) { die(mysql_error()); } $row = mysql_fetch_row($res); if (!$row) { // echo "No mission.\n"; return false; } $target_x = $row[0]; $target_y = $row[1]; $min_clubs = $row[2]; $recursive = $row[3]; $seq = $row[4]; $with_ram = $row[5]; echo "Mission : (" . $row[0] . " , " . $row[1] . ") with " . $min_clubs . " clubs\n"; // if(being_attacked()){ // echo "Cancel mission.\n"; // return false; // } // How many clubs there ? // onClick="document.snd.t1.value=1; return false; if (!preg_match('/on[cC]lick="document\\.snd\\.t1\\.value=([0-9]+); return false;/', $result, $matches)) { echo "no club for mission .\n"; return true; } $curr_clubs = $matches[1]; echo $curr_clubs . " clubs.\n"; if ($curr_clubs < $min_clubs) { echo "no enough clubs for mission.\n"; return true; } $axes = ''; $tks = ''; $hero = ''; $rams = ''; if ($recursive > 0) { // update the mission $sql = "update mission set `recursive` = TO_DAYS(now()) where `seq` = " . $seq; if (!mysql_query($sql)) { die(mysql_error()); } // daily farm $clubs = $min_clubs; } else { // uniq mission, need all clubs, axes, tks and hero // onClick="document.snd.t11.value=1; return false;" if (preg_match('/on[cC]lick="document\\.snd\\.t11\\.value=1; return false;/', $result, $matches)) { $hero = 1; } else { echo "Hero does NOT in home.\n"; return true; } // onClick="document.snd.t3.value=1; return false; if (!preg_match('/on[cC]lick="document\\.snd\\.t3\\.value=([0-9]+); return false;/', $result, $matches)) { $axes = 0; } else { $axes = $matches[1]; } // onClick="document.snd.t6.value=1; return false; if (!preg_match('/on[cC]lick="document\\.snd\\.t6\\.value=([0-9]+); return false;/', $result, $matches)) { $tks = 0; } else { $tks = $matches[1]; } // ram if ($with_ram == 1) { // onClick="document.snd.t7.value=1; return false; if (preg_match('/on[cC]lick="document\\.snd\\.t7\\.value=([0-9]+); return false;/', $result, $matches)) { $rams = $matches[1]; } } // Delete the mission $sql = "delete from mission where `seq` = " . $seq; if (!mysql_query($sql)) { die(mysql_error()); } $clubs = $curr_clubs; } attack_func($target_x, $target_y, $clubs, $axes, $tks, $rams, '', $hero, $result); return true; }
} $sql = "update accounts set busy = 1 where id = {$account}"; mysql_query($sql); $sql = "select wood_name, brick_name, iron_name, crop_name, report_str from servers where addr = '{$server}'"; $res = mysql_query($sql); if (!$res) { die(mysql_error()); } $row = mysql_fetch_row($res); if (!$row) { die("Server not found. {$server} \n"); } $convert = array($row[0] => 0, $row[1] => 1, $row[2] => 2, $row[3] => 3); $report_str = explode(',', $row[4]); $result = login(); $hour = get_server_hour($result); $sql = "select id, auto_transfer, noraid, name, newbie, last_beg, crop, cart_capacity, defence, party, party_due_time, x, y from villages where account = {$account} order by rand()"; $res = mysql_query($sql); if (!$res) { die(mysql_error()); } while ($row = mysql_fetch_row($res)) { $village = $row[0]; $auto_transfer = $row[1]; $noraid = $row[2]; $name = $row[3]; $newbie = $row[4]; $last_beg = $row[5]; $buycrop = $row[6]; $cart_capacity = $row[7]; $defence = $row[8];