Jump to content

[SOLVED] So easy a caveman could do it... Um, I can't seem to grow hair...


WiFiTech

Recommended Posts

Here is what we do now:

  We set up free hotspots the help promote the sponsor. We have 4 different hardware devices that have 4 different ways of starting RADIUS authentication. By taking the WAN IP we are able to display and image promoting the sponsor (assuming a static IP), and then have a seperate Welcome page for each device type.

 

Here is what I want to do:

  Have a single Welcome Page, that using a variable that doesn't change allows us to display the sponsor content, as well as, the proper logon authentication info.

 

Here is the direction I am heading:

  Using a url variable, ie. https://domain.com/index.php?location=locationid I would like to use ifelse and php include to display the proper sponsor content and Logon method info.

 

Here is what I can settle for:

  Use 4 different pages for the logon, and get a better image/content script that allows for the DHCP style of WAN IP so that we are not having to constantly check every location for a WAN IP change.

 

Thank you for any help that you can offer, I included the current script below if I could get a different variable to use and the syntax on the php include I would be honored...

<?php
if ($_SERVER['REMOTE_ADDR'] == "10.20.30.40")
{ $image = "https://login.domain.com/image/locationimage01.jpg"; }
if ($_SERVER['REMOTE_ADDR'] == "10.20.30.46")
{ $image = "https://login.domain.com/image/locationimage02.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.4")
{ $image = "https://login.domain.com/image/locationimage03.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.41")
{ $image = "https://login.domain.com/image/locationimage04.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.49")
{ $image = "https://login.domain.com/image/locationimage05.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.42")
{ $image = "https://login.domain.com/image/locationimage06.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.4")
{ $image = "https://login.domain.com/image/locationimage07.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.43")
{ $image = "https://login.domain.com/image/locationimage08.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.47")
{ $image = "https://login.domain.com/image/locationimage09.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.48")
{ $image = "https://login.domain.com/image/locationimage10.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.14")
{ $image = "https://login.domain.com/image/locationimage11.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.24")
{ $image = "https://login.domain.com/image/locationimage12.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.34")
{ $image = "https://login.domain.com/image/locationimage13.jpg"; } 
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.54")
{ $image = "https://login.domain.com/image/locationimage14.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.64")
{ $image = "https://login.domain.com/image/locationimage15.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.74")
{ $image = "https://login.domain.com/image/locationimage16.jpg"; }
elseif ($_SERVER['REMOTE_ADDR'] == "10.20.30.84")
{ $image = "https://login.domain.com/image/locationimage17.jpg"; }
else { $image = "https://login.domain.com/image/locationimagedefault.jpg"; }
print "<img src=\"$image\">";
?>
</p>

Link to comment
Share on other sites

I did not absorb all of that, but the code can be improved into a structure like so:

 

<pre>
<?php
$ip_images = array(
	'40' => '1.jpg',
	'46' => '2.jpg'
);
function call_image (&$matches) {
	global $ip_images;
	if (array_key_exists($matches[1], $ip_images)) {
		return '<img src="' . $ip_images[$matches[1]] . '"/>';
	}
	else {
		return null;
	}
}
$ip = '10.20.30.46';
echo preg_replace_callback('/\A(?:\d+\.){3}(\d+)\z/', 'call_image', $ip);
?>
</pre>

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.