3v4l.org

run code in 300+ PHP versions simultaneously
<?php //===================================================================================== //Apply real_escape_string to strip out SQL injection function makeSafe($value){ //if (isset($value)){ $value = mysql_real_escape_string($value); $value = $this->clean_html($value); $value = strip_tags(trim($value)); //} return $value; //return mysql_real_escape_string($value); } //===================================================================================== //Clean out html code. From html2txt() in http://us2.php.net/manual/en/function.strip-tags.php function clean_html($document){ $search = array( '@<script[^>]*?>.*?</script>@si', // Strip out javascript '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA ); //Replace any of the patterns listed above $text = preg_replace($search, '', $document); //Replace or remove any illegal characters $text = preg_replace('/;/', ' ', $text); //semicolons $text = preg_replace('/"/', "'", $text); //double quotations $text = preg_replace('/[\%\?\*]/', ' ', $text); //wildcards $text = preg_replace('/[\:\`\$\/\\\=\~\<\>\|\!\^]/', ' ', $text); //other uneeded symbols $text = preg_replace('/[-]{2,}/', '-', $text); //more than 1 dash in a row $text = preg_replace("/[\']{2,}/", "'", $text); //more than 1 single quotation in a row $text = preg_replace("/[\&]{2,}/", '&', $text); //more than 1 ampersand in a row $text = preg_replace("/[ ]{2,}/", ' ', $text); //more than 1 space in a row //And replace any leftover special characters $text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); //Return the value return $text; } $mystring = " Validating data... Done validating... test 123............stdClass Object ( [feedback_text] => Array ( [text] => Robert'); DROP TABLE Stftudents;--' ? Mom [format] => 1 ) [name] => connor - admin, 2 - john [email] => rcooper@c2ti.com [submitbutton] => Submit Feedback [text_len] => 41 )"; $mystring2 = makeSafe($mystring); echo $mystring2;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oDB8h
function name:  (null)
number of ops:  7
compiled vars:  !0 = $mystring, !1 = $mystring2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   ASSIGN                                                   !0, '%0AValidating+data...+Done+validating...+test+123............stdClass+Object%0A%28%0A++++%5Bfeedback_text%5D+%3D%3E+Array%0A++++++++%28%0A++++++++++++%5Btext%5D+%3D%3E+Robert%27%29%3B+DROP+TABLE+Stftudents%3B--%27+%3F+Mom%0A++++++++++++%5Bformat%5D+%3D%3E+1%0A++++++++%29%0A%0A++++%5Bname%5D+%3D%3E+connor+-+admin%2C+2+-+john%0A++++%5Bemail%5D+%3D%3E+rcooper%40c2ti.com%0A++++%5Bsubmitbutton%5D+%3D%3E+Submit+Feedback%0A++++%5Btext_len%5D+%3D%3E+41%0A%29'
   70     1        INIT_FCALL                                               'makesafe'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   71     5        ECHO                                                     !1
          6      > RETURN                                                   1

Function makesafe:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oDB8h
function name:  makeSafe
number of ops:  19
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    9     1        INIT_FCALL_BY_NAME                                       'mysql_real_escape_string'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   10     5        FETCH_THIS                                       $3      
          6        INIT_METHOD_CALL                                         $3, 'clean_html'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $4      
          9        ASSIGN                                                   !0, $4
   11    10        INIT_FCALL                                               'strip_tags'
         11        INIT_FCALL                                               'trim'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $6      
         14        SEND_VAR                                                 $6
         15        DO_ICALL                                         $7      
         16        ASSIGN                                                   !0, $7
   14    17      > RETURN                                                   !0
   16    18*     > RETURN                                                   null

End of function makesafe

Function clean_html:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oDB8h
function name:  clean_html
number of ops:  64
compiled vars:  !0 = $document, !1 = $search, !2 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        ASSIGN                                                   !1, <array>
   35     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !2, $4
   38     8        INIT_FCALL                                               'preg_replace'
          9        SEND_VAL                                                 '%2F%3B%2F'
         10        SEND_VAL                                                 '+'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $6      
         13        ASSIGN                                                   !2, $6
   39    14        INIT_FCALL                                               'preg_replace'
         15        SEND_VAL                                                 '%2F%22%2F'
         16        SEND_VAL                                                 '%27'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                         $8      
         19        ASSIGN                                                   !2, $8
   40    20        INIT_FCALL                                               'preg_replace'
         21        SEND_VAL                                                 '%2F%5B%5C%25%5C%3F%5C%2A%5D%2F'
         22        SEND_VAL                                                 '+'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $10     
         25        ASSIGN                                                   !2, $10
   41    26        INIT_FCALL                                               'preg_replace'
         27        SEND_VAL                                                 '%2F%5B%5C%3A%5C%60%5C%24%5C%2F%5C%5C%3D%5C%7E%5C%3C%5C%3E%5C%7C%5C%21%5C%5E%5D%2F'
         28        SEND_VAL                                                 '+'
         29        SEND_VAR                                                 !2
         30        DO_ICALL                                         $12     
         31        ASSIGN                                                   !2, $12
   42    32        INIT_FCALL                                               'preg_replace'
         33        SEND_VAL                                                 '%2F%5B-%5D%7B2%2C%7D%2F'
         34        SEND_VAL                                                 '-'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                         $14     
         37        ASSIGN                                                   !2, $14
   43    38        INIT_FCALL                                               'preg_replace'
         39        SEND_VAL                                                 '%2F%5B%5C%27%5D%7B2%2C%7D%2F'
         40        SEND_VAL                                                 '%27'
         41        SEND_VAR                                                 !2
         42        DO_ICALL                                         $16     
         43        ASSIGN                                                   !2, $16
   44    44        INIT_FCALL                                               'preg_replace'
         45        SEND_VAL                                                 '%2F%5B%5C%26%5D%7B2%2C%7D%2F'
         46        SEND_VAL                                                 '%26'
         47        SEND_VAR                                                 !2
         48        DO_ICALL                                         $18     
         49        ASSIGN                                                   !2, $18
   45    50        INIT_FCALL                                               'preg_replace'
         51        SEND_VAL                                                 '%2F%5B+%5D%7B2%2C%7D%2F'
         52        SEND_VAL                                                 '+'
         53        SEND_VAR                                                 !2
         54        DO_ICALL                                         $20     
         55        ASSIGN                                                   !2, $20
   48    56        INIT_FCALL                                               'htmlspecialchars'
         57        SEND_VAR                                                 !2
         58        SEND_VAL                                                 3
         59        SEND_VAL                                                 'UTF-8'
         60        DO_ICALL                                         $22     
         61        ASSIGN                                                   !2, $22
   51    62      > RETURN                                                   !2
   52    63*     > RETURN                                                   null

End of function clean_html

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.47 ms | 1407 KiB | 22 Q