<?php
/*
  $Id: reviews.php,v 1.34 2002/06/22 00:07:50 harley_vb Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2002 osCommerce

  Released under the GNU General Public License
*/
?>
<!-- reviews //-->
<tr>
<td>

<TABLE cellSpacing=0 cellPadding=0 width="100%">
                    <TBODY>
                    <TR>
                      <TD colSpan=3 width="135" align="right"><IMG alt=reviews
                       src="images/reviews.gif"></TD></TR>

                      <TD vAlign="top" width="212" align="center">
                        <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                          <TBODY>
                          <TR>
                            <TD>
                              <TABLE cellSpacing=0
                              cellPadding=0 width="100%" border=0>
                                <TBODY>

                                <TR>

                      <TD>
<?php
  $random_select = "select r.reviews_id, r.reviews_rating, substring(rd.reviews_text, 1, 60) as reviews_text, p.products_id, p.products_image from " . TABLE_REVIEWS . " r left join " . TABLE_PRODUCTS . " p on r.products_id = p.products_id, " . TABLE_REVIEWS_DESCRIPTION . " rd where p.products_status = '1' and rd.reviews_id = r.reviews_id And languages_id = '" . $languages_id . "'";
  if ($HTTP_GET_VARS['products_id']) {
    $random_select .= " and p.products_id = '" . $HTTP_GET_VARS['products_id'] . "'";
  }
  $random_select .= " order by r.reviews_id DESC limit " . MAX_RANDOM_SELECT_REVIEWS;
  $random_product = tep_random_select($random_select);

  if ($random_product) {
// display random review box
    $random_product['products_name'] = tep_get_products_name($random_product['products_id']);
    $review = htmlspecialchars($random_product['reviews_text']);
    $review = tep_break_string($review, 15, '-<br>');

    $info_box_contents = array();
    $info_box_contents[] = array('align' => 'left',
                                 'text'  => '<div align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $random_product['products_id'] . '&reviews_id=' . $random_product['reviews_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></div><a class="pagenavi" href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $random_product['products_id'] . '&reviews_id=' . $random_product['reviews_id'], 'NONSSL') . '">' . $review . ' ..</a><br><div align="center">' . tep_image(DIR_WS_IMAGES . 'stars_' . $random_product['reviews_rating'] . '.gif' , sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $random_product['reviews_rating'])) . '</div>');
    new rightBox($info_box_contents);
  } elseif ($HTTP_GET_VARS['products_id']) {
// display 'write a review' box
    $info_box_contents = array();
    $info_box_contents[] = array('align' => 'left',
                                 'text'  => '<table border="0" cellspacing="0" cellpadding="2"><tr><td class="reviewbox"><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'products_id=' . $HTTP_GET_VARS['products_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'box_write_review.gif') . '</a></td><td class="reviewbox"><a class="pagenavi" href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'products_id=' . $HTTP_GET_VARS['products_id'], 'NONSSL') . '">' . BOX_REVIEWS_WRITE_REVIEW .'</a></td></tr></table>');
    new rightBox($info_box_contents);
  } else {
// display 'no reviews' box
    $info_box_contents = array();
    $info_box_contents[] = array('align' => 'left',
                                 'text'  => BOX_REVIEWS_NO_REVIEWS);
    new rightBox($info_box_contents);
  }
?></TD>
                    </TR>
                                </TBODY></TABLE></TD></TR></TBODY></TABLE></TD>

      <TD
                      width="7" height="1"><IMG
                        height=1
                        src="images/pixel_trans.gif"
                        width=6></TD>
    </TR>
                    <TR>
                      <TD colSpan=3 valign="top"></TD></TR></TBODY></TABLE>
       </tr></tr>
<!-- reviews_eof //-->