Loading ...
Sorry, an error occurred while loading the content.
 

RE: [phpXperts] ***Detecting requested domain & IP

Expand Messages
  • Muthukumar Selvarasu
    Hi I hope you asking you wanted to record the detection from another-domain.com in my-domain.com Since you included database.php in your another-domain.com
    Message 1 of 4 , Apr 1, 2008

      Hi

       

      I hope you asking you wanted to record the detection from another-domain.com in my-domain.com

       

      Since you included database.php in your another-domain.com from my-domain.com, so you can write the code in database.php @ my-domain.com

       

      If ($_SERVER[‘HTTP_HOST’]==”another-domain.com”) do the code  else do the code…..

       

      I hope you will the path you want to reach 

       

      Thanks,

      Muthukumar Selvarasu,

      Project Manager (Web Development),

      Webmasters Ltd.

       

       

      From: phpexperts@yahoogroups.com [mailto:phpexperts@yahoogroups.com] On Behalf Of A.N.M. Saiful Islam
      Sent: Tuesday, April 01, 2008 7:33 PM
      To: php experts; iiuc porgrammers
      Subject: [phpXperts] ***Detecting requested domain & IP

       

      Dear PHP Xperts,

       

      Let my domain is www.my-domain.com & my IP is 192.168.25.36

       

      Let another domain is www.another-domain.com & its IP is 101.256.23.43

       

      A PHP file is in www.another-domain.com contains the following code:

       

      <?php include “http://www.my-domain.com/header/database.php”; ?>

       

      <link rel='stylesheet' type='text/css' href='http://www.my-domain.com/header/style/common/css/misc.css' />

       

      Now how could I detect that the request to my server (www.my-domain.com & 192.168.25.36) has come, is from www.another-domain.com & 101.256.23.43

       

      *My priority is domain name detection. That is from which domain a request has come.

       

      @Saiful



      Regards,


      Saiful

      A. N. M. Saiful Islam
      www.anm-saiful.info
      email@...

      Chief Executive Officer
      FSclick
      www.fsclick.com

      Founder & Managing Director
      bdport
      www.bdport.com

      Director and Head of the IT Division
      ICT & eShop Development Ltd
      389, Askardigi, West Side, Chittagong

       


      You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.

    • shiplu
      Hello, If http://www.my-domain.com/header/database.php is requested, in database.php $_SERVER[ HTTP_HOST ] will contain www.my-domain.com . It doesnt depend
      Message 2 of 4 , Apr 1, 2008
        Hello,

        If http://www.my-domain.com/header/database.php is requested, in database.php $_SERVER['HTTP_HOST'] will contain "www.my-domain.com". It doesnt depend on the request url at all. it depends on the Host: header that is sent to apache sever on www.my-domain.com. php just captures the Host header and put it in HTTP_HOST variable. if you send a XXX header, php will put it in HTTP_XXX server variable. So it wont work for you.
        However you can use $_SERVER['
        REMOTE_ADDR']. It will contain 101.256.23.43. This is the IP of the domain that is requesting the URI on your server. But you can not detect which domain is requested. because connections are not created by domain. they are created by IP. Though you can use gethostbyaddr() type function to reverse the IP to domain mapping. that will only work if 101.256.23.43 has only one domain. But normally in shared hosting lots of domain is created by domain pointer. In that case gethostbyaddr() wont retrieve the correct domain name.
        So you have to rely on IP address only.

        Hope that helps.

        Thanks

        --
        Shiplu
        Freelance Developer
        http://talk.cmyweb.net/

      Your message has been successfully submitted and would be delivered to recipients shortly.