
Originally Posted by
logic_earth
If you don't actually get the "section" within the script (because mod_rewrite doesn't send it) then there is nothing to do, no hole to fix.
One only needs to validate, filter, sanitize things that you use from the user input. If you never touch it within your code then you don't need to do anything with it.
I am wondering if the way I am going about all of this is hokey?! 
When a user clicks on some navigation tab (e.g. "Finance"), then my "articles/index.php" script uses a $_GET['section'] to query the database for all Articles in that chosen Section.
With some Articles in hand, down in the HTML part of that script, I have this code which dynamically generates the URL's for each Article...
PHP Code:
<!-- ARTICLE LISTING -->
<div id="boxArticleIndex">
<h2><?php echo $sectionName; ?> Articles</h2>
<?php
// ******************************************
// Display Article-Summaries for a Section. *
// ******************************************
while (mysqli_stmt_fetch($stmt1)){
// Format Published On.
$publishedOn = date('F j, Y', strtotime($publishedOn));
// (e.g. "local.debbie/finance/articles/postage-meters-can-save-you-money")
$articleURL = generateArticleURL($sectionSlug, $articleSlug);
$summary = str_replace('{url}', $articleURL, $summary);
echo "<div class='articleSummary'>
<h3>$heading</h3>
<a href='" . $articleURL . "'>$image</a>
<div class='date'>Published: $publishedOn</div>
$summary
</div>";
}
?>
So for my "articles/index.php" script, I am using $_GET['section'].
However, the minute a user clicks on a link like this...
http://local.debbie/finance/articles/postage-meters-can-save-you-money
...my "articles/article.php" script fires, which is an Article Template.
In my .htaccess, I have this code...
Code:
#PRETTY: articles/postage-meters-can-save-you-money
#UGLY: articles/article.php?slug=postage-meters-can-save-you-money
#Rewrite only if the request is not pointing to a real file (e.g. add_comment.php, index.php).
RewriteCond %{REQUEST_FILENAME} !-f
#Match any kind of slug. PHP will decide if it's valid or not.
RewriteRule articles/(.+)$ articles/article.php?slug=$1 [L]
So I am taking the "dynamic" Article URL, and parsing it up so the "Article Slug" is assigned to "?slug=", but my mod_rewrite does NOT do anything with the "faux Section", and that brings us to the current discussion...
It seems to me that I need a way to validate the "Section" in the URL when my "articles/article.php" script loads, right? 
Debbie
Bookmarks