'nested conditional' that can identify parent page?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alan Jones

    'nested conditional' that can identify parent page?


    Hello everyone, any help would be greatly appreciated. :)

    What I'm trying to do may not be advisable, but here goes...

    I want a page named signature.php to appear conditionally as
    an include within another include so that it will, for example,
    appear in index.php but not in other result pages that use the
    same top level include.

    The method would need to determine what page it is inside of
    during each given instance. I guess something like...

    if page is index.php then include file else do nothing

    A 'nested conditional' seems obvious but I don't know how to
    create an argument that checks the result page file name or
    otherwise id's that parent page.

    Obviously, I'm new to PHP and my understanding of basic
    programming is very limited. I'm also new to the group. I hope
    to learn quickly, and I look forward to helping others in the
    future.
  • fel

    #2
    Re: 'nested conditional' that can identify parent page?

    On 11 mayo, 17:42, Alan Jones <a...@jalanjone s.comwrote:
    Hello everyone, any help would be greatly appreciated. :)
    >
    What I'm trying to do may not be advisable, but here goes...
    >
    I want a page named signature.php to appear conditionally as
    an include within another include so that it will, for example,
    appear in index.php but not in other result pages that use the
    same top level include.
    >
    The method would need to determine what page it is inside of
    during each given instance. I guess something like...
    >
    if page is index.php then include file else do nothing
    >
    A 'nested conditional' seems obvious but I don't know how to
    create an argument that checks the result page file name or
    otherwise id's that parent page.
    >
    Obviously, I'm new to PHP and my understanding of basic
    programming is very limited. I'm also new to the group. I hope
    to learn quickly, and I look forward to helping others in the
    future.

    use debug_backtrace () ?

    Comment

    • ZeldorBlat

      #3
      Re: 'nested conditional' that can identify parent page?

      On May 11, 6:42 pm, Alan Jones <a...@jalanjone s.comwrote:
      Hello everyone, any help would be greatly appreciated. :)
      >
      What I'm trying to do may not be advisable, but here goes...
      >
      I want a page named signature.php to appear conditionally as
      an include within another include so that it will, for example,
      appear in index.php but not in other result pages that use the
      same top level include.
      >
      The method would need to determine what page it is inside of
      during each given instance. I guess something like...
      >
      if page is index.php then include file else do nothing
      >
      A 'nested conditional' seems obvious but I don't know how to
      create an argument that checks the result page file name or
      otherwise id's that parent page.
      >
      Obviously, I'm new to PHP and my understanding of basic
      programming is very limited. I'm also new to the group. I hope
      to learn quickly, and I look forward to helping others in the
      future.
      You can always find out what the "top-level" script is with
      $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME'] then base your
      decision to include on that.

      <http://www.php.net/manual/en/
      reserved.variab les.php#reserve d.variables.ser ver>

      However, if you want to include something on one page only why
      wouldn't you just include it on that page? For example, if you want
      to include "common.php " on every page and "signature. php" on index.php
      only, why not just put the following on index.php:

      include('common .php');
      include('signat ure.php');

      instead of putting signature.php inside common.php under some
      condition?

      Comment

      • Alan Jones

        #4
        Re: 'nested conditional' that can identify parent page?

        On 11 May 2007 15:59:55 -0700, fel <felipevaldez@g mail.comwrote:
        >On 11 mayo, 17:42, Alan Jones <a...@jalanjone s.comwrote:
        >Hello everyone, any help would be greatly appreciated. :)
        >>
        >What I'm trying to do may not be advisable, but here goes...
        >>
        >I want a page named signature.php to appear conditionally as
        >an include within another include so that it will, for example,
        >appear in index.php but not in other result pages that use the
        >same top level include.
        >>
        >The method would need to determine what page it is inside of
        >during each given instance. I guess something like...
        >>
        >if page is index.php then include file else do nothing
        >>
        >A 'nested conditional' seems obvious but I don't know how to
        >create an argument that checks the result page file name or
        >otherwise id's that parent page.
        >>
        >Obviously, I'm new to PHP and my understanding of basic
        >programming is very limited. I'm also new to the group. I hope
        >to learn quickly, and I look forward to helping others in the
        >future.
        >
        >
        >use debug_backtrace () ?
        Thank you for the quick response. I'll check that out and report
        back any success.

        I was thinking something so simple as declaring a string in the
        parent page and getting a conditional statement within the first
        include to see it, act on it's presence; decide whether to process
        the second include. Shirley this can be done :D

        Comment

        • Alan Jones

          #5
          Re: 'nested conditional' that can identify parent page?

          On 11 May 2007 16:47:16 -0700, ZeldorBlat <zeldorblat@gma il.com>
          wrote:
          >On May 11, 6:42 pm, Alan Jones <a...@jalanjone s.comwrote:
          >Hello everyone, any help would be greatly appreciated. :)
          >>
          >What I'm trying to do may not be advisable, but here goes...
          >>
          >I want a page named signature.php to appear conditionally as
          >an include within another include so that it will, for example,
          >appear in index.php but not in other result pages that use the
          >same top level include.
          >>
          >The method would need to determine what page it is inside of
          >during each given instance. I guess something like...
          >>
          >if page is index.php then include file else do nothing
          >>
          >A 'nested conditional' seems obvious but I don't know how to
          >create an argument that checks the result page file name or
          >otherwise id's that parent page.
          >>
          >Obviously, I'm new to PHP and my understanding of basic
          >programming is very limited. I'm also new to the group. I hope
          >to learn quickly, and I look forward to helping others in the
          >future.
          >
          >You can always find out what the "top-level" script is with
          >$_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME'] then base your
          >decision to include on that.
          >
          ><http://www.php.net/manual/en/
          >reserved.varia bles.php#reserv ed.variables.se rver>
          I think that may be my answer. :) Thank you, I'll need to read up
          on it a bit and do some testing.
          >However, if you want to include something on one page only why
          >wouldn't you just include it on that page? For example, if you want
          >to include "common.php " on every page and "signature. php" on index.php
          >only, why not just put the following on index.php:
          >
          >include('commo n.php');
          >include('signa ture.php');
          >
          >instead of putting signature.php inside common.php under some
          >condition?
          My proposed solution is probably overkill. My original problem is
          positioning of the content. All of the content in the first include
          is within a table.

          In the parent page, I could create the table structure of the first
          include, break the first include into parts, and populate the cells
          individually with the pieces and parts of the first and second
          include. My problem with that is I want to retain the ability to
          work with, edit, the first include as a single page.

          In the parent page, maybe there is a way to specify the position/
          location of one include inside another?

          Comment

          • ZeldorBlat

            #6
            Re: 'nested conditional' that can identify parent page?

            On May 11, 8:36 pm, Alan Jones <a...@jalanjone s.comwrote:
            On 11 May 2007 16:47:16 -0700, ZeldorBlat <zeldorb...@gma il.com>
            wrote:
            >
            >
            >
            On May 11, 6:42 pm, Alan Jones <a...@jalanjone s.comwrote:
            Hello everyone, any help would be greatly appreciated. :)
            >
            What I'm trying to do may not be advisable, but here goes...
            >
            I want a page named signature.php to appear conditionally as
            an include within another include so that it will, for example,
            appear in index.php but not in other result pages that use the
            same top level include.
            >
            The method would need to determine what page it is inside of
            during each given instance. I guess something like...
            >
            if page is index.php then include file else do nothing
            >
            A 'nested conditional' seems obvious but I don't know how to
            create an argument that checks the result page file name or
            otherwise id's that parent page.
            >
            Obviously, I'm new to PHP and my understanding of basic
            programming is very limited. I'm also new to the group. I hope
            to learn quickly, and I look forward to helping others in the
            future.
            >
            You can always find out what the "top-level" script is with
            $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME'] then base your
            decision to include on that.
            >
            <http://www.php.net/manual/en/
            reserved.variab les.php#reserve d.variables.ser ver>
            >
            I think that may be my answer. :) Thank you, I'll need to read up
            on it a bit and do some testing.
            >
            However, if you want to include something on one page only why
            wouldn't you just include it on that page? For example, if you want
            to include "common.php " on every page and "signature. php" on index.php
            only, why not just put the following on index.php:
            >
            include('common .php');
            include('signat ure.php');
            >
            instead of putting signature.php inside common.php under some
            condition?
            >
            My proposed solution is probably overkill. My original problem is
            positioning of the content. All of the content in the first include
            is within a table.
            >
            In the parent page, I could create the table structure of the first
            include, break the first include into parts, and populate the cells
            individually with the pieces and parts of the first and second
            include. My problem with that is I want to retain the ability to
            work with, edit, the first include as a single page.
            >
            In the parent page, maybe there is a way to specify the position/
            location of one include inside another?
            What I would do in that case is define a variable or constant in your
            top (index) page before including common.php, then check for it before
            including signature.php. That way you aren't limited to only showing
            it on index.php, but can instead pick and choose which pages to
            include it on.

            So, in your index.php (or any other page on which you want to show
            the "signature" ) you would do something like this:

            define('SHOW_SI GNATURE', true);
            include('common .php');

            Then, common.php might look something like this:

            //output some HTML
            if(defined('SHO W_SIGNATURE') && SHOW_SIGNATURE)
            include('signat ure.php')
            //output some more HTML

            That's basically the same as checking the value of
            $_SERVER['SCRIPT_NAME'] but it gives you a bit more flexibility.

            Comment

            • Alan Jones

              #7
              Re: 'nested conditional' that can identify parent page?

              On 11 May 2007 17:46:48 -0700, ZeldorBlat <zeldorblat@gma il.com>
              wrote:
              >My proposed solution is probably overkill. My original problem is
              >positioning of the content. All of the content in the first include
              >is within a table.
              >>
              >In the parent page, I could create the table structure of the first
              >include, break the first include into parts, and populate the cells
              >individually with the pieces and parts of the first and second
              >include. My problem with that is I want to retain the ability to
              >work with, edit, the first include as a single page.
              >>
              >In the parent page, maybe there is a way to specify the position/
              >location of one include inside another?
              >
              >What I would do in that case is define a variable or constant in your
              >top (index) page before including common.php, then check for it before
              >including signature.php. That way you aren't limited to only showing
              >it on index.php, but can instead pick and choose which pages to
              >include it on.
              >
              >So, in your index.php (or any other page on which you want to show
              >the "signature" ) you would do something like this:
              >
              >define('SHOW_S IGNATURE', true);
              >include('commo n.php');
              First of all, thank you very much for clueing me in on this area of
              programming. Without your help, I would still be very lost, but is
              there a way to make basename, or a similar function, simply return
              the filename of the parent page; the page the include is in? Thanks
              again, I really appreciate any help I can get.

              Comment

              • ZeldorBlat

                #8
                Re: 'nested conditional' that can identify parent page?

                On May 12, 7:35 pm, Alan Jones <a...@jalanjone s.comwrote:
                On 11 May 2007 17:46:48 -0700, ZeldorBlat <zeldorb...@gma il.com>
                wrote:
                >
                >
                >
                My proposed solution is probably overkill. My original problem is
                positioning of the content. All of the content in the first include
                is within a table.
                >
                In the parent page, I could create the table structure of the first
                include, break the first include into parts, and populate the cells
                individually with the pieces and parts of the first and second
                include. My problem with that is I want to retain the ability to
                work with, edit, the first include as a single page.
                >
                In the parent page, maybe there is a way to specify the position/
                location of one include inside another?
                >
                What I would do in that case is define a variable or constant in your
                top (index) page before including common.php, then check for it before
                including signature.php. That way you aren't limited to only showing
                it on index.php, but can instead pick and choose which pages to
                include it on.
                >
                So, in your index.php (or any other page on which you want to show
                the "signature" ) you would do something like this:
                >
                define('SHOW_SI GNATURE', true);
                include('common .php');
                >
                First of all, thank you very much for clueing me in on this area of
                programming. Without your help, I would still be very lost, but is
                there a way to make basename, or a similar function, simply return
                the filename of the parent page; the page the include is in? Thanks
                again, I really appreciate any help I can get.
                Yes -- look at the following URL:

                <http://www.php.net/manual/en/
                reserved.variab les.php#reserve d.variables.ser ver>

                and try the various variables available to see what they return.

                Comment

                • Alan Jones

                  #9
                  Re: 'nested conditional' that can identify parent page?

                  On 12 May 2007 19:51:19 -0700, ZeldorBlat <zeldorblat@gma il.com>
                  wrote:
                  >First of all, thank you very much for clueing me in on this area of
                  >programming. Without your help, I would still be very lost, but is
                  >there a way to make basename, or a similar function, simply return
                  >the filename of the parent page; the page the include is in? Thanks
                  >again, I really appreciate any help I can get.
                  >
                  >Yes -- look at the following URL:
                  >
                  ><http://www.php.net/manual/en/reserved.variab les.php#reserve d.variables.ser ver>
                  >
                  >and try the various variables available to see what they return.
                  I went thru that page last night and the most promising seemed to
                  be 'REQUEST_URI', which is supposed to output, "The URI which was
                  given in order to access this page; for instance, '/index.html'."

                  However, both...

                  echo ($_SERVER['REQUEST_URI']);

                  and...

                  echo basename($_SERV ER['REQUEST_URI']);

                  ....returned the name of the file it is in, the include 'child' file,
                  and not the actual page URL accessed; /index.php. I need the
                  include script to know if it is being run within index.php.

                  Again, thanks for racking your brain on this with me. I'm at a
                  total loss... :(

                  BTW, might you or anyone be able to help with understanding
                  'open_basedir restriction'? I received the following error when
                  trying to use the link() function...

                  link ("/index.php","/index_body.php" );

                  Warning: link(): open_basedir restriction in effect.
                  File(/index.php) is not within the allowed path(s):
                  (/home/httpd/vhosts/jalanjones.com/httpdocs:/tmp) in
                  /home/httpd/vhosts/jalanjones.com/httpdocs/index_body.php on line 46

                  Thanks :)

                  Comment

                  • Schraalhans Keukenmeester

                    #10
                    Re: 'nested conditional' that can identify parent page?

                    At Sun, 13 May 2007 03:26:41 +0000, Alan Jones let his monkeys type:
                    On 12 May 2007 19:51:19 -0700, ZeldorBlat <zeldorblat@gma il.com>
                    wrote:
                    >
                    >[snip]
                    >
                    I went thru that page last night and the most promising seemed to
                    be 'REQUEST_URI', which is supposed to output, "The URI which was
                    given in order to access this page; for instance, '/index.html'."
                    >
                    However, both...
                    >
                    echo ($_SERVER['REQUEST_URI']);
                    >
                    and...
                    >
                    echo basename($_SERV ER['REQUEST_URI']);
                    >
                    ...returned the name of the file it is in, the include 'child' file,
                    and not the actual page URL accessed; /index.php. I need the
                    include script to know if it is being run within index.php.
                    >
                    It _should_ tell you the top level calling script. Show us what you
                    are doing exactly please. Btw, I am no fan of include files behaving
                    differently depending on where they're called from. What if your script
                    name changes ?
                    BTW, might you or anyone be able to help with understanding
                    'open_basedir restriction'? I received the following error when trying
                    to use the link() function...
                    >
                    link ("/index.php","/index_body.php" );
                    >
                    Open_basedir is a php setting telling the server the top_level directory
                    from which files can be opened in your scripts. It's commonly set to point
                    to your httpdocs dir. (In php.ini)
                    You got this warning because you tried linking files from your server's
                    root directory. Link takes a filepath, not a url. In other words, remove
                    the / from the arguments. (Or provide a full path to the file):

                    link ("index.php","i ndex_body.php") ;

                    Using the phpinfo() function you can see if open_basedir is set and if so,
                    to what directory.

                    HTH
                    Sh.

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: 'nested conditional' that can identify parent page?

                      Alan Jones wrote:
                      On 12 May 2007 19:51:19 -0700, ZeldorBlat <zeldorblat@gma il.com>
                      wrote:
                      >
                      >>First of all, thank you very much for clueing me in on this area of
                      >>programming . Without your help, I would still be very lost, but is
                      >>there a way to make basename, or a similar function, simply return
                      >>the filename of the parent page; the page the include is in? Thanks
                      >>again, I really appreciate any help I can get.
                      >Yes -- look at the following URL:
                      >>
                      ><http://www.php.net/manual/en/reserved.variab les.php#reserve d.variables.ser ver>
                      >>
                      >and try the various variables available to see what they return.
                      >
                      I went thru that page last night and the most promising seemed to
                      be 'REQUEST_URI', which is supposed to output, "The URI which was
                      given in order to access this page; for instance, '/index.html'."
                      >
                      However, both...
                      >
                      echo ($_SERVER['REQUEST_URI']);
                      >
                      and...
                      >
                      echo basename($_SERV ER['REQUEST_URI']);
                      >
                      ...returned the name of the file it is in, the include 'child' file,
                      and not the actual page URL accessed; /index.php. I need the
                      include script to know if it is being run within index.php.
                      >
                      Again, thanks for racking your brain on this with me. I'm at a
                      total loss... :(
                      >
                      BTW, might you or anyone be able to help with understanding
                      'open_basedir restriction'? I received the following error when
                      trying to use the link() function...
                      >
                      link ("/index.php","/index_body.php" );
                      >
                      Warning: link(): open_basedir restriction in effect.
                      File(/index.php) is not within the allowed path(s):
                      (/home/httpd/vhosts/jalanjones.com/httpdocs:/tmp) in
                      /home/httpd/vhosts/jalanjones.com/httpdocs/index_body.php on line 46
                      >
                      Thanks :)
                      Alan,

                      $_SERVER['REQUEST_URI'] does give the uri used to fetch the page. I'm
                      not sure what you mean by 'child' file. Are you using frames? Maybe if
                      you post the code you're using (including that in the 'parent' and
                      'child' pages) it will be more clear.

                      And as Schraalhans indicated, commands which relate to the underlying
                      filesystem (i.e. link, fopen, include, etc.) reference the file system
                      directly. So if you use absolute paths (beginning with '/'), it is the
                      root directory of the file system. But your host has limited you so all
                      you can access are files in /hom/httpd/vhosts/jalanjones.com/httpdocs
                      and /tmp.

                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Alan Jones

                        #12
                        Re: 'nested conditional' that can identify parent page?

                        On Sun, 13 May 2007 09:44:20 +0200, Schraalhans Keukenmeester
                        <invalid@invali d.spamwrote:
                        >echo ($_SERVER['REQUEST_URI']);
                        >>
                        >and...
                        >>
                        >echo basename($_SERV ER['REQUEST_URI']);
                        >>
                        >...returned the name of the file it is in, the include 'child' file,
                        >and not the actual page URL accessed; /index.php. I need the
                        >include script to know if it is being run within index.php.
                        >>
                        >
                        >It _should_ tell you the top level calling script. Show us what you
                        >are doing exactly please.
                        Thanks for the help. Please see my response to Jerry's post. Just
                        want to consolidate the thread. :)
                        >Btw, I am no fan of include files behaving
                        >differently depending on where they're called from. What if your script
                        >name changes ?
                        I hope to get the request_uri result working correctly for now, and
                        then compose a script simple enough to not cause future problems.
                        >Open_basedir is a php setting telling the server the top_level directory
                        >from which files can be opened in your scripts. It's commonly set to point
                        >to your httpdocs dir. (In php.ini)
                        >You got this warning because you tried linking files from your server's
                        >root directory. Link takes a filepath, not a url. In other words, remove
                        >the / from the arguments. (Or provide a full path to the file):
                        >
                        >link ("index.php","i ndex_body.php") ;
                        Thanks, I'll put that aside for now. Hopefully, I won't need to use
                        link().
                        >Using the phpinfo() function you can see if open_basedir is set and if so,
                        >to what directory.
                        Apparently it is: /home/httpd/vhosts/jalanjones.com/httpdocs:/tmp

                        I assume that's the correct setting.

                        Comment

                        • Alan Jones

                          #13
                          Re: 'nested conditional' that can identify parent page?

                          On Sun, 13 May 2007 09:41:17 -0500, Jerry Stuckle
                          <jstucklex@attg lobal.netwrote:
                          >Alan,
                          >
                          >$_SERVER['REQUEST_URI'] does give the uri used to fetch the page. I'm
                          >not sure what you mean by 'child' file. Are you using frames? Maybe if
                          >you post the code you're using (including that in the 'parent' and
                          >'child' pages) it will be more clear.
                          Thanks for helping me. :)

                          To isolate the process, I have recreated the scenario using new
                          files, file names, and a new folder called 'test'.



                          : Inside of index2.php is...

                          <html><head><ti tle></title>
                          <meta http-equiv="Content-Type" content="text/html;
                          charset=iso-8859-1">
                          </head><body>

                          <p>This sentence is in the index2.php file.</p>

                          <p><?php include('http://jalanjones.com/test/content.php');? ></p>

                          <p>Why is there a numeral one (1) at the end? (scratching
                          head)<br><br></p>

                          </body></html>

                          : ...and inside of /test/content.php is...

                          <html><head><ti tle></title>
                          <meta http-equiv="Content-Type" content="text/html;
                          charset=iso-8859-1">
                          </head><body>
                          <table cellpadding="10 " style="border:1 px solid #333333"><tr><t d>

                          <p><br>This table is in the content.php 'include' file.</p>

                          <p>REQUEST_UR I result:&nbsp;&n bsp;&nbsp;<b>
                          <?php echo($_SERVER['REQUEST_URI']);?></b></p>

                          <p>The result (/test/content.php) is the name of the include/child
                          file, not the parent page; the URL.</p>

                          <p>Below is phpinfo() run from inside the include file. Please see
                          the PHP Variables section...<br>< br></p>

                          <?php echo phpinfo();?>

                          </table></tr></td>
                          </body></html>

                          Can anyone identify the culprit? Again, I am very new to PHP so it
                          is probably something only a clueless newb would do. :D
                          >And as Schraalhans indicated, commands which relate to the underlying
                          >filesystem (i.e. link, fopen, include, etc.) reference the file system
                          >directly. So if you use absolute paths (beginning with '/'), it is the
                          >root directory of the file system. But your host has limited you so all
                          >you can access are files in /hom/httpd/vhosts/jalanjones.com/httpdocs
                          >and /tmp.
                          Thanks, I hope to avoid using link().

                          Comment

                          • Norman Peelman

                            #14
                            Re: 'nested conditional' that can identify parent page?

                            Alan Jones wrote:
                            On Sun, 13 May 2007 09:41:17 -0500, Jerry Stuckle
                            <jstucklex@attg lobal.netwrote:
                            >
                            >Alan,
                            >>
                            >$_SERVER['REQUEST_URI'] does give the uri used to fetch the page. I'm
                            >not sure what you mean by 'child' file. Are you using frames? Maybe if
                            >you post the code you're using (including that in the 'parent' and
                            >'child' pages) it will be more clear.
                            >
                            Thanks for helping me. :)
                            >
                            To isolate the process, I have recreated the scenario using new
                            files, file names, and a new folder called 'test'.
                            >

                            >
                            : Inside of index2.php is...
                            >
                            <html><head><ti tle></title>
                            <meta http-equiv="Content-Type" content="text/html;
                            charset=iso-8859-1">
                            </head><body>
                            >
                            <p>This sentence is in the index2.php file.</p>
                            >
                            <p><?php include('http://jalanjones.com/test/content.php');? ></p>
                            >
                            <p>Why is there a numeral one (1) at the end? (scratching
                            head)<br><br></p>
                            >
                            </body></html>
                            >
                            : ...and inside of /test/content.php is...
                            >
                            <html><head><ti tle></title>
                            <meta http-equiv="Content-Type" content="text/html;
                            charset=iso-8859-1">
                            </head><body>
                            <table cellpadding="10 " style="border:1 px solid #333333"><tr><t d>
                            >
                            <p><br>This table is in the content.php 'include' file.</p>
                            >
                            <p>REQUEST_UR I result:&nbsp;&n bsp;&nbsp;<b>
                            <?php echo($_SERVER['REQUEST_URI']);?></b></p>
                            >
                            <p>The result (/test/content.php) is the name of the include/child
                            file, not the parent page; the URL.</p>
                            >
                            <p>Below is phpinfo() run from inside the include file. Please see
                            the PHP Variables section...<br>< br></p>
                            >
                            <?php echo phpinfo();?>
                            >
                            </table></tr></td>
                            </body></html>
                            >
                            Can anyone identify the culprit? Again, I am very new to PHP so it
                            is probably something only a clueless newb would do. :D
                            >
                            >And as Schraalhans indicated, commands which relate to the underlying
                            >filesystem (i.e. link, fopen, include, etc.) reference the file system
                            >directly. So if you use absolute paths (beginning with '/'), it is the
                            >root directory of the file system. But your host has limited you so all
                            >you can access are files in /hom/httpd/vhosts/jalanjones.com/httpdocs
                            >and /tmp.
                            >
                            Thanks, I hope to avoid using link().
                            >
                            I see what you mean... look at it this way... when retrieving a file
                            via HTTP:// the $_SERVER['REQUEST_URI'] will be set to the uri that
                            contains it. HINT: the -containing- uri. When retrieving from the
                            filesystem $_SERVER['REQUEST_URI'] is coming from the original page
                            therefor pointing to the right /index.php or whatever. It's like there
                            are two $_SERVER['REQUEST_URI'] variables but they don't collide.

                            example:

                            index.php
                            ---
                            <?PHP
                            echo $_SERVER['REQUEST_URI'].'<br>';
                            include('http://insert.your.dom ain/page2.php'); // http transport
                            include('page2. php'); // filesystem
                            echo $_SERVER['REQUEST_URI'].'<br>';
                            ?>

                            page2.php
                            ---
                            <?PHP
                            echo $_SERVER['REQUEST_URI'].'<br>';
                            ?>

                            ---

                            will output:

                            /index.php
                            /page2.php
                            /index.php
                            /index.php

                            obviously your not after /page2.php






                            Norm

                            Comment

                            • Jerry Stuckle

                              #15
                              Re: 'nested conditional' that can identify parent page?

                              Alan Jones wrote:
                              On Sun, 13 May 2007 09:41:17 -0500, Jerry Stuckle
                              <jstucklex@attg lobal.netwrote:
                              >
                              >Alan,
                              >>
                              >$_SERVER['REQUEST_URI'] does give the uri used to fetch the page. I'm
                              >not sure what you mean by 'child' file. Are you using frames? Maybe if
                              >you post the code you're using (including that in the 'parent' and
                              >'child' pages) it will be more clear.
                              >
                              Thanks for helping me. :)
                              >
                              To isolate the process, I have recreated the scenario using new
                              files, file names, and a new folder called 'test'.
                              >

                              >
                              : Inside of index2.php is...
                              >
                              <html><head><ti tle></title>
                              <meta http-equiv="Content-Type" content="text/html;
                              charset=iso-8859-1">
                              </head><body>
                              >
                              <p>This sentence is in the index2.php file.</p>
                              >
                              <p><?php include('http://jalanjones.com/test/content.php');? ></p>
                              >
                              <p>Why is there a numeral one (1) at the end? (scratching
                              head)<br><br></p>
                              >
                              </body></html>
                              >
                              : ...and inside of /test/content.php is...
                              >
                              <html><head><ti tle></title>
                              <meta http-equiv="Content-Type" content="text/html;
                              charset=iso-8859-1">
                              </head><body>
                              <table cellpadding="10 " style="border:1 px solid #333333"><tr><t d>
                              >
                              <p><br>This table is in the content.php 'include' file.</p>
                              >
                              <p>REQUEST_UR I result:&nbsp;&n bsp;&nbsp;<b>
                              <?php echo($_SERVER['REQUEST_URI']);?></b></p>
                              >
                              <p>The result (/test/content.php) is the name of the include/child
                              file, not the parent page; the URL.</p>
                              >
                              <p>Below is phpinfo() run from inside the include file. Please see
                              the PHP Variables section...<br>< br></p>
                              >
                              <?php echo phpinfo();?>
                              >
                              </table></tr></td>
                              </body></html>
                              >
                              Can anyone identify the culprit? Again, I am very new to PHP so it
                              is probably something only a clueless newb would do. :D
                              >
                              >And as Schraalhans indicated, commands which relate to the underlying
                              >filesystem (i.e. link, fopen, include, etc.) reference the file system
                              >directly. So if you use absolute paths (beginning with '/'), it is the
                              >root directory of the file system. But your host has limited you so all
                              >you can access are files in /hom/httpd/vhosts/jalanjones.com/httpdocs
                              >and /tmp.
                              >
                              Thanks, I hope to avoid using link().
                              >
                              This is working normally. When you said:

                              <?php include('http://jalanjones.com/test/content.php');? >

                              This resulted in another call to the server to fetch test/content.php.
                              So the URL in there will be "test/content.php". The only difference
                              here is you included it from the server side instead of the client side
                              - but when the http: request reaches the server, the server neither
                              knows nor cares about the origin. The PHP file is executed and the
                              results returned to index2.php, where they are displayed.

                              Now, if you would have instead done something like:

                              <?php include($_SERVE R['DOCUMENT_ROOT'] . '/test/content.php');? >

                              This would have gone directly to the file system and included the file
                              without an additional call to Apache. The file would have been
                              included, the code executed and the results displayed.

                              Do you see the difference between the two?


                              --
                              =============== ===
                              Remove the "x" from my email address
                              Jerry Stuckle
                              JDS Computer Training Corp.
                              jstucklex@attgl obal.net
                              =============== ===

                              Comment

                              Working...