I'm trying to write Flash detection in PHP (using VB/JavaScript).
I'm really close to getting it working. I set a variable to "ok" if it detects flash. I can echo it to the page and if I echo the gettype, it says string.
However if I do this:
if ($flashNorm == "ok) {
echo("Flash detected");
}
It doesn't do it.
Here's my code
<?php
// flashCheck
function checkFlashNormal() {
$normalFlash = "
<script type=\"text/javascript\">
var browser = navigator.userAgent.toLowerCase();
__flashVersion = 0;_
____if ( navigator.plugins != null && navigator.plugins.length > 0 ) {
________var flashPlugin = navigator.plugins['Shockwave Flash'];
________if ( typeof flashPlugin == 'object' ) {
____________if ( flashPlugin.description.indexOf('7.') != -1 ) {
document.write('ok');
_________ } _
}
}
</script>";
return $normalFlash;
}
function checkFlashWindows() {
$windowsFlash = "
<script type=\"text/vbscript\">
on error resume next
Dim checkForFlash7
checkForFlash7 = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.7\")))
if checkForFlash7 = true then
document.write('ok')
end if
</script>";
return $windowsFlash;
}
?>
</head>
<body>
<?php
if(!$_SESSION['flash']) {
$flashNorm = checkFlashNormal();
$flashWin = checkFlashWindows();
if($flashNorm == "ok" || $flashWin == "ok") {
echo("Flash detected");
} else {
echo("No flash detected");
}
}
?>