Beispiel #1
0
/**
 *
 * 掘出陣列裡層的 $key-array
 *
 */
function dig($array, $key = false, $deep = 1)
{
    if (!$array) {
        return !is_array($array) ? false : array();
    }
    $ret = array();
    $mod = is_object(current($array)) ? 'o' : 'a';
    if ($deep == 1) {
        reset($array);
        while (list($k, $v) = each($array)) {
            if ($key && $mod == 'a' && isset($v[$key])) {
                $ret[] = $v[$key];
            } else {
                if ($key && $mod == 'o' && isset($v->{$key})) {
                    $ret[] = $v->{$key};
                } else {
                    if (!$key) {
                        $ret = array_merge($ret, $v);
                    }
                }
            }
        }
        return $ret;
    } else {
        while (list($k, $v) = each($array)) {
            $ret = array_merge($ret, dig($v, $key, $deep - 1));
        }
        return $ret;
    }
}
Beispiel #2
0
 /**
  * Find an object.
  *
  * @param  string $primaryValue
  * @return mixed
  */
 public function find($primaryValue = null)
 {
     if ($primaryValue === null) {
         $primaryValue = dig($this->data, $this->primary);
     }
     if ($primaryValue === null) {
         return null;
     }
     try {
         return $this->db->getConnection()->getAgent()->get("SELECT * FROM `{$this->name}` WHERE `{$this->primary}` = ?", [$primaryValue]);
     } catch (\Exception $e) {
         return null;
     }
 }
Beispiel #3
0
function dig($node)
{
    var_dump($node);
    $nodeType = gumbo_node_get_type($node);
    switch ($nodeType) {
        case GUMBO_NODE_ELEMENT:
            var_dump(gumbo_element_get_tag_name($node));
            $children = gumbo_element_get_children($node);
            var_dump($children);
            foreach ($children as $child) {
                dig($child);
            }
            break;
        case GUMBO_NODE_TEXT:
            var_dump(gumbo_text_get_text($node));
            break;
    }
}
Beispiel #4
0
function scan()
{
    if (isset($_POST['host']) && isset($_POST['nmap']) || isset($_POST['dig']) || isset($_POST['whois'])) {
        echo '<div class="post"><h2 class="title"><a href="#">Scan results</a></h2><div class="entry">';
        echo '<p class="meta">Used proxychains: ';
        if ($_POST['proxychains'] == 'yes') {
            echo 'Yes &nbsp;&bull;&nbsp;';
        } else {
            echo 'No &nbsp;&bull;&nbsp;';
        }
        echo ' Target - ' . htmlspecialchars($_POST['host']) . '</p>';
        if ($_POST['nmap'] == 'yes') {
            nmap($_POST['host'], $_POST['ncmd']);
        }
        if ($_POST['dig'] == 'yes') {
            dig($_POST['host']);
        }
        if ($_POST['whois'] == 'yes') {
            whois($_POST['host']);
        }
        echo '</div></div>';
    }
}
Beispiel #5
0
 /**
  * Getter.
  *
  * @param  string $key
  * @param  mixed  $valueDefault
  * @return mixed
  */
 public final function get($key, $valueDefault = null)
 {
     return dig($this->data, $key, $valueDefault);
 }
Beispiel #6
0
function solution($A, $B, $K)
{
    global $longestPath;
    //QUERO O MAIOR CAMINHO
    //COMECA DO MENOR CAMINHO PARA O MAIOR
    //CONTA O NUMERO QUE MENOS SE REPETE EM AMBAS AS ARRAYS
    //NO EXEMPLO ACIMA, 5 E 9 SAO OS QUE MENOS SE REPETEM
    //$C PARA COUNT
    for ($tgh = 1; $tgh <= $K + 1; $tgh++) {
        $path = array();
        unset($AB);
        unset($lessRepeated);
        //echo "<b>STARTING TRIAL #$tgh</b>";
        $longestPath = 0;
        $AB = array_merge($A, $B);
        asort($AB);
        $AB[] = "999999999";
        //EXTRA ELEMENT
        //print_r($AB);//echo "<br>";
        $last = -1;
        $lessTimes = 999999999;
        //EACH road WILL REPEAT AT LEAST ONE TIME
        $currentTimes = 999999999;
        //FIND EXTREMITIES - LEAST REPEATED NUMBER
        foreach ($AB as $i) {
            $currentTimes++;
            //CALCULATE ONCE CHANGED
            if ($i != $last) {
                if ($currentTimes - 1 == $lessTimes) {
                    $lessRepeated[] = $last;
                    $lessTimes = $currentTimes - 1;
                } elseif ($currentTimes - 1 < $lessTimes) {
                    $lessTimes = $currentTimes - 1;
                    unset($lessRepeated);
                    $lessRepeated[] = $last;
                }
                $currentTimes = 1;
            }
            //echo "** $i | $currentTimes **<br>";
            $last = $i;
        }
        unset($AB);
        //to save some memory
        //FINISH LEAST REPEATED NUMBER
        //print_r($lessRepeated);
        //FIND BIGGEST PATH FROM THOSE EXTREMITIES
        //BASED ON TRANSPORT TYCOON
        //CREATE FIRST LEVEL PATH
        $path = array();
        for ($i = 0; $i <= count($A) - 1; $i++) {
            $path[$A[$i]][$B[$i]] = 1;
            $path[$B[$i]][$A[$i]] = 1;
        }
        //if ($tgh>1) {//print_r($path); die; }
        //print_r($path);
        if ($tgh > 1) {
            //echo "AQUIAQUIAQUI<br>";
            //echo "<xmp>";print_r($path);//echo "</xmp>";
            //die;
        }
        //$longestPath=-1;
        foreach ($lessRepeated as $x) {
            foreach ($lessRepeated as $z) {
                //$way[$x][$z] = array();
                //echo "Buscando de $x ate $z<br>";
                //print_r($path);
                //echo $longestPath."<br>";
                $path = dig($path, $x, $z, 1);
            }
        }
        $path['path'] = array_values($path['path']);
        if ($tgh > $K) {
            return $longestPath;
        }
        //echo $longestPath."<br>";
        //echo "<xmp>";
        //print_r($path);//echo "</xmp>";
        //echo "CAMINHO A SER DESTRUIDO:";
        //if ($longestPath%2==1)
        $ptbd = intval(floor($longestPath / 2));
        //echo "POSITION TO BE DESTROYED: $ptbd TO ".($ptbd+1);
        $searchFor = array_slice($path['path'], $ptbd, 2);
        //tries to find the a/b pair
        $foundPair = false;
        $chaves = array_keys($A, $searchFor[0]);
        foreach ($chaves as $chave) {
            if ($B[$chave] == $searchFor[1]) {
                $foundPair = true;
                //echo "FOUND PAIR $searchFor[0] | $searchFor[1] at position $chave";
                break;
            }
        }
        if (!$foundPair) {
            $chaves = array_keys($B, $searchFor[0]);
            foreach ($chaves as $chave) {
                if ($A[$chave] == $searchFor[1]) {
                    $foundPair = true;
                    //echo "FOUND PAIR $searchFor[0] | $searchFor[1] at position $chave";
                    break;
                }
            }
        }
        unset($A[$chave]);
        unset($B[$chave]);
        $A = array_values($A);
        $B = array_values($B);
        //print_r($A);
        //print_r($B); die;
    }
}
Beispiel #7
0
// nothing to do yet
if (!$queryType) {
    exit;
}
// Make sure the target appears valid
if (!$target || !preg_match("/^[\\w\\d\\.\\-]+\\.[\\w\\d]{1,4}\$/i", $target)) {
    // bugfix
    message("Error: You have no valid IP or host.");
    exit;
}
// Figure out which tasks to perform, and do them
if ($queryType == "all" || $queryType == "lookup") {
    lookup($target);
}
if ($queryType == "all" || $queryType == "dig") {
    dig($target);
}
if ($queryType == "all" || $queryType == "wwwhois") {
    wwwhois($target);
}
if ($queryType == "all" || $queryType == "arin") {
    arin($target);
}
if ($queryType == "all" || $queryType == "checkp") {
    echo "<h3>The function port check is not yet finished and will therefore be skipped;)</h3>";
}
/*checkp($target,$portNum); */
if ($queryType == "all" || $queryType == "p") {
    p($target);
}
if ($queryType == "all" || $queryType == "tr") {