1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to Include External PHP File into footer.php

Discussion in 'Blogging' started by Claudiu, Mar 31, 2010.

  1. Claudiu

    Claudiu Regular Member

    Joined:
    Feb 28, 2009
    Messages:
    289
    Likes Received:
    81
    Location:
    127.0.0.1
    Hi,

    I have footer.php file in my wpA site and file.php in my wpB website.

    I want to include file.php into footer.php

    i've tried include = 'http://websiteB/file.php' and gets me this error
    I've looked over google and couln't find any trick to solve this ..

    I'm thinking rewriting the function.php might work .. but i don't know what to write there ...

    I'd appreciate some help on this ..
     
    Last edited: Mar 31, 2010
  2. BlackOut

    BlackOut Registered Member

    Joined:
    Jan 25, 2008
    Messages:
    55
    Likes Received:
    30
    Gender:
    Male
    You should use the full path instead of the url in include. So add include("/pathto/websiteb/file.php"); incase websiteb is hosted somewhere else you should copy file.php file to websiteA's folder.
     
  3. corbin2

    corbin2 Registered Member

    Joined:
    Jan 16, 2010
    Messages:
    66
    Likes Received:
    41
    Some Hosts do not allow this kind of includes.
     
  4. namewithnogaps

    namewithnogaps Junior Member

    Joined:
    Mar 28, 2010
    Messages:
    199
    Likes Received:
    74
    usually hosts won't allow including externally hosted files.
     
  5. tpaolo

    tpaolo Regular Member

    Joined:
    May 28, 2009
    Messages:
    333
    Likes Received:
    45
    you should allow base_url module, btw including php files from external sources is a risky practice most servers wouldn't allow when running sharing enviroments

    you better use javascript or, depending on the content of file.php, some scraping tool
     
  6. shaundunne

    shaundunne Registered Member

    Joined:
    Apr 6, 2009
    Messages:
    59
    Likes Received:
    18
    Occupation:
    Codewrangler
    Location:
    London
    Home Page:
    you could try using an iframe.

    include, require and require_once will work if you are including from the same server.
     
  7. Claudiu

    Claudiu Regular Member

    Joined:
    Feb 28, 2009
    Messages:
    289
    Likes Received:
    81
    Location:
    127.0.0.1
    i appreciate your input guys, but it was kinda obvious that i can't use the include as i've posted the include error i got .. anyway .. problem solved with another turnaround trick ..

    for those having similar problem google for - fopen read external file -
     
  8. demoniox

    demoniox Registered Member

    Joined:
    Mar 5, 2007
    Messages:
    98
    Likes Received:
    83
    use this eval(file_get_contents($file));
     
  9. aftershock2020

    aftershock2020 Senior Member

    Joined:
    Oct 19, 2007
    Messages:
    981
    Likes Received:
    477
    Just create a link in your footer to a blank php page, with a header ( ); redirect function to the offer site page leading to your desired target file/source.

    All you do is:

    1. Create a new php page and add it to your site, with the following link in the source code:

    <?php
    header("Location: http://www.your-target-link.here");
    ?>

    2. Create the link in your site footer to this new php page you've just created, within your current site that the visitor with land on.

    They will click the link in the footer and it will take them instantly to the offsite page where whatever file, zip, page, etc. you want to have popup.


    You don't have to worry about the hosts not approving the redirect, as it is standard php practice. However, you do have to be aware of whatever content the visitor is getting on the other end of that link, as it will get you shut down, should it be something unethical. To each their own, just not my bag.
     
    Last edited: Mar 31, 2010
  10. smashedpumpkins

    smashedpumpkins Regular Member

    Joined:
    Mar 3, 2010
    Messages:
    231
    Likes Received:
    84
    Use the following.
    PHP:
    <?php include($_SERVER['DOCUMENT_ROOT'].'/file.php'); ?>
     
  11. asif2bd

    asif2bd Newbie

    Joined:
    Jan 23, 2009
    Messages:
    40
    Likes Received:
    2
    Occupation:
    CEO at ARCom
    Location:
    DK-BD
    Home Page:
    Server fopen function is disabled. try including java file and wrote code at java script, then run java from footer.
     
  12. russaus

    russaus Junior Member

    Joined:
    Mar 5, 2010
    Messages:
    164
    Likes Received:
    17
    Occupation:
    software engineer
    Location:
    /dev/null & canada
    this is not for linking externally (see title)
     
  13. dremy154

    dremy154 Newbie

    Joined:
    Feb 11, 2010
    Messages:
    30
    Likes Received:
    3
    for anyone else that needs to know how to do this, it depends on your server's php.ini configuration. Most will have this function disabled; however on hostgator, surprisingly they have the variable set to on, and this is in shared hosting!!!

    search this in your php.ini file:
    Code:
    allow_url_include 
    if it is set like this :
    Code:
    allow_url_include = Off
    set it to "On" and save the php.ini

    hope this helps :)
     
  14. dremy154

    dremy154 Newbie

    Joined:
    Feb 11, 2010
    Messages:
    30
    Likes Received:
    3
    Oh, and I will tell you this from experience, if your host is Godaddy, you don't have access to the php.ini file, AND fopen is disabled so you would definitely have to find a workaround. Java sound like a viable alternative, I will check it out.

    peace