<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1020039" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1020039</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/practical-navigation#comment-1122269</link>
    <description> &lt;p&gt;I&#039;ll keep that code handy, I might need it again..&lt;/p&gt;
 </description>
     <pubDate>Thu, 26 Dec 2002 11:53:38 +0000</pubDate>
 <dc:creator>nuk3</dc:creator>
 <guid isPermaLink="false">comment 1122269 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/practical-navigation#comment-1122264</link>
    <description> &lt;p&gt;For the record...&lt;br /&gt;
if(!preg_match(&quot;/^[a-z0-9]+$/i&quot;, $page)) {&lt;/p&gt;
&lt;p&gt;becomes:&lt;br /&gt;
if(!preg_match(&quot;/^[a-z0-9_\-]+$/i&quot;, $page)) {&lt;/p&gt;
 </description>
     <pubDate>Thu, 26 Dec 2002 04:45:15 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1122264 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/practical-navigation#comment-1122263</link>
    <description> &lt;p&gt;No need to worry anymore, I&#039;ve decided to scrap all the fancy scripting and include the template on each page, thanks for all your help anyway!&lt;/p&gt;
 </description>
     <pubDate>Thu, 26 Dec 2002 01:50:49 +0000</pubDate>
 <dc:creator>nuk3</dc:creator>
 <guid isPermaLink="false">comment 1122263 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/practical-navigation#comment-1122262</link>
    <description> &lt;p&gt;How can I make it so underscores and hyphens are allowed to be used? I cant make any sense of that validation code &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/confused.png&quot; title=&quot;Confused&quot; alt=&quot;Confused&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Thu, 26 Dec 2002 00:49:49 +0000</pubDate>
 <dc:creator>nuk3</dc:creator>
 <guid isPermaLink="false">comment 1122262 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/practical-navigation#comment-1122232</link>
    <description> &lt;p&gt;also include will return false on failure, so a more compact method of testing success would be...&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;include(\&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;includes/&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;.php\&quot;) or die(\&quot;Page doesn&#039;t exist: &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;.php\&quot;);&lt;br /&gt;&lt;br /&gt;// or&lt;br /&gt;&lt;br /&gt;if(!include(\&quot;includes/&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;.php\&quot;)) { // do something }&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Wed, 25 Dec 2002 00:09:32 +0000</pubDate>
 <dc:creator>ROB</dc:creator>
 <guid isPermaLink="false">comment 1122232 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/practical-navigation#comment-1122200</link>
    <description> &lt;p&gt;Yeah, don&#039;t you just hate people who do that? They think, just because it&#039;s there they should go have a look at it and see what havoc they can do? ...&lt;/p&gt;
 </description>
     <pubDate>Tue, 24 Dec 2002 07:01:14 +0000</pubDate>
 <dc:creator>Renegade</dc:creator>
 <guid isPermaLink="false">comment 1122200 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/practical-navigation#comment-1122161</link>
    <description> &lt;p&gt;It&#039;s always best to be paranoid about data coming into your scripts.&lt;/p&gt;
&lt;p&gt;It&#039;s a very good idea to pattern match the filename first.  That will prevent any wise guys from trying to navigate your filesystem.&lt;/p&gt;
&lt;p&gt;The only ideal solution, IMO, is to know which files are allowed to be included.  And to only include those files (such as a large CASE selection).&lt;/p&gt;
&lt;p&gt;Side note... this IF statement is uneccessary:&lt;br /&gt;
if ($file != &quot;.&quot; &amp;amp;&amp;amp; $file != &quot;..&quot; &amp;amp;&amp;amp; $file != &quot;.htaccess&quot;) {&lt;/p&gt;
 </description>
     <pubDate>Mon, 23 Dec 2002 07:20:53 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1122161 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/practical-navigation#comment-1122155</link>
    <description> &lt;p&gt;Hmmm, overkill it may be, but after reading through it seems allot safer.. What does everyone else think?&lt;/p&gt;
 </description>
     <pubDate>Mon, 23 Dec 2002 00:27:09 +0000</pubDate>
 <dc:creator>nuk3</dc:creator>
 <guid isPermaLink="false">comment 1122155 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/practical-navigation#comment-1122141</link>
    <description> &lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;This may seem like over kill...&lt;/p&gt;
&lt;p&gt;but, I never trust anything coming into my scripts.&lt;/p&gt;
&lt;p&gt;I also read into the directory instead of file_exists();&lt;br /&gt;
because I have seen it cause trouble on some windows systems!&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// error 1 = bad page name i.e., (\&quot;page\&quot; can only contain (a-z0-9)/i&lt;br /&gt;&lt;br /&gt;// error 2 = bad page name i.e., (\&quot;page\&quot; to include does not exist)&lt;br /&gt;&lt;br /&gt;// if a error is found redirect to....&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$home &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= \&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;/members\&quot;;&lt;br /&gt;&lt;br /&gt;// only allow by [GET METHOD], you can change this!&lt;br /&gt;&lt;br /&gt;if (isset(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_GET&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;page&#039;])) {&lt;br /&gt;&lt;br /&gt;// define &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$test&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;....&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$test&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;\&quot;;&lt;br /&gt;&lt;br /&gt;// convert &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_GET&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; to simple &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$var&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; name&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_GET&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;page&#039;];&lt;br /&gt;&lt;br /&gt;// test what is coming into the script&lt;br /&gt;&lt;br /&gt;// never trust anything sent to your scripts!&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$test&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = verify(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;);&lt;br /&gt;&lt;br /&gt;// if the (page test = verify function) returns [0]&lt;br /&gt;// everything is (OK) OK = include page was found&lt;br /&gt;// so include the page from the (GET METHOD)&lt;br /&gt;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$test&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; == 0) {&lt;br /&gt;&lt;br /&gt;include(&#039;includes/&#039;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;.&#039;.php&#039;);&lt;br /&gt;&lt;br /&gt;} else {&lt;br /&gt;&lt;br /&gt;// if the (page test = verify function) returns [1]&lt;br /&gt;// something went wrong &amp;gt; (could be only 2 things)&lt;br /&gt;// 1. bad page name [a-z0-9] only&lt;br /&gt;// 2. include page not found.......&lt;br /&gt;// redirect them, or change and (echo a error!)&lt;br /&gt;&lt;br /&gt;header(\&quot;Location: &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$home&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;/\&quot;);&lt;br /&gt;&lt;br /&gt;exit;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;} else {&lt;br /&gt;&lt;br /&gt;// we got here because there is no (GET METHOD &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$var&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; [&#039;page&#039;])&lt;br /&gt;// redirect them, or change and (echo a error!)&lt;br /&gt;&lt;br /&gt;header(\&quot;Location: &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$home&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;/\&quot;);&lt;br /&gt;&lt;br /&gt;exit;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// the function to verify the request from the users browser!&lt;br /&gt;&lt;br /&gt;function verify(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;) {&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$test&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = 0;&lt;br /&gt;&lt;br /&gt;// path to the includes directory&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$dir&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;some_directory/on/your/server/to/includes\&quot;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$check&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = \&quot;\&quot;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;.\&quot;.php\&quot;;&lt;br /&gt;&lt;br /&gt;// change this to what you will allow in your include page names&lt;br /&gt;&lt;br /&gt;if(!preg_match(\&quot;/^[a-z0-9]+$/i\&quot;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$page&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;)) { &lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$test&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = 1;&lt;br /&gt;&lt;br /&gt;} else {&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$test&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = 1;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$handle&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;=opendir(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$dir&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;); &lt;br /&gt;&lt;br /&gt;while ((&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = readdir(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$handle&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;))!== false){ &lt;br /&gt;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; != \&quot;.\&quot; &amp;amp;&amp;amp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; != \&quot;..\&quot; &amp;amp;&amp;amp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; != \&quot;.htaccess\&quot;) {&lt;br /&gt;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; == &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$check&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;) {&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$test&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = 0;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;closedir(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$handle&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$test&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;F!&lt;/p&gt;
 </description>
     <pubDate>Sun, 22 Dec 2002 13:02:24 +0000</pubDate>
 <dc:creator>Fataqui</dc:creator>
 <guid isPermaLink="false">comment 1122141 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/practical-navigation#comment-1122137</link>
    <description> &lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;Quote: &lt;em&gt;Originally posted by Mark Hensler &lt;/em&gt;&lt;br /&gt;
&lt;strong&gt;and beware... there is NO security in the above code.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Consider the following:&lt;br /&gt;
your_page.php?page=../.htaccess &lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;How would get aroun that?&lt;/p&gt;
 </description>
     <pubDate>Sun, 22 Dec 2002 08:04:38 +0000</pubDate>
 <dc:creator>Renegade</dc:creator>
 <guid isPermaLink="false">comment 1122137 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
