예제 #1
0
 if ($auto_transfer > 0) {
     if (build_task_exist($account, $village)) {
         $result = switch_village($village);
         build($village, $result, $newbie);
     }
     transfer_to_village($village, $auto_transfer);
 } else {
     if ($village > 0) {
         $result = switch_village($village);
     }
     $attack_time_left = detect_attack($result);
     if ($attack_time_left > 900) {
         $next_check_time = min($next_check_time, $attack_time_left - 900);
     }
     $oasis_attack_time_left = detect_oasis_attack($result);
     update_check_time($result);
     build($village, $result, $newbie);
     list($wood, $brick, $iron, $crop, $warehouse_capacity, , , $granary_capacity) = get_res_info($result);
     if ($village == $main_village) {
         detect_message($result, $account, $message, $user, $server);
         if ($attack_time_left >= 0 && $beacon == 0) {
             $sql = "update accounts set beacon = 1 where id = {$account}";
             if (!mysql_query($sql)) {
                 die(mysql_error());
             }
             $title = "{$server},{$user},{$attack_time_left}";
             attack_mail($title);
         } else {
             if ($attack_time_left < 0 && $beacon == 1) {
                 $sql = "update accounts set beacon = 0 where id = {$account}";
                 if (!mysql_query($sql)) {
예제 #2
0
function build_or_upgrade($id, $gid = 0)
{
    global $server;
    $referer = "http://{$server}/dorf" . ($id <= 18 ? "1" : "2") . ".php";
    $url = "http://{$server}/build.php?id={$id}";
    echo $url . "\n";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_REFERER, $referer);
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    // <a href="dorf2.php?a=28&c=23d">
    $ret = preg_match('/href="(dorf[12]\\.php\\?a=[0-9]+&amp;c=[0-9a-z]+)">/', $result, $matches);
    if (!$ret) {
        // relay point
        // dorf2.php?a=16&id=39&c=2e0
        if ($id == 39) {
            $gid = 16;
        }
        // wall
        // dorf2.php?a=31&id=40&c=061
        if ($id == 40) {
            $ret = preg_match('/href="(dorf2\\.php\\?a=[0-9]+&amp;id=' . $id . '&amp;c=[0-9a-z]+)">/', $result, $matches);
        } else {
            if ($gid > 0) {
                // <a href="dorf2.php?a=23&id=33&c=0c6">
                $ret = preg_match('/href="(dorf[12]\\.php\\?a=' . $gid . '&amp;id=' . $id . '&amp;c=[0-9a-z]+)">/', $result, $matches);
            }
        }
    }
    if (!$ret) {
        echo "Busy or lacking resources or failed .. {$gid} {$id}\n";
        return false;
    }
    $url2 = "http://{$server}/" . html_entity_decode($matches[1]);
    echo $url2 . "\n";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url2);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    update_check_time($result);
    return true;
}