including one php file in multiple sites

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rodeored
    Junior Member
    • May 2004
    • 9

    #1

    including one php file in multiple sites

    I have a php file which includes some commonly used functions. These are functions I have been working on for years and I still update them. I include this file on all php pages on all my websites. However, since I have a separate copy of the file on each website, sometimes it is complicated keeping them all updated. Is there a way to have all my websites access the same copy of this file ?

    I have tried to include using
    include "http://oneofmysites.com/functions.php"
    but that doesn't work.
  • -Oz-
    Senior Member
    • Mar 2004
    • 545

    #2
    i think the best/only way to do it is with fopen. include doesn't allow urls.
    Dan Blomberg

    Comment

    • Elite
      Senior Member
      • Apr 2004
      • 168

      #3
      Include does allow urls if "URL fopen wrappers" is enabled - Which I don't think they are at dathorn (for security I assume)...

      Comment

      • Buddha
        Senior Member
        • Mar 2004
        • 825

        #4
        Why not just script the FTP?

        Wrote something similiar in Perl to sync my development and production sites. I solved the common function problem by building my scripts (using Perl again) from a central library.

        Something like ...

        Code:
        #!/user/bin/perl
        use Net::FTP;
        
        $filename = 'c://code/includes/super.php';
        %project = (
          'ftp_username' => 'username_here',
          'ftp_path' => '/httpdocs/includes',
          'ftp_host' => 'ftp.domain.com',
          'ftp_password' => 'password_here'
        );
        
        # Open the connection to the host
        $ftp = Net::FTP->new($project{'ftp_host'});
        $ftp->login($project{'ftp_username'}, $project{'ftp_password'});
        
        # Put the file on the server
        $ftp->put($filename, $project{'ftp_path'});
        
        # All done
        $ftp->quit;
        ... which probably needs some debugging. It's just to give you a general idea how easy it is in Perl. Can do it in PHP too.
        "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

        Comment

        • djn
          Senior Member
          • Mar 2004
          • 140

          #5
          If your websites are all on the same server you might share the thing putting a line
          include_path="/home/yourusername/yourshareddir/"
          into a php.ini file on each website.
          Been using this for a while with a centralized installation of Smarty and AdoDB without a hitch.

          Comment

          • Elite
            Senior Member
            • Apr 2004
            • 168

            #6
            If your websites are all on the same server you might share the thing putting a line
            include_path="/home/yourusername/yourshareddir/"
            into a php.ini file on each website.
            Been using this for a while with a centralized installation of Smarty and AdoDB without a hitch.
            Nice - I like this

            Comment

            • rodeored
              Junior Member
              • May 2004
              • 9

              #7
              Originally posted by djn
              If your websites are all on the same server you might share the thing putting a line
              include_path="/home/yourusername/yourshareddir/"
              into a php.ini file on each website.
              Been using this for a while with a centralized installation of Smarty and AdoDB without a hitch.
              Thanks- that works fine for the sites I have at Dathorn, which eliminates most of my multiple copies of functions problem. Now if I can just get all my web site customers to switch to Dathorn !

              Comment

              Working...