3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ExternalLinkController { public function index() { $link = null; if (isset($_GET['link'])) { $link = trim(urldecode($_GET['link'])); } elseif (isset($_GET['u'])) { $link = trim(urldecode($_GET['u'])); } elseif (isset($_GET['q'])) { $link = 'http://search.about.com/?q=' . trim($_GET['q']); $this->insertAppReferral($link); } if ($link) { $this->redirect($link); } else { return show_404(); } } public function ajx() { $link = $_GET['link']; $this->setAboutCookies($link); $response = true; header('Content-type: application/json'); echo json_encode($response); return $this; } private function redirect($link) { if (stripos($link, 'http') !== 0) { $link = 'http://' . $link; } $this->setAboutCookies($link); // Permanent redirection header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $link); exit; } private function setAboutCookies($link) { if (stripos($link, 'about.com') && stripos($link, 'caloriecount.about.com') === false) { $expire = new DateTime('+1800 seconds', new DateTimeZone('GMT')); $secure = false; } } private function insertAppReferral($link) { if (!$link) return false; $master = Db::connect('master'); $sql = sprintf("INSERT INTO app_referal (campaign, ipaddr, date, device, val) VALUES (%s, %s, NOW(), %s, %s)", 'asdf', 'asdf', 'asdf', 'asdf' ); mysqli_query($master, $sql); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Hk4K
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E > > RETURN                                                   1

Class ExternalLinkController:
Function index:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 45
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 27
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 40
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 45
Branch analysis from position: 41
Branch analysis from position: 45
Branch analysis from position: 40
filename:       /in/2Hk4K
function name:  index
number of ops:  49
compiled vars:  !0 = $link
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, null
    6     1        FETCH_IS                                         ~2      '_GET'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~2, 'link'
          3      > JMPZ                                                     ~3, ->14
    7     4    >   INIT_FCALL                                               'trim'
          5        INIT_FCALL                                               'urldecode'
          6        FETCH_R                      global              ~4      '_GET'
          7        FETCH_DIM_R                                      ~5      ~4, 'link'
          8        SEND_VAL                                                 ~5
          9        DO_ICALL                                         $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !0, $7
         13      > JMP                                                      ->40
    8    14    >   FETCH_IS                                         ~9      '_GET'
         15        ISSET_ISEMPTY_DIM_OBJ                         0          ~9, 'u'
         16      > JMPZ                                                     ~10, ->27
    9    17    >   INIT_FCALL                                               'trim'
         18        INIT_FCALL                                               'urldecode'
         19        FETCH_R                      global              ~11     '_GET'
         20        FETCH_DIM_R                                      ~12     ~11, 'u'
         21        SEND_VAL                                                 ~12
         22        DO_ICALL                                         $13     
         23        SEND_VAR                                                 $13
         24        DO_ICALL                                         $14     
         25        ASSIGN                                                   !0, $14
         26      > JMP                                                      ->40
   10    27    >   FETCH_IS                                         ~16     '_GET'
         28        ISSET_ISEMPTY_DIM_OBJ                         0          ~16, 'q'
         29      > JMPZ                                                     ~17, ->40
   11    30    >   INIT_FCALL                                               'trim'
         31        FETCH_R                      global              ~18     '_GET'
         32        FETCH_DIM_R                                      ~19     ~18, 'q'
         33        SEND_VAL                                                 ~19
         34        DO_ICALL                                         $20     
         35        CONCAT                                           ~21     'http%3A%2F%2Fsearch.about.com%2F%3Fq%3D', $20
         36        ASSIGN                                                   !0, ~21
   12    37        INIT_METHOD_CALL                                         'insertAppReferral'
         38        SEND_VAR_EX                                              !0
         39        DO_FCALL                                      0          
   15    40    > > JMPZ                                                     !0, ->45
   16    41    >   INIT_METHOD_CALL                                         'redirect'
         42        SEND_VAR_EX                                              !0
         43        DO_FCALL                                      0          
         44      > JMP                                                      ->48
   18    45    >   INIT_FCALL_BY_NAME                                       'show_404'
         46        DO_FCALL                                      0  $25     
         47      > RETURN                                                   $25
   20    48    > > RETURN                                                   null

End of function index

Function ajx:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Hk4K
function name:  ajx
number of ops:  17
compiled vars:  !0 = $link, !1 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   FETCH_R                      global              ~2      '_GET'
          1        FETCH_DIM_R                                      ~3      ~2, 'link'
          2        ASSIGN                                                   !0, ~3
   24     3        INIT_METHOD_CALL                                         'setAboutCookies'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
   26     6        ASSIGN                                                   !1, <true>
   28     7        INIT_FCALL                                               'header'
          8        SEND_VAL                                                 'Content-type%3A+application%2Fjson'
          9        DO_ICALL                                                 
   29    10        INIT_FCALL                                               'json_encode'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $8      
         13        ECHO                                                     $8
   31    14        FETCH_THIS                                       ~9      
         15      > RETURN                                                   ~9
   32    16*     > RETURN                                                   null

End of function ajx

Function redirect:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 9
filename:       /in/2Hk4K
function name:  redirect
number of ops:  21
compiled vars:  !0 = $link
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   35     1        INIT_FCALL                                               'stripos'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'http'
          4        DO_ICALL                                         $1      
          5        IS_NOT_IDENTICAL                                         $1, 0
          6      > JMPZ                                                     ~2, ->9
   36     7    >   CONCAT                                           ~3      'http%3A%2F%2F', !0
          8        ASSIGN                                                   !0, ~3
   39     9    >   INIT_METHOD_CALL                                         'setAboutCookies'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
   42    12        INIT_FCALL                                               'header'
         13        SEND_VAL                                                 'HTTP%2F1.1+301+Moved+Permanently'
         14        DO_ICALL                                                 
   43    15        INIT_FCALL                                               'header'
         16        CONCAT                                           ~7      'Location%3A+', !0
         17        SEND_VAL                                                 ~7
         18        DO_ICALL                                                 
   44    19      > EXIT                                                     
   45    20*     > RETURN                                                   null

End of function redirect

Function setaboutcookies:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 22
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 12
filename:       /in/2Hk4K
function name:  setAboutCookies
number of ops:  23
compiled vars:  !0 = $link, !1 = $expire, !2 = $secure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
   48     1        INIT_FCALL                                               'stripos'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'about.com'
          4        DO_ICALL                                         $3      
          5      > JMPZ_EX                                          ~4      $3, ->12
          6    >   INIT_FCALL                                               'stripos'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 'caloriecount.about.com'
          9        DO_ICALL                                         $5      
         10        TYPE_CHECK                                    4  ~6      $5
         11        BOOL                                             ~4      ~6
         12    > > JMPZ                                                     ~4, ->22
   49    13    >   NEW                                              $7      'DateTime'
         14        SEND_VAL_EX                                              '%2B1800+seconds'
         15        NEW                                              $8      'DateTimeZone'
         16        SEND_VAL_EX                                              'GMT'
         17        DO_FCALL                                      0          
         18        SEND_VAR_NO_REF_EX                                       $8
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !1, $7
   50    21        ASSIGN                                                   !2, <false>
   52    22    > > RETURN                                                   null

End of function setaboutcookies

Function insertappreferral:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Hk4K
function name:  insertAppReferral
number of ops:  21
compiled vars:  !0 = $link, !1 = $master, !2 = $sql
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
   55     1        BOOL_NOT                                         ~3      !0
          2      > JMPZ                                                     ~3, ->4
          3    > > RETURN                                                   <false>
   57     4    >   INIT_STATIC_METHOD_CALL                                  'Db', 'connect'
          5        SEND_VAL_EX                                              'master'
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !1, $4
   58     8        INIT_FCALL                                               'sprintf'
          9        SEND_VAL                                                 'INSERT+INTO+app_referal+%28campaign%2C+ipaddr%2C+date%2C+device%2C+val%29+VALUES+%28%25s%2C+%25s%2C+NOW%28%29%2C+%25s%2C+%25s%29'
   59    10        SEND_VAL                                                 'asdf'
   60    11        SEND_VAL                                                 'asdf'
   61    12        SEND_VAL                                                 'asdf'
   62    13        SEND_VAL                                                 'asdf'
         14        DO_ICALL                                         $6      
   58    15        ASSIGN                                                   !2, $6
   64    16        INIT_FCALL_BY_NAME                                       'mysqli_query'
         17        SEND_VAR_EX                                              !1
         18        SEND_VAR_EX                                              !2
         19        DO_FCALL                                      0          
   65    20      > RETURN                                                   null

End of function insertappreferral

End of class ExternalLinkController.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.22 ms | 1408 KiB | 25 Q