...

View Full Version : What does this code snippet do?



LondonBoy
11-13-2006, 05:45 PM
if(preg_match("/^192.127{1}/", getenv(REMOTE_ADDR))){
define("HOST", "http://192.127.111.306/rea/");
}else{
define("HOST", "http://80.40.255.109/rea/");
}

// Absolut application path.
define("ABS_APP_PATH", DOCUMENT_ROOT.CTXPATH);

The first snippet, does that disallow other ip addresses to access the web page?

sir pannels
11-13-2006, 05:48 PM
The first snippet, does that disallow other ip addresses to access the web page?
It just changes where you look depending on your IP range ...
any IP address that does not start 192.127. is sent to http://80.40.255.109/rea/ rather than http://192.127.111.306/rea

LondonBoy
11-13-2006, 06:14 PM
oh i see, thanks for that.

what about the other snippet:

define("CTXPATH", "rea/");

define("ABS_APP_PATH", DOCUMENT_ROOT.CTXPATH);

what is this doing?

GJay
11-13-2006, 11:14 PM
in that code snippet, nothing is sent anywhere. HOST is (after the code) defined as a different thing depending on the IP-test.

the define() function allows you to set a constant value
i.e.


define('FOO','bar');
echo FOO;

will echo 'bar'

take a look at http://php.net/define



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum