3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare (strict_types = 1); // change to if(0) to allow fpm/apache/etc modes.. if (1) { if (php_sapi_name() !== 'cli') { die("for security reasons, only cli mode is allowed."); } } init(); $save_path = ''; // will be set by get_url() $url = get_url(); $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_ENCODING => '', CURLOPT_USERAGENT => '4chan_backuper_php; libcurl/' . (curl_version()['version']) . ' php/' . PHP_VERSION, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_AUTOREFERER => 1, )); $html = fetch($url); m200(); $new_domd = my_dom_loader($html); $new_xp = new DOMXPath($new_domd); if (!file_exists($save_path . "index.html")) { //var_dump(base64_encode($new_domd->saveHTML())); $clone = my_dom_loader($new_domd->saveHTML()); $clone_xp = new DOMXPath($clone); $should_be_removed = (int)($clone_xp->query("//div[@class='thread']")->item(0)->childNodes->length); $removed = 0; foreach ($clone_xp->query("//div[@class='thread']")->item(0)->childNodes as $child) { ++$removed; $child->parentNode->removeChild($child); } if ($removed !== $should_be_removed) { throw new \LogicException("removed: {$removed} - should be removed: {$should_be_removed}"); } file_put_contents($save_path . "index.html", $clone->saveHTML(), LOCK_EX); unset($clone, $clone_xp, $child); } $old_domd = my_dom_loader(file_get_contents($save_path . "index.html")); $old_xp = new DOMXPath($old_domd); $old_thread = $old_xp->query("//div[@class='thread']")->item(0); while (true) { $new_posts = 0; $new_images = 0; foreach ($new_xp->query("//div[@class='thread']//div[contains(@class,'postContainer') and @id]") as $post) { $id = $post->getAttribute("id"); assert(!empty($id)); if ($old_xp->query('//div[@id=' . xpath_quote($id) . ']')->length > 0) { //already processed this post. continue; } $old_thread->appendChild(($post = $old_domd->importNode($post, true))); ++$new_posts; $img = $post->getElementsByTagName("img"); if ($img->length < 1) { continue; } $img = $img->item(0); $a = $old_xp->query("//a[contains(@class,'fileThumb')]", $post); if ($a->length < 1) { continue; } $a = $a->item(0); $full_url = $a->getAttribute("href"); $full_bname = basename($full_url); if (empty($full_url) || empty($full_bname)) { continue; } $thumb_url = $img->getAttribute("src"); $thumb_bname = basename($full_url); if (empty($thumb_url) || empty($thumb_bname)) { continue; } ++$new_images; $thumb_binary = fetch($thumb_url); m200(); $full_binary = fetch($full_url); m200(); file_put_contents($save_path . "images" . DIRECTORY_SEPARATOR . "thumbnails" . DIRECTORY_SEPARATOR . $thumb_bname, $thumb_binary); file_put_contents($save_path . "images" . DIRECTORY_SEPARATOR . $full_bname, $full_binary); $a->setAttribute("href", "images/" . $full_bname); $img->setAttribute("src", "images/thumbnails/" . $thumb_bname); } if ($new_posts > 0 || $new_images > 0) { //file_put_contents($save_path . "index.html", $old_domd->saveHTML(), LOCK_EX); } echo "new posts: {$new_posts} - new images: {$new_images}\n"; $sleeptime = 10; echo "sleeping {$sleeptime} seconds and refetching.."; sleep($sleeptime); echo ".\nfetching again.\n"; $html = fetch($url); m200(); $new_domd = my_dom_loader($html); $new_xp = new DOMXPath($new_domd); } function my_dom_loader(string $html): \DOMDocument { $html = trim($html); if (empty($html)) { //.... } if (false === stripos($html, '<?xml encoding=')) { $html = '<?xml encoding="UTF-8">' . $html; } $ret = @DOMDocument::loadHTML($html, LIBXML_NOBLANKS | LIBXML_NONET | LIBXML_BIGLINES); if (!$ret) { throw new \Exception("failed to create DOMDocument from input html!"); } return $ret; } // "must be http 200" function m200(): void { global $ch; $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($code !== 200) { $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); throw new \RuntimException("expected http \"200 OK\" but got {$code} - url: \"{$url}\""); } } function fetch(string $url, int &$code = null): string { if (substr($url, 0, 2) === "//") { $url = "http:" . $url; } echo "fetching \"{$url}\".."; global $ch; curl_setopt_array($ch, array( CURLOPT_URL => $url, )); $data = curl_exec($ch); if (curl_errno($ch) !== CURLE_OK) { throw new \RuntimeException("curl error: " . curl_errno($ch) . ": " . curl_error($ch)); } $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); echo "http code \"{$code}\"."; return $data; } function get_url(): string { global $argv; global $save_path; if (isset($_REQUEST['url'])) { echo "got url from \$_REQUEST\n"; $url = (string)$_REQUEST['url']; } elseif (!empty($argv) && count($argv) > 1) { echo "got url from \$argv\n"; $url = $argv; unset($url[0]); $url = implode("", $url); } elseif (php_sapi_name() === 'cli') { //interactive mode stream_set_blocking(STDIN, true); echo "enter 4chan url: "; $url = fgets(STDIN); } else { throw new \RuntimeException("url not specified! (and not running interactively)"); } $url = trim($url); if (!preg_match('/^(?:https?\:\/\/)?boards\.4chan\.org\/(?<board_name>.*?)\/.*?\/(?<thread_id>\d+)/', $url, $matches)) { throw new \RuntimeException("url \"{$url}\" does not look like a 4chan board url! - they are supposed to look something like http://boards.4chan.org/hc/thread/1501699#p1508333"); } $board_name = $matches['board_name']; $thread_id = $matches['thread_id']; $url = "http://boards.4chan.org/{$board_name}/thread/{$thread_id}"; echo "url parsed: \"{$url}\"\n"; $save_path = getcwd() . DIRECTORY_SEPARATOR . "backups"; mymkdir($save_path); $save_path .= DIRECTORY_SEPARATOR . $board_name; mymkdir($save_path); $save_path .= DIRECTORY_SEPARATOR . $thread_id; mymkdir($save_path); $save_path .= DIRECTORY_SEPARATOR; mymkdir($save_path . "images"); mymkdir($save_path . "images" . DIRECTORY_SEPARATOR . "thumbnails"); return $url; } function mymkdir(string $path): void { if (is_dir($path)) { return; } echo "making folder \"{$path}\".."; if (!mkdir($path)) { throw new \RuntimeException("ERROR: could not make folder!"); } echo ". done.\n"; } function init() { static $firstrun = true; if ($firstrun !== true) { return; } $firstrun = false; error_reporting(E_ALL); set_error_handler("hhb_exception_error_handler"); // ini_set("log_errors",'On'); // ini_set("display_errors",'On'); // ini_set("log_errors_max_len",'0'); // ini_set("error_prepend_string",'<error>'); // ini_set("error_append_string",'</error>'.PHP_EOL); // ini_set("error_log",__DIR__.DIRECTORY_SEPARATOR.'error_log.php.txt'); assert_options(ASSERT_ACTIVE, 1); assert_options(ASSERT_WARNING, 0); assert_options(ASSERT_QUIET_EVAL, 1); assert_options(ASSERT_CALLBACK, 'hhb_assert_handler'); } function hhb_exception_error_handler($errno, $errstr, $errfile, $errline) { if (!(error_reporting() & $errno)) { // This error code is not included in error_reporting return; } throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } function hhb_assert_handler($file, $line, $code, $desc = null) { $errstr = 'Assertion failed at ' . $file . ':' . $line . ' ' . $desc . ' code: ' . $code; throw new ErrorException($errstr, 0, 1, $file, $line); } //based on https://stackoverflow.com/a/1352556/1067003 function xpath_quote(string $value): string { if (false === strpos($value, '"')) { return '"' . $value . '"'; } if (false === strpos($value, '\'')) { return '\'' . $value . '\''; } // if the value contains both single and double quotes, construct an // expression that concatenates all non-double-quote substrings with // the quotes, e.g.: // // concat("'foo'", '"', "bar") $sb = 'concat('; $substrings = explode('"', $value); for ($i = 0; $i < count($substrings); ++$i) { $needComma = ($i > 0); if ($substrings[$i] !== '') { if ($i > 0) { $sb .= ', '; } $sb .= '"' . $substrings[$i] . '"'; $needComma = true; } if ($i < (count($substrings) - 1)) { if ($needComma) { $sb .= ', '; } $sb .= "'\"'"; } } $sb .= ')'; return $sb; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 1, Position 2 = 6
Branch analysis from position: 1
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 113
Branch analysis from position: 55
2 jumps found. (Code = 77) Position 1 = 84, Position 2 = 91
Branch analysis from position: 84
2 jumps found. (Code = 78) Position 1 = 85, Position 2 = 91
Branch analysis from position: 85
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
Branch analysis from position: 91
2 jumps found. (Code = 43) Position 1 = 94, Position 2 = 102
Branch analysis from position: 94
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 102
1 jumps found. (Code = 42) Position 1 = 300
Branch analysis from position: 300
2 jumps found. (Code = 44) Position 1 = 301, Position 2 = 133
Branch analysis from position: 301
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 133
2 jumps found. (Code = 77) Position 1 = 139, Position 2 = 265
Branch analysis from position: 139
2 jumps found. (Code = 78) Position 1 = 140, Position 2 = 265
Branch analysis from position: 140
2 jumps found. (Code = 43) Position 1 = 162, Position 2 = 163
Branch analysis from position: 162
1 jumps found. (Code = 42) Position 1 = 139
Branch analysis from position: 139
Branch analysis from position: 163
2 jumps found. (Code = 43) Position 1 = 179, Position 2 = 180
Branch analysis from position: 179
1 jumps found. (Code = 42) Position 1 = 139
Branch analysis from position: 139
Branch analysis from position: 180
2 jumps found. (Code = 43) Position 1 = 192, Position 2 = 193
Branch analysis from position: 192
1 jumps found. (Code = 42) Position 1 = 139
Branch analysis from position: 139
Branch analysis from position: 193
2 jumps found. (Code = 47) Position 1 = 207, Position 2 = 209
Branch analysis from position: 207
2 jumps found. (Code = 43) Position 1 = 210, Position 2 = 211
Branch analysis from position: 210
1 jumps found. (Code = 42) Position 1 = 139
Branch analysis from position: 139
Branch analysis from position: 211
2 jumps found. (Code = 47) Position 1 = 221, Position 2 = 223
Branch analysis from position: 221
2 jumps found. (Code = 43) Position 1 = 224, Position 2 = 225
Branch analysis from position: 224
1 jumps found. (Code = 42) Position 1 = 139
Branch analysis from position: 139
Branch analysis from position: 225
1 jumps found. (Code = 42) Position 1 = 139
Branch analysis from position: 139
Branch analysis from position: 223
Branch analysis from position: 209
Branch analysis from position: 265
2 jumps found. (Code = 47) Position 1 = 268, Position 2 = 270
Branch analysis from position: 268
2 jumps found. (Code = 43) Position 1 = 271, Position 2 = 271
Branch analysis from position: 271
2 jumps found. (Code = 44) Position 1 = 301, Position 2 = 133
Branch analysis from position: 301
Branch analysis from position: 133
Branch analysis from position: 271
Branch analysis from position: 270
Branch analysis from position: 265
Branch analysis from position: 91
Branch analysis from position: 113
Branch analysis from position: 6
filename:       /in/74VVU
function name:  (null)
number of ops:  302
compiled vars:  !0 = $save_path, !1 = $url, !2 = $ch, !3 = $html, !4 = $new_domd, !5 = $new_xp, !6 = $clone, !7 = $clone_xp, !8 = $should_be_removed, !9 = $removed, !10 = $child, !11 = $old_domd, !12 = $old_xp, !13 = $old_thread, !14 = $new_posts, !15 = $new_images, !16 = $post, !17 = $id, !18 = $img, !19 = $a, !20 = $full_url, !21 = $full_bname, !22 = $thumb_url, !23 = $thumb_bname, !24 = $thumb_binary, !25 = $full_binary, !26 = $sleeptime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E > > JMPZ                                                     1, ->6
    5     1    >   INIT_FCALL                                               'php_sapi_name'
          2        DO_ICALL                                         $27     
          3        IS_NOT_IDENTICAL                                         $27, 'cli'
          4      > JMPZ                                                     ~28, ->6
    6     5    > > EXIT                                                     'for+security+reasons%2C+only+cli+mode+is+allowed.'
    9     6    >   INIT_FCALL_BY_NAME                                       'init'
          7        DO_FCALL                                      0          
   10     8        ASSIGN                                                   !0, ''
   11     9        INIT_FCALL_BY_NAME                                       'get_url'
         10        DO_FCALL                                      0  $31     
         11        ASSIGN                                                   !1, $31
   12    12        INIT_FCALL_BY_NAME                                       'curl_init'
         13        DO_FCALL                                      0  $33     
         14        ASSIGN                                                   !2, $33
   13    15        INIT_FCALL_BY_NAME                                       'curl_setopt_array'
         16        SEND_VAR_EX                                              !2
   14    17        FETCH_CONSTANT                                   ~35     'CURLOPT_ENCODING'
         18        INIT_ARRAY                                       ~36     '', ~35
   15    19        FETCH_CONSTANT                                   ~37     'CURLOPT_USERAGENT'
         20        INIT_FCALL_BY_NAME                                       'curl_version'
         21        DO_FCALL                                      0  $38     
         22        FETCH_DIM_R                                      ~39     $38, 'version'
         23        CONCAT                                           ~40     '4chan_backuper_php%3B+libcurl%2F', ~39
         24        CONCAT                                           ~41     ~40, '+php%2F'
   14    25        CONCAT                                           ~42     ~41, '8.0.0'
         26        ADD_ARRAY_ELEMENT                                ~36     ~42, ~37
   16    27        FETCH_CONSTANT                                   ~43     'CURLOPT_RETURNTRANSFER'
         28        ADD_ARRAY_ELEMENT                                ~36     1, ~43
   17    29        FETCH_CONSTANT                                   ~44     'CURLOPT_FOLLOWLOCATION'
         30        ADD_ARRAY_ELEMENT                                ~36     1, ~44
   18    31        FETCH_CONSTANT                                   ~45     'CURLOPT_AUTOREFERER'
         32        ADD_ARRAY_ELEMENT                                ~36     1, ~45
         33        SEND_VAL_EX                                              ~36
         34        DO_FCALL                                      0          
   20    35        INIT_FCALL_BY_NAME                                       'fetch'
         36        SEND_VAR_EX                                              !1
         37        DO_FCALL                                      0  $47     
         38        ASSIGN                                                   !3, $47
   21    39        INIT_FCALL_BY_NAME                                       'm200'
         40        DO_FCALL                                      0          
   22    41        INIT_FCALL_BY_NAME                                       'my_dom_loader'
         42        SEND_VAR_EX                                              !3
         43        DO_FCALL                                      0  $50     
         44        ASSIGN                                                   !4, $50
   23    45        NEW                                              $52     'DOMXPath'
         46        SEND_VAR_EX                                              !4
         47        DO_FCALL                                      0          
         48        ASSIGN                                                   !5, $52
   24    49        INIT_FCALL                                               'file_exists'
         50        CONCAT                                           ~55     !0, 'index.html'
         51        SEND_VAL                                                 ~55
         52        DO_ICALL                                         $56     
         53        BOOL_NOT                                         ~57     $56
         54      > JMPZ                                                     ~57, ->113
   26    55    >   INIT_FCALL_BY_NAME                                       'my_dom_loader'
         56        INIT_METHOD_CALL                                         !4, 'saveHTML'
         57        DO_FCALL                                      0  $58     
         58        SEND_VAR_NO_REF_EX                                       $58
         59        DO_FCALL                                      0  $59     
         60        ASSIGN                                                   !6, $59
   27    61        NEW                                              $61     'DOMXPath'
         62        SEND_VAR_EX                                              !6
         63        DO_FCALL                                      0          
         64        ASSIGN                                                   !7, $61
   28    65        INIT_METHOD_CALL                                         !7, 'query'
         66        SEND_VAL_EX                                              '%2F%2Fdiv%5B%40class%3D%27thread%27%5D'
         67        DO_FCALL                                      0  $64     
         68        INIT_METHOD_CALL                                         $64, 'item'
         69        SEND_VAL_EX                                              0
         70        DO_FCALL                                      0  $65     
         71        FETCH_OBJ_R                                      ~66     $65, 'childNodes'
         72        FETCH_OBJ_R                                      ~67     ~66, 'length'
         73        CAST                                          4  ~68     ~67
         74        ASSIGN                                                   !8, ~68
   29    75        ASSIGN                                                   !9, 0
   30    76        INIT_METHOD_CALL                                         !7, 'query'
         77        SEND_VAL_EX                                              '%2F%2Fdiv%5B%40class%3D%27thread%27%5D'
         78        DO_FCALL                                      0  $71     
         79        INIT_METHOD_CALL                                         $71, 'item'
         80        SEND_VAL_EX                                              0
         81        DO_FCALL                                      0  $72     
         82        FETCH_OBJ_R                                      ~73     $72, 'childNodes'
         83      > FE_RESET_R                                       $74     ~73, ->91
         84    > > FE_FETCH_R                                               $74, !10, ->91
   31    85    >   PRE_INC                                                  !9
   32    86        FETCH_OBJ_R                                      ~76     !10, 'parentNode'
         87        INIT_METHOD_CALL                                         ~76, 'removeChild'
         88        SEND_VAR_EX                                              !10
         89        DO_FCALL                                      0          
   30    90      > JMP                                                      ->84
         91    >   FE_FREE                                                  $74
   34    92        IS_NOT_IDENTICAL                                         !9, !8
         93      > JMPZ                                                     ~78, ->102
   35    94    >   NEW                                              $79     'LogicException'
         95        ROPE_INIT                                     4  ~81     'removed%3A+'
         96        ROPE_ADD                                      1  ~81     ~81, !9
         97        ROPE_ADD                                      2  ~81     ~81, '+-+should+be+removed%3A+'
         98        ROPE_END                                      3  ~80     ~81, !8
         99        SEND_VAL_EX                                              ~80
        100        DO_FCALL                                      0          
        101      > THROW                                         0          $79
   37   102    >   INIT_FCALL                                               'file_put_contents'
        103        CONCAT                                           ~84     !0, 'index.html'
        104        SEND_VAL                                                 ~84
        105        INIT_METHOD_CALL                                         !6, 'saveHTML'
        106        DO_FCALL                                      0  $85     
        107        SEND_VAR                                                 $85
        108        SEND_VAL                                                 2
        109        DO_ICALL                                                 
   38   110        UNSET_CV                                                 !6
        111        UNSET_CV                                                 !7
        112        UNSET_CV                                                 !10
   40   113    >   INIT_FCALL_BY_NAME                                       'my_dom_loader'
        114        INIT_FCALL                                               'file_get_contents'
        115        CONCAT                                           ~87     !0, 'index.html'
        116        SEND_VAL                                                 ~87
        117        DO_ICALL                                         $88     
        118        SEND_VAR_NO_REF_EX                                       $88
        119        DO_FCALL                                      0  $89     
        120        ASSIGN                                                   !11, $89
   41   121        NEW                                              $91     'DOMXPath'
        122        SEND_VAR_EX                                              !11
        123        DO_FCALL                                      0          
        124        ASSIGN                                                   !12, $91
   42   125        INIT_METHOD_CALL                                         !12, 'query'
        126        SEND_VAL_EX                                              '%2F%2Fdiv%5B%40class%3D%27thread%27%5D'
        127        DO_FCALL                                      0  $94     
        128        INIT_METHOD_CALL                                         $94, 'item'
        129        SEND_VAL_EX                                              0
        130        DO_FCALL                                      0  $95     
        131        ASSIGN                                                   !13, $95
   43   132      > JMP                                                      ->300
   44   133    >   ASSIGN                                                   !14, 0
   45   134        ASSIGN                                                   !15, 0
   46   135        INIT_METHOD_CALL                                         !5, 'query'
        136        SEND_VAL_EX                                              '%2F%2Fdiv%5B%40class%3D%27thread%27%5D%2F%2Fdiv%5Bcontains%28%40class%2C%27postContainer%27%29+and+%40id%5D'
        137        DO_FCALL                                      0  $99     
        138      > FE_RESET_R                                       $100    $99, ->265
        139    > > FE_FETCH_R                                               $100, !16, ->265
   47   140    >   INIT_METHOD_CALL                                         !16, 'getAttribute'
        141        SEND_VAL_EX                                              'id'
        142        DO_FCALL                                      0  $101    
        143        ASSIGN                                                   !17, $101
   48   144        ASSERT_CHECK                                             
        145        INIT_FCALL                                               'assert'
        146        ISSET_ISEMPTY_CV                                 ~103    !17
        147        BOOL_NOT                                         ~104    ~103
        148        SEND_VAL                                                 ~104
        149        SEND_VAL                                                 'assert%28%21empty%28%24id%29%29'
        150        DO_ICALL                                                 
   49   151        INIT_METHOD_CALL                                         !12, 'query'
        152        INIT_FCALL_BY_NAME                                       'xpath_quote'
        153        SEND_VAR_EX                                              !17
        154        DO_FCALL                                      0  $106    
        155        CONCAT                                           ~107    '%2F%2Fdiv%5B%40id%3D', $106
        156        CONCAT                                           ~108    ~107, '%5D'
        157        SEND_VAL_EX                                              ~108
        158        DO_FCALL                                      0  $109    
        159        FETCH_OBJ_R                                      ~110    $109, 'length'
        160        IS_SMALLER                                               0, ~110
        161      > JMPZ                                                     ~111, ->163
   51   162    > > JMP                                                      ->139
   53   163    >   INIT_METHOD_CALL                                         !13, 'appendChild'
        164        INIT_METHOD_CALL                                         !11, 'importNode'
        165        SEND_VAR_EX                                              !16
        166        SEND_VAL_EX                                              <true>
        167        DO_FCALL                                      0  $112    
        168        ASSIGN                                           ~113    !16, $112
        169        SEND_VAL_EX                                              ~113
        170        DO_FCALL                                      0          
   54   171        PRE_INC                                                  !14
   55   172        INIT_METHOD_CALL                                         !16, 'getElementsByTagName'
        173        SEND_VAL_EX                                              'img'
        174        DO_FCALL                                      0  $116    
        175        ASSIGN                                                   !18, $116
   56   176        FETCH_OBJ_R                                      ~118    !18, 'length'
        177        IS_SMALLER                                               ~118, 1
        178      > JMPZ                                                     ~119, ->180
   57   179    > > JMP                                                      ->139
   59   180    >   INIT_METHOD_CALL                                         !18, 'item'
        181        SEND_VAL_EX                                              0
        182        DO_FCALL                                      0  $120    
        183        ASSIGN                                                   !18, $120
   60   184        INIT_METHOD_CALL                                         !12, 'query'
        185        SEND_VAL_EX                                              '%2F%2Fa%5Bcontains%28%40class%2C%27fileThumb%27%29%5D'
        186        SEND_VAR_EX                                              !16
        187        DO_FCALL                                      0  $122    
        188        ASSIGN                                                   !19, $122
   61   189        FETCH_OBJ_R                                      ~124    !19, 'length'
        190        IS_SMALLER                                               ~124, 1
        191      > JMPZ                                                     ~125, ->193
   62   192    > > JMP                                                      ->139
   64   193    >   INIT_METHOD_CALL                                         !19, 'item'
        194        SEND_VAL_EX                                              0
        195        DO_FCALL                                      0  $126    
        196        ASSIGN                                                   !19, $126
   65   197        INIT_METHOD_CALL                                         !19, 'getAttribute'
        198        SEND_VAL_EX                                              'href'
        199        DO_FCALL                                      0  $128    
        200        ASSIGN                                                   !20, $128
   66   201        INIT_FCALL                                               'basename'
        202        SEND_VAR                                                 !20
        203        DO_ICALL                                         $130    
        204        ASSIGN                                                   !21, $130
   67   205        ISSET_ISEMPTY_CV                                 ~132    !20
        206      > JMPNZ_EX                                         ~132    ~132, ->209
        207    >   ISSET_ISEMPTY_CV                                 ~133    !21
        208        BOOL                                             ~132    ~133
        209    > > JMPZ                                                     ~132, ->211
   68   210    > > JMP                                                      ->139
   70   211    >   INIT_METHOD_CALL                                         !18, 'getAttribute'
        212        SEND_VAL_EX                                              'src'
        213        DO_FCALL                                      0  $134    
        214        ASSIGN                                                   !22, $134
   71   215        INIT_FCALL                                               'basename'
        216        SEND_VAR                                                 !20
        217        DO_ICALL                                         $136    
        218        ASSIGN                                                   !23, $136
   72   219        ISSET_ISEMPTY_CV                                 ~138    !22
        220      > JMPNZ_EX                                         ~138    ~138, ->223
        221    >   ISSET_ISEMPTY_CV                                 ~139    !23
        222        BOOL                                             ~138    ~139
        223    > > JMPZ                                                     ~138, ->225
   73   224    > > JMP                                                      ->139
   75   225    >   PRE_INC                                                  !15
   76   226        INIT_FCALL_BY_NAME                                       'fetch'
        227        SEND_VAR_EX                                              !22
        228        DO_FCALL                                      0  $141    
        229        ASSIGN                                                   !24, $141
   77   230        INIT_FCALL_BY_NAME                                       'm200'
        231        DO_FCALL                                      0          
   78   232        INIT_FCALL_BY_NAME                                       'fetch'
        233        SEND_VAR_EX                                              !20
        234        DO_FCALL                                      0  $144    
        235        ASSIGN                                                   !25, $144
   79   236        INIT_FCALL_BY_NAME                                       'm200'
        237        DO_FCALL                                      0          
   80   238        INIT_FCALL                                               'file_put_contents'
        239        CONCAT                                           ~147    !0, 'images'
        240        CONCAT                                           ~148    ~147, '%2F'
        241        CONCAT                                           ~149    ~148, 'thumbnails'
        242        CONCAT                                           ~150    ~149, '%2F'
        243        CONCAT                                           ~151    ~150, !23
        244        SEND_VAL                                                 ~151
        245        SEND_VAR                                                 !24
        246        DO_ICALL                                                 
   81   247        INIT_FCALL                                               'file_put_contents'
        248        CONCAT                                           ~153    !0, 'images'
        249        CONCAT                                           ~154    ~153, '%2F'
        250        CONCAT                                           ~155    ~154, !21
        251        SEND_VAL                                                 ~155
        252        SEND_VAR                                                 !25
        253        DO_ICALL                                                 
   82   254        INIT_METHOD_CALL                                         !19, 'setAttribute'
        255        SEND_VAL_EX                                              'href'
        256        CONCAT                                           ~157    'images%2F', !21
        257        SEND_VAL_EX                                              ~157
        258        DO_FCALL                                      0          
   83   259        INIT_METHOD_CALL                                         !18, 'setAttribute'
        260        SEND_VAL_EX                                              'src'
        261        CONCAT                                           ~159    'images%2Fthumbnails%2F', !23
        262        SEND_VAL_EX                                              ~159
        263        DO_FCALL                                      0          
   46   264      > JMP                                                      ->139
        265    >   FE_FREE                                                  $100
   85   266        IS_SMALLER                                       ~161    0, !14
        267      > JMPNZ_EX                                         ~161    ~161, ->270
        268    >   IS_SMALLER                                       ~162    0, !15
        269        BOOL                                             ~161    ~162
        270    > > JMPZ                                                     ~161, ->271
   88   271    >   ROPE_INIT                                     5  ~164    'new+posts%3A+'
        272        ROPE_ADD                                      1  ~164    ~164, !14
        273        ROPE_ADD                                      2  ~164    ~164, '+-+new+images%3A+'
        274        ROPE_ADD                                      3  ~164    ~164, !15
        275        ROPE_END                                      4  ~163    ~164, '%0A'
        276        ECHO                                                     ~163
   89   277        ASSIGN                                                   !26, 10
   90   278        ROPE_INIT                                     3  ~169    'sleeping+'
        279        ROPE_ADD                                      1  ~169    ~169, !26
        280        ROPE_END                                      2  ~168    ~169, '+seconds+and+refetching..'
        281        ECHO                                                     ~168
   91   282        INIT_FCALL                                               'sleep'
        283        SEND_VAR                                                 !26
        284        DO_ICALL                                                 
   92   285        ECHO                                                     '.%0Afetching+again.%0A'
   93   286        INIT_FCALL_BY_NAME                                       'fetch'
        287        SEND_VAR_EX                                              !1
        288        DO_FCALL                                      0  $172    
        289        ASSIGN                                                   !3, $172
   94   290        INIT_FCALL_BY_NAME                                       'm200'
        291        DO_FCALL                                      0          
   95   292        INIT_FCALL_BY_NAME                                       'my_dom_loader'
        293        SEND_VAR_EX                                              !3
        294        DO_FCALL                                      0  $175    
        295        ASSIGN                                                   !4, $175
   96   296        NEW                                              $177    'DOMXPath'
        297        SEND_VAR_EX                                              !4
        298        DO_FCALL                                      0          
        299        ASSIGN                                                   !5, $177
   43   300    > > JMPNZ                                                    <true>, ->133
  259   301    > > RETURN                                                   1

Function my_dom_loader:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 7
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 7
filename:       /in/74VVU
function name:  my_dom_loader
number of ops:  32
compiled vars:  !0 = $html, !1 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   99     0  E >   RECV                                             !0      
  101     1        INIT_FCALL                                               'trim'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
  102     5        ISSET_ISEMPTY_CV                                         !0
          6      > JMPZ                                                     ~4, ->7
  105     7    >   INIT_FCALL                                               'stripos'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 '%3C%3Fxml+encoding%3D'
         10        DO_ICALL                                         $5      
         11        TYPE_CHECK                                    4          $5
         12      > JMPZ                                                     ~6, ->15
  106    13    >   CONCAT                                           ~7      '%3C%3Fxml+encoding%3D%22UTF-8%22%3E', !0
         14        ASSIGN                                                   !0, ~7
  108    15    >   BEGIN_SILENCE                                    ~9      
         16        INIT_STATIC_METHOD_CALL                                  'DOMDocument', 'loadHTML'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 4196608
         19        DO_FCALL                                      0  $10     
         20        END_SILENCE                                              ~9
         21        ASSIGN                                                   !1, $10
  109    22        BOOL_NOT                                         ~12     !1
         23      > JMPZ                                                     ~12, ->28
  110    24    >   NEW                                              $13     'Exception'
         25        SEND_VAL_EX           

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
295.93 ms | 1428 KiB | 32 Q