Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. <?php
  2. if (!isset($_GET['url']) || !filter_var($_GET['url'], FILTER_VALIDATE_URL)) exit('Incorrect url');
  3. $base_url = parse_url($_GET['url']);
  4. $base = $base_url['scheme'] . '://' . $base_url['host'];
  5. $html = file_get_contents($_GET['url']);
  6. if (!preg_match('/HTTP\/\d\.\d 2\d\d/', $http_response_header[0])) exit('Status: ' . $http_response_header[0]);
  7. printf("%-140s %s\n", $_GET['url'], $http_response_header[0]);
  8. if (!preg_match_all('/href=["\'](.+)["\']/Uis', strip_tags($html, '<a>'), $matches)) exit('No child urls found');
  9. foreach (array_unique($matches[1]) as $url) {
  10.     $child = parse_url($url);
  11.     if (!empty($child['scheme']) && !in_array(strtolower($child['scheme']), ['http', 'https'], true)) continue;
  12.     if (!empty($child['host']) && strtolower($base_url['host']) != strtolower($child['host']) ) continue;
  13.     if (strpos($url, $base) !== 0) $url = $base . '/' . ltrim($url, '/');
  14.     printf("  %-138s %s\n", $url, get_headers($url)[0]);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement