????

Your IP : 216.73.216.174


Current Path : /home2/morganrand/www/store/includes/
Upload File :
Current File : /home2/morganrand/www/store/includes/recently_viewed_products.php

<?php
/*

Adapted by AVeliki from: http://addons.oscommerce.com/info/7759

Recently Viewed Products (for all oscommerce versions)
Without database queries for better performance! (c) 2010

Released under the GNU General Public License

NOTES:

To adjust image size: Near line 45 below (it begins with $last_visited_thumb), change the default value of 80 to your preferred height and adjust width by entering a value between the '' just before height. 
For example, a new line with a height of 70 and a width of 65 would look like this:

$last_visited_thumb = tep_image(DIR_WS_IMAGES . $item_image, $item_name, '65', '70');

You probably will only want to have a value for one OR the other, but not both; leaving either width or height blank ( '' ) will maintain the image's original aspect ratio.

This contribution can be viewed in a live store at http://www.cheesyflix.com

*/

// Lets set the number of history items to display
$display_count = 5;

$action = (isset($_GET['action']) ? $_GET['action'] : '');
if ($action == 'clear_history') {
  unset($_SESSION['last_product_views']);
 }
// Build history string
$last_product_views = $_SESSION['last_product_views'];
if ($last_product_views != "") { 
/* echo '<pre>';
print_r($last_product_views);
echo '</pre>';
exit; */
  $visited_array = explode('|', $_SESSION['last_product_views']);
  
  $output_count = 1;    
        foreach ($visited_array as $visited_array_item) {
          $visited_item = trim($visited_array_item);
		  //echo trim($visited_array_item);
		  
                if ( ($visited_item != "") && ($output_count <= $display_count) ) {
						
                        $item_pieces = explode("^", $visited_item);
						/* echo '<pre>';
						print_r($item_pieces);
						echo '</pre>'; */
                        $item_image = trim($item_pieces[0]);
                        $item_name = trim($item_pieces[1]);
                        $item_url = trim($item_pieces[2]);
                        $recent_visited_output .= '<div class="tabl_pp" style="text-align: center; width:20%;">';
                        $last_visited_thumb = tep_image(DIR_WS_IMAGES . $item_image, $item_name, '132', '122');
                        $recent_visited_output .= '<a href="http://' . $item_url . '">' . $last_visited_thumb . '</a><br>' . $item_name;
                        $recent_visited_output .= "</div>";
                        $output_count++;
                }
        }
}

// Now look at the current page
if (basename($_SERVER['SCRIPT_NAME']) == "product_info.php") {

		$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.products_group from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
		$product_info = tep_db_fetch_array($product_info_query);
        // First remove the action=clear_history from the url
        $current_product_path = str_replace('&action=clear_history', '', $_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI']);
        //$pieces = explode("?osCsid", $current_product_path);
        //$current_product_path = $pieces[0];
        $new_array_item = $product_info['products_image'] . '^' . $product_info['products_name'] . '^' . $current_product_path;

// and add it to the $_SESSION variable
  $last_product_views = $_SESSION['last_product_views'];
  if ($last_product_views == "") {
  
        $_SESSION['last_product_views'] = trim($new_array_item);
  } else {
        $items_array = explode('|', $_SESSION['last_product_views']);   
        $count = 1;
        $new_array_string = '';
          foreach ($items_array as $array_item) {
                if ($count <= $display_count) {
                  $array_item = trim($array_item);
                  if ($array_item != "") {
                        if ($array_item != $new_array_item) {
                      $new_array_string .= "|" . $array_item;
                          $count++;
                        }       
                  }
                }
      }
        $_SESSION['last_product_views'] = $new_array_item . '|' . $new_array_string;
  }
}

// Display history string to browser
if ($last_product_views != "") {
      /* $info_box_contents = array();
      $info_box_contents[] = array('align' => 'left', 
							'text' => '&nbsp;' . TEXT_LAST_VISITED_PRODUCTS);
      new contentBox($info_box_contents, 'true', 'true', tep_href_link($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], tep_get_all_get_params(array('action')) . 'action=clear_history')); */
      
	  echo '<div class="recent_item">&nbsp;&nbsp;'.TEXT_LAST_VISITED_PRODUCTS.'</div>';
      $info_box_contents = array();
      $info_box_contents[] = array('params' => 'width:100%;',
							'align' => 'left',								
							'params' => 'valign="top"',
							'text' => $recent_visited_output);							
      /* $info_box_contents = array();
      $info_box_contents[] = array('align' => 'left', 
							'params' => 'valign="top"',
							'text' => $recent_visited_output); */
      new contentBox($info_box_contents);
          ?>
          <table>
            <tr>
          <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
        </tr>
      </table>
      <?php
} // end if ($last_product_views != "")
?>