[help] readfile and url

Discussion in 'PHP' started by emalker, Oct 19, 2010.

  1. #1
    I have a PHP file which is loaded with the following on another site:
    <? Php read file ("http://abc.com/xxxx.php");?>

    Can you write something into the PHP-file(http://abc.com/xxxx.php) which shows the URL of the site where the file is loaded?

    I've tried using $_SERVER['PHP_SELF']; but it does not work, I think it's because it is run through the readfile

    Any ideas ?
     
    emalker, Oct 19, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    well assuming xxxx.php exists within the root/base directory, you can do:

    <?php readfile("http://{$_SERVER['HTTP_HOST']}/xxxx.php");?>
    PHP:
     
    danx10, Oct 19, 2010 IP
  3. emalker

    emalker Active Member

    Messages:
    91
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #3
    The idea is good. But I can not check if $ _SERVER ['HTTP_HOST'] will be manually changed.
    Therefore it's best the feature is located inside the PHP file (http://abc.com/xxxx.php)
     
    emalker, Oct 19, 2010 IP
  4. emalker

    emalker Active Member

    Messages:
    91
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #4
    I've tried using "include", but it does not work across domains
     
    emalker, Oct 19, 2010 IP
  5. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #5
    Ellaborate? what exactly are you trying to do in more detail? so I can help you better
     
    danx10, Oct 20, 2010 IP
  6. emalker

    emalker Active Member

    Messages:
    91
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #6
    I want to know(track) where this script is loaded <? Php read file ("http://abc.com/xxxx.php");?>
     
    emalker, Oct 20, 2010 IP
  7. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #7
    ThePHPMaster, Oct 20, 2010 IP
  8. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #8
    So is http://abc.com/xxxx.php always going to be the same (same domain)?
     
    danx10, Oct 21, 2010 IP
  9. AnoxiA

    AnoxiA Peon

    Messages:
    27
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    file_get_content is more usefull,but still you should check php.net for help with setting php.ini to remote file inclusion
     
    AnoxiA, Oct 22, 2010 IP