3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Disable time limit to keep the script running set_time_limit(0); // Domain to start crawling $domain = "http://webdevwonders.com"; // Content to search for existence $content = "google-analytics.com/ga.js"; // Tag in which you look for the content $content_tag = "script"; // Name of the output file $output_file = "analytics_domains.txt"; // Maximum urls to check $max_urls_to_check = 100; $rounds = 0; // Array to hold all domains to check $domain_stack = array(); // Maximum size of domain stack $max_size_domain_stack = 1000; // Hash to hold all domains already checked $checked_domains = array(); // Loop through the domains as long as domains are available in the stack // and the maximum number of urls to check is not reached while ($domain != "" && $rounds < $max_urls_to_check) { $doc = new DOMDocument(); // Get the sourcecode of the domain @$doc->loadHTMLFile($domain); $found = false; // Loop through each found tag of the specified type in the dom // and search for the specified content foreach($doc->getElementsByTagName($content_tag) as $tag) { if (strpos($tag->nodeValue, $content)) { $found = true; break; } } // Add the domain to the checked domains hash $checked_domains[$domain] = $found; // Loop through each "a"-tag in the dom // and add its href domain to the domain stack if it is not an internal link foreach($doc->getElementsByTagName('a') as $link) { $href = $link->getAttribute('href'); if (strpos($href, 'http://') !== false && strpos($href, $domain) === false) { $href_array = explode("/", $href); // Keep the domain stack to the predefined max of domains // and only push domains to the stack that have not been checked yet if (count($domain_stack) < $max_size_domain_stack && $checked_domains["http://".$href_array[2]] === null) { array_push($domain_stack, "http://".$href_array[2]); } }; } // Remove all duplicate urls from stack $domain_stack = array_unique($domain_stack); $domain = $domain_stack[0]; // Remove the assigned domain from domain stack unset($domain_stack[0]); // Reorder the domain stack $domain_stack = array_values($domain_stack); $rounds++; } $found_domains = ""; // Add all domains where the specified search string // has been found to the found domains string foreach ($checked_domains as $key => $value) { if ($value) { $found_domains .= $key."\n"; } } echo $found_domains;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 95
Branch analysis from position: 95
2 jumps found. (Code = 46) Position 1 = 97, Position 2 = 99
Branch analysis from position: 97
2 jumps found. (Code = 44) Position 1 = 100, Position 2 = 13
Branch analysis from position: 100
2 jumps found. (Code = 77) Position 1 = 102, Position 2 = 108
Branch analysis from position: 102
2 jumps found. (Code = 78) Position 1 = 103, Position 2 = 108
Branch analysis from position: 103
2 jumps found. (Code = 43) Position 1 = 105, Position 2 = 107
Branch analysis from position: 105
1 jumps found. (Code = 42) Position 1 = 102
Branch analysis from position: 102
Branch analysis from position: 107
Branch analysis from position: 108
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 108
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 36
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 36
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 77) Position 1 = 43, Position 2 = 82
Branch analysis from position: 43
2 jumps found. (Code = 78) Position 1 = 44, Position 2 = 82
Branch analysis from position: 44
2 jumps found. (Code = 46) Position 1 = 54, Position 2 = 60
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 81
Branch analysis from position: 61
2 jumps found. (Code = 46) Position 1 = 69, Position 2 = 74
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 81
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 81
Branch analysis from position: 74
Branch analysis from position: 81
Branch analysis from position: 60
Branch analysis from position: 82
2 jumps found. (Code = 46) Position 1 = 97, Position 2 = 99
Branch analysis from position: 97
Branch analysis from position: 99
Branch analysis from position: 82
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 36
Branch analysis from position: 36
Branch analysis from position: 99
filename:       /in/6nSkX
function name:  (null)
number of ops:  111
compiled vars:  !0 = $domain, !1 = $content, !2 = $content_tag, !3 = $output_file, !4 = $max_urls_to_check, !5 = $rounds, !6 = $domain_stack, !7 = $max_size_domain_stack, !8 = $checked_domains, !9 = $doc, !10 = $found, !11 = $tag, !12 = $link, !13 = $href, !14 = $href_array, !15 = $found_domains, !16 = $value, !17 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'set_time_limit'
          1        SEND_VAL                                                 0
          2        DO_ICALL                                                 
    6     3        ASSIGN                                                   !0, 'http%3A%2F%2Fwebdevwonders.com'
    8     4        ASSIGN                                                   !1, 'google-analytics.com%2Fga.js'
   10     5        ASSIGN                                                   !2, 'script'
   12     6        ASSIGN                                                   !3, 'analytics_domains.txt'
   14     7        ASSIGN                                                   !4, 100
   15     8        ASSIGN                                                   !5, 0
   17     9        ASSIGN                                                   !6, <array>
   19    10        ASSIGN                                                   !7, 1000
   21    11        ASSIGN                                                   !8, <array>
   25    12      > JMP                                                      ->95
   26    13    >   NEW                                              $28     'DOMDocument'
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !9, $28
   29    16        BEGIN_SILENCE                                    ~31     
         17        INIT_METHOD_CALL                                         !9, 'loadHTMLFile'
         18        SEND_VAR_EX                                              !0
         19        DO_FCALL                                      0          
         20        END_SILENCE                                              ~31
   30    21        ASSIGN                                                   !10, <false>
   34    22        INIT_METHOD_CALL                                         !9, 'getElementsByTagName'
         23        SEND_VAR_EX                                              !2
         24        DO_FCALL                                      0  $34     
         25      > FE_RESET_R                                       $35     $34, ->36
         26    > > FE_FETCH_R                                               $35, !11, ->36
   35    27    >   INIT_FCALL                                               'strpos'
         28        FETCH_OBJ_R                                      ~36     !11, 'nodeValue'
         29        SEND_VAL                                                 ~36
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $37     
         32      > JMPZ                                                     $37, ->35
   36    33    >   ASSIGN                                                   !10, <true>
   37    34      > JMP                                                      ->36
   34    35    > > JMP                                                      ->26
         36    >   FE_FREE                                                  $35
   42    37        ASSIGN_DIM                                               !8, !0
         38        OP_DATA                                                  !10
   45    39        INIT_METHOD_CALL                                         !9, 'getElementsByTagName'
         40        SEND_VAL_EX                                              'a'
         41        DO_FCALL                                      0  $40     
         42      > FE_RESET_R                                       $41     $40, ->82
         43    > > FE_FETCH_R                                               $41, !12, ->82
   46    44    >   INIT_METHOD_CALL                                         !12, 'getAttribute'
         45        SEND_VAL_EX                                              'href'
         46        DO_FCALL                                      0  $42     
         47        ASSIGN                                                   !13, $42
   47    48        INIT_FCALL                                               'strpos'
         49        SEND_VAR                                                 !13
         50        SEND_VAL                                                 'http%3A%2F%2F'
         51        DO_ICALL                                         $44     
         52        TYPE_CHECK                                  1018  ~45     $44
         53      > JMPZ_EX                                          ~45     ~45, ->60
         54    >   INIT_FCALL                                               'strpos'
         55        SEND_VAR                                                 !13
         56        SEND_VAR                                                 !0
         57        DO_ICALL                                         $46     
         58        TYPE_CHECK                                    4  ~47     $46
         59        BOOL                                             ~45     ~47
         60    > > JMPZ                                                     ~45, ->81
   48    61    >   INIT_FCALL                                               'explode'
         62        SEND_VAL                                                 '%2F'
         63        SEND_VAR                                                 !13
         64        DO_ICALL                                         $48     
         65        ASSIGN                                                   !14, $48
   51    66        COUNT                                            ~50     !6
         67        IS_SMALLER                                       ~51     ~50, !7
         68      > JMPZ_EX                                          ~51     ~51, ->74
   52    69    >   FETCH_DIM_R                                      ~52     !14, 2
         70        CONCAT                                           ~53     'http%3A%2F%2F', ~52
         71        FETCH_DIM_R                                      ~54     !8, ~53
         72        TYPE_CHECK                                    2  ~55     ~54
         73        BOOL                                             ~51     ~55
         74    > > JMPZ                                                     ~51, ->81
   53    75    >   INIT_FCALL                                               'array_push'
         76        SEND_REF                                                 !6
         77        FETCH_DIM_R                                      ~56     !14, 2
         78        CONCAT                                           ~57     'http%3A%2F%2F', ~56
         79        SEND_VAL                                                 ~57
         80        DO_ICALL                                                 
   45    81    > > JMP                                                      ->43
         82    >   FE_FREE                                                  $41
   59    83        INIT_FCALL                                               'array_unique'
         84        SEND_VAR                                                 !6
         85        DO_ICALL                                         $59     
         86        ASSIGN                                                   !6, $59
   60    87        FETCH_DIM_R                                      ~61     !6, 0
         88        ASSIGN                                                   !0, ~61
   62    89        UNSET_DIM                                                !6, 0
   64    90        INIT_FCALL                                               'array_values'
         91        SEND_VAR                                                 !6
         92        DO_ICALL                                         $63     
         93        ASSIGN                                                   !6, $63
   65    94        PRE_INC                                                  !5
   25    95    >   IS_NOT_EQUAL                                     ~66     !0, ''
         96      > JMPZ_EX                                          ~66     ~66, ->99
         97    >   IS_SMALLER                                       ~67     !5, !4
         98        BOOL                                             ~66     ~67
         99    > > JMPNZ                                                    ~66, ->13
   68   100    >   ASSIGN                                                   !15, ''
   71   101      > FE_RESET_R                                       $69     !8, ->108
        102    > > FE_FETCH_R                                       ~70     $69, !16, ->108
        103    >   ASSIGN                                                   !17, ~70
   72   104      > JMPZ                                                     !16, ->107
   73   105    >   CONCAT                                           ~72     !17, '%0A'
        106        ASSIGN_OP                                     8          !15, ~72
   71   107    > > JMP                                                      ->102
        108    >   FE_FREE                                                  $69
   76   109        ECHO                                                     !15
        110      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.28 ms | 1400 KiB | 25 Q