PHP include question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BSleazy
    Confirmed User
    • Aug 2002
    • 6721

    #1

    PHP include question

    How would I make a little file that I can add links to that shows up on 100's of sites.

    The purpose is to just be able to update one file instead of 100's. Get it?
    icq 156131086
  • BradM
    Confirmed User
    • Dec 2003
    • 3397

    #2
    include("filename.php");

    Comment

    • fris
      Too lazy to set a custom title
      • Aug 2002
      • 55679

      #3
      i do this with a lot of my sites i just edit 1 link file say links.inc

      <?include "http://www.domain.com/links.inc"?>

      on any site you want to do it, and all you have to do is update that one links.inc file
      Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

      Comment

      • BSleazy
        Confirmed User
        • Aug 2002
        • 6721

        #4
        Alright sweat. Thanks guys.
        icq 156131086

        Comment

        • Nookster
          Confirmed IT Professional
          • Nov 2005
          • 3744

          #5
          Yep, the above examples will work for what you need. But I advise that if you use a database in said include do NOT use .inc for the file extension, and like always keep the dbase connection info out of the domain root directory.
          The Best Affiliate Software, Ever.

          Comment

          • u-Bob
            there's no $$$ in porn
            • Jul 2005
            • 33063

            #6
            readfile();

            Comment

            • k0nr4d
              Confirmed User
              • Aug 2006
              • 9231

              #7
              Originally posted by Fris
              i do this with a lot of my sites i just edit 1 link file say links.inc

              <?include "http://www.domain.com/links.inc"?>

              on any site you want to do it, and all you have to do is update that one links.inc file
              That works...
              ...if you want your sites to all load really slowly and use more system resources then they need to...

              Theres lots of methods, best one being
              @include('/var/www/domain.com/links.php'); <-- never name anything .inc because that would read plain text. if you decide at some point to include some php code into the links file, if its named php it will be parsed if someone accesses it directly instead of showing your code to the person using .inc.

              Don't include() over http as thats going to be very if your network lags. If you have to do it across several servers, setup a cron job that will download the links file to the other servers, or rsync, or scp, or whatever you want. If all your domains are on one server, include using the absolute path.
              Last edited by k0nr4d; 02-27-2007, 07:52 PM.
              Mechanical Bunny Media
              Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

              Comment

              • tenderobject
                Need Designs? 312352846
                • Dec 2004
                • 11688

                #8
                Originally posted by k0nr4d
                That works...
                ...if you want your sites to all load really slowly and use more system resources then they need to...

                Theres lots of methods, best one being
                @include('/var/www/domain.com/links.php'); <-- never name anything .inc because that would read plain text. if you decide at some point to include some php code into the links file, if its named php it will be parsed if someone accesses it directly instead of showing your code to the person using .inc.

                Don't include() over http as thats going to be very if your network lags. If you have to do it across several servers, setup a cron job that will download the links file to the other servers, or rsync, or scp, or whatever you want. If all your domains are on one server, include using the absolute path.
                so whats thebest suntax fo include? iom using this ins some of my sites and it lags it sometimes.


                NEED DESIGNS?!?

                Comment

                • k0nr4d
                  Confirmed User
                  • Aug 2006
                  • 9231

                  #9
                  include('/absolute/path/to/file'); is the best syntax. You can put a @ in front of the include if you want to supress warnings if the file doesn't exist or is unreadable from that location due to open_base_dir restrictions.
                  Mechanical Bunny Media
                  Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

                  Comment

                  • pornpf69
                    Too lazy to set a custom title
                    • Jun 2004
                    • 15782

                    #10
                    Originally posted by k0nr4d
                    That works...
                    ...if you want your sites to all load really slowly and use more system resources then they need to...

                    Theres lots of methods, best one being
                    @include('/var/www/domain.com/links.php'); <-- never name anything .inc because that would read plain text. if you decide at some point to include some php code into the links file, if its named php it will be parsed if someone accesses it directly instead of showing your code to the person using .inc.

                    Don't include() over http as thats going to be very if your network lags. If you have to do it across several servers, setup a cron job that will download the links file to the other servers, or rsync, or scp, or whatever you want. If all your domains are on one server, include using the absolute path.
                    very informative!! thank you for your input!!

                    Comment

                    • spasmo
                      Confirmed User
                      • Dec 2005
                      • 2678

                      #11
                      I use:

                      <? include("$_SERVER[DOCUMENT_ROOT]/includes/include_filename.php"); ?>

                      or in cases where it's an absolute path (as stated above) I omit the $_SERVER[DOCUMENT_ROOT].

                      Surfers: Go here for hot babes.

                      Comment

                      • PHP-CODER-FOR-HIRE
                        Confirmed User
                        • Nov 2006
                        • 1090

                        #12
                        Really only useful if all the sites are on the same server

                        Comment

                        • k0nr4d
                          Confirmed User
                          • Aug 2006
                          • 9231

                          #13
                          Originally posted by spasmo
                          I use:

                          <? include("$_SERVER[DOCUMENT_ROOT]/includes/include_filename.php"); ?>

                          or in cases where it's an absolute path (as stated above) I omit the $_SERVER[DOCUMENT_ROOT].
                          That works too, but keep in mind (im not POSITIVE of this, but 90% sure) that the $_SERVER variables don't work if you are coding for CLI
                          Mechanical Bunny Media
                          Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

                          Comment

                          • spasmo
                            Confirmed User
                            • Dec 2005
                            • 2678

                            #14
                            Originally posted by k0nr4d
                            That works too, but keep in mind (im not POSITIVE of this, but 90% sure) that the $_SERVER variables don't work if you are coding for CLI
                            I think you're right. The $_SERVER variables are passed by Apache, aren't they?

                            Surfers: Go here for hot babes.

                            Comment

                            • k0nr4d
                              Confirmed User
                              • Aug 2006
                              • 9231

                              #15
                              yeah i believe so
                              Mechanical Bunny Media
                              Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

                              Comment

                              • u-Bob
                                there's no $$$ in porn
                                • Jul 2005
                                • 33063

                                #16
                                Guys, when including static files (without php code), use readfile() instead of include(). </2 cents>

                                Comment

                                • d00t
                                  Confirmed User
                                  • Sep 2002
                                  • 3766

                                  #17
                                  Originally posted by u-Bob
                                  Guys, when including static files (without php code), use readfile() instead of include(). </2 cents>
                                  why is that?

                                  Comment

                                  • borked
                                    Totally Borked
                                    • Feb 2005
                                    • 6284

                                    #18
                                    just add this to a header file:
                                    <?php
                                    $pathArr = pathinfo(__FILE__);
                                    ini_set('include_path', ini_get('include_path').':'.$pathArr['dirname'].'/includes');
                                    ?>

                                    then you're all set - you can forget about worrying to add the full pathname -
                                    add any file to includes/ directory then include them simply with
                                    include('filename.php');

                                    For coding work - hit me up on andy // borkedcoder // com
                                    (consider figuring out the email as test #1)



                                    All models are wrong, but some are useful. George E.P. Box. p202

                                    Comment

                                    • u-Bob
                                      there's no $$$ in porn
                                      • Jul 2005
                                      • 33063

                                      #19
                                      Originally posted by d00t
                                      why is that?
                                      cuz it's 15 times faster and uses alot less resources.

                                      Comment

                                      • k0nr4d
                                        Confirmed User
                                        • Aug 2006
                                        • 9231

                                        #20
                                        readfile() is actually alot more then 15 times faster, uses far far far less ram, but like he said only works on static files with no php code in them
                                        Mechanical Bunny Media
                                        Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

                                        Comment

                                        • HomeFry
                                          Confirmed User
                                          • Jun 2006
                                          • 1062

                                          #21
                                          Just use an iframe.
                                          Need Mushrooms Designed? Gimme-Website

                                          Comment

                                          • k0nr4d
                                            Confirmed User
                                            • Aug 2006
                                            • 9231

                                            #22
                                            Originally posted by HomeFry
                                            Just use an iframe.
                                            they dotn get indexed by google
                                            Mechanical Bunny Media
                                            Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

                                            Comment

                                            Working...