function next_page($array, $text = 'Next', $var = 'pg') { $current = isset($_GET[$var]) ? $_GET[$var] : 1; $pages = count($array) - 1; if ($current < $pages) { $query = prepare_query(array($var => $current + 1)); return '<a href="?' . $query . '">' . $text . '</a>'; } else { return ''; } }
if ($query || $qttl != '') { echo "<center>"; $input_arr = array(); $pdo = new PDO("mysql:host={$DATABASE};dbname={$DBTABLE}", $DBUSER, $DBPASSWD); if (filter_var($query, FILTER_VALIDATE_IP) || preg_match('/^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5]|\\*)\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5]|\\*)\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5]|\\*)$/', $query) || preg_match('/^[a-f0-9]{1,4}:((\\*|([a-f0-9]{0,4}):){1,6}(\\*|([a-f0-9]{1,4})))$/i', $query)) { $t_query = str_replace('*', '%', $query); $input_arr[':query'] = $t_query; $sql = "SELECT * FROM pdns WHERE answer LIKE :query {$qtype} {$qttl} {$fromdate} {$todate} {$qsort} LIMIT {$DBLIMIT}"; echo "<b>Passive DNS Records for IP: {$query} </b><br><br>"; } elseif (is_numeric($query)) { echo "<b>Passive DNS Records for ASN: {$query} </b> <br><br>"; $sql = "SELECT * FROM pdns WHERE (asn= :query) {$qtype} {$qttl} {$fromdate} {$todate} {$qsort} LIMIT {$DBLIMIT}"; $input_arr[':query'] = $query; } else { echo "<b>Passive DNS Records for Domain: {$query} </b> <br><br>"; $q_str = prepare_query($query, $input_arr); $sql = "SELECT * FROM pdns WHERE ({$q_str}) {$qtype} {$qttl} {$fromdate} {$todate} {$qsort} LIMIT {$DBLIMIT}"; } $stmt = $pdo->prepare($sql); //echo $sql; //var_dump($input_arr); $stmt->execute($input_arr); if ($stmt->rowCount() == 0) { echo '<b>No records found...</b><br><br>'; } else { echo '<table cellpadding="2"><tr><td>#</td><td><b>First Seen</b></td><td><b>Last Seen</b></td><td><b>Type</b></td></td><td><b>Query</b></td><td><b>Answer</b></td><td><b>TTL</b><td><b>ASN</b></td><td><b>Count</b></td></tr>'; echo ' '; $href = "?type=" . urlencode($type) . "&compare=" . urlencode($compare) . "&ttl=" . urlencode($ttl) . "&sort=" . urlencode($sort) . "&dir=" . urlencode($dir); while ($r = $stmt->fetch(PDO::FETCH_ASSOC)) { $a = strtolower($r['ANSWER']); $q = strtolower($r['QUERY']);
static function request_query($query, $endpoint) { return json_decode(file_get_contents(prepare_query($query, $endpoint)), true); }