Reply to Re: Parsing .htaccess file

Your name:

Reply:


Posted by Erwin Moller on 02/17/06 12:21

Stefan Bellon wrote:

> Erwin Moller wrote:
>
>> $myLines = file('path/to/.htaccess');
>> foreach($myLines as $oneLine){
>> echo htmlentities($oneLine)."<br>";
>> }
>>
>> Does that show correctly?
>
> This does print the content correctly, yes, thanks a lot. However, if I
> want to parse (and replace) the content using ereg_replace I get funny
> results as the bracket < seems to be represented as &lt; internally.
> So, when trying to get at the filename, I need to do something like
>
> ereg_replace("&lt;Files (.*)&gt;", "\\1", htmlentities($line))
>
> Wow. Is this the easiest way of filtering out the information? All I
> want to do is build a list of "who may access which file according to
> the information inside the .htaccess file".
>

Hi,

No, it is not the easiest way, but it shows the output right to the browser.
If you use < and > in your output, your webbrowser will interpret that as a
tag.
adding htmlentities replaces the <> (and other problematic characters) by
their HTMLequivalents.

You can do what you were trying to do, but I cannot help you with the
regexp, because I suck at regexpr.
So my response was just a warning to use htmlentities whenever you are
feeding information to a browser, because of the unexpected result you get
when you do not.
Of course: Looking in the source (view source) of the page could help too.

Regards,
Erwin

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация