Click here to get back home

Server side or PHP include?

 HomeNewsGroups | Search | About
 alt.www.webmaster    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Server side or PHP include? Heidi 03-15-2007
Get Chitika Premium
Posted by Heidi on March 15, 2007, 6:04 pm
Please log in for more thread options


I want to use it for my category links so I can add, edit or remove new ones
easily.
I read on wikipedia.org that both PHP and Server Side includes have
potential security risks.

So what should I do? use Server side includes, use PHP includes, or just
edit every single page of the site each time I make a change to the
categories?

=)

Heidi



Posted by Els on March 15, 2007, 5:45 pm
Please log in for more thread options


Heidi wrote:

> I want to use it for my category links so I can add, edit or remove new ones
> easily.
> I read on wikipedia.org that both PHP and Server Side includes have
> potential security risks.
>
> So what should I do? use Server side includes, use PHP includes, or just
> edit every single page of the site each time I make a change to the
> categories?

I use PHP, which has the added benefit I can tell it to "add this
class if you're on this page", so I can make the link[1] to the
current page appear different.

[1]- I actually substitute the href attribute with the class, so it's
not really a link.

--
Els http://locusmeus.com/

Now playing: Musical Youth - Pass The Dutchie

Posted by Els on March 15, 2007, 6:00 pm
Please log in for more thread options


Blinky the Shark wrote:

> Els wrote:
>> Heidi wrote:
>>
>>> I want to use it for my category links so I can add, edit or remove new ones
>>> easily.
>>> I read on wikipedia.org that both PHP and Server Side includes have
>>> potential security risks.
>>>
>>> So what should I do? use Server side includes, use PHP includes, or just
>>> edit every single page of the site each time I make a change to the
>>> categories?
>>
>> I use PHP, which has the added benefit I can tell it to "add this
>> class if you're on this page", so I can make the link[1] to the
>> current page appear different.
>>
>> [1]- I actually substitute the href attribute with the class, so it's
>> not really a link.
>
> Can you explain that a little more, Els? At least enough that I can
> find what you're doing in my O'Reilly "Programming PHP" book? :)

From the menu file I include in every page on my site:

<li><a <?php if ($_SERVER['PHP_SELF']=="/photography.html") {print
('class="current"');}else{print ('href="/photography.html"');}
?>>photography</a></li>        

No idea how to find that in your O'Reilly "Programming PHP" book, I
only have a Prentice Hall "Core PHP Programming" book ;-)

--
Els http://locusmeus.com/

Now playing: Joan Jett - I Love Rock And Roll

Posted by Toby A Inkster on March 15, 2007, 9:30 pm
Please log in for more thread options


Els wrote:

> <li><a <?php if ($_SERVER['PHP_SELF']=="/photography.html") {print
> ('class="current"');}else{print ('href="/photography.html"');}
> ?>>photography</a></li>

Is this more readable?

<?php
        $menus = array(
                        'a' => array(
                                'home'                => '/index.html',
                                'sitemap'        => '/sitemap.html',
                                'contact'        => '/contact.html'
                        ),
                        'b' => array(
                                'about'                => '/about.html',
                                'blog'                => 'http://blog.locusmeus.com/',
                                'photography'        => '/photography.html',
                                'computer'        => '/computer.html',
                                'travel'        => '/travel.html',
                                'exit'                => '/exit.html'
                        )
                );

        print '<div id="nav">'."\n";
        foreach ($menus as $class => $menu)
        {
                printf('<ul class="%s">'."\n", $class);
                foreach ($menu as $label => $url)
                {
                        $attr = sprintf('href="%s"', htmlentities($url));
                        if ($_SERVER['PHP_SELF']==$n) $attr = 'class="current"';

                        printf('<li><a %s>%s</a></li>'."\n",
                                $attr, htmlentities($label));
                }
                print "</ul>\n";
        }                
        print "</div>\n";
?>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

Posted by Els on March 16, 2007, 4:08 am
Please log in for more thread options


Toby A Inkster wrote:

> Els wrote:
>
>> <li><a <?php if ($_SERVER['PHP_SELF']=="/photography.html") {print
>> ('class="current"');}else{print ('href="/photography.html"');}
>> ?>>photography</a></li>
>
> Is this more readable?
>
> <?php
>         $menus = array(
>                         'a' => array(
>                                 'home'                => '/index.html',
>                                 'sitemap'        => '/sitemap.html',
>                                 'contact'        => '/contact.html'
>                         ),
>                         'b' => array(
>                                 'about'                => '/about.html',
>                                 'blog'                => 'http://blog.locusmeus.com/',
>                                 'photography'        => '/photography.html',
>                                 'computer'        => '/computer.html',
>                                 'travel'        => '/travel.html',
>                                 'exit'                => '/exit.html'
>                         )
>                 );
>
>         print '<div id="nav">'."\n";
>         foreach ($menus as $class => $menu)
>         {
>                 printf('<ul class="%s">'."\n", $class);
>                 foreach ($menu as $label => $url)
>                 {
>                         $attr = sprintf('href="%s"', htmlentities($url));
>                         if ($_SERVER['PHP_SELF']==$n) $attr = 'class="current"';
>
>                         printf('<li><a %s>%s</a></li>'."\n",
>                                 $attr, htmlentities($label));
>                 }
>                 print "</ul>\n";
>         }                
>         print "</div>\n";
> ?>

Thanks! :-)
As you may have guessed, I don't know much PHP, so I just couldn't
have come up with this lot, and even when reading it, I don't
understand half of it.

However, I copied it into my file, above my own code, and it just
doesn't write the 'current' class.
(and while you're at it - could you make the href appear *plus* add a
class "partof" on pages that aren't in the menu, like on this one:
http://locusmeus.com/tent-city-london.html ?) ;-)

--
Els http://locusmeus.com/

Similar ThreadsPosted
Client side versus Server side April 17, 2006, 1:26 pm
What language does Google use server-side? October 6, 2005, 4:46 pm
Server Side Includes frustration! July 27, 2006, 5:26 pm
JavaScript server-side scripting platforms? December 19, 2006, 5:01 am
Stripping whitespace at server-side from HTML generated by JSP November 21, 2005, 5:59 pm
Sending attachments using server side mail gateway? January 24, 2007, 7:53 pm
2 Divs side-by-side causing me grief November 11, 2006, 4:57 pm
controlling 2 floating objects side-by-side September 30, 2008, 11:51 am
Side by side search comparison August 19, 2006, 12:02 pm
Re: SSI and HTML or PHP and include? January 25, 2006, 4:16 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap