3v4l.org

run code in 300+ PHP versions simultaneously
<?php $scandir = scandir('c:/keycounter'); $stats = array(); foreach($scandir as $filename){ if(substr($filename, -4) !== '.day') continue; $date = substr($filename, 0, -4); $stats[$date]= array('k' => 0, 'm' => 0); $content = file_get_contents('c:/keycounter/'.$filename); $lines = explode("\n", $content); foreach($lines as $line){ if($line === '') { continue; } $exp2 = explode(",", $line); $stats[$date]['k']+=intval($exp2[0]); $stats[$date]['m']+=intval($exp2[1]); } } $kplot = array(); $mplot = array(); foreach($stats as $date => $stat){ $kplot[$date] = $stat['k']; $mplot[$date] = $stat['m']; } function time_flot($data){ ksort($data); $rand = md5(rand(100000,10000000)); $dt = ''; foreach ($data as $key => $val) { $dt.='[' . date('U', strtotime($key)) * 1000 .','. $val . '],'; } ob_start(); ?> <div id="flot-<?php echo $rand ?>" style="height:100%; width: 100%; min-height: 200px; min-width: 300px;"></div> <script type="text/javascript"> $(function() { var d = [<?php echo $dt ?>]; // helper for returning the weekends in a period function weekendAreas(axes) { var markings = [], d = new Date(axes.xaxis.min); // go to the first Saturday d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 1) % 7)); d.setUTCSeconds(0); d.setUTCMinutes(0); d.setUTCHours(0); var i = d.getTime(); // when we dont set yaxis, the rectangle automatically // extends to infinity upwards and downwards do { markings.push({ xaxis: { from: i, to: i + 24 * 60 * 60 * 1000 } }); i += 7 * 24 * 60 * 60 * 1000; } while (i < axes.xaxis.max); return markings; } var options = { xaxis: { mode: "time", tickLength: 5, timeformat: "%d %b", monthNames: ["jan", "feb", "mar", "apr", "mai", "jun", "jul", "aug", "sep", "okt", "nov", "des"] }, selection: { mode: "x" }, grid: { markings: weekendAreas, hoverable: true, }, }; $("<div id='flot-<?php echo $rand ?>-tooltip'></div>").css({ position: "absolute", display: "none", border: "1px solid #ddd", padding: "2px", "background-color": "#eee", opacity: 0.80 }).appendTo("body"); var plot = $.plot("#flot-<?php echo $rand ?>", [d], options); $("#flot-<?php echo $rand ?>").bind("plothover", function (event, pos, item) { if (item) { var x = item.datapoint[0].toFixed(), y = item.datapoint[1].toFixed(); var date = new Date(x * 1); $("#flot-<?php echo $rand ?>-tooltip").html(date.getFullYear()+ "/" + (date.getMonth() + 1) + "/" + date.getDate() + " ("+ y + ")") .css({top: item.pageY+0, left: item.pageX+25}) .fadeIn(200); } else { $("#flot-<?php echo $rand ?>-tooltip").hide(); } }); // now connect the two }); </script> <?php $str = ob_get_contents(); ob_end_clean(); return $str; } ?> <script language="javascript" type="text/javascript" src="jquery-1.9.1.min.js"></script> <script language="javascript" type="text/javascript" src="jquery.flot.js"></script> <script language="javascript" type="text/javascript" src="jquery.flot.time.js"></script> <style> .flot{ background: white; border-radius: 10px; border: 1px solid orange; padding: 10px; margin-bottom: 10px; } </style> <?php echo 'avg_k: ' . intval(array_sum($kplot) / count($kplot)) . '<br/>'; ?> <div class="plot" style="width: 1500px; height: 400px;"> <?php echo time_flot($kplot);?> </div> <br/> <?php echo 'avg_m: ' . intval(array_sum($mplot) / count($mplot)) . '<br/>'; ?> <div class="plot" style="width: 1500px; height: 400px;"> <?php echo time_flot($mplot);?> </div>

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 55
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 55
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 53
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 53
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 37
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 53
Branch analysis from position: 55
2 jumps found. (Code = 77) Position 1 = 59, Position 2 = 68
Branch analysis from position: 59
2 jumps found. (Code = 78) Position 1 = 60, Position 2 = 68
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
Branch analysis from position: 55
filename:       /in/nvWnR
function name:  (null)
number of ops:  101
compiled vars:  !0 = $scandir, !1 = $stats, !2 = $filename, !3 = $date, !4 = $content, !5 = $lines, !6 = $line, !7 = $exp2, !8 = $kplot, !9 = $mplot, !10 = $stat
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'scandir'
          1        SEND_VAL                                                 'c%3A%2Fkeycounter'
          2        DO_ICALL                                         $11     
          3        ASSIGN                                                   !0, $11
    3     4        ASSIGN                                                   !1, <array>
    5     5      > FE_RESET_R                                       $14     !0, ->55
          6    > > FE_FETCH_R                                               $14, !2, ->55
    6     7    >   INIT_FCALL                                               'substr'
          8        SEND_VAR                                                 !2
          9        SEND_VAL                                                 -4
         10        DO_ICALL                                         $15     
         11        IS_NOT_IDENTICAL                                         $15, '.day'
         12      > JMPZ                                                     ~16, ->14
         13    > > JMP                                                      ->6
    7    14    >   INIT_FCALL                                               'substr'
         15        SEND_VAR                                                 !2
         16        SEND_VAL                                                 0
         17        SEND_VAL                                                 -4
         18        DO_ICALL                                         $17     
         19        ASSIGN                                                   !3, $17
    8    20        ASSIGN_DIM                                               !1, !3
         21        OP_DATA                                                  <array>
    9    22        INIT_FCALL                                               'file_get_contents'
         23        CONCAT                                           ~20     'c%3A%2Fkeycounter%2F', !2
         24        SEND_VAL                                                 ~20
         25        DO_ICALL                                         $21     
         26        ASSIGN                                                   !4, $21
   10    27        INIT_FCALL                                               'explode'
         28        SEND_VAL                                                 '%0A'
         29        SEND_VAR                                                 !4
         30        DO_ICALL                                         $23     
         31        ASSIGN                                                   !5, $23
   11    32      > FE_RESET_R                                       $25     !5, ->53
         33    > > FE_FETCH_R                                               $25, !6, ->53
   12    34    >   IS_IDENTICAL                                             !6, ''
         35      > JMPZ                                                     ~26, ->37
   13    36    > > JMP                                                      ->33
   15    37    >   INIT_FCALL                                               'explode'
         38        SEND_VAL                                                 '%2C'
         39        SEND_VAR                                                 !6
         40        DO_ICALL                                         $27     
         41        ASSIGN                                                   !7, $27
   16    42        FETCH_DIM_R                                      ~31     !7, 0
         43        CAST                                          4  ~32     ~31
         44        FETCH_DIM_RW                                     $29     !1, !3
         45        ASSIGN_DIM_OP                +=               1          $29, 'k'
         46        OP_DATA                                                  ~32
   17    47        FETCH_DIM_R                                      ~35     !7, 1
         48        CAST                                          4  ~36     ~35
         49        FETCH_DIM_RW                                     $33     !1, !3
         50        ASSIGN_DIM_OP                +=               1          $33, 'm'
         51        OP_DATA                                                  ~36
   11    52      > JMP                                                      ->33
         53    >   FE_FREE                                                  $25
    5    54      > JMP                                                      ->6
         55    >   FE_FREE                                                  $14
   21    56        ASSIGN                                                   !8, <array>
   22    57        ASSIGN                                                   !9, <array>
   23    58      > FE_RESET_R                                       $39     !1, ->68
         59    > > FE_FETCH_R                                       ~40     $39, !10, ->68
         60    >   ASSIGN                                                   !3, ~40
   24    61        FETCH_DIM_R                                      ~43     !10, 'k'
         62        ASSIGN_DIM                                               !8, !3
         63        OP_DATA                                                  ~43
   25    64        FETCH_DIM_R                                      ~45     !10, 'm'
         65        ASSIGN_DIM                                               !9, !3
         66        OP_DATA                                                  ~45
   23    67      > JMP                                                      ->59
         68    >   FE_FREE                                                  $39
  104    69        ECHO                                                     '%0A%3Cscript+language%3D%22javascript%22+type%3D%22text%2Fjavascript%22+src%3D%22jquery-1.9.1.min.js%22%3E%3C%2Fscript%3E%0A%3Cscript+language%3D%22javascript%22+type%3D%22text%2Fjavascript%22+src%3D%22jquery.flot.js%22%3E%3C%2Fscript%3E%0A%3Cscript+language%3D%22javascript%22+type%3D%22text%2Fjavascript%22+src%3D%22jquery.flot.time.js%22%3E%3C%2Fscript%3E%0A%0A%3Cstyle%3E%0A.flot%7B%0A++++background%3A+white%3B%0A++++border-radius%3A+10px%3B%0A++++border%3A+1px+solid+orange%3B%0A++++padding%3A+10px%3B%0A++++margin-bottom%3A+10px%3B%0A%7D%0A%3C%2Fstyle%3E%0A%0A'
  119    70        INIT_FCALL                                               'array_sum'
         71        SEND_VAR                                                 !8
         72        DO_ICALL                                         $46     
         73        COUNT                                            ~47     !8
         74        DIV                                              ~48     $46, ~47
         75        CAST                                          4  ~49     ~48
         76        CONCAT                                           ~50     'avg_k%3A+', ~49
         77        CONCAT                                           ~51     ~50, '%3Cbr%2F%3E'
         78        ECHO                                                     ~51
  120    79        ECHO                                                     '%3Cdiv+class%3D%22plot%22+style%3D%22width%3A+1500px%3B+height%3A+400px%3B%22%3E%0A'
  121    80        INIT_FCALL                                               'time_flot'
         81        SEND_VAR                                                 !8
         82        DO_FCALL                                      0  $52     
         83        ECHO                                                     $52
  122    84        ECHO                                                     '%3C%2Fdiv%3E%0A%3Cbr%2F%3E%0A'
  124    85        INIT_FCALL                                               'array_sum'
         86        SEND_VAR                                                 !9
         87        DO_ICALL                                         $53     
         88        COUNT                                            ~54     !9
         89        DIV                                              ~55     $53, ~54
         90        CAST                                          4  ~56     ~55
         91        CONCAT                                           ~57     'avg_m%3A+', ~56
         92        CONCAT                                           ~58     ~57, '%3Cbr%2F%3E'
         93        ECHO                                                     ~58
  125    94        ECHO                                                     '%3Cdiv+class%3D%22plot%22+style%3D%22width%3A+1500px%3B+height%3A+400px%3B%22%3E%0A'
  126    95        INIT_FCALL                                               'time_flot'
         96        SEND_VAR                                                 !9
         97        DO_FCALL                                      0  $59     
         98        ECHO                                                     $59
  127    99        ECHO                                                     '%3C%2Fdiv%3E'
        100      > RETURN                                                   1

Function time_flot:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 30
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 30
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/nvWnR
function name:  time_flot
number of ops:  55
compiled vars:  !0 = $data, !1 = $rand, !2 = $dt, !3 = $val, !4 = $key, !5 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        INIT_FCALL                                               'ksort'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
   30     4        INIT_FCALL                                               'md5'
          5        INIT_FCALL                                               'rand'
          6        SEND_VAL                                                 100000
          7        SEND_VAL                                                 10000000
          8        DO_ICALL                                         $7      
          9        SEND_VAR                                                 $7
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !1, $8
   31    12        ASSIGN                                                   !2, ''
   32    13      > FE_RESET_R                                       $11     !0, ->30
         14    > > FE_FETCH_R                                       ~12     $11, !3, ->30
         15    >   ASSIGN                                                   !4, ~12
   33    16        INIT_FCALL                                               'date'
         17        SEND_VAL                                                 'U'
         18        INIT_FCALL                                               'strtotime'
         19        SEND_VAR                                                 !4
         20        DO_ICALL                                         $14     
         21        SEND_VAR                                                 $14
         22        DO_ICALL                                         $15     
         23        MUL                                              ~16     $15, 1000
         24        CONCAT                                           ~17     '%5B', ~16
         25        CONCAT                                           ~18     ~17, '%2C'
         26        CONCAT                                           ~19     ~18, !3
         27        CONCAT                                           ~20     ~19, '%5D%2C'
         28        ASSIGN_OP                                     8          !2, ~20
   32    29      > JMP                                                      ->14
         30    >   FE_FREE                                                  $11
   35    31        INIT_FCALL                                               'ob_start'
         32        DO_ICALL                                                 
   37    33        ECHO                                                     '++++%3Cdiv+id%3D%22flot-'
         34        ECHO                                                     !1
         35        ECHO                                                     '%22+style%3D%22height%3A100%25%3B+width%3A+100%25%3B+min-height%3A+200px%3B+min-width%3A+300px%3B%22%3E%3C%2Fdiv%3E%0A++++%3Cscript+type%3D%22text%2Fjavascript%22%3E%0A+++++++++%24%28function%28%29+%7B%0A+++++++++%09var+d+%3D++%5B'
   40    36        ECHO                                                     !2
         37        ECHO                                                     '%5D%3B%0A+++++++++%09%2F%2F+helper+for+returning+the+weekends+in+a+period%0A+++++++++%09function+weekendAreas%28axes%29+%7B%0A+++++++++%09%09var+markings+%3D+%5B%5D%2C+%0A+++++++++%09++++++++d+%3D+new+Date%28axes.xaxis.min%29%3B%0A+++++++++%09%09%2F%2F+go+to+the+first+Saturday%0A+++++++++%09%09d.setUTCDate%28d.getUTCDate%28%29+-+%28%28d.getUTCDay%28%29+%2B+1%29+%25+7%29%29%3B%0A+++++++++%09%09d.setUTCSeconds%280%29%3B%0A+++++++++%09%09d.setUTCMinutes%280%29%3B%0A+++++++++%09%09d.setUTCHours%280%29%3B%0A+++++++++%09%09var+i+%3D+d.getTime%28%29%3B%0A+++++++++%09%09%2F%2F+when+we+dont+set+yaxis%2C+the+rectangle+automatically%0A+++++++++%09%09%2F%2F+extends+to+infinity+upwards+and+downwards%0A+++++++++%09%09do+%7B%0A+++++++++%09%09%09markings.push%28%7B+xaxis%3A+%7B+from%3A+i%2C+to%3A+i+%2B+24+%2A+60+%2A+60+%2A+1000+%7D+%7D%29%3B%0A+++++++++%09%09%09i+%2B%3D+7+%2A+24+%2A+60+%2A+60+%2A+1000%3B%0A+++++++++%09%09%7D+while+%28i+%3C+axes.xaxis.max%29%3B%0A+++++++++%09%09return+markings%3B%0A+++++++++%09%7D%0A+++++++++%09var+options+%3D+%7B%0A+++++++++%09%09xaxis%3A+%7B%0A+++++++++%09%09%09mode%3A+%22time%22%2C%0A+++++++++%09%09%09tickLength%3A+5%2C%0A+++++++++%09%09%09timeformat%3A+%22%25d+%25b%22%2C%0A+++++++++%09%09%09monthNames%3A+%5B%22jan%22%2C+%22feb%22%2C+%22mar%22%2C+%22apr%22%2C+%22mai%22%2C+%22jun%22%2C+%22jul%22%2C+%22aug%22%2C+%22sep%22%2C+%22okt%22%2C+%22nov%22%2C+%22des%22%5D%0A+++++++++%09%09%7D%2C%0A+++++++++%09%09selection%3A+%7B%0A+++++++++%09%09%09mode%3A+%22x%22%0A+++++++++%09%09%7D%2C%0A+++++++++%09%09grid%3A+%7B%0A+++++++++%09%09%09markings%3A+weekendAreas%2C%0A+++++++++%09%09%09hoverable%3A+true%2C%0A+++++++++%09%09%7D%2C%0A+++++++++%09%7D%3B%0A+++++++++%09%24%28%22%3Cdiv+id%3D%27flot-'
   74    38        ECHO                                                     !1
         39        ECHO                                                     '-tooltip%27%3E%3C%2Fdiv%3E%22%29.css%28%7B%0A+++++++++%09%09position%3A+%22absolute%22%2C%0A+++++++++%09%09display%3A+%22none%22%2C%0A+++++++++%09%09border%3A+%221px+solid+%23ddd%22%2C%0A+++++++++%09%09padding%3A+%222px%22%2C%0A+++++++++%09%09%22background-color%22%3A+%22%23eee%22%2C%0A+++++++++%09%09opacity%3A+0.80%0A+++++++++%09%7D%29.appendTo%28%22body%22%29%3B%0A+++++++++%09var+plot+%3D+%24.plot%28%22%23flot-'
   82    40        ECHO                                                     !1
         41        ECHO                                                     '%22%2C+%5Bd%5D%2C+options%29%3B%0A+++++++++%09%24%28%22%23flot-'
   83    42        ECHO                                                     !1
         43        ECHO                                                     '%22%29.bind%28%22plothover%22%2C+function+%28event%2C+pos%2C+item%29+%7B%0A+++++++++%09%09if+%28item%29+%7B%0A+++++++++%09%09%09var+x+%3D+item.datapoint%5B0%5D.toFixed%28%29%2C%0A+++++++++%09%09%09%09y+%3D+item.datapoint%5B1%5D.toFixed%28%29%3B%0A+++++++++%09%09++++var+date+%3D+new+Date%28x+%2A+1%29%3B%0A+++++++++%09%09%09%24%28%22%23flot-'
   88    44        ECHO                                                     !1
         45        ECHO                                                     '-tooltip%22%29.html%28date.getFullYear%28%29%2B+%22%2F%22+%2B+%28date.getMonth%28%29+%2B+1%29+%2B+%22%2F%22+%2B+date.getDate%28%29+%2B+%22+%28%22%2B+y+%2B+%22%29%22%29%0A+++++++++%09%09%09%09.css%28%7Btop%3A+item.pageY%2B0%2C+left%3A+item.pageX%2B25%7D%29%0A+++++++++%09%09%09%09.fadeIn%28200%29%3B%0A+++++++++%09%09%7D+else+%7B%0A+++++++++%09%09%09%24%28%22%23flot-'
   92    46        ECHO                                                     !1
         47        ECHO                                                     '-tooltip%22%29.hide%28%29%3B%0A+++++++++%09%09%7D%0A+++++++++%09%7D%29%3B%0A+++++++++%09%2F%2F+now+connect+the+two%0A+++++++++%7D%29%3B%0A+++++++++%3C%2Fscript%3E%0A++++'
   99    48        INIT_FCALL                                               'ob_get_contents'
         49        DO_ICALL                                         $23     
         50        ASSIGN                                                   !5, $23
  100    51        INIT_FCALL                                               'ob_end_clean'
         52        DO_ICALL                                                 
  101    53      > RETURN                                                   !5
  102    54*     > RETURN                                                   null

End of function time_flot

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.16 ms | 1415 KiB | 41 Q