3v4l.org

run code in 300+ PHP versions simultaneously
function convertLHS( $lhs ) { global $x400Delimiter; $retval = ""; $eles = explode('.',$lhs ); $num = count($eles); if ( $num == 1) $retval = "S=" . strtoupper($eles[0]) . $x400Delimiter; if ( $num == 2) $retval = "S=" . strtoupper($eles[1]) . $x400Delimiter . "G=" . strtoupper($eles[0]) . $x400Delimiter; if ( $num > 2) $retval = "S=" . strtoupper($eles[$num-1]) . $x400Delimiter . getInitials($lhs) . "G=" . strtoupper($eles[0]) . $x400Delimiter; return $retval ; } // domain element // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function convertSubDomain( $domain ) { global $x400Delimiter; $retval = ""; $eles = explode('.',$domain ); $num = count($eles); if ( $num == 1) return "OU=" . strtoupper($eles[0]) . $x400Delimiter; } // sort initials if they exist // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function getInitials($lhs) { global $x400Delimiter; $retval = "I="; $eles = explode('.',$lhs ); $num = count($eles); for ($i=1;$i<$num-1;$i++) { $subStr = $eles[$i]; // test if multiple if (strlen($subStr) > 1) { $arr = str_split($subStr); $subStr = implode('.',$arr); } $retval .= strtoupper($subStr) . '.'; } return rtrim($retval,'.' ). $x400Delimiter; } // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function normaliseX400($x400) { return $x400; } // get the posted search string $searchString = $_GET['searchStr']; $x400 = ""; try { global $x400Prefix; global $x400Postfix; $lhsrhs = explode("@",$searchString); $emailComps['domain'] = $lhsrhs[1]; $emailComps['name'] = $lhsrhs[0]; $emailComps['subdomain'] = explode(".x.gsi.gov.uk",$emailComps['domain'] )[0]; $x400 = normaliseX400 ( convertSubdomain($emailComps['subdomain'] ) . convertLHS($emailComps['name']) ); $x400 = $x400Prefix . $x400 . $x400Postfix; } catch (Exception $e) { throw new Exception( 'Failed to analyse email ['.$searchString.'] ', $e); } //print_r($emailComps); // output the basic html ?> <p>Found a [ <?php echo strtoupper($emailComps['subdomain']); ?> ] confidential other government department address in ( <?php echo $searchString ; ?> ).</p> <p>Click here to email: <a href= "mailto:%3C?php%20echo%20urlencode($x400);%20?%3E"> X.400 address for <?php echo $emailComps['name'] ?> </a><br></p> <address> <?php echo $x400 ?> </address>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9OUdg
function name:  (null)
number of ops:  15
compiled vars:  !0 = $emailComps, !1 = $searchString, !2 = $x400
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     'function+convertLHS%28+%24lhs+%29%0A%7B%0A%0Aglobal+%24x400Delimiter%3B%0A%0A++++%24retval+%3D+%22%22%3B%0A++++++++%24eles+%3D+explode%28%27.%27%2C%24lhs+%29%3B%0A++++++++%24num+%3D++count%28%24eles%29%3B%0A++++++++if+%28+%24num+%3D%3D+1%29%0A+++++++++++%24retval+%3D+%22S%3D%22+.+strtoupper%28%24eles%5B0%5D%29+.+%24x400Delimiter%3B%0A++++++++if+%28+%24num+%3D%3D+2%29%0A+++++++++++%24retval+%3D+%22S%3D%22+.+strtoupper%28%24eles%5B1%5D%29+.+%24x400Delimiter%0A+++++++++++.++%22G%3D%22+.+strtoupper%28%24eles%5B0%5D%29+.+%24x400Delimiter%3B%0A++++++++if+%28+%24num+%3E+2%29%0A+++++++++++%24retval+%3D+%22S%3D%22+.+strtoupper%28%24eles%5B%24num-1%5D%29+.+%24x400Delimiter%0A+++++++++++.+++getInitials%28%24lhs%29%0A+++++++++++.++%22G%3D%22+.+strtoupper%28%24eles%5B0%5D%29+.+%24x400Delimiter%3B%0A+++++++++%0A%0A++++return+%24retval+%3B%0A%7D%0A%0A%2F%2F+domain+element%0A%2F%2F+---------------------------------------%0A%2F%2F+Function+Declaration%0A%2F%2F+----------------------------------------%0A%2F%2F+name%3A++++++++%0A%2F%2F+does%3A++++++++%0A%2F%2F+accepts%3A+%0A%2F%2F+returns%3A+%0Afunction+convertSubDomain%28+%24domain+%29%0A%7B%0A%0Aglobal+%24x400Delimiter%3B%0A++++%24retval+%3D+%22%22%3B%0A++++++++%24eles+%3D+explode%28%27.%27%2C%24domain+%29%3B%0A++++++++%24num+%3D++count%28%24eles%29%3B%0A++++++++if+%28+%24num+%3D%3D+1%29%0A+++++++++++return+%22OU%3D%22+.+strtoupper%28%24eles%5B0%5D%29+.+%24x400Delimiter%3B%0A%0A%7D%0A%0A%0A%2F%2F+sort+initials+if+they+exist%0A%2F%2F+---------------------------------------%0A%2F%2F+Function+Declaration%0A%2F%2F+----------------------------------------%0A%2F%2F+name%3A++++++++%0A%2F%2F+does%3A++++++++%0A%2F%2F+accepts%3A+%0A%2F%2F+returns%3A+%0Afunction+getInitials%28%24lhs%29%0A%7B%0A%0Aglobal+%24x400Delimiter%3B%0A++++%24retval+%3D+%22I%3D%22%3B%0A++++++++%24eles+%3D+explode%28%27.%27%2C%24lhs+%29%3B%0A++++++++%24num+%3D++count%28%24eles%29%3B%0A++++++++for+%28%24i%3D1%3B%24i%3C%24num-1%3B%24i%2B%2B%29%0A++++++++%7B%0A+++++++++++%24subStr+%3D+%24eles%5B%24i%5D%3B%0A+++++++++++%2F%2F+test+if+multiple%0A+++++++++++if+%28strlen%28%24subStr%29+%3E+1%29%0A+++++++++++%7B%0A++++++++++++++%24arr+%3D+str_split%28%24subStr%29%3B%0A++++++++++++++++++%24subStr+%3D+implode%28%27.%27%2C%24arr%29%3B%0A+++++++++++%0A+++++++++++%7D%0A+++++++++++%24retval+.%3D+strtoupper%28%24subStr%29+.+%27.%27%3B%0A++++++++%7D%0A++++return+rtrim%28%24retval%2C%27.%27+%29.+%24x400Delimiter%3B%0A%0A%0A%7D%0A%0A%2F%2F+---------------------------------------%0A%2F%2F+Function+Declaration%0A%2F%2F+----------------------------------------%0A%2F%2F+name%3A++++++++%0A%2F%2F+does%3A++++++++%0A%2F%2F+accepts%3A+%0A%2F%2F+returns%3A+%0Afunction+normaliseX400%28%24x400%29%0A%7B%0A%0A%0A++++++++return+%24x400%3B%0A%0A%7D%0A%0A%0A%0A%0A%2F%2F+get+the+posted+search+string%0A+%24searchString+%3D+%24_GET%5B%27searchStr%27%5D%3B+%0A+%24x400+%3D+%22%22%3B%0A%0Atry%0A%7B+%0A%0A%0Aglobal+%24x400Prefix%3B%0Aglobal+%24x400Postfix%3B%0A%0A%0A++++++++%24lhsrhs+%3D+explode%28%22%40%22%2C%24searchString%29%3B%0A++++++++%24emailComps%5B%27domain%27%5D+%3D+%24lhsrhs%5B1%5D%3B%0A++++++++%24emailComps%5B%27name%27%5D+%3D+%24lhsrhs%5B0%5D%3B%0A++++++++%24emailComps%5B%27subdomain%27%5D+%3D+++explode%28%22.x.gsi.gov.uk%22%2C%24emailComps%5B%27domain%27%5D+%29%5B0%5D%3B%0A++++++++%0A++++++++%24x400+%3D+normaliseX400+%28+%0A+++++++++++++++convertSubdomain%28%24emailComps%5B%27subdomain%27%5D+%29+%0A+++++++++++++++++.+convertLHS%28%24emailComps%5B%27name%27%5D%29++%29%3B%0A+++++++++++++++++%0A++++++++%24x400+%3D+%24x400Prefix+.+%24x400+.++%24x400Postfix%3B%0A%0A%7D%0Acatch+%28Exception+%24e%29%0A%7B%0A++throw+new+Exception%28+%27Failed+to+analyse+email+%5B%27.%24searchString.%27%5D+%27%2C+%24e%29%3B%0A+%7D++++++%0A++++++++%2F%2Fprint_r%28%24emailComps%29%3B%0A+%0A+%0A+%2F%2F+output+the+basic+html%0A+%3F%3E%0A%0A%3Cp%3EFound+a+%5B%0A'
  129     1        INIT_FCALL                                               'strtoupper'
          2        FETCH_DIM_R                                      ~3      !0, 'subdomain'
          3        SEND_VAL                                                 ~3
          4        DO_ICALL                                         $4      
          5        ECHO                                                     $4
  130     6        ECHO                                                     '%5D+confidential+other+government+department+address+in+%28%0A'
  131     7        ECHO                                                     !1
  132     8        ECHO                                                     '%29.%3C%2Fp%3E%0A%3Cp%3EClick+here+to+email%3A+%3Ca+href%3D%0A%22mailto%3A%253C%3Fphp%2520echo%2520urlencode%28%24x400%29%3B%2520%3F%253E%22%3E%0AX.400+address%0Afor+%0A'
  137     9        FETCH_DIM_R                                      ~5      !0, 'name'
         10        ECHO                                                     ~5
  138    11        ECHO                                                     '%3C%2Fa%3E%3Cbr%3E%3C%2Fp%3E%0A%3Caddress%3E%0A'
  140    12        ECHO                                                     !2
  141    13        ECHO                                                     '%3C%2Faddress%3E'
         14      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.21 ms | 1400 KiB | 15 Q