navigation include not functioning

navigation include not functioning

am 05.08.2009 19:00:57 von Allen McCabe

--0016364eed74642c7a047067f270
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

I am trying to generate pages by importing content in includes, and using my
navigation include to tell PHP to replace a $thisPage variable which all the
includes use

The idea behind it (I know tons of people do it, but I'm new to this
concept), is to have a 'layout' page where only a variable changes using
$_GET on an href (index.php?page=services or index.php?page=about) to load
the new 'pages'.

PROBLEM:
All my links are displaying the current page state, and links are not
building around the link text (hrefs are built conditionally with if
$thisPage != services then build the link, otherwise leave it as normal
text). Same thing with the background image behind the link text (to
indicate a page's current position). If the condition is not true, all the
links (except the true current 'page') are supposed reload index.php and
pass a variable to itself to place into $thisPage using
href="index.php?page=" (after which I have a variable which stores "about"
or "services" within the if statement near the link text.

If this sounds like something you are familiar with (former issues and
whatnot) please let me know what I'm doing wrong. I would be happy to give
you any code you want to look at (index.php or navigation.php, whatever).

Thanks again for your help PHP gurus!

--0016364eed74642c7a047067f270--

Re: navigation include not functioning

am 05.08.2009 19:10:40 von Jerry Wilborn

--001636458c0e25f7ff0470681523
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

I'm having trouble understanding your description of the problem. Can you
tell us what you're seeing and what you expect to see?
Jerry Wilborn
jerrywilborn@gmail.com


On Wed, Aug 5, 2009 at 12:00 PM, Allen McCabe wrote:

> I am trying to generate pages by importing content in includes, and using
> my
> navigation include to tell PHP to replace a $thisPage variable which all
> the
> includes use
>
> The idea behind it (I know tons of people do it, but I'm new to this
> concept), is to have a 'layout' page where only a variable changes using
> $_GET on an href (index.php?page=services or index.php?page=about) to load
> the new 'pages'.
>
> PROBLEM:
> All my links are displaying the current page state, and links are not
> building around the link text (hrefs are built conditionally with if
> $thisPage != services then build the link, otherwise leave it as normal
> text). Same thing with the background image behind the link text (to
> indicate a page's current position). If the condition is not true, all the
> links (except the true current 'page') are supposed reload index.php and
> pass a variable to itself to place into $thisPage using
> href="index.php?page=" (after which I have a variable which stores "about"
> or "services" within the if statement near the link text.
>
> If this sounds like something you are familiar with (former issues and
> whatnot) please let me know what I'm doing wrong. I would be happy to give
> you any code you want to look at (index.php or navigation.php, whatever).
>
> Thanks again for your help PHP gurus!
>

--001636458c0e25f7ff0470681523--

Re: navigation include not functioning

am 05.08.2009 19:19:00 von Allen McCabe

--00163646c2e2f3adb3047068323a
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Sure.

When I load my site, default.php loads ( displaying:
http://uplinkdesign.hostzi.com/ in the browser as expected). $thisPage is
set to "about" via:

if (!isset($thisPage)) {
$thisPage="about";
} else {
$thisPage = addslashes($_GET['page']);
}
?>

in the tags.


I am seeing this:

The first 2 includes work just fine, loading to proper middle section and
proper right-hand-side page content, the navigation include also loads, but
all the of "tabs" (background images) are the currentpage image, as opposed
to not, as they should be (the the exception of the About Us background
image).

It seems that $thisPage is equal to all four values, so all the if
statements within navigation tell PHP to load the current page image for all
4 links.

Does this help?
On Wed, Aug 5, 2009 at 10:10 AM, Jerry Wilborn wrote:

> I'm having trouble understanding your description of the problem. Can you
> tell us what you're seeing and what you expect to see?
> Jerry Wilborn
> jerrywilborn@gmail.com
>
>
>
> On Wed, Aug 5, 2009 at 12:00 PM, Allen McCabe wrote:
>
>> I am trying to generate pages by importing content in includes, and using
>> my
>> navigation include to tell PHP to replace a $thisPage variable which all
>> the
>> includes use
>>
>> The idea behind it (I know tons of people do it, but I'm new to this
>> concept), is to have a 'layout' page where only a variable changes using
>> $_GET on an href (index.php?page=services or index.php?page=about) to load
>> the new 'pages'.
>>
>> PROBLEM:
>> All my links are displaying the current page state, and links are not
>> building around the link text (hrefs are built conditionally with if
>> $thisPage != services then build the link, otherwise leave it as normal
>> text). Same thing with the background image behind the link text (to
>> indicate a page's current position). If the condition is not true, all the
>> links (except the true current 'page') are supposed reload index.php and
>> pass a variable to itself to place into $thisPage using
>> href="index.php?page=" (after which I have a variable which stores "about"
>> or "services" within the if statement near the link text.
>>
>> If this sounds like something you are familiar with (former issues and
>> whatnot) please let me know what I'm doing wrong. I would be happy to give
>> you any code you want to look at (index.php or navigation.php, whatever).
>>
>> Thanks again for your help PHP gurus!
>>
>
>

--00163646c2e2f3adb3047068323a--

Re: navigation include not functioning

am 05.08.2009 19:28:57 von Martin Scotta

I think you are looking for something like this:

$page =3D array_key_exists( 'page', $_GET ) ? GET['page'] : 'index';

Then you MUST sanitize the $page variable.

I often use the querystring to wrapp the module you are requesting:

www.example.org/?path/to/molude (note that .htaccess is required)

# the you can access by
echo $path =3D $_SERVER['QUERY_STRING'];

On Wed, Aug 5, 2009 at 2:19 PM, Allen McCabe wrote:
> Sure.
>
> When I load my site, default.php loads ( displaying:
> http://uplinkdesign.hostzi.com/ in the browser as expected). $thisPage is
> set to "about" via:
>
> > if (!isset($thisPage)) {
> =A0$thisPage=3D"about";
> =A0} else {
> =A0$thisPage =3D addslashes($_GET['page']);
> =A0}
> ?>
>
> in the tags.
>
>
> I am seeing this:
>
> The first 2 includes work just fine, loading to proper middle section and
> proper right-hand-side page content, the navigation include also loads, b=
ut
> all the of "tabs" (background images) are the currentpage image, as oppos=
ed
> to not, as they should be (the the exception of the About Us background
> image).
>
> It seems that $thisPage is equal to all four values, so all the if
> statements within navigation tell PHP to load the current page image for =
all
> 4 links.
>
> Does this help?
> On Wed, Aug 5, 2009 at 10:10 AM, Jerry Wilborn wr=
ote:
>
>> I'm having trouble understanding your description of the problem. =A0Can=
you
>> tell us what you're seeing and what you expect to see?
>> Jerry Wilborn
>> jerrywilborn@gmail.com
>>
>>
>>
>> On Wed, Aug 5, 2009 at 12:00 PM, Allen McCabe wro=
te:
>>
>>> I am trying to generate pages by importing content in includes, and usi=
ng
>>> my
>>> navigation include to tell PHP to replace a $thisPage variable which al=
l
>>> the
>>> includes use
>>>
>>> The idea behind it (I know tons of people do it, but I'm new to this
>>> concept), is to have a 'layout' page where only a variable changes usin=
g
>>> $_GET on an href (index.php?page=3Dservices or index.php?page=3Dabout) =
to load
>>> the new 'pages'.
>>>
>>> PROBLEM:
>>> All my links are displaying the current page state, and links are not
>>> building around the link text (hrefs are built conditionally with if
>>> $thisPage !=3D services then build the link, otherwise leave it as norm=
al
>>> text). Same thing with the background image behind the link text (to
>>> indicate a page's current position). If the condition is not true, all =
the
>>> links (except the true current 'page') are supposed reload index.php an=
d
>>> pass a variable to itself to place into $thisPage using
>>> href=3D"index.php?page=3D" (after which I have a variable which stores =
"about"
>>> or "services" within the if statement near the link text.
>>>
>>> If this sounds like something you are familiar with (former issues and
>>> whatnot) please let me know what I'm doing wrong. I would be happy to g=
ive
>>> you any code you want to look at (index.php or navigation.php, whatever=
).
>>>
>>> Thanks again for your help PHP gurus!
>>>
>>
>>
>



--=20
Martin Scotta

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: navigation include not functioning

am 05.08.2009 20:52:51 von Ollisso

On Wed, 05 Aug 2009 20:19:00 +0300, Allen McCabe
wrote:

> Sure.
>
> When I load my site, default.php loads ( displaying:
> http://uplinkdesign.hostzi.com/ in the browser as expected). $thisPage is
> set to "about" via:
>
> > if (!isset($thisPage)) {
> $thisPage="about";
> } else {
> $thisPage = addslashes($_GET['page']);
> }
> ?>
>
> in the tags.
>
>
> I am seeing this:
>
> The first 2 includes work just fine, loading to proper middle section and
> proper right-hand-side page content, the navigation include also loads,
> but
> all the of "tabs" (background images) are the currentpage image, as
> opposed
> to not, as they should be (the the exception of the About Us background
> image).
>
> It seems that $thisPage is equal to all four values, so all the if
> statements within navigation tell PHP to load the current page image for
> all
> 4 links.
>
> Does this help?

Looks like you need something like that:
$pages = array(
// list of modules you have, for example:
'about' , 'help', etc
);
$page = isset($_GET['page']) && isset($pages[$_GET['page']]) ?
$_GET['page'] : 'about';
// about is default page here

then just:
include 'modules/'.$page.'.php';

Always remember that you have to check what is included.
Best approach(if possible) to have a predefined list of all modules which
can be included.

Else, there is some nasty things like:
?page=../index.php
(infinity recurssion)

?page=http://otherhost.com/hacker.
(inclusion of malicious script)
and so on.




> On Wed, Aug 5, 2009 at 10:10 AM, Jerry Wilborn
> wrote:
>
Look

>> I'm having trouble understanding your description of the problem. Can
>> you
>> tell us what you're seeing and what you expect to see?
>> Jerry Wilborn
>> jerrywilborn@gmail.com
>>
>>
>>
>> On Wed, Aug 5, 2009 at 12:00 PM, Allen McCabe
>> wrote:
>>
>>> I am trying to generate pages by importing content in includes, and
>>> using
>>> my
>>> navigation include to tell PHP to replace a $thisPage variable which
>>> all
>>> the
>>> includes use
>>>
>>> The idea behind it (I know tons of people do it, but I'm new to this
>>> concept), is to have a 'layout' page where only a variable changes
>>> using
>>> $_GET on an href (index.php?page=services or index.php?page=about) to
>>> load
>>> the new 'pages'.
>>>
>>> PROBLEM:
>>> All my links are displaying the current page state, and links are not
>>> building around the link text (hrefs are built conditionally with if
>>> $thisPage != services then build the link, otherwise leave it as normal
>>> text). Same thing with the background image behind the link text (to
>>> indicate a page's current position). If the condition is not true, all
>>> the
>>> links (except the true current 'page') are supposed reload index.php
>>> and
>>> pass a variable to itself to place into $thisPage using
>>> href="index.php?page=" (after which I have a variable which stores
>>> "about"
>>> or "services" within the if statement near the link text.
>>>
>>> If this sounds like something you are familiar with (former issues and
>>> whatnot) please let me know what I'm doing wrong. I would be happy to
>>> give
>>> you any code you want to look at (index.php or navigation.php,
>>> whatever).
>>>
>>> Thanks again for your help PHP gurus!
>>>
>>
>>
>
>



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: navigation include not functioning

am 05.08.2009 22:36:12 von Allen McCabe

--00163646c2e231480904706af401
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Okay, I see how href="?page=contact" would work, and I do indeed have only
one file (which loads includes), but it still is not working. Clicking a
link, be href=?page=contact, href=?page=services, whatever, it still loads
the page with the ?page=whatever attached to the URL, but it is not
subsituting the $page variable within the include snippets, and it just
loads the 'about' versions of all includes (/phpincludes/about_content.php
as opposed to /phpincludes/services_content.php or whichever).

This is really stumping me and try as I might I cannot see why it will not
work. Here is some of my code as it is currently:

On default.php:

[code=default.php]




$pages = array(
// list of includes:
'about' , 'services', 'portfolio', 'contact'
);
$page = isset($_GET['page']) && isset($pages[$_GET['page']]) ?
$_GET['page'] : 'about';
// about is default page here

?>
<br /> <br /> [/code]<br /> <br /> then in the body tags<br /> <br /> [code=default.php]<br /> <br /> <td><?php include('phpincludes/' . $page . '_centerbar.php'); ?></td><br /> </tr><br /> <?php include('phpincludes/nav2.php'); ?><br /> <tr><br /> <br /> [/code]<br /> [code=nav2.php]<br /> <br /> <br /> <br /> [/code]<br /> <br /> It is surprisingly little code and I am starting to wonder if any php<br /> settings on my server are inhibiting this. What do you think?<br /> <br /> <br /> <br /> 2009/8/5 ollisso <ollisso@fromru.com><br /> <br /> > On Wed, 05 Aug 2009 22:08:30 +0300, Allen McCabe <allenmccabe@gmail.com><br /> > wrote:<br /> ><br /> > You can do something like that:<br /> ><br /> > links:<br /> > <br /> ><br /> > This will work if you have only one file, all the time and it is default<br /> > one for current folder. (normally that is index.php, might be default.php in<br /> > your case)<br /> ><br /> > Second option is to use more harder approach:<br /> ><br /> > $pos =<br /> > min(strpos($_SERVER['QUERY_STRING'],'&'),strpos($_SERVER['QU ERY_STRING'],'='));<br /> > $act = ($pos!==false) ? substr($_SERVER['QUERY_STRING'], 0, $pos) :<br /> > $_SERVER['QUERY_STRING'];<br /> > $page = strtolower($act);<br /> ><br /> > then you can use links like:<br /> > href='?contact'<br /> > or if you need:<br /> > href='?contact=1' (in case of GET forms)<br /> ><br /> ><br /> > Third option is to use mod_rewrite, but this is slightly harder :)<br /> ><br /> > But then you will be able to use links like:<br /> > www.domain.com/contact/<br /> > (which will work like: index.php?page=contact internally)<br /> ><br /> > About checking what is included:<br /> > Imagine following scenario:<br /> ><br /> > $page = isset($_GET['page']) ? $_GET['page'] : 'about';<br /> ><br /> > include 'modules/'.$page.'.php';<br /> ><br /> > Problem here is that you can include ANY file.<br /> > For example:<br /> > ?page=../index<br /> > will work as:<br /> > include 'modules/../index.php';<br /> ><br /> > Which is crearly not what is intended.<br /> ><br /> > There is also much more dangerous scenarios of this.<br /> ><br /> > I hope this explains something :)<br /> ><br /> ><br /> ><br /> > Excellent, your snippet is working nicely. Thank you!<br /> >><br /> >> Unfortunately, when I click a link ( <a href="<br /> >> http://uplinkdesign.hostzi.com/default.php?page=contact"> ),<br /> >> deafult.php?contact shows in the browser, but the default (about) content<br /> >> is<br /> >> loading.<br /> >><br /> >> Also, I don't know what you mean by checking what is included.<br /> >><br /> >> 2009/8/5 ollisso <ollisso@fromru.com><br /> >><br /> >> On Wed, 05 Aug 2009 20:19:00 +0300, Allen McCabe <allenmccabe@gmail.com><br /> >>> wrote:<br /> >>><br /> >>> Sure.<br /> >>><br /> >>>><br /> >>>> When I load my site, default.php loads ( displaying:<br /> >>>> http://uplinkdesign.hostzi.com/ in the browser as expected). $thisPage<br /> >>>> is<br /> >>>> set to "about" via:<br /> >>>><br /> >>>> <?php<br /> >>>> if (!isset($thisPage)) {<br /> >>>> $thisPage="about";<br /> >>>> } else {<br /> >>>> $thisPage = addslashes($_GET['page']);<br /> >>>> }<br /> >>>> ?><br /> >>>><br /> >>>> in the <head> tags.<br /> >>>><br /> >>>><br /> >>>> I am seeing this:<br /> >>>><br /> >>>> The first 2 includes work just fine, loading to proper middle section<br /> >>>> and<br /> >>>> proper right-hand-side page content, the navigation include also loads,<br /> >>>> but<br /> >>>> all the of "tabs" (background images) are the currentpage image, as<br /> >>>> opposed<br /> >>>> to not, as they should be (the the exception of the About Us background<br /> >>>> image).<br /> >>>><br /> >>>> It seems that $thisPage is equal to all four values, so all the if<br /> >>>> statements within navigation tell PHP to load the current page image for<br /> >>>> all<br /> >>>> 4 links.<br /> >>>><br /> >>>> Does this help?<br /> >>>><br /> >>>><br /> >>> Looks like you need something like that:<br /> >>> $pages = array(<br /> >>> // list of modules you have, for example:<br /> >>> 'about' , 'help', etc<br /> >>> );<br /> >>> $page = isset($_GET['page']) && isset($pages[$_GET['page']]) ?<br /> >>> $_GET['page'] : 'about';<br /> >>> // about is default page here<br /> >>><br /> >>> then just:<br /> >>> include 'modules/'.$page.'.php';<br /> >>><br /> >>> Always remember that you have to check what is included.<br /> >>> Best approach(if possible) to have a predefined list of all modules which<br /> >>> can be included.<br /> >>><br /> >>> Else, there is some nasty things like:<br /> >>> ?page=../index.php<br /> >>> (infinity recurssion)<br /> >>><br /> >>> ?page=http://otherhost.com/hacker.<br /> >>> (inclusion of malicious script)<br /> >>> and so on.<br /> >>><br /> >>><br /> >>><br /> >>><br /> >>> On Wed, Aug 5, 2009 at 10:10 AM, Jerry Wilborn <jerrywilborn@gmail.com<br /> >>><br /> >>>> >wrote:<br /> >>>><br /> >>>> Look<br /> >>>><br /> >>><br /> >>><br /> >>> I'm having trouble understanding your description of the problem. Can<br /> >>><br /> >>>> you<br /> >>>>> tell us what you're seeing and what you expect to see?<br /> >>>>> Jerry Wilborn<br /> >>>>> jerrywilborn@gmail.com<br /> >>>>><br /> >>>>><br /> >>>>><br /> >>>>> On Wed, Aug 5, 2009 at 12:00 PM, Allen McCabe <allenmccabe@gmail.com<br /> >>>>> >wrote:<br /> >>>>><br /> >>>>> I am trying to generate pages by importing content in includes, and<br /> >>>>> using<br /> >>>>><br /> >>>>>> my<br /> >>>>>> navigation include to tell PHP to replace a $thisPage variable which<br /> >>>>>> all<br /> >>>>>> the<br /> >>>>>> includes use <?php include('phpincludes/' . $thisPage . '.php') ?><br /> >>>>>><br /> >>>>>> The idea behind it (I know tons of people do it, but I'm new to this<br /> >>>>>> concept), is to have a 'layout' page where only a variable changes<br /> >>>>>> using<br /> >>>>>> $_GET on an href (index.php?page=services or index.php?page=about) to<br /> >>>>>> load<br /> >>>>>> the new 'pages'.<br /> >>>>>><br /> >>>>>> PROBLEM:<br /> >>>>>> All my links are displaying the current page state, and links are not<br /> >>>>>> building around the link text (hrefs are built conditionally with if<br /> >>>>>> $thisPage != services then build the link, otherwise leave it as<br /> >>>>>> normal<br /> >>>>>> text). Same thing with the background image behind the link text (to<br /> >>>>>> indicate a page's current position). If the condition is not true, all<br /> >>>>>> the<br /> >>>>>> links (except the true current 'page') are supposed reload index.php<br /> >>>>>> and<br /> >>>>>> pass a variable to itself to place into $thisPage using<br /> >>>>>> href="index.php?page=" (after which I have a variable which stores<br /> >>>>>> "about"<br /> >>>>>> or "services" within the if statement near the link text.<br /> >>>>>><br /> >>>>>> If this sounds like something you are familiar with (former issues and<br /> >>>>>> whatnot) please let me know what I'm doing wrong. I would be happy to<br /> >>>>>> give<br /> >>>>>> you any code you want to look at (index.php or navigation.php,<br /> >>>>>> whatever).<br /> >>>>>><br /> >>>>>> Thanks again for your help PHP gurus!<br /> >>>>>><br /> >>>>>><br /> >>>>>><br /> >>>>><br /> >>>>><br /> >>>><br /> >>>><br /> >>><br /> >>><br /> >><br /> >><br /> ><br /> ><br /> <br /> --00163646c2e231480904706af401--</p> </article> <article> <h2>Re: navigation include not functioning</h2><span>am 05.08.2009 22:44:50 von Martin Scotta</span> <p>You are using a value-filled array as a key-filled. Try this snippet<br /> and look the results...<br /> <br /> $pages =3D array('about' , 'services', 'portfolio', 'contact');<br /> $page =3D array_key_exists( 'page', $_GET ) ? $_GET[ 'page' ] : 'about';<br /> /*if*/ false ===3D array_search( $page, $pages, true ) && (<br /> $page =3D 'about'<br /> );<br /> <br /> # note the sintax used to avoid if-statement<br /> # this has the same behaviour, but with less performance<br /> $pages =3D array('about' , 'services', 'portfolio', 'contact');<br /> $page =3D array_key_exists( 'page', $_GET ) ? $_GET[ 'page' ] : 'about';<br /> if( false ===3D array_search( $page, $pages, true ))<br /> {<br /> $page =3D 'about';<br /> }<br /> <br /> <br /> <br /> On Wed, Aug 5, 2009 at 5:36 PM, Allen McCabe<allenmccabe@gmail.com> wrote:<br /> > Okay, I see how href=3D"?page=3Dcontact" would work, and I do indeed have=<br /> only<br /> > one file (which loads includes), but it still is not working. Clicking a<br /> > link, be href=3D?page=3Dcontact, href=3D?page=3Dservices, whatever, it st=<br /> ill loads<br /> > the page with the ?page=3Dwhatever attached to the URL, but it is not<br /> > subsituting the $page variable within the include snippets, and it just<br /> > loads the 'about' versions of all includes (/phpincludes/about_content.ph=<br /> p<br /> > as opposed to /phpincludes/services_content.php or whichever).<br /> ><br /> > This is really stumping me and try as I might I cannot see why it will no=<br /> t<br /> > work. Here is some of my code as it is currently:<br /> ><br /> > On default.php:<br /> ><br /> > [code=3Ddefault.php]<br /> ><br /> > <html><br /> > <head><br /> > <?php<br /> ><br /> > $pages =3D array(<br /> > // list of includes:<br /> > =A0'about' , 'services', 'portfolio', 'contact'<br /> > );<br /> > $page =3D isset($_GET['page']) && isset($pages[$_GET['page']]) =A0?<br /> > $_GET['page'] : 'about';<br /> > // about is default page here<br /> ><br /> > ?><br /> > <title><br /> ><br /> > [/code]<br /> ><br /> > then in the body tags<br /> ><br /> > [code=3Ddefault.php]<br /> ><br /> > <td><?php include('phpincludes/' . $page . '_centerbar.php'); ?></td><br /> > </tr><br /> > =A0<?php include('phpincludes/nav2.php'); ?><br /> > =A0<tr><br /> ><br /> > [/code]<br /> > [code=3Dnav2.php]<br /> ><br /> > <br /> ><br /> > [/code]<br /> ><br /> > It is surprisingly little code and I am starting to wonder if any php<br /> > settings on my server are inhibiting this. What do you think?<br /> ><br /> ><br /> ><br /> > 2009/8/5 ollisso <ollisso@fromru.com><br /> ><br /> >> On Wed, 05 Aug 2009 22:08:30 +0300, Allen McCabe <allenmccabe@gmail.com><br /> >> wrote:<br /> >><br /> >> You can do something like that:<br /> >><br /> >> links:<br /> >> <br /> >><br /> >> This will work if you have only one file, all the time and it is default<br /> >> one for current folder. (normally that is index.php, might be default.ph=<br /> p in<br /> >> your case)<br /> >><br /> >> Second option is to use more harder approach:<br /> >><br /> >> $pos =A0  =<br /> >> min(strpos($_SERVER['QUERY_STRING'],'&'),strpos($_SERVER['QU ERY_STRING']=<br /> ,'=3D'));<br /> >> $act =A0  = ($pos!==false) ? substr($_SERVER['QUERY_STRING'], 0,=<br /> =A0$pos) :<br /> >> $_SERVER['QUERY_STRING'];<br /> >> $page =A0 =3D strtolower($act);<br /> >><br /> >> then you can use links like:<br /> >> href=3D'?contact'<br /> >> or if you need:<br /> >> href=3D'?contact=3D1' (in case of GET forms)<br /> >><br /> >><br /> >> Third option is to use mod_rewrite, but this is slightly harder :)<br /> >><br /> >> But then you will be able to use links like:<br /> >> www.domain.com/contact/<br /> >> (which will work like: index.php?page=3Dcontact internally)<br /> >><br /> >> About checking what is included:<br /> >> Imagine following scenario:<br /> >><br /> >> $page =A0 =3D isset($_GET['page']) ? $_GET['page'] : 'about';<br /> >><br /> >> include 'modules/'.$page.'.php';<br /> >><br /> >> Problem here is that you can include ANY file.<br /> >> For example:<br /> >> ?page=3D../index<br /> >> will work as:<br /> >> include 'modules/../index.php';<br /> >><br /> >> Which is crearly not what is intended.<br /> >><br /> >> There is also much more dangerous scenarios of this.<br /> >><br /> >> I hope this explains something :)<br /> >><br /> >><br /> >><br /> >> Excellent, your snippet is working nicely. Thank you!<br /> >>><br /> >>> Unfortunately, when I click a link ( <a href=3D"<br /> >>> http://uplinkdesign.hostzi.com/default.php?page=3Dcontact"> ),<br /> >>> deafult.php?contact shows in the browser, but the default (about) conte=<br /> nt<br /> >>> is<br /> >>> loading.<br /> >>><br /> >>> Also, I don't know what you mean by checking what is included.<br /> >>><br /> >>> 2009/8/5 ollisso <ollisso@fromru.com><br /> >>><br /> >>> On Wed, 05 Aug 2009 20:19:00 +0300, Allen McCabe <allenmccabe@gmail.com=<br /> ><br /> >>>> wrote:<br /> >>>><br /> >>>> Sure.<br /> >>>><br /> >>>>><br /> >>>>> When I load my site, default.php loads ( displaying:<br /> >>>>> http://uplinkdesign.hostzi.com/ in the browser as expected). $thisPag=<br /> e<br /> >>>>> is<br /> >>>>> set to "about" via:<br /> >>>>><br /> >>>>> <?php<br /> >>>>> if (!isset($thisPage)) {<br /> >>>>> =A0$thisPage=3D"about";<br /> >>>>> =A0} else {<br /> >>>>> =A0$thisPage =3D addslashes($_GET['page']);<br /> >>>>> =A0}<br /> >>>>> ?><br /> >>>>><br /> >>>>> in the <head> tags.<br /> >>>>><br /> >>>>><br /> >>>>> I am seeing this:<br /> >>>>><br /> >>>>> The first 2 includes work just fine, loading to proper middle section<br /> >>>>> and<br /> >>>>> proper right-hand-side page content, the navigation include also load=<br /> s,<br /> >>>>> but<br /> >>>>> all the of "tabs" (background images) are the currentpage image, as<br /> >>>>> opposed<br /> >>>>> to not, as they should be (the the exception of the About Us backgrou=<br /> nd<br /> >>>>> image).<br /> >>>>><br /> >>>>> It seems that $thisPage is equal to all four values, so all the if<br /> >>>>> statements within navigation tell PHP to load the current page image =<br /> for<br /> >>>>> all<br /> >>>>> 4 links.<br /> >>>>><br /> >>>>> Does this help?<br /> >>>>><br /> >>>>><br /> >>>> Looks like you need something like that:<br /> >>>> $pages  = array(<br /> >>>> // list of modules you have, for example:<br /> >>>> =A0'about' , 'help', etc<br /> >>>> );<br /> >>>> $page =A0 =3D isset($_GET['page']) && isset($pages[$_GET['page']]) =A0=<br /> ?<br /> >>>> =A0$_GET['page'] : 'about';<br /> >>>> // about is default page here<br /> >>>><br /> >>>> then just:<br /> >>>> include 'modules/'.$page.'.php';<br /> >>>><br /> >>>> Always remember that you have to check what is included.<br /> >>>> Best approach(if possible) to have a predefined list of all modules wh=<br /> ich<br /> >>>> can be included.<br /> >>>><br /> >>>> Else, there is some nasty things like:<br /> >>>> ?page=3D../index.php<br /> >>>> (infinity recurssion)<br /> >>>><br /> >>>> ?page=3Dhttp://otherhost.com/hacker.<br /> >>>> (inclusion of malicious script)<br /> >>>> and so on.<br /> >>>><br /> >>>><br /> >>>><br /> >>>><br /> >>>> On Wed, Aug 5, 2009 at 10:10 AM, Jerry Wilborn <jerrywilborn@gmail.com<br /> >>>><br /> >>>>> >wrote:<br /> >>>>><br /> >>>>> Look<br /> >>>>><br /> >>>><br /> >>>><br /> >>>> =A0I'm having trouble understanding your description of the problem. =<br /> =A0Can<br /> >>>><br /> >>>>> you<br /> >>>>>> tell us what you're seeing and what you expect to see?<br /> >>>>>> Jerry Wilborn<br /> >>>>>> jerrywilborn@gmail.com<br /> >>>>>><br /> >>>>>><br /> >>>>>><br /> >>>>>> On Wed, Aug 5, 2009 at 12:00 PM, Allen McCabe <allenmccabe@gmail.com<br /> >>>>>> >wrote:<br /> >>>>>><br /> >>>>>> I am trying to generate pages by importing content in includes, and<br /> >>>>>> using<br /> >>>>>><br /> >>>>>>> my<br /> >>>>>>> navigation include to tell PHP to replace a $thisPage variable whic=<br /> h<br /> >>>>>>> all<br /> >>>>>>> the<br /> >>>>>>> includes use <?php include('phpincludes/' . $thisPage . '.php') ?><br /> >>>>>>><br /> >>>>>>> The idea behind it (I know tons of people do it, but I'm new to thi=<br /> s<br /> >>>>>>> concept), is to have a 'layout' page where only a variable changes<br /> >>>>>>> using<br /> >>>>>>> $_GET on an href (index.php?page=3Dservices or index.php?page=3Dabo=<br /> ut) to<br /> >>>>>>> load<br /> >>>>>>> the new 'pages'.<br /> >>>>>>><br /> >>>>>>> PROBLEM:<br /> >>>>>>> All my links are displaying the current page state, and links are n=<br /> ot<br /> >>>>>>> building around the link text (hrefs are built conditionally with i=<br /> f<br /> >>>>>>> $thisPage !=3D services then build the link, otherwise leave it as<br /> >>>>>>> normal<br /> >>>>>>> text). Same thing with the background image behind the link text (t=<br /> o<br /> >>>>>>> indicate a page's current position). If the condition is not true, =<br /> all<br /> >>>>>>> the<br /> >>>>>>> links (except the true current 'page') are supposed reload index.ph=<br /> p<br /> >>>>>>> and<br /> >>>>>>> pass a variable to itself to place into $thisPage using<br /> >>>>>>> href=3D"index.php?page=3D" (after which I have a variable which sto=<br /> res<br /> >>>>>>> "about"<br /> >>>>>>> or "services" within the if statement near the link text.<br /> >>>>>>><br /> >>>>>>> If this sounds like something you are familiar with (former issues =<br /> and<br /> >>>>>>> whatnot) please let me know what I'm doing wrong. I would be happy =<br /> to<br /> >>>>>>> give<br /> >>>>>>> you any code you want to look at (index.php or navigation.php,<br /> >>>>>>> whatever).<br /> >>>>>>><br /> >>>>>>> Thanks again for your help PHP gurus!<br /> >>>>>>><br /> >>>>>>><br /> >>>>>>><br /> >>>>>><br /> >>>>>><br /> >>>>><br /> >>>>><br /> >>>><br /> >>>><br /> >>><br /> >>><br /> >><br /> >><br /> ><br /> <br /> <br /> <br /> --=20<br /> Martin Scotta<br /> <br /> -- <br /> PHP General Mailing List (http://www.php.net/)<br /> To unsubscribe, visit: http://www.php.net/unsub.php</p> </article> <article> <h2>Re: navigation include not functioning</h2><span>am 06.08.2009 17:39:13 von TedD</span> <p>At 10:00 AM -0700 8/5/09, Allen McCabe wrote:<br /> >-snip-<br /> ><br /> >If this sounds like something you are familiar with (former issues and<br /> >whatnot) please let me know what I'm doing wrong.<br /> <br /> Try this:<br /> <br /> http://sperling.com/examples/include-demo/<br /> <br /> If you follow what's given there, you'll be further along on includes.<br /> <br /> After that, you can try smart navigation:<br /> <br /> http://sperling.com/examples/smart-menu/<br /> <br /> HTH's,<br /> <br /> tedd<br /> -- <br /> -------<br /> http://sperling.com http://ancientstones.com http://earthstones.com<br /> <br /> -- <br /> PHP General Mailing List (http://www.php.net/)<br /> To unsubscribe, visit: http://www.php.net/unsub.php</p> </article> <footer> <a href="/">Index</a> | <a href="/impressum.php">Impressum</a> | <a href="/datenschutz.php">Datenschutz</a> | <a href="https://www.xodox.de/">XODOX</a> </footer> </main> </body> </html>