Captive portal, In over my head.

Alright, my head hurts cause I am banging my head against the wall. I have used code from a website to make a captive portal, for a hotel. My problem is its working, actually working good. I just don’t know how to make the site redirect to a sight after the PHP code works. Can someone help me? Here is the code. let me know how bad it really is:

[php]

<?php $server_name = "www"; $domain_name = "not.com"; $site_name = "Test Set"; // Path to the arp command on the local server $arp = "/usr/sbin/arp"; // The following file is used to keep track of users $users = "/var/lib/users"; // Check if we've been redirected by firewall to here. // If so redirect to registration address if ($_SERVER['SERVER_NAME']!="$server_name.$domain_name") { header("location:http://$server_name.$domain_name/index.php?add=" .urlencode($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'])); exit; } // Attempt to get the client's mac address $mac = shell_exec("$arp -a ".$_SERVER['REMOTE_ADDR']); preg_match('/..:..:..:..:..:../',$mac , $matches); @$mac = $matches[0]; if (!isset($mac)) { exit; } if (!isset($_POST['email']) || !isset($_POST['name'])) { // Name or email address not entered therefore display form ?> <?php } else { enable_address(); } // This function enables the PC on the system by calling iptables, and also saving the // details in the users file for next time the firewall is reset function enable_address() { global $name; global $email; global $mac; global $users; file_put_contents($users,$_POST['name']."\t".$_POST['email']."\t" .$_SERVER['REMOTE_ADDR']."\t$mac\t".date("d.m.Y")."\n",FILE_APPEND + LOCK_EX); // Add PC to the firewall exec("sudo iptables -I internet 1 -t mangle -m mac --mac-source $mac -j RETURN"); // The following line removes connection tracking for the PC // This clears any previous (incorrect) route info for the redirection exec("sudo rmtrack ".$_SERVER['REMOTE_ADDR']); sleep(1); header("location:http://".$_GET['add']); exit; } // Function to print page header function print_header() { ?> Welcome to <?php echo $site_name;?> <?php[/php]

which bit of php? don’t have all of it. You have a couple of header locations already in there.

I think both headers as you put it are supposed to be here for that. I remove one or the other and the script stops working. I am going off of this web sight and plugging it in to my HTML for the redirect site…
http://www. andybev.com/index.php/ Using_iptables_and_PHP_to_create_a_captive_portal

Here is the whole code with HTML added. This is just killing me.
All I want it to do it redirect to MY page after authenticating I can not find were I screwed up. I know there is more then one header but ever time I remove them it stops the redirect from working.
[php]<?php

$server_name = “www”;
$domain_name = “spokaneramada.com”;
$site_name = “Ramada at the Spokane Airport”;

// Path to the arp command on the local server
$arp = “/usr/sbin/arp”;

// The following file is used to keep track of users
$users = “/var/lib/users”;

// Check if we’ve been redirected by firewall to here.
// If so redirect to registration address
if ($_SERVER[‘SERVER_NAME’]!="$server_name.$domain_name") {
header(“location:http://$server_name.$domain_name/index.php?add=”
.urlencode($_SERVER[‘SERVER_NAME’].$_SERVER[‘REQUEST_URI’]));
exit;
}

// Attempt to get the client’s mac address
$mac = shell_exec("$arp -a ".$_SERVER[‘REMOTE_ADDR’]);
preg_match(’/…:…:…:…:…:…/’,$mac , $matches);
@$mac = $matches[0];
if (!isset($mac)) { exit; }

if (!isset($_POST[‘email’]) || !isset($_POST[‘name’])) {
// Name or email address not entered therefore display form
?>

Wireless Internet Access Page .bodycopy { font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; font-size: 11px; line-height: 16px} .bodylink { font-family: Verdana, Arial, Helvetica, sans-serif; color: #0066CC; font-size: 11px; line-height: 16px; font-weight: bold} .lrgcopy { font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000; font-size: 12px; line-height: 16px; font-weight: bold} .loginbutton{ border-style:solid; border-width:2px; border-color:#666666; font-family:Verdana,Arial, Helvetica, sans-serif; font-size:12px; font-weight: bold; color:#FFFFFF; background-color:#666666;} .TextBox { font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 11px; color: #333333; text-decoration: none; border: 1px solid #CCCCCC;} .blue11 { font-family:Verdana,Arial,Helvetica,sans-serif; font-size:11px; font-style:normal; color: #346FB6;font-weight:normal;} .red11 { font-family:Verdana,Arial,Helvetica,sans-serif; font-size:11px; font-style:normal; color: #990000;font-weight:normal;} .white11 { font-family:Verdana,Arial,Helvetica,sans-serif; font-size:11px; font-style:normal; color: #FFFFFF;font-weight:normal;}

Terms and conditions

Please read the terms and conditions below.
Fill in the information and press submit to connect.
Wyndham Hotel Group. Terms of Use of Internet TERMS, CONDITIONS AND NOTICES This Hotel offers its guests complimentary high-speed Internet access via its third party Internet provider on an AS IS, AS AVAILABLE basis. This Hotel is neither liable nor responsible for any use, access, and/or connection to the Internet service, or for any transmission or result obtained or produced through use of the Internet service. Prior to use of the high-speed Internet service, the Hotel advises its guests to review the third party Internet provider's applicable terms of use and privacy policy. This site is operated by TLeePC and contains material which is derived in whole or in part from material supplied by TLeePC and other sources. The material on this site is protected by international copyright and trademark laws. You may not modify, copy, reproduce, republish, upload, post, transmit, or distribute in any way any material from this site including code and software. You may download material from this site for your personal, non-commercial use only,provided you keep intact all copyright and other proprietary notices.TLeePC has provided links to and pointers to Internet sites maintained by third parties. Neither TLeePC, its parent or subsidiary companies, nor their affiliates operate or control in any respect any information, products or services on these third-party sites. The materials in this site and the third-party sites are provided AS IS, and without warranties of any kind either express or implied.To the fullest extent permissible pursuant to applicable law, TLeePC disclaims all warranties, express or implied, including, but not limited to, implied warranties of merchantability and fitness for a particular purpose. TLeePC does not warrant that the functions contained in the materials will be uninterrupted or error-free, that defects will be corrected, or that this site, including bulletin boards, or the server that makes it available, are free of viruses or other harmful components.TLeePC does not warrant or make any representations regarding the use or the results of the use of the materials in this site or in third-party sites in terms of their correctness, accuracy, timeliness, reliability, or otherwise. You (and not TLeePC) assume the entire cost of all necessary maintenance, repair, or correction.Under no circumstances, including, but not limited to, negligence, shall TLeePC, its subsidiary and parent companies or affiliates be liable for any direct, indirect, incidental, special or consequential damages that result from the use of, or the inability to use, TLeePC materials. You specifically acknowledge and agree that TLeePC is not liable for any defamatory, offensive or illegal conduct of any user. If you are dissatisfied with any TLeePC material, or with any of TLeePC's terms and conditions, your sole and exclusive remedy is to discontinue using TLeePC.
Your full name:
Your Room number:
For Customer Service Call: 509-998-2079
<?php } else { enable_address(); }

// This function enables the PC on the system by calling iptables, and also saving the
// details in the users file for next time the firewall is reset

function enable_address() {

global $name;
global $email;
global $mac;
global $users;

file_put_contents($users,$_POST['name']."\t".$_POST['email']."\t"
    .$_SERVER['REMOTE_ADDR']."\t$mac\t".date("m.d.Y")."\n",FILE_APPEND + LOCK_EX);

// Add PC to the firewall
exec("sudo iptables -I internet 1 -t mangle -m mac --mac-source $mac -j RETURN");
// The following line removes connection tracking for the PC
// This clears any previous (incorrect) route info for the redirection
exec("sudo rmtrack ".$_SERVER['REMOTE_ADDR']);

echo “User logged in.”;
exit;
}

// Function to print page header
function print_header() {

}

// Function to print page footer
function print_footer() {
echo “”;
echo “”;

}

?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service