当前位置: 首页>>代码示例>>PHP>>正文


PHP my_curl_init函数代码示例

本文整理汇总了PHP中my_curl_init函数的典型用法代码示例。如果您正苦于以下问题:PHP my_curl_init函数的具体用法?PHP my_curl_init怎么用?PHP my_curl_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了my_curl_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: start_party

function start_party($account, $village)
{
    global $server;
    $url = "http://{$server}/build.php?gid=24";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    if (preg_match('#<span id=timer1>([0-9]+):([0-9]+):([0-9]+)</span>#', $result, $match)) {
        $hour = $match[1];
        $minute = $match[2];
        $second = $match[3];
        $due_time = time() + $hour * 3600 + $minute * 60 + $second;
        $sql = "update villages set party_due_time = {$due_time} where account = {$account} and id = {$village}";
        if (!mysql_query($sql)) {
            die(mysql_error());
        }
        echo $sql . "\n";
        echo "Party due time {$hour}:{$minute}:{$second} ...\n";
    } else {
        if (preg_match('#<a href="build.php\\?id=([0-9]+)&a=1">[^<]+</a>#', $result, $match)) {
            $id = $match[1];
            $referer = $url;
            $url = "http://{$server}/build.php?id={$id}&a=1";
            $ch = my_curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            $result = curl_exec($ch);
            curl_close($ch);
            echo "Party ...\n";
        }
    }
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:32,代码来源:cron_one.php

示例2: being_attacked

function being_attacked()
{
    global $server;
    // <td><b class="c5 f10" align="right">&raquo; 1</b></td>
    // <td><b class="c5 f10">攻&#25802;</b></td>
    // <td align="center" class="f10">在</td>
    // <td class="f10"><span id=timer2>0:27:23</span> 小時</td>
    $url = "http://{$server}/dorf1.php";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    $pos = strpos($result, '<td><b class="c5 f10" align="right">&raquo;');
    if ($pos === false) {
        return false;
    }
    echo "************ Being ATTACKED !!! ************\n";
    $ret = preg_match('/<td class="f10"><span id=timer[0-9]>([0-9]+):[0-9]+:[0-9]+<\\/span>/', $result, $matches, 0, $pos);
    if ($ret) {
        echo intval($matches[1]) . " hours remain. \n";
        if (intval($matches[1]) <= 1) {
            return true;
        }
    }
    return false;
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:26,代码来源:utils.php

示例3: get_a2b_page

function get_a2b_page()
{
    global $server;
    // get a2b page
    $url = "http://{$server}/build.php?gid=16";
    echo $url . "\n";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:12,代码来源:cancel.php

示例4: get_map

function get_map($basic_x, $basic_y, $my_villages)
{
    global $server;
    $url = "http://{$server}/karte.php";
    // 21x21 35x35 49x49 63x63 77x77 91x91
    define("RANGE", 49);
    $range = (RANGE - 7) / 2;
    for ($x = $basic_x - $range; $x <= $basic_x + $range; $x = $x + 7) {
        for ($y = $basic_y - $range; $y <= $basic_y + $range; $y = $y + 7) {
            // xp=-124&yp=-54&s1.x=&s1.y=&s1=ok
            $postfields = "xp={$x}&yp={$y}&s1.x=&s1.y=&s1=ok";
            echo $postfields . "\n";
            $ch = my_curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
            curl_setopt($ch, CURLOPT_REFERER, $url);
            $result = curl_exec($ch);
            curl_close($ch);
            parse($result, $my_villages);
        }
    }
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:23,代码来源:populations.php

示例5: mysql_query

}
$account = $_GET['a'];
require_once "common.php";
require_once "db.php";
$sql = "select server, user, password, race, main_village, last_report from accounts where id = {$account}";
$res = mysql_query($sql);
if (!$res) {
    die(mysql_error());
}
$row = mysql_fetch_row($res);
if (!$row) {
    die("Account not found. {$account} \n");
}
$server = $row[0];
$url = "http://{$server}/dorf1.php";
$ch = my_curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);
$all_id = parse_html($result);
$db_all = array();
$sql = "select id from villages where account = {$account}";
$res = mysql_query($sql);
if (!$res) {
    die(mysql_error());
}
while ($row = mysql_fetch_row($res)) {
    $id = $row[0];
    array_push($db_all, $id);
}
foreach ($all_id as $id => $val) {
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:31,代码来源:reset.php

示例6: my_curl_init

<?php

require_once 'common.php';
$url = "http://{$server}/a2b.php";
$ch = my_curl_init(true);
echo $argv[1] . "\n";
echo $argv[2] . "\n";
usleep($argv[2]);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $argv[1]);
curl_setopt($ch, CURLOPT_REFERER, $url);
$result = curl_exec($ch);
curl_close($ch);
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:14,代码来源:catapult-child.php

示例7: attack_func

function attack_func($target_x, $target_y, $t1, $t3, $t6, $t7, $t8, $t11, $result, $target_player = "")
{
    global $server;
    $url = "http://{$server}/a2b.php";
    assert($t1 > 0 || $t1 == '');
    assert($t3 > 0 || $t3 == '');
    assert($t6 > 0 || $t6 == '');
    assert($t7 > 0 || $t7 == '');
    assert($t8 > 0 || $t8 == '');
    assert($t11 == 1 || $t11 == '');
    $hero_post_str = '';
    // onClick="document.snd.t11.value=1; return false;"
    if (preg_match('/on[cC]lick="document\\.snd\\.t11\\.value=1; return false;/', $result, $matches)) {
        // echo "Hero in home.\n";
        if ($t11 == '') {
            $hero_post_str = '&t11=';
        } else {
            $hero_post_str = '&t11=1';
        }
    }
    // <input type="hidden" name="timestamp" value="1252545240" />
    $ret = preg_match('/<input type="hidden" name="timestamp" value="([0-9]+)"/', $result, $matches);
    if (!$ret) {
        die("get timestamp failed.");
    }
    $timestamp = $matches[1];
    // <input type="hidden" name="timestamp_checksum" value="c831c6" />
    $ret = preg_match('/<input type="hidden" name="timestamp_checksum" value="([a-z0-9]+)"/', $result, $matches);
    if (!$ret) {
        die("get timestamp_checksum failed.");
    }
    $timestamp_checksum = $matches[1];
    // Post it
    // b=1&t1=1&t4=&t7=&t9=&t2=&t5=&t8=&t10=&t3=&t6=&c=3&dname=&x=-69&y=-2&s1.x=&s1.y=&s1=ok
    // b=1&t1=50&t4=&t7=&t9=&t2=&t5=&t8=&t10=&t3=&t6=&t11=1&c=3&dname=&x=-122&y=-45&s1.x=&s1.y=&s1=ok
    $postfields = 'timestamp=' . $timestamp . '&timestamp_checksum=' . $timestamp_checksum . '&b=1&t1=' . $t1 . '&t4=&t7=' . $t7 . '&t9=&t2=&t5=&t8=' . $t8 . '&t10=&t3=' . $t3 . '&t6=' . $t6 . $hero_post_str . '&c=3&dname=&x=' . $target_x . '&y=' . $target_y . '&s1.x=&s1.y=&s1=ok';
    echo $postfields . "\n";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    // Check if succeeded
    // "hidden" name="kid"
    $ret = preg_match('/"hidden" name="kid"/', $result, $matches);
    if ($ret) {
        // <input type="hidden" name="id" value="39">
        $ret = preg_match('/<input type="hidden" name="id" value="([0-9]+)"/', $result, $matches);
        if (!$ret) {
            die("get id failed.");
        }
        $id = $matches[1];
        // echo "id = " . $id . "\n";
        // <input type="hidden" name="a" value="46137">
        $ret = preg_match('/<input type="hidden" name="a" value="([0-9]+)"/', $result, $matches);
        if (!$ret) {
            die("get a failed.");
        }
        $a = $matches[1];
        // echo "a = " . $a . "\n";
        // <input type="hidden" name="c" value="3">
        $ret = preg_match('/<input type="hidden" name="c" value="([0-9]+)"/', $result, $matches);
        if (!$ret) {
            die("get c failed.");
        }
        $c = $matches[1];
        // echo "c = " . $c . "\n";
        // <input type="hidden" name="kid" value="356724">
        $ret = preg_match('/<input type="hidden" name="kid" value="([0-9]+)"/', $result, $matches);
        if (!$ret) {
            die("get kid failed.");
        }
        $kid = $matches[1];
        // echo "kid = " . $kid . "\n";
        // <input type="hidden" name="t1" value="10">
        $ret = preg_match('/<input type="hidden" name="t1" value="([0-9]+)"/', $result, $matches);
        if (!$ret) {
            die("get t1 failed.");
        }
        $t1 = $matches[1];
        // echo "t1 = " . $t1 . "\n";
        // <input type="hidden" name="t3" value="10">
        $ret = preg_match('/<input type="hidden" name="t3" value="([0-9]+)"/', $result, $matches);
        if (!$ret) {
            die("get t3 failed.");
        }
        $t3 = $matches[1];
        // echo "t3 = " . $t3 . "\n";
        // <input type="hidden" name="t6" value="10">
        $ret = preg_match('/<input type="hidden" name="t6" value="([0-9]+)"/', $result, $matches);
        if (!$ret) {
            die("get t6 failed.");
        }
        $t6 = $matches[1];
        // echo "t6 = " . $t6 . "\n";
        // <input type="hidden" name="t7" value="10">
        $ret = preg_match('/<input type="hidden" name="t7" value="([0-9]+)"/', $result, $matches);
        if (!$ret) {
//.........这里部分代码省略.........
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:101,代码来源:attack_func.php

示例8: auto_reinforce_tk

function auto_reinforce_tk($x, $y, $num)
{
    global $server;
    $url = "http://{$server}/a2b.php";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    // How many army there ?
    // onClick="document.snd.t1.value=1; return false;
    if (!preg_match('/onClick="document\\.snd\\.t6\\.value=([0-9]+); return false;/', $result, $matches)) {
        echo "failed to get current army.\n";
        return false;
    }
    $curr_army = $matches[1];
    echo $curr_army . " army.\n";
    if ($curr_army < $num) {
        echo "no engouth reinforce army there. {$curr_army} need {$num} \n";
        return false;
    }
    $curr_army = $num;
    // b=1&t1=80&t4=&t7=&t9=&t2=&t5=&t8=&t10=&t3=&t6=&c=2&dname=&x=-128&y=-46&s1.x=&s1.y=&s1=ok
    $postfields = 'b=1&t1=&t4=&t7=&t9=&t2=&t5=&t8=&t10=&t3=&t6=' . $curr_army . '&c=2&dname=&x=' . $x . '&y=' . $y . '&s1.x=&s1.y=&s1=ok';
    echo $postfields . "\n";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    // Check if succeeded
    // "hidden" name="kid"
    if (!preg_match('/"hidden" name="kid"/', $result, $matches)) {
        echo "no kid found.\n";
        return false;
    }
    // <input type="hidden" name="id" value="39">
    $ret = preg_match('/<input type="hidden" name="id" value="([0-9]+)">/', $result, $matches);
    if (!$ret) {
        die("get id failed.");
    }
    $id = $matches[1];
    echo "id = " . $id . "\n";
    // <input type="hidden" name="a" value="46137">
    $ret = preg_match('/<input type="hidden" name="a" value="([0-9]+)">/', $result, $matches);
    if (!$ret) {
        die("get a failed.");
    }
    $a = $matches[1];
    echo "a = " . $a . "\n";
    // <input type="hidden" name="c" value="3">
    $ret = preg_match('/<input type="hidden" name="c" value="([0-9]+)">/', $result, $matches);
    if (!$ret) {
        die("get c failed.");
    }
    $c = $matches[1];
    echo "c = " . $c . "\n";
    // <input type="hidden" name="kid" value="356724">
    $ret = preg_match('/<input type="hidden" name="kid" value="([0-9]+)">/', $result, $matches);
    if (!$ret) {
        die("get kid failed.");
    }
    $kid = $matches[1];
    echo "kid = " . $kid . "\n";
    // <input type="hidden" name="t2" value="10">
    $ret = preg_match('/<input type="hidden" name="t6" value="([0-9]+)">/', $result, $matches);
    if (!$ret) {
        die("get t6 failed.");
    }
    $t6 = $matches[1];
    echo "t6 = " . $t6 . "\n";
    // id=39&a=3953&c=2&kid=357519&t1=80&t2=0&t3=0&t4=0&t5=0&t6=0&t7=0&t8=0&t9=0&t10=0&t11=0&s1.x=&s1.y=&s1=ok
    $postfields = 'id=' . $id . '&a=' . $a . '&c=' . $c . '&kid=' . $kid . '&t1=0&t2=0&t3=0&t4=0&t5=0&t6=' . $t6 . '&t7=0&t8=0&t9=0&t10=0' . '&t11=0&s1.x=&s1.y=&s1=ok';
    echo $postfields . "\n";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    if (!$result) {
        echo curl_error($ch);
        return false;
    }
    echo "reinforcing ({$x}, {$y}) {$num} tk ... \n";
    return true;
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:89,代码来源:reinforce.php

示例9: build_settler

function build_settler()
{
    global $server, $village, $main_village;
    if ($village == $main_village && $village != 0) {
        $url = "http://{$server}/build.php?gid=26";
    } else {
        $url = "http://{$server}/build.php?gid=25";
    }
    echo $url . "\n";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    // onClick="document.snd.t10.value=0
    if (!preg_match('/on[cC]lick="document\\.snd\\.t10\\.value=([0-9]+)/', $result, $matches)) {
        echo "Failed to build settler.\n";
        return;
    }
    $num = intval($matches[1]);
    if ($num <= 0) {
        echo "No resource to build settler.\n";
        return;
    }
    // <input type="hidden" name="id" value="19">
    if (!preg_match('/<input type="hidden" name="id" value="([0-9]+)"/', $result, $matches)) {
        echo "get id failed.\n";
        return;
    }
    $id = $matches[1];
    echo "id = " . $id . "\n";
    // <input type="hidden" name="z" value="15">
    if (!preg_match('/<input type="hidden" name="z" value="([0-9]+)"/', $result, $matches)) {
        echo "get z failed.\n";
        return;
    }
    $z = $matches[1];
    echo "z = " . $z . "\n";
    // <input type="hidden" name="a" value="2">
    if (!preg_match('/<input type="hidden" name="a" value="([0-9]+)"/', $result, $matches)) {
        echo "get a failed.\n";
        return;
    }
    $a = $matches[1];
    echo "a = " . $a . "\n";
    // id=19&z=4802&a=2&t10=1&s1.x=&s1.y=&s1=ok
    $postfields = 'id=' . $id . '&z=' . $z . '&a=' . $a . '&t10=' . $num . '&s1.x=&s1.y=&s1=ok';
    echo $postfields . "\n";
    $referer = $url;
    $url = "http://{$server}/build.php";
    echo $url . "\n";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    curl_setopt($ch, CURLOPT_REFERER, $referer);
    $result = curl_exec($ch);
    curl_close($ch);
    if (!$result) {
        echo curl_error($ch) . "\n";
    }
    echo "Building... {$num} settlers.\n";
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:62,代码来源:army.php

示例10: sell

function sell($m1, $rid1, $m2, $rid2, $free = 2, $reserve = 0)
{
    global $server;
    $url = "http://{$server}/build.php?gid=17&t=2";
    echo $url;
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    // get current resource
    $curr_res = get_res_info($result);
    if ($curr_res[$rid1 - 1] < $m1) {
        echo "No enough resource to sell.\n";
        return false;
    }
    if ($curr_res[$rid1 - 1] < $reserve) {
        echo "Resource too few.\n";
        return false;
    }
    // get free merchants
    // <p class="f10">���l�F 19/20</p><p><input type="image"
    $ret = preg_match('/<p class="f10">\\S+ ([0-9]+)\\/[0-9]+<\\/p><p><input type="image"/', $result, $matches);
    if (!$ret) {
        echo "FAILED : get free merchants.\n";
        return false;
    }
    $free_m = $matches[1];
    echo "Free merchants : {$free_m} \n";
    if ($free_m <= $free) {
        echo "No enough free merchants.\n";
        return false;
    }
    // <input type="hidden" name="id" value="27">
    $ret = preg_match('/<input type="hidden" name="id" value="([0-9]+)">/', $result, $matches);
    if (!$ret) {
        die("get id failed.");
    }
    $id = $matches[1];
    // <input type="hidden" name="a" value="113321">
    $ret = preg_match('/<input type="hidden" name="a" value="([0-9]+)">/', $result, $matches);
    if (!$ret) {
        die("get a failed.");
    }
    $a = $matches[1];
    //id=23&t=2&a=4&m1=1000&rid1=2&d2=2&m2=2000&rid2=4&s1.x=21&s1.y=7&s1=ok
    $postfields = "id={$id}&t=2&a={$a}&m1={$m1}&rid1={$rid1}&d2=2&m2={$m2}&rid2={$rid2}&s1.x=21&s1.y=7&s1=ok";
    echo "{$postfields}\n";
    $referer = $url;
    $url = "http://{$server}/build.php";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    curl_setopt($ch, CURLOPT_REFERER, $referer);
    $result = curl_exec($ch);
    curl_close($ch);
    return true;
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:58,代码来源:transfer.php

示例11: build_or_upgrade

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;
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:44,代码来源:build.php

示例12: delete_self_trade_reports

function delete_self_trade_reports()
{
    global $server;
    $village_names = array();
    for ($s = 0; $s <= 10; $s = $s + 10) {
        $url = "http://{$server}/berichte.php?s={$s}&t=2";
        echo $url . "\n";
        $ch = my_curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        $result = curl_exec($ch);
        curl_close($ch);
        if (empty($village_names)) {
            $village_names = get_all_village_names($result);
            // print_r($village_names);
        }
        for ($i = 0; $i < 10; $i++) {
            // <td class="s7"><a href="berichte.php?id=605449">öが新しい村に供給しました</a> (新)</td>
            if (!preg_match_all('#<td class="s7"><a href="berichte\\.php\\?id=([0-9]+)">([^<]+)が([^<]+)に供給しました</a> [^<]+</td>#', $result, $matches, PREG_SET_ORDER)) {
                break;
            }
            $targets = array();
            foreach ($matches as $match) {
                $id = $match[1];
                $from = $match[2];
                $to = $match[3];
                if (in_array($from, $village_names) && in_array($to, $village_names)) {
                    // <td width="22"><input type="Checkbox" name="n1" value="605561"></td>
                    if (preg_match('#<td width="22"><input type="Checkbox" name="(n[0-9]+)" value="' . $id . '"></td>#', $result, $match)) {
                        $targets[$id] = $match[1];
                    } else {
                        echo "delete_self_trade_reports : failed to get post var name. {$id}\n";
                    }
                }
            }
            if (!empty($targets)) {
                // t=2&n1=605561&del=%E6%B6%88%E5%8E%BB
                // <input class="std" name="del" type="Submit" value="消去">
                $referer = $url;
                $url = "http://{$server}/berichte.php";
                $postfields = 't=2&';
                foreach ($targets as $id => $pname) {
                    $postfields = $postfields . $pname . '=' . $id . '&';
                }
                $postfields .= 'del=%E6%B6%88%E5%8E%BB';
                echo $postfields . "\n";
                $ch = my_curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
                curl_setopt($ch, CURLOPT_REFERER, $referer);
                $result = curl_exec($ch);
                curl_close($ch);
            } else {
                break;
            }
        }
    }
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:58,代码来源:read-reports.php

示例13: login

function login()
{
    global $server;
    global $user;
    global $password;
    $url = "http://{$server}/dorf1.php";
    echo $url . "\n";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    // check if need login
    $ret = preg_match('/<td><img class="res"/', $result);
    //echo $result;
    if (!$ret) {
        // Announce
        if (preg_match('/<a href="dorf1\\.php\\?ok/', $result)) {
            echo "ANNOUNCE ...\n";
            // file_put_contents("announce.html", $result);
            $filename = "announce.html";
            if (!($handle = fopen($filename, 'w'))) {
                die("Cannot open file ({$filename})");
            }
            if (fwrite($handle, $result) === FALSE) {
                die("Cannot write to file ({$filename})");
            }
            fclose($handle);
            $ch = my_curl_init();
            curl_setopt($ch, CURLOPT_URL, $url . '?ok=1');
            $result = curl_exec($ch);
            curl_close($ch);
            if (preg_match('/<td><img class="res"/', $result)) {
                echo "login ok ....\n";
                return $result;
            } else {
                die("FAILED: login ....");
            }
        }
        // <input type="hidden" name="login" value="1198128845">
        $ret = preg_match('/<input type="hidden" name="login" value="([0-9]+)">/', $result, $matches);
        if (!$ret) {
            die("get post value login failed.");
        }
        $login = $matches[1];
        // echo $login . "\n";
        // <input class="fm fm110" type="text" name="e96c60c" value="" maxlength="15"> <span class="e f7"></span>
        $ret = preg_match('/<input class="fm fm110" type="text" name="([a-z0-9]+)" value=".*?" maxlength="15"> <span class="e f7"><\\/span>/', $result, $matches);
        if (!$ret) {
            die("get post name user failed.");
        }
        $var_user = $matches[1];
        // echo $var_user . "\n";
        // <input class="fm fm110" type="password" name="ee54ffc" value="" maxlength="20"> <span class="e f7"></span>
        $ret = preg_match('/<input class="fm fm110" type="password" name="([a-z0-9]+)" value=".*?" maxlength="20"> <span class="e f7"><\\/span>/', $result, $matches);
        if (!$ret) {
            die("get post name password failed.");
        }
        $var_password = $matches[1];
        // echo $var_password . "\n";
        // <p align="center"><input type="hidden" name="e50439e" value="">
        $ret = preg_match('/<p align="center"><input type="hidden" name="([a-z0-9]+)" value="([a-z0-9]*)">/', $result, $matches);
        if (!$ret) {
            die("get post anonymous name and value failed.");
        }
        $var_anonymous_name = $matches[1];
        $var_anonymous_value = $matches[2];
        // echo $var_anonymous_name . "\n";
        // echo $var_anonymous_value . "\n";
        // w=1152%3A864&login=1198128731&e96c60c=Kimon&ee54ffc=********&e50439e=cc87212bcd&s1.x=&s1.y=&s1=login&autologin=ja
        $postfields = 'w=1152%3A864' . '&login=' . $login . '&' . $var_user . '=' . urlencode($user) . '&' . $var_password . '=' . $password . '&' . $var_anonymous_name . '=' . $var_anonymous_value . '&s1.x=&s1.y=&s1=login';
        echo $postfields . "\n";
        $ch = my_curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
        $result = curl_exec($ch);
        curl_close($ch);
        // echo $result;
        $ret = preg_match('/<td><img class="res"/', $result);
        if ($ret) {
            echo "login ok.\n";
        } else {
            echo $result;
            die("FAILED: login.");
        }
    } else {
        echo "cookie login ok.\n";
    }
    return $result;
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:90,代码来源:login.php

示例14: auto_defence_oasis

function auto_defence_oasis($home_x, $home_y, $defence_unit, $defence_unit_speed)
{
    global $server;
    $url = "http://{$server}/build.php?gid=16";
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    $res = get_defence_oasis($result);
    print_r($res);
    if (empty($res)) {
        return false;
    }
    foreach ($res as &$a) {
        $x = $a[0];
        $y = $a[1];
        $remain = $a[2];
        $arrive = $a[3];
        $distance = calc_distance($home_x, $home_y, $x, $y);
        $need_time = 3600 * $distance / $defence_unit_speed;
        $wait_time = $remain - $need_time;
        array_push($a, $wait_time);
    }
    usort($res, "cmp");
    print_r($res);
    $last_wait_time = 0;
    foreach ($res as $b) {
        $x = $b[0];
        $y = $b[1];
        $arrive = $b[3];
        $wait_time = $b[4];
        //print_r($a);
        // too late
        if ($wait_time < 0) {
            echo "wait time < 0\n";
            continue;
        }
        // 20 minutes
        if ($wait_time - $last_wait_time > 1200) {
            echo "wait time - last wait time > 1200\n";
            break;
        }
        $arrive2 = minus_time_str($arrive, 30);
        echo "raid {$x}, {$y} {$arrive2}\n";
        raid($x, $y, array($defence_unit => 2), $arrive2);
        $last_wait_time = $wait_time;
    }
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:48,代码来源:utils.php

示例15: build

function build($village, $result)
{
    global $server;
    // Get a build task
    $sql = "select `seq`, `id` from `build` where `village` = {$village} order by `seq` limit 1";
    $res = mysql_query($sql);
    if (!$res) {
        die(mysql_error());
    }
    $row = mysql_fetch_row($res);
    if (!$row) {
        echo "No build task more. Try to auto build.\n";
        $id = get_auto_build_resource_field_id($result);
        $seq = -1;
    } else {
        $seq = $row[0];
        $id = $row[1];
    }
    $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('/<a href="(dorf[12]\\.php\\?a=[0-9]+&c=[0-9a-z]+)">/', $result, $matches);
    if (!$ret) {
        echo "Busy or lacking resources or failed.\n";
        return;
    }
    $url2 = "http://{$server}/" . $matches[1];
    echo $url2 . "\n";
    if ($seq >= 0) {
        // Update the target
        $sql = "delete from `build` where `seq` = {$seq}";
        if (!mysql_query($sql)) {
            die(mysql_error());
        }
    }
    $ch = my_curl_init();
    curl_setopt($ch, CURLOPT_URL, $url2);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    //echo $result;
}
开发者ID:GaryHuang-CL,项目名称:y1910061,代码行数:48,代码来源:build.php


注:本文中的my_curl_init函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。