- strtoupper: documentation ( source)
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>