Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What does this code snippet do?

    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?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    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

  • #3
    Regular Coder
    Join Date
    Aug 2006
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    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.
    PHP Code:
    define('FOO','bar');
    echo 
    FOO
    will echo 'bar'

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •