Forum Moderators: coopster

Message Too Old, No Replies

php include

php include

         

ads112001

2:18 pm on Dec 8, 2010 (gmt 0)

10+ Year Member



I need to create a website that has an online version and a version for internal computers ("kiosks"). The internal version doesn't include a top nav. I don't want to duplicate the entire site just to include the top nav. Is there an easier way to do this without duplicating the entire site?

Readie

10:19 am on Dec 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A simple if statement should suffice. if(!$is_internal) { require_once 'top_menu.php'; }

If the internal version is only going to be for computers on an LAN, you could probably assign true or false to $is_internal based on whether or not the visitors IP begins with "192.168"

SteveWh

10:49 am on Dec 9, 2010 (gmt 0)

10+ Year Member



Something like this?

You'll need a way to determine whether the request is from inside or outside your internal network. I don't know how to do that, but one idea might be to check the visitor's IP.

<?php
// 0=false, 1=true
$forkiosk = 0;
if(preg_match("/^192\.168\.[0-9]{1,3}\.[0-9]{1,3}$/", $_SERVER['REMOTE_ADDR']))
{
$forkiosk = 1;
}

if($forkiosk === 0)
{
include($_SERVER['DOCUMENT_ROOT'] . '/includes/topnav.php');
}