WiFiTech Posted September 27, 2007 Share Posted September 27, 2007 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 https://forums.phpfreaks.com/topic/70928-solved-so-easy-a-caveman-could-do-it-um-i-cant-seem-to-grow-hair/ Share on other sites More sharing options...
effigy Posted September 27, 2007 Share Posted September 27, 2007 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 https://forums.phpfreaks.com/topic/70928-solved-so-easy-a-caveman-could-do-it-um-i-cant-seem-to-grow-hair/#findComment-356573 Share on other sites More sharing options...
WiFiTech Posted September 27, 2007 Author Share Posted September 27, 2007 I like that code, harder to understand but much simpler to deal with, as we add more locations. It looks like we would be able to define the variable value to a coresponding image file by using an array. Thank you for offering that to me effigy. Link to comment https://forums.phpfreaks.com/topic/70928-solved-so-easy-a-caveman-could-do-it-um-i-cant-seem-to-grow-hair/#findComment-356583 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.