3v4l.org

run code in 300+ PHP versions simultaneously
<pre> <?php $user = "<username>"; $password = "<password>"; $cameraid = "<camera id>"; //authentification $response = get_web_page("http://diskstation:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=2&account=". $user."&passwd=".$password."&session=SurveillanceStation&format=sid"); //echo $response; $resArr = array(); $resArr = ($response); $resArr = json_decode($response,true); //sid in the array $sid=array(); $sid=$resArr[data]; //echo $sid[sid]; //Request API info: //http://diskstation:5000/webapi/query.cgi?api=SYNO.API.Info&method=Query&version=1&query=SYNO.SurveillanceStation.ExternalRecording //List camera's to find camera ID: //http://diskstation:5000/webapi/_______________________________________________________entry.cgi?api=SYNO.SurveillanceStation.Camera&method=List&version=1&offset=1&limit=30&sid=<sid> //look for: "id": //send Start record $url="http://diskstation:5000/webapi/_______________________________________________________entry.cgi?api=SYNO.SurveillanceStation.ExternalRecording&method=Record&version=2&cameraId=". $cameraid. "&_sid=".$sid[sid]."&action="; //echo 'url: '.$url.'<br />'; $response = get_web_page($url.'start'); sleep(10); $response = get_web_page($url.'stop'); function get_web_page($url) { $options = array (CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle compressed CURLOPT_USERAGENT => "test", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10 ); // stop after 10 redirects $ch = curl_init ( $url ); curl_setopt_array ( $ch, $options ); $content = curl_exec ( $ch ); $err = curl_errno ( $ch ); $errmsg = curl_error ( $ch ); $header = curl_getinfo ( $ch ); $httpCode = curl_getinfo ( $ch, CURLINFO_HTTP_CODE ); curl_close ( $ch ); $header ['errno'] = $err; $header ['errmsg'] = $errmsg; $header ['content'] = $content; echo 'response:<br />'.$content.'<br />'; return $header ['content']; } ?> </pre>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vr0rk
function name:  (null)
number of ops:  45
compiled vars:  !0 = $user, !1 = $password, !2 = $cameraid, !3 = $response, !4 = $resArr, !5 = $sid, !6 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     '%3Cpre%3E%0A'
    3     1        ASSIGN                                                   !0, '%3Cusername%3E'
    4     2        ASSIGN                                                   !1, '%3Cpassword%3E'
    5     3        ASSIGN                                                   !2, '%3Ccamera+id%3E'
    7     4        INIT_FCALL_BY_NAME                                       'get_web_page'
          5        CONCAT                                           ~10     'http%3A%2F%2Fdiskstation%3A5000%2Fwebapi%2Fauth.cgi%3Fapi%3DSYNO.API.Auth%26method%3DLogin%26version%3D2%26account%3D', !0
          6        CONCAT                                           ~11     ~10, '%26passwd%3D'
          7        CONCAT                                           ~12     ~11, !1
          8        CONCAT                                           ~13     ~12, '%26session%3DSurveillanceStation%26format%3Dsid'
          9        SEND_VAL_EX                                              ~13
         10        DO_FCALL                                      0  $14     
         11        ASSIGN                                                   !3, $14
    9    12        ASSIGN                                                   !4, <array>
   10    13        ASSIGN                                                   !4, !3
   11    14        INIT_FCALL                                               'json_decode'
         15        SEND_VAR                                                 !3
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $18     
         18        ASSIGN                                                   !4, $18
   13    19        ASSIGN                                                   !5, <array>
   14    20        FETCH_CONSTANT                                   ~21     'data'
         21        FETCH_DIM_R                                      ~22     !4, ~21
         22        ASSIGN                                                   !5, ~22
   22    23        CONCAT                                           ~24     'http%3A%2F%2Fdiskstation%3A5000%2Fwebapi%2F_______________________________________________________entry.cgi%3Fapi%3DSYNO.SurveillanceStation.ExternalRecording%26method%3DRecord%26version%3D2%26cameraId%3D', !2
         24        CONCAT                                           ~25     ~24, '%26_sid%3D'
         25        FETCH_CONSTANT                                   ~26     'sid'
         26        FETCH_DIM_R                                      ~27     !5, ~26
         27        CONCAT                                           ~28     ~25, ~27
         28        CONCAT                                           ~29     ~28, '%26action%3D'
         29        ASSIGN                                                   !6, ~29
   24    30        INIT_FCALL_BY_NAME                                       'get_web_page'
         31        CONCAT                                           ~31     !6, 'start'
         32        SEND_VAL_EX                                              ~31
         33        DO_FCALL                                      0  $32     
         34        ASSIGN                                                   !3, $32
   25    35        INIT_FCALL                                               'sleep'
         36        SEND_VAL                                                 10
         37        DO_ICALL                                                 
   26    38        INIT_FCALL_BY_NAME                                       'get_web_page'
         39        CONCAT                                           ~35     !6, 'stop'
         40        SEND_VAL_EX                                              ~35
         41        DO_FCALL                                      0  $36     
         42        ASSIGN                                                   !3, $36
   52    43        ECHO                                                     '%3C%2Fpre%3E'
         44      > RETURN                                                   1

Function get_web_page:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vr0rk
function name:  get_web_page
number of ops:  65
compiled vars:  !0 = $url, !1 = $options, !2 = $ch, !3 = $content, !4 = $err, !5 = $errmsg, !6 = $header, !7 = $httpCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   28     1        FETCH_CONSTANT                                   ~8      'CURLOPT_RETURNTRANSFER'
          2        INIT_ARRAY                                       ~9      <true>, ~8
   29     3        FETCH_CONSTANT                                   ~10     'CURLOPT_HEADER'
   28     4        ADD_ARRAY_ELEMENT                                ~9      <false>, ~10
   30     5        FETCH_CONSTANT                                   ~11     'CURLOPT_FOLLOWLOCATION'
   28     6        ADD_ARRAY_ELEMENT                                ~9      <true>, ~11
   31     7        FETCH_CONSTANT                                   ~12     'CURLOPT_ENCODING'
          8        ADD_ARRAY_ELEMENT                                ~9      '', ~12
   32     9        FETCH_CONSTANT                                   ~13     'CURLOPT_USERAGENT'
         10        ADD_ARRAY_ELEMENT                                ~9      'test', ~13
   33    11        FETCH_CONSTANT                                   ~14     'CURLOPT_AUTOREFERER'
   28    12        ADD_ARRAY_ELEMENT                                ~9      <true>, ~14
   34    13        FETCH_CONSTANT                                   ~15     'CURLOPT_CONNECTTIMEOUT'
         14        ADD_ARRAY_ELEMENT                                ~9      120, ~15
   35    15        FETCH_CONSTANT                                   ~16     'CURLOPT_TIMEOUT'
         16        ADD_ARRAY_ELEMENT                                ~9      120, ~16
   36    17        FETCH_CONSTANT                                   ~17     'CURLOPT_MAXREDIRS'
         18        ADD_ARRAY_ELEMENT                                ~9      10, ~17
   28    19        ASSIGN                                                   !1, ~9
   37    20        INIT_FCALL_BY_NAME                                       'curl_init'
         21        SEND_VAR_EX                                              !0
         22        DO_FCALL                                      0  $19     
         23        ASSIGN                                                   !2, $19
   38    24        INIT_FCALL_BY_NAME                                       'curl_setopt_array'
         25        SEND_VAR_EX                                              !2
         26        SEND_VAR_EX                                              !1
         27        DO_FCALL                                      0          
   39    28        INIT_FCALL_BY_NAME                                       'curl_exec'
         29        SEND_VAR_EX                                              !2
         30        DO_FCALL                                      0  $22     
         31        ASSIGN                                                   !3, $22
   40    32        INIT_FCALL_BY_NAME                                       'curl_errno'
         33        SEND_VAR_EX                                              !2
         34        DO_FCALL                                      0  $24     
         35        ASSIGN                                                   !4, $24
   41    36        INIT_FCALL_BY_NAME                                       'curl_error'
         37        SEND_VAR_EX                                              !2
         38        DO_FCALL                                      0  $26     
         39        ASSIGN                                                   !5, $26
   42    40        INIT_FCALL_BY_NAME                                       'curl_getinfo'
         41        SEND_VAR_EX                                              !2
         42        DO_FCALL                                      0  $28     
         43        ASSIGN                                                   !6, $28
   43    44        INIT_FCALL_BY_NAME                                       'curl_getinfo'
         45        SEND_VAR_EX                                              !2
         46        FETCH_CONSTANT                                   ~30     'CURLINFO_HTTP_CODE'
         47        SEND_VAL_EX                                              ~30
         48        DO_FCALL                                      0  $31     
         49        ASSIGN                                                   !7, $31
   44    50        INIT_FCALL_BY_NAME                                       'curl_close'
         51        SEND_VAR_EX                                              !2
         52        DO_FCALL                                      0          
   45    53        ASSIGN_DIM                                               !6, 'errno'
         54        OP_DATA                                                  !4
   46    55        ASSIGN_DIM                                               !6, 'errmsg'
         56        OP_DATA                                                  !5
   47    57        ASSIGN_DIM                                               !6, 'content'
         58        OP_DATA                                                  !3
   48    59        CONCAT                                           ~37     'response%3A%3Cbr+%2F%3E', !3
         60        CONCAT                                           ~38     ~37, '%3Cbr+%2F%3E'
         61        ECHO                                                     ~38
   49    62        FETCH_DIM_R                                      ~39     !6, 'content'
         63      > RETURN                                                   ~39
   50    64*     > RETURN                                                   null

End of function get_web_page

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.63 ms | 1404 KiB | 17 Q