Loading ...
Sorry, an error occurred while loading the content.
 

Re: [NH] Need help with path for PHP incude

Expand Messages
  • rhorbas@gmx.net
    ... That s basically the same -- I m just elaborating on this specific method of inclusion, because it s rather failsafe. Inclusion of files via http is
    Message 1 of 25 , Mar 6, 2012
      Mike Breiding wrote:
      > On 3/6/2012 5:01 PM, rhorbas@... wrote:
      >> Mike Breiding - Morgantown WV schrieb am 07.03.2012 00:54:
      >>> On 3/6/2012 4:42 PM, Rudolf Horbas wrote:
      >>>> <?php include $_SERVER['DOCUMENT_ROOT'] .
      >>>> '/2011/mtown2gv_nov_2011_p1/w1navigation.php'; ?>
      >>>> should do it. HTH, Rudi
      >
      >>> That did it!
      >> Great!
      >>
      >>> Have you any input on the use of a specific path:
      >>> http://epicroadtrips.us/2011/mtown2gv_nov_2011_p1/w1navigation.php
      >>
      >> What exactly do you mean?
      >
      > You answered that here:
      >
      >> Yes, you can. Not only will this fail in certain configs
      >> (allow_url_fopen, allow_url_include): There's no point using a slow http
      >> request via the network when the file is on the same disk.
      >> Use an absolute path instead, and prepend it with the server var
      >> DOCUMENT_ROOT:
      >>
      >> <?php
      >> include $_SERVER['DOCUMENT_ROOT'] .
      >> '/2011/mtown2gv_nov_2011_p1/w1navigation.php';
      >> ?>

      That's basically the same -- I'm just elaborating on this specific
      method of inclusion, because it's rather failsafe.

      Inclusion of files via http is definitely slower and completely
      unnecessary here, because php is allowed to get the file via it's own
      disk system.
      Getting the file via http has other disadvantages: It's being processed
      by php first, so any *php* code in the file is not available to the
      files including it, unless it generates php code itself, which would be
      really awkward.
      In other contexts, where you don't have complete control over the
      included file's contents, it's even a dangerous idea: Any generated php
      code in the file is being executed in the server's context, so it would
      be easy to insert malicious code. That's why many server configurations
      will have disabled it by default.

      So in a nutshell:

      Never use this method, unless you have very specific reasons to do so.

      Relative paths ("../../path/to/include.php") will get you there, albeit
      it takes some experience to find the correct path.

      Absolute paths with the server's document root (that's where the files
      are stored that are accessible via a browser) as a variable will almost
      always work.

      Rudi
    • John Wallace
      Seems I also remember that some servers need to have an include directory where the includes are kept? John Wallace Pontiac Power Rules !!!
      Message 2 of 25 , Mar 7, 2012
        Seems I also remember that some servers need to have an 'include' directory where the includes are kept?


        John Wallace
        Pontiac Power Rules !!!
        www.wallaceracing.com <http://www.wallaceracing.com/>



        _____

        From: ntb-html@yahoogroups.com [mailto:ntb-html@yahoogroups.com] On Behalf Of Mike Breiding - Morgantown WV
        Sent: Tuesday, March 06, 2012 2:54 PM
        To: ntb-html@yahoogroups.com
        Cc: John Wallace
        Subject: Re: [NH] Re: Need help with path for PHP incude




        On 3/6/2012 12:20 PM, John Wallace wrote:
        > OK, then use http://epicroadtrips.us/2011/mtown2gv_nov_2011_p1/w1navigation.php in your include path statement and not the server
        > directory path?

        Tried that. No go.
        Thanks,
        -Mike
        =================

        >
        > <?php include_once("<http://epicroadtrips.us/2011/mtown2gv_nov_2011_p1/w1navigation.php>
        > http://epicroadtrips.us/2011/mtown2gv_nov_2011_p1/w1navigation.php"); ?>
        >
        > The include path you used may not be in your public html area?
        >
        > With PHP, we can't see what the actual file looks like, just what is interpreted by the browser.
        >
        >
        > John Wallace
        > Pontiac Power Rules !!!
        > www.wallaceracing.com<http://www.wallaceracing.com/>
        >
        >
        >
        > _____
        >
        > From: ntb-html@yahoogroups.com <mailto:ntb-html%40yahoogroups.com> [mailto:ntb-html@yahoogroups.com
        <mailto:ntb-html%40yahoogroups.com> ] On Behalf Of Mike Breiding - Morgantown WV
        > Sent: Tuesday, March 06, 2012 2:06 PM
        > To: ntb-html@yahoogroups.com <mailto:ntb-html%40yahoogroups.com>
        > Cc: hockeyreferee_2000
        > Subject: Re: [NH] Re: Need help with path for PHP incude
        >
        >
        >
        >
        > On 3/6/2012 11:45 AM, hockeyreferee_2000 wrote:
        >> I think that what you want is:
        >> <?php include_once("../2011/mtown2gv_nov_2011_p1/w1navigation.php"); ?>
        >
        > Still will not work.
        > See: http://epicroadtrips.us/2011/az/fossil_creek/index1.php
        >
        > Source:
        > <div id="navwrapper">
        > <div id="navigation">
        > Warning: include_once(../2011/mtown2gv_nov_2011_p1/w1navigation.php):
        > failed to open stream: No such file or directory in
        > /hsphere/local/home/mbreidin/epicroadtrips.us/2011/az/fossil_creek/index1.php
        > on line 415
        >
        > Warning: include_once(): Failed opening
        > '../2011/mtown2gv_nov_2011_p1/w1navigation.php' for inclusion
        > (include_path='.:/hsphere/shared/apache/libexec/php5ext/php/') in
        > /hsphere/local/home/mbreidin/epicroadtrips.us/2011/az/fossil_creek/index1.php
        > on line 415
        > </div>
        > </div>
        >
        > Thanks,
        > -Mike
        > ================================
        >
        >>
        >> --- In ntb-html@yahoogroups.com <mailto:ntb-html%40yahoogroups.com> <mailto:ntb-html%40yahoogroups.com> , Mike Breiding -
        Morgantown WV<mike@...> wrote:
        >>>
        >>> On 3/6/2012 10:52 AM, John Wallace wrote:
        >>>> The same way you do the other links?>
        >>>> a href = ' http://epicroadtrips.us/2011/az/fossil_creek/ '
        >>>> Since you don't have a file name listing in the urls, it will open 'index.html' or 'index.php'
        >>>> (or whatever the default is setup as)
        >>>
        >>> Hmmm...
        >>> I am trying to have http://epicroadtrips.us/2011/az/fossil_creek/ refer
        >>> to the menus here:
        >>> http://epicroadtrips.us/2011/mtown2gv_nov_2011_p1/w1navigation.php
        >>>
        >>> -mb
        >>> ============================
        >>>>
        >>>> John Wallace
        >>>> Pontiac Power Rules !!!
        >>>> www.wallaceracing.com<http://www.wallaceracing.com/>
        >>>>
        >>>> _____
        >>>>
        >>>> From: ntb-html@yahoogroups.com <mailto:ntb-html%40yahoogroups.com> <mailto:ntb-html%40yahoogroups.com>
        [mailto:ntb-html@yahoogroups.com <mailto:ntb-html%40yahoogroups.com>
        > <mailto:ntb-html%40yahoogroups.com> ] On Behalf Of Mike Breiding - Morgantown WV
        >>>> Sent: Tuesday, March 06, 2012 12:34 PM
        >>>> To: NTB HTML
        >>>> Subject: [NH] Need help with path for PHP incude
        >>>>
        >>>>
        >>>> Greetings,
        >>>> I seem to have forgotten something very basic.
        >>>>
        >>>> I cannot seem to get the path correct for this:
        >>>> I need http://epicroadtrips.us/2011/az/fossil_creek/ to use the PHP menu
        >>>> from here:
        >>>> http://epicroadtrips.us/2011/mtown2gv_nov_2011_p1/w1navigation.php
        >>>>
        >>>> How would the path be written to do that?
        >>>> <?php include("path to PHP menu"); ?>
        >>>>
        >>>> I have tried and tried but I cant seem to get it.
        >>>> Thanks,
        >>>> -Mike
        >
        >
        >
        >
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >
        > ------------------------------------
        >
        > Fookes Software: http://www.fookes.com/
        > NoteTab website: http://www.notetab.com/
        > NoteTab Discussion Lists: http://www.notetab.com/groups.php
        >
        > ***
        > Yahoo! Groups Links
        >
        >
        >
        >
        >





        [Non-text portions of this message have been removed]
      • Mike Breiding - Morgantown WV
        ... I think this is just a user preference. I put my includes wherever needed. But, in this instance, poor planning caused a problem with my being able to
        Message 3 of 25 , Mar 7, 2012
          On 3/7/2012 4:57 AM, John Wallace wrote:
          > Seems I also remember that some servers need to have an 'include' directory where the includes are kept?

          I think this is just a user preference.
          I put my includes wherever needed.

          But, in this instance, poor planning caused a problem with my being able
          to figure out how to access the files from another directory.

          Thanks,
          -Mike
        • Mike Breiding - Morgantown WV
          Rudi, Thanks for your elaboration and details below. But, I admit it strained my pea sized brain! -Mike ====================
          Message 4 of 25 , Mar 7, 2012
            Rudi,
            Thanks for your elaboration and details below.
            But, I admit it strained my pea sized brain!
            -Mike
            ====================

            On 3/6/2012 11:57 PM, rhorbas@... wrote:
            > Mike Breiding wrote:
            >> On 3/6/2012 5:01 PM, rhorbas@... wrote:
            >>> Mike Breiding - Morgantown WV schrieb am 07.03.2012 00:54:
            >>>> On 3/6/2012 4:42 PM, Rudolf Horbas wrote:
            >>>>> <?php include $_SERVER['DOCUMENT_ROOT'] .
            >>>>> '/2011/mtown2gv_nov_2011_p1/w1navigation.php'; ?>
            >>>>> should do it. HTH, Rudi
            >>
            >>>> That did it!
            >>> Great!
            >>>
            >>>> Have you any input on the use of a specific path:
            >>>> http://epicroadtrips.us/2011/mtown2gv_nov_2011_p1/w1navigation.php
            >>>
            >>> What exactly do you mean?
            >>
            >> You answered that here:
            >>
            >>> Yes, you can. Not only will this fail in certain configs
            >>> (allow_url_fopen, allow_url_include): There's no point using a slow http
            >>> request via the network when the file is on the same disk.
            >>> Use an absolute path instead, and prepend it with the server var
            >>> DOCUMENT_ROOT:
            >>>
            >>> <?php
            >>> include $_SERVER['DOCUMENT_ROOT'] .
            >>> '/2011/mtown2gv_nov_2011_p1/w1navigation.php';
            >>> ?>
            >
            > That's basically the same -- I'm just elaborating on this specific
            > method of inclusion, because it's rather failsafe.
            >
            > Inclusion of files via http is definitely slower and completely
            > unnecessary here, because php is allowed to get the file via it's own
            > disk system.
            > Getting the file via http has other disadvantages: It's being processed
            > by php first, so any *php* code in the file is not available to the
            > files including it, unless it generates php code itself, which would be
            > really awkward.
            > In other contexts, where you don't have complete control over the
            > included file's contents, it's even a dangerous idea: Any generated php
            > code in the file is being executed in the server's context, so it would
            > be easy to insert malicious code. That's why many server configurations
            > will have disabled it by default.
            >
            > So in a nutshell:
            >
            > Never use this method, unless you have very specific reasons to do so.
            >
            > Relative paths ("../../path/to/include.php") will get you there, albeit
            > it takes some experience to find the correct path.
            >
            > Absolute paths with the server's document root (that's where the files
            > are stored that are accessible via a browser) as a variable will almost
            > always work.
            >
            > Rudi
            >
            >
            > ------------------------------------
          • Mike Breiding - Morgantown WV
            I m back again with the same need but a different situation. I want to use an include within and include. I would like to use a master menu as an include for
            Message 5 of 25 , Jul 28, 2012
              I'm back again with the same need but a different situation.

              I want to use an include within and include.

              I would like to use a master menu as an include for each of my pages.
              The master is here:
              http://epicroadtrips.us/master_menu.php

              I want to use the master include in this include:
              <div id="navwrapper">
              <div id="navigation">
              <?php include("w1navigation.php"); ?>
              </div>
              </div>

              This would be the file w1navigation.php with the "master_menu.php" include.
              I am hoping for this result for each page menu:
              http://epicroadtrips.us/2012/escape/
              The above link uses a copy and paste to include the master menu.


              ~~~~~~~~w1navigation.php~~~~~~~~~
              <h4>Mike Breiding's Epic Road Trips<br /> Spain: 10 Days in Segovia</h4>

              <ul>
              <li class="week">Week 1</li>
              <li<?php if ($thisPage=="day1-03september2010") echo "
              id=\"currentpage\""; ?>><a href='http://epicroadtrips.us/2010/spain/d1/'
              title="Day 1: My First Flight East - Pittsburgh, DC, Madrid,
              Segovia">Day 1: My First Flight East - Pittsburgh, DC, Madrid,
              Segovia</a></li>

              <?php include("master_menu.php"); ?>

              li style="font-size: 100%; margin-left: 15px; margin-top:
              15px"><strong><a href="http://EpicRoadTrips.us" target="_blank"
              title="Mike Breiding's Epic Road Trips">
              ERT - HOME</a></strong></li>
              </ul>

              <div id="dedication">
              <p><a href='http://EpicRoadTrips.us/dad' target="_blank" title=" My
              dad's web site ">This site is dedicated to my father:<br />
              <strong style="font-size:105%">George H. Breiding</strong><br />
              Read more...</a></p>
              ~~~~~~~~~~~~~~~~~

              The question is the same as before.
              How to direct each current page menu to the same master_menu.php file so
              it is added to the current page menu.

              I am not sure this is clear or not.

              Thanks,
              -Mike




              On 3/6/2012 6:49 PM, Rudolf Horbas wrote:
              > Mick Housel wrote:
              >
              >> include("http://epicroadtrips.us/2011/mtown2gv_nov_2011_p1/w1navigation.php");
              >> (long line above)
              >>
              >> You can't get any more straightforward than completely defining the
              >> path, my preference.
              >
              > Yes, you can. Not only will this fail in certain configs
              > (allow_url_fopen, allow_url_include): There's no point using a slow http
              > request via the network when the file is on the same disk.
              > Use an absolute path instead, and prepend it with the server var
              > DOCUMENT_ROOT:
              >
              > <?php
              > include $_SERVER['DOCUMENT_ROOT'] .
              > '/2011/mtown2gv_nov_2011_p1/w1navigation.php';
              > ?>
              >
              > Rudi
              >
              >
              > ------------------------------------
              >
              > Fookes Software: http://www.fookes.com/
              > NoteTab website: http://www.notetab.com/
              > NoteTab Discussion Lists: http://www.notetab.com/groups.php
              >
              > ***
              > Yahoo! Groups Links
              >
              >
              >
              >
              >
            • John Shotsky
              I ve never tried that, but if not supported, I would break the master include into two parts, then call the first one, then the sub include, then the second
              Message 6 of 25 , Jul 28, 2012
                I've never tried that, but if not supported, I would break the master include into two parts, then call the first one,
                then the 'sub' include, then the second part of the master include.

                Regards,
                John
                RecipeTools Web Site: http://recipetools.gotdns.com/


                -----Original Message-----
                From: ntb-html@yahoogroups.com [mailto:ntb-html@yahoogroups.com] On Behalf Of Mike Breiding - Morgantown WV
                Sent: Saturday, July 28, 2012 10:05
                To: ntb-html@yahoogroups.com
                Cc: Rudolf Horbas
                Subject: Re: [NH] Need help with path for PHP incude

                I'm back again with the same need but a different situation.

                I want to use an include within and include.

                I would like to use a master menu as an include for each of my pages.
                The master is here:
                http://epicroadtrips.us/master_menu.php

                I want to use the master include in this include:
                <div id="navwrapper">
                <div id="navigation">
                <?php include("w1navigation.php"); ?>
                </div>
                </div>

                This would be the file w1navigation.php with the "master_menu.php" include.
                I am hoping for this result for each page menu:
                http://epicroadtrips.us/2012/escape/
                The above link uses a copy and paste to include the master menu.


                ~~~~~~~~w1navigation.php~~~~~~~~~
                <h4>Mike Breiding's Epic Road Trips<br /> Spain: 10 Days in Segovia</h4>

                <ul>
                <li class="week">Week 1</li>
                <li<?php if ($thisPage=="day1-03september2010") echo "
                id=\"currentpage\""; ?>><a href='http://epicroadtrips.us/2010/spain/d1/'
                title="Day 1: My First Flight East - Pittsburgh, DC, Madrid,
                Segovia">Day 1: My First Flight East - Pittsburgh, DC, Madrid,
                Segovia</a></li>

                <?php include("master_menu.php"); ?>

                li style="font-size: 100%; margin-left: 15px; margin-top:
                15px"><strong><a href="http://EpicRoadTrips.us" target="_blank"
                title="Mike Breiding's Epic Road Trips">
                ERT - HOME</a></strong></li>
                </ul>

                <div id="dedication">
                <p><a href='http://EpicRoadTrips.us/dad' target="_blank" title=" My
                dad's web site ">This site is dedicated to my father:<br />
                <strong style="font-size:105%">George H. Breiding</strong><br />
                Read more...</a></p>
                ~~~~~~~~~~~~~~~~~

                The question is the same as before.
                How to direct each current page menu to the same master_menu.php file so
                it is added to the current page menu.

                I am not sure this is clear or not.

                Thanks,
                -Mike




                On 3/6/2012 6:49 PM, Rudolf Horbas wrote:
                > Mick Housel wrote:
                >
                >> include("http://epicroadtrips.us/2011/mtown2gv_nov_2011_p1/w1navigation.php");
                >> (long line above)
                >>
                >> You can't get any more straightforward than completely defining the
                >> path, my preference.
                >
                > Yes, you can. Not only will this fail in certain configs
                > (allow_url_fopen, allow_url_include): There's no point using a slow http
                > request via the network when the file is on the same disk.
                > Use an absolute path instead, and prepend it with the server var
                > DOCUMENT_ROOT:
                >
                > <?php
                > include $_SERVER['DOCUMENT_ROOT'] .
                > '/2011/mtown2gv_nov_2011_p1/w1navigation.php';
                > ?>
                >
                > Rudi
                >
                >
                > ------------------------------------
                >
                > Fookes Software: http://www.fookes.com/
                > NoteTab website: http://www.notetab.com/
                > NoteTab Discussion Lists: http://www.notetab.com/groups.php
                >
                > ***
                > Yahoo! Groups Links
                >
                >
                >
                >
                >


                ------------------------------------

                Fookes Software: http://www.fookes.com/
                NoteTab website: http://www.notetab.com/
                NoteTab Discussion Lists: http://www.notetab.com/groups.php

                ***
                Yahoo! Groups Links
              • Mike Breiding - Morgantown WV
                ... Hi John, My main brain twister is how to point all the pages to one include file. In other words - figuring out the path to use for each one. If the
                Message 7 of 25 , Jul 28, 2012
                  On 7/28/2012 1:21 PM, John Shotsky wrote:
                  > I've never tried that, but if not supported, I would break the master include into two parts, then call the first one,
                  > then the 'sub' include, then the second part of the master include. Regards, John

                  Hi John,
                  My main brain twister is how to point all the pages to one include file.
                  In other words - figuring out the path to use for each one.

                  If the include within an include is not supported I think I can work
                  with that. But the path question is my concern.

                  Thanks,
                  -Mike
                • Axel Berger
                  ... Not sure if I ve got it, but could you write is as an absolute path beginning with a slash / to make it work from everywhere? Axel
                  Message 8 of 25 , Jul 28, 2012
                    Mike Breiding - Morgantown WV wrote:
                    > But the path question is my concern.

                    Not sure if I've got it, but could you write is as an absolute path
                    beginning with a slash "/" to make it work from everywhere?

                    Axel
                  • Mike Breiding - Morgantown WV
                    ... I will see what I can do with that. Thanks, -Mike
                    Message 9 of 25 , Jul 29, 2012
                      On 7/28/2012 7:22 PM, Axel Berger wrote:
                      > Mike Breiding - Morgantown WV wrote:
                      >> But the path question is my concern.
                      >
                      > Not sure if I've got it, but could you write is as an absolute path
                      > beginning with a slash "/" to make it work from everywhere?

                      I will see what I can do with that.
                      Thanks,
                      -Mike


                      >
                      > Axel
                      >
                      >
                      > ------------------------------------
                      >
                      > Fookes Software: http://www.fookes.com/
                      > NoteTab website: http://www.notetab.com/
                      > NoteTab Discussion Lists: http://www.notetab.com/groups.php
                      >
                      > ***
                      > Yahoo! Groups Links
                      >
                      >
                      >
                      >
                      >
                    • rhorbas@gmx.net
                      the following is failsafe: $_SERVER[ DOCUMENT_ROOT ] . /path/to/your/include.php Rudi
                      Message 10 of 25 , Jul 30, 2012
                        the following is failsafe:

                        $_SERVER['DOCUMENT_ROOT'] . '/path/to/your/include.php'

                        Rudi

                        Mike Breiding - Morgantown WV schrieb am 29.07.2012 14:58:
                        > On 7/28/2012 7:22 PM, Axel Berger wrote:
                        >> Mike Breiding - Morgantown WV wrote:
                        >>> But the path question is my concern.
                        >>
                        >> Not sure if I've got it, but could you write is as an absolute path
                        >> beginning with a slash "/" to make it work from everywhere?
                        >
                        > I will see what I can do with that.
                        > Thanks,
                        > -Mike
                        >
                        >
                        >>
                        >> Axel
                      • Mike Breiding - Morgantown WV
                        ... Thanks. I will play with this. -Mike
                        Message 11 of 25 , Jul 30, 2012
                          On 7/30/2012 11:07 AM, rhorbas@... wrote:
                          > the following is failsafe:
                          >
                          > $_SERVER['DOCUMENT_ROOT'] . '/path/to/your/include.php'


                          Thanks.
                          I will play with this.
                          -Mike

                          >
                          > Rudi
                          >
                          > Mike Breiding - Morgantown WV schrieb am 29.07.2012 14:58:
                          >> On 7/28/2012 7:22 PM, Axel Berger wrote:
                          >>> Mike Breiding - Morgantown WV wrote:
                          >>>> But the path question is my concern.
                          >>>
                          >>> Not sure if I've got it, but could you write is as an absolute path
                          >>> beginning with a slash "/" to make it work from everywhere?
                          >>
                          >> I will see what I can do with that.
                          >> Thanks,
                          >> -Mike
                          >>
                          >>
                          >>>
                          >>> Axel
                        Your message has been successfully submitted and would be delivered to recipients shortly.