lee the bean Posted July 10, 2013 Posted July 10, 2013 Hi, I noticed many moons ago that some mischievous bots were hitting: /index.php?cPath=0 There didn't seem to be any problem with this so I ignored. The page that gets displayed is a page I'd like to make use of. That is it displays a top level categories tree which places the top level categories images into the top of the body text area, along with a selection of new products. I thought I could make use of this (cat images at top level) and send shopping cart users there with a continue shopping button (better than sending to the DEFAULT_FILE index.php). However because of the way that oscommerce likes to create page links using the parameters list from the url we end up with cPath=0_1 for top category 1 on some page links and cPath=1 for other links. Not a problem as such - however it is for SEO as there would be duplicate contents indexed (the canonical also adds the cPath=0_1 in the head). So a long winded way of getting to my request - "is there a good add-on that gives me the same results as cPath=0 - but no other changes for 2.3.3" Since raising a separate issue with inappropriate URL's being accessed by BING ( see http://www.oscommerce.com/forums/topic/393524-233-how-to-prevent-inappropriate-url-parameters/ ) I thought I'd revisit the cPath=0 phenomenon. I looked in google and bing webmasters to find these BOTS are accessing 'cPath=' as part of their searching your site tosh. I still think it would be appropriate to only accept valid url parameters to only get indexed valid urls. Anything else should 404 - that way we don't need to worry about BOTS doing naughty things, google or bing spending more time onsite and penalizing for duplicate content. It would also help with malicious code injectors etc. Hope this makes sense - tried searching for a good add-on but could only find ones that do more than what I would like.
lee the bean Posted August 14, 2013 Author Posted August 14, 2013 Finally put my brain into gear:- Add following code to the third section of index.php after <h1><?php echo HEADING_TITLE; ?></h1> and before <?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); include(DIR_WS_MODULES . FILENAME_UPCOMING_PRODUCTS); Here is code: <div class="contentContainer"> <div class="contentText"> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <?php if (isset($cPath) && tep_not_null($cPath)) { // check to see if there are deeper categories within the current category $category_links = array_reverse($cPath_array); for($i=0, $n=sizeof($category_links); $i<$n; $i++) { $categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $categories = tep_db_fetch_array($categories_query); if ($categories['total'] < 1) { // do nothing, go through the loop } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); break; // we've found the deepest category the customer is in } } } else { $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); } $number_of_categories = tep_db_num_rows($categories_query); $rows = 0; while ($categories = tep_db_fetch_array($categories_query)) { $rows++; $cPath_new = tep_get_path($categories['categories_id']); $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; echo ' <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br />' . $categories['categories_name'] . '</a></td>' . "\n"; if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) { echo ' </tr>' . "\n"; echo ' <tr>' . "\n"; } } ?> </tr> </table> <br /> </div> Der Der. And to fix the bots prefixing category zero to cPath parameters (as seen in google) cPath=0; cPath=0_1 etc Find following in application_top.php :- // calculate category path if (isset($HTTP_GET_VARS['cPath'])) { $cPath = $HTTP_GET_VARS['cPath']; Add if (substr($cPath, 0, 1) == "0") { $cPath = substr($cPath, 2); } Der Der. However this doesn't stop the split_page_results.php from parsing duff parameters to the page number links (the functionality needs a rethink in my opinion).
Recommended Posts
Archived
This topic is now archived and is closed to further replies.