Can readfile do this?

Discussion in 'PHP' started by furca, May 17, 2011.

  1. #1
    Hi,

    Here is what I want to do. Thanks in advance for the help!

    1) I want to use <?php readfile("http://othersite.com/names.php") ?> on mysite.com.
    2) I want it to JUST display the text "mysite.com".
    4) I want to use the same <?php readfile("http://othersite.com/names.php") ?> on mysite2.com
    5) I want it to JUST display the text "mysite2.com".

    So ideally, the readfile would say something like..

    IF the domain "mysite.com" is accessing this readfile, please give them the text "mysite.com".
    IF the domain "mysite2.com" is accessing this readfile, please give them the text "mysite2.com"

    How can I make this possible? Basically, I want the value of readfile to change depending on the site accessing it. It's okay if I have to use something other than readfile, just tell me what and how!

    Thank you!
     
    furca, May 17, 2011 IP
  2. x319

    x319 Well-Known Member

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    103
    #2
    Hey,

    Not exactly sure what your trying to do, but if I understand right;

    You can do:

    
    // othersite.com ~ names.php
    print $_GET['site'];
    
    // mysite.com
    readfile('http://othersite.com/names.php?site=mysite.com'); // will output "mysite.com"
    
    // mysite2.com
    readfile('http://othersite.com/names.php?site=mysite2.com'); // will output "mysite2.com"
    
    PHP:
     
    x319, May 17, 2011 IP
  3. bitist

    bitist Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    In names.php to have to check the IP of the mysite.com, mysite2.com somehting like this:
    
    if(IP_mysite) {
        echo "mysite.com";
    } elseif(IP_mysite2) {
        echo "mysite2.com";
    }
    
    Code (markup):
     
    bitist, May 18, 2011 IP