3v4l.org

run code in 300+ PHP versions simultaneously
<?php // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $vmDir = '/var/spool/asterisk/voicemail/especial'; $idCustomer = $_SESSION['user_data']['id']; $vmCustomer = $vmDir . '/' . $idCustomer; $req = $_REQUEST['c']; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(in_array($req, array('get', 'del'))) { switch($req) { /** * Ruta para listar mensajes de voz */ case 'get_list': $newVmList = $oldVmList = array(); $response = array(); $index = 0; /* nuevos mensajes de voz */ chdir($vmCustomer . '/INBOX'); array_multisort(array_map('filemtime', ($newVmList = glob("*.txt"))), SORT_DESC, $newVmList); /* archivo mensajes de voz */ chdir($vmCustomer . '/Old'); array_multisort(array_map('filemtime', ($oldVmList = glob("*.txt"))), SORT_DESC, $oldVmList); foreach($newVmList as $file) { $response[$index] = parseVmInfoFile($file, true); $response[$index]['new'] = true; $index++; } foreach($oldVmList as $file) { $response[$index] = parseVmInfoFile($file, false); $response[$index]['new'] = false; $index++; } echo json_encode($response); break; /** * Ruta que se ejecuta para recuperar el fichero de audio * del mensaje y mover los mensajes nuevos al directorio * de archivo */ case 'play': $vmInfo = $_GET['vm_info']; $wavFile = $vmCustomer . '/' . ($new ? 'INBOX' : 'Old') . '/' . basename($vmInfo['file'], '.txt') . '.wav'; $fh = fopen($wavFile, 'rb'); header("Content-Type: audio/wav"); header("Content-Length: " . filesize($wavFile)); fpassthru($fh); break; /** * Ruta para eliminar un mensaje de voz */ case 'del': $vmInfo = $_GET['vm_info']; $txtFile = $vmCustomer . '/' . ($new ? 'INBOX' : 'Old') . '/' . $vmInfo['file']; $wavFile = $vmCustomer . '/' . ($new ? 'INBOX' : 'Old') . '/' . basename($vmInfo['file'], '.txt') . '.wav'; unlink($txtFile); unlink($wavFile); break; } } /** * Parsea la informaciĆ³n contenida en el fichero de txt * asociado al mensaje de voz * * @param string $file Nombre del fichero * @param boolean $new Nuevo mensaje de voz (true) o de * archivo * @return array */ function parseVmInfoFile($file, $new) { $path = $vmCustomer . '/' . ($new ? 'INBOX' : 'Old'); $vmInfo = parse_ini_file($path . '/' . $file); return array( 'callerid' => $vmInfo['callerid'], 'date' => new \DateTime($vmInfo['origdate']), 'duration' => (int)$vmInfo['duration'], 'file' => $file ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 164
Branch analysis from position: 13
5 jumps found. (Code = 188) Position 1 = 21, Position 2 = 92, Position 3 = 129, Position 4 = 164, Position 5 = 14
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 60, Position 2 = 72
Branch analysis from position: 60
2 jumps found. (Code = 78) Position 1 = 61, Position 2 = 72
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
Branch analysis from position: 72
2 jumps found. (Code = 77) Position 1 = 74, Position 2 = 86
Branch analysis from position: 74
2 jumps found. (Code = 78) Position 1 = 75, Position 2 = 86
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
Branch analysis from position: 86
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 86
Branch analysis from position: 72
Branch analysis from position: 92
2 jumps found. (Code = 43) Position 1 = 97, Position 2 = 99
Branch analysis from position: 97
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 99
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 129
2 jumps found. (Code = 43) Position 1 = 134, Position 2 = 136
Branch analysis from position: 134
1 jumps found. (Code = 42) Position 1 = 137
Branch analysis from position: 137
2 jumps found. (Code = 43) Position 1 = 144, Position 2 = 146
Branch analysis from position: 144
1 jumps found. (Code = 42) Position 1 = 147
Branch analysis from position: 147
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 146
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 136
2 jumps found. (Code = 43) Position 1 = 144, Position 2 = 146
Branch analysis from position: 144
Branch analysis from position: 146
Branch analysis from position: 164
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 92
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 129
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 164
Branch analysis from position: 164
Branch analysis from position: 129
Branch analysis from position: 92
Branch analysis from position: 21
Branch analysis from position: 164
filename:       /in/LKR3l
function name:  (null)
number of ops:  165
compiled vars:  !0 = $vmDir, !1 = $idCustomer, !2 = $vmCustomer, !3 = $req, !4 = $newVmList, !5 = $oldVmList, !6 = $response, !7 = $index, !8 = $file, !9 = $vmInfo, !10 = $wavFile, !11 = $new, !12 = $fh, !13 = $txtFile
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2Fvar%2Fspool%2Fasterisk%2Fvoicemail%2Fespecial'
    4     1        FETCH_R                      global              ~15     '_SESSION'
          2        FETCH_DIM_R                                      ~16     ~15, 'user_data'
          3        FETCH_DIM_R                                      ~17     ~16, 'id'
          4        ASSIGN                                                   !1, ~17
    5     5        CONCAT                                           ~19     !0, '%2F'
          6        CONCAT                                           ~20     ~19, !1
          7        ASSIGN                                                   !2, ~20
    6     8        FETCH_R                      global              ~22     '_REQUEST'
          9        FETCH_DIM_R                                      ~23     ~22, 'c'
         10        ASSIGN                                                   !3, ~23
    9    11        IN_ARRAY                                                 !3, <array>
         12      > JMPZ                                                     ~25, ->164
   11    13    > > SWITCH_STRING                                            !3, [ 'get_list':->21, 'play':->92, 'del':->129, ], ->164
   16    14    >   IS_EQUAL                                                 !3, 'get_list'
         15      > JMPNZ                                                    ~26, ->21
   51    16    >   IS_EQUAL                                                 !3, 'play'
         17      > JMPNZ                                                    ~26, ->92
   66    18    >   IS_EQUAL                                                 !3, 'del'
         19      > JMPNZ                                                    ~26, ->129
         20    > > JMP                                                      ->164
   17    21    >   ASSIGN                                           ~27     !5, <array>
         22        ASSIGN                                                   !4, ~27
   18    23        ASSIGN                                                   !6, <array>
   19    24        ASSIGN                                                   !7, 0
   22    25        INIT_FCALL                                               'chdir'
         26        CONCAT                                           ~31     !2, '%2FINBOX'
         27        SEND_VAL                                                 ~31
         28        DO_ICALL                                                 
   23    29        INIT_FCALL                                               'array_multisort'
         30        INIT_FCALL                                               'array_map'
         31        SEND_VAL                                                 'filemtime'
         32        INIT_FCALL                                               'glob'
         33        SEND_VAL                                                 '%2A.txt'
         34        DO_ICALL                                         $33     
         35        ASSIGN                                           ~34     !4, $33
         36        SEND_VAL                                                 ~34
         37        DO_ICALL                                         $35     
         38        SEND_VAL                                                 $35
         39        SEND_VAL                                                 3
         40        SEND_REF                                                 !4
         41        DO_ICALL                                                 
   26    42        INIT_FCALL                                               'chdir'
         43        CONCAT                                           ~37     !2, '%2FOld'
         44        SEND_VAL                                                 ~37
         45        DO_ICALL                                                 
   27    46        INIT_FCALL                                               'array_multisort'
         47        INIT_FCALL                                               'array_map'
         48        SEND_VAL                                                 'filemtime'
         49        INIT_FCALL                                               'glob'
         50        SEND_VAL                                                 '%2A.txt'
         51        DO_ICALL                                         $39     
         52        ASSIGN                                           ~40     !5, $39
         53        SEND_VAL                                                 ~40
         54        DO_ICALL                                         $41     
         55        SEND_VAL                                                 $41
         56        SEND_VAL                                                 3
         57        SEND_REF                                                 !5
         58        DO_ICALL                                                 
   29    59      > FE_RESET_R                                       $43     !4, ->72
         60    > > FE_FETCH_R                                               $43, !8, ->72
   30    61    >   INIT_FCALL_BY_NAME                                       'parseVmInfoFile'
         62        SEND_VAR_EX                                              !8
         63        SEND_VAL_EX                                              <true>
         64        DO_FCALL                                      0  $45     
         65        ASSIGN_DIM                                               !6, !7
         66        OP_DATA                                                  $45
   31    67        FETCH_DIM_W                                      $46     !6, !7
         68        ASSIGN_DIM                                               $46, 'new'
         69        OP_DATA                                                  <true>
   33    70        PRE_INC                                                  !7
   29    71      > JMP                                                      ->60
         72    >   FE_FREE                                                  $43
   36    73      > FE_RESET_R                                       $49     !5, ->86
         74    > > FE_FETCH_R                                               $49, !8, ->86
   37    75    >   INIT_FCALL_BY_NAME                                       'parseVmInfoFile'
         76        SEND_VAR_EX                                              !8
         77        SEND_VAL_EX                                              <false>
         78        DO_FCALL                                      0  $51     
         79        ASSIGN_DIM                                               !6, !7
         80        OP_DATA                                                  $51
   38    81        FETCH_DIM_W                                      $52     !6, !7
         82        ASSIGN_DIM                                               $52, 'new'
         83        OP_DATA                                                  <false>
   40    84        PRE_INC                                                  !7
   36    85      > JMP                                                      ->74
         86    >   FE_FREE                                                  $49
   43    87        INIT_FCALL                                               'json_encode'
         88        SEND_VAR                                                 !6
         89        DO_ICALL                                         $55     
         90        ECHO                                                     $55
   45    91      > JMP                                                      ->164
   52    92    >   FETCH_R                      global              ~56     '_GET'
         93        FETCH_DIM_R                                      ~57     ~56, 'vm_info'
         94        ASSIGN                                                   !9, ~57
   53    95        CONCAT                                           ~59     !2, '%2F'
         96      > JMPZ                                                     !11, ->99
         97    >   QM_ASSIGN                                        ~60     'INBOX'
         98      > JMP                                                      ->100
         99    >   QM_ASSIGN                                        ~60     'Old'
        100    >   CONCAT                                           ~61     ~59, ~60
        101        CONCAT                                           ~62     ~61, '%2F'
   54   102        INIT_FCALL                                               'basename'
        103        FETCH_DIM_R                                      ~63     !9, 'file'
        104        SEND_VAL                                                 ~63
        105        SEND_VAL                                                 '.txt'
        106        DO_ICALL                                         $64     
        107        CONCAT                                           ~65     ~62, $64
        108        CONCAT                                           ~66     ~65, '.wav'
   53   109        ASSIGN                                                   !10, ~66
   56   110        INIT_FCALL                                               'fopen'
        111        SEND_VAR                                                 !10
        112        SEND_VAL                                                 'rb'
        113        DO_ICALL                                         $68     
        114        ASSIGN                                                   !12, $68
   58   115        INIT_FCALL                                               'header'
        116        SEND_VAL                                                 'Content-Type%3A+audio%2Fwav'
        117        DO_ICALL                                                 
   59   118        INIT_FCALL                                               'header'
        119        INIT_FCALL                                               'filesize'
        120        SEND_VAR                                                 !10
        121        DO_ICALL                                         $71     
        122        CONCAT                                           ~72     'Content-Length%3A+', $71
        123        SEND_VAL                                                 ~72
        124        DO_ICALL                                                 
   61   125        INIT_FCALL                                               'fpassthru'
        126        SEND_VAR                                                 !12
        127        DO_ICALL                                                 
   62   128      > JMP                                                      ->164
   67   129    >   FETCH_R                      global              ~75     '_GET'
        130        FETCH_DIM_R                                      ~76     ~75, 'vm_info'
        131        ASSIGN                                                   !9, ~76
   68   132        CONCAT                                           ~78     !2, '%2F'
        133      > JMPZ                                                     !11, ->136
        134    >   QM_ASSIGN                                        ~79     'INBOX'
        135      > JMP                                                      ->137
        136    >   QM_ASSIGN                                        ~79     'Old'
        137    >   CONCAT                                           ~80     ~78, ~79
        138        CONCAT                                           ~81     ~80, '%2F'
        139        FETCH_DIM_R                                      ~82     !9, 'file'
        140        CONCAT                                           ~83     ~81, ~82
        141        ASSIGN                                                   !13, ~83
   69   142        CONCAT                                           ~85     !2, '%2F'
        143      > JMPZ                                                     !11, ->146
        144    >   QM_ASSIGN                                        ~86     'INBOX'
        145      > JMP                                                      ->147
        146    >   QM_ASSIGN                                        ~86     'Old'
        147    >   CONCAT                                           ~87     ~85, ~86
        148        CONCAT                                           ~88     ~87, '%2F'
   70   149        INIT_FCALL                                               'basename'
        150        FETCH_DIM_R                                      ~89     !9, 'file'
        151        SEND_VAL                                                 ~89
        152        SEND_VAL                                                 '.txt'
        153        DO_ICALL                                         $90     
        154        CONCAT                                           ~91     ~88, $90
        155        CONCAT                                           ~92     ~91, '.wav'
   69   156        ASSIGN                                                   !10, ~92
   72   157        INIT_FCALL                                               'unlink'
        158        SEND_VAR                                                 !13
        159        DO_ICALL                                                 
   73   160        INIT_FCALL                                               'unlink'
        161        SEND_VAR                                                 !10
        162        DO_ICALL                                                 
   75   163      > JMP                                                      ->164
   98   164    > > RETURN                                                   1

Function parsevminfofile:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LKR3l
function name:  parseVmInfoFile
number of ops:  29
compiled vars:  !0 = $file, !1 = $new, !2 = $path, !3 = $vmCustomer, !4 = $vmInfo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   88     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   89     2        CONCAT                                           ~5      !3, '%2F'
          3      > JMPZ                                                     !1, ->6
          4    >   QM_ASSIGN                                        ~6      'INBOX'
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~6      'Old'
          7    >   CONCAT                                           ~7      ~5, ~6
          8        ASSIGN                                                   !2, ~7
   90     9        INIT_FCALL                                               'parse_ini_file'
         10        CONCAT                                           ~9      !2, '%2F'
         11        CONCAT                                           ~10     ~9, !0
         12        SEND_VAL                                                 ~10
         13        DO_ICALL                                         $11     
         14        ASSIGN                                                   !4, $11
   93    15        FETCH_DIM_R                                      ~13     !4, 'callerid'
         16        INIT_ARRAY                                       ~14     ~13, 'callerid'
   94    17        NEW                                              $15     'DateTime'
         18        CHECK_FUNC_ARG                                           
         19        FETCH_DIM_FUNC_ARG                               $16     !4, 'origdate'
         20        SEND_FUNC_ARG                                            $16
         21        DO_FCALL                                      0          
         22        ADD_ARRAY_ELEMENT                                ~14     $15, 'date'
   95    23        FETCH_DIM_R                                      ~18     !4, 'duration'
         24        CAST                                          4  ~19     ~18
         25        ADD_ARRAY_ELEMENT                                ~14     ~19, 'duration'
   96    26        ADD_ARRAY_ELEMENT                                ~14     !0, 'file'
         27      > RETURN                                                   ~14
   98    28*     > RETURN                                                   null

End of function parsevminfofile

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.83 ms | 1404 KiB | 37 Q