Jump to content

Need some Syntax help, has some JS.


thaidomizil

Recommended Posts

Hi, i'm trying to show an iframe based on visitor location and some other things which are getting checked through javascript (flash enabled, java installed), i tried to implement it like this:

 

// include functions
include("geoip.inc");

// read GeoIP database
$handle = geoip_open("GeoIP.dat", GEOIP_STANDARD);
$ip = $_SERVER["REMOTE_ADDR"];
$country = geoip_country_name_by_addr($handle, $ip);

$referer = $_SERVER['HTTP_REFERER'];
$referer_parse = parse_url($referer);

if($referer_parse['host'] == "badreferer.com" || $referer_parse['host'] == "www.badreferer.com" or $country !== 'Germany') {
     // do nothing
} else {
     echo '<script type="text/javascript">
var java_enabled = false;
var js_enabled = true;
var flash_enabled = false;
var browser_support = false;
var os_support = false;

var lsBrowser = navigator.userAgent;
if((lsBrowser.indexOf("MSIE") >= 0) || (lsBrowser.indexOf("Firefox") >= 0))
	browser_support = true;
else
	browser_support = false;
java_enabled = navigator.javaEnabled();
if (navigator.appVersion.indexOf("Win") >= 0) os_support = true;
if(navigator.plugins && navigator.plugins["Shockwave Flash"])
	flash_enabled = true;
else if(window.ActiveXObject)
{
	try{
		control = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
		if(control) flash_enabled = true;
	}
	catch(e){
		if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) flash_enabled = true;
	}
}
country = "$country";
if(java_enabled && js_enabled && flash_enabled && browser_support && os_support && (country == "Germany"))
	document.write("<iframe width="700" height="500" src="http://www.iframe.com">");
</script>';
}

 

This gave me no syntax errors but the script doesn't seem to work anymore, the original script (without having changed any " or ') is this:

 

<script type="text/javascript">
var java_enabled = false;
var js_enabled = true;
var flash_enabled = false;
var browser_support = false;
var os_support = false;

var lsBrowser = navigator.userAgent;
if((lsBrowser.indexOf("MSIE") >= 0) || (lsBrowser.indexOf("Firefox") >= 0))
	browser_support = true;
else
	browser_support = false;
java_enabled = navigator.javaEnabled();
if (navigator.appVersion.indexOf("Win") >= 0) os_support = true;
if(navigator.plugins && navigator.plugins["Shockwave Flash"])
	flash_enabled = true;
else if(window.ActiveXObject)
{
	try{
		control = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
		if(control) flash_enabled = true;
	}
	catch(e){
		if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) flash_enabled = true;
	}
}
country = '$country';
if(java_enabled && js_enabled && flash_enabled && browser_support && os_support && (country == 'Germany'))
	document.write("<iframe width='700' height='500' src='http://www.iframe.com'>");
</script>

 

Which works fine, can someone help me please setting the right syntax for the "echo" version, thanks!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.