[Techtalk] Web site setup

Yaroslav Fedevych jaroslaw at linux.org.ua
Wed Apr 20 19:30:35 EST 2005


On Wed, Apr 20, 2005 at 10:15:12AM +0100, Dan wrote:
> I have an interesting problem with web sites that I'd like your comments
> on. Currently our web site is static and is maintained by a
> non-programmer who knows just enough HTML to get by. Since all our web
> pages have the same style (and not just CSS), we'd like to use PHP to
> dynamically generate the top and bottom of each page.
> 
> The person who maintains our web site is intelligent but isn't a
> programmer, so we want to make this as easy as possible for her. I'd
> like to have each page look something like this:
> 
> <?php
> $title = 'Foo';
> $content = '
> <p>The main content of the page goes here.</p>
> ';
> include('main-library.inc');
> ?>
> 

W-w-w-what?? 

<?php 
$title='Foo';
...?>
<p>The main content of the page goes here.</p>

And that's all of it. Remember that PHP was made to be embedded into
HTML...

> That's quite feasible except that you would have to escape all the
> single quotes in the HTML content, which would be a pain for big
> documents. PHP supports here-documents but that's not great either,
> because you'd have to escape dollar signs and backslashes. Perl may
> allow here-documents that you don't have to escape, but Perl isn't a
> great choice because we're not doing any heavy-duty processing. This is
> such a simple problem but there doesn't seem to be an easy solution.

You can even craft a function ... oh, you don't need it since there is
readfile(). Read the file into a variable and echo it where appropriate.

> 
> An alternative is to store the main content in a separate text file, but
> we don't want "unfriendly URIs" (URIs where the page is specified after
> a question mark, like http://example.com/site?page=foo/bar/baz) because
> they're not processed as well e.g. by search engines. 

They are ... well, not so secure. http://example.com/site?page=/etc/passwd.
Or what is more amazing if content is include()'d: http://example.com/site?page=site
I love such recursion...


-- 
X windows: Warn your friends about it.



More information about the Techtalk mailing list