Created
January 17, 2017 07:25
-
-
Save Maikuolan/48cdf3d9d9d50d7ba7a8b1f3efcc5b4c to your computer and use it in GitHub Desktop.
Diagnosing UA problem in CIDRAM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Test file to assist in diagnosing possible problems with user agents in CIDRAM. | |
$CSS = 'style="width:600px;background-color:#ff9;border:1px solid #000"'; | |
echo '<html><body><h4>Test 1: Printing the standard "$_SERVER[\'HTTP_USER_AGENT\']" variable.</h4>'; | |
echo 'Success condition: You should see your UA printed in the box below.<br />'; | |
echo '<input ' . $CSS . ' type="text" value="' . $_SERVER['HTTP_USER_AGENT'] . '" readonly /><br /><br />'; | |
$TestArr = array( | |
'UA' => empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'] | |
); | |
echo '<html><body><h4>Test 2: Assigning "$_SERVER[\'HTTP_USER_AGENT\']" to "$TestArr[\'UA\']" and attempting to print.</h4>'; | |
echo 'Success condition: You should see your UA printed in the box below.<br />'; | |
echo '<input ' . $CSS . ' type="text" value="' . $TestArr['UA'] . '" readonly /><br /><br />'; | |
$TestArr['UALC'] = strtolower($TestArr['UA']); | |
echo '<html><body><h4>Test 3: Converting to lower-case and attempting to print.</h4>'; | |
echo 'Success condition: You should see your UA (in lower-case) printed in the box below.<br />'; | |
echo '<input ' . $CSS . ' type="text" value="' . $TestArr['UALC'] . '" readonly /><br /><br />'; | |
echo '<html><body><h4>Test 4: Attempting to print via a separate scope (emulating a module scope).</h4>'; | |
echo 'Success condition: You should see your UA printed in the box below.<br />'; | |
$Arr = array(0 => 'foo'); | |
array_walk($Arr, function($Var) use (&$TestArr, &$CSS) { | |
echo '<input ' . $CSS . ' type="text" value="' . $TestArr['UA'] . '" readonly /><br /><br />'; | |
}); | |
echo '<html><body><h4>Testing individual signatures.</h4>'; | |
echo 'A small selection of the normally included signatures will be printed, following by a "Yes" or "No", to indicate whether they were triggered by your UA.<br /><br />'; | |
echo '"%(?i)(?=.*opera)(?=.*(?:firefox|msie)).*%" -> '; | |
echo preg_match("%(?i)(?=.*opera)(?=.*(?:firefox|msie)).*%", $TestArr['UA']) ? '<b>Yes</b>' : '<b>No</b>'; | |
echo "<br />"; | |
echo '"%(?i)(?=.*firefox)(?=.*(?:chrom(?:e|ium)|msie)).*%" -> '; | |
echo preg_match("%(?i)(?=.*firefox)(?=.*(?:chrom(?:e|ium)|msie)).*%",$TestArr['UA']) ? '<b>Yes</b>' : '<b>No</b>'; | |
echo "<br />"; | |
echo '"%(?i:(?=(?:.*)(?:mozilla.*){2,})|(?=.*(?:msie.*){2,})).*%" -> '; | |
echo preg_match("%(?i:(?=(?:.*)(?:mozilla.*){2,})|(?=.*(?:msie.*){2,})).*%",$TestArr['UA']) ? '<b>Yes</b>' : '<b>No</b>'; | |
echo "<br /><br />"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment