[ Index ] |
|
Code source de osCommerce 2.2ms2-060817 |
1 <?php 2 /* 3 $Id: product_reviews_write.php,v 1.55 2003/06/20 14:25:58 hpdl Exp $ 4 5 osCommerce, Open Source E-Commerce Solutions 6 http://www.oscommerce.com 7 8 Copyright (c) 2003 osCommerce 9 10 Released under the GNU General Public License 11 */ 12 13 require ('includes/application_top.php'); 14 15 if (!tep_session_is_registered('customer_id')) { 16 $navigation->set_snapshot(); 17 tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); 18 } 19 20 $product_info_query = tep_db_query("select p.products_id, p.products_model, p.products_image, p.products_price, p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); 21 if (!tep_db_num_rows($product_info_query)) { 22 tep_redirect(tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params(array('action')))); 23 } else { 24 $product_info = tep_db_fetch_array($product_info_query); 25 } 26 27 $customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); 28 $customer = tep_db_fetch_array($customer_query); 29 30 if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) { 31 $rating = tep_db_prepare_input($HTTP_POST_VARS['rating']); 32 $review = tep_db_prepare_input($HTTP_POST_VARS['review']); 33 34 $error = false; 35 if (strlen($review) < REVIEW_TEXT_MIN_LENGTH) { 36 $error = true; 37 38 $messageStack->add('review', JS_REVIEW_TEXT); 39 } 40 41 if (($rating < 1) || ($rating > 5)) { 42 $error = true; 43 44 $messageStack->add('review', JS_REVIEW_RATING); 45 } 46 47 if ($error == false) { 48 tep_db_query("insert into " . TABLE_REVIEWS . " (products_id, customers_id, customers_name, reviews_rating, date_added) values ('" . (int)$HTTP_GET_VARS['products_id'] . "', '" . (int)$customer_id . "', '" . tep_db_input($customer['customers_firstname']) . ' ' . tep_db_input($customer['customers_lastname']) . "', '" . tep_db_input($rating) . "', now())"); 49 $insert_id = tep_db_insert_id(); 50 51 tep_db_query("insert into " . TABLE_REVIEWS_DESCRIPTION . " (reviews_id, languages_id, reviews_text) values ('" . (int)$insert_id . "', '" . (int)$languages_id . "', '" . tep_db_input($review) . "')"); 52 53 tep_redirect(tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params(array('action')))); 54 } 55 } 56 57 if ($new_price = tep_get_products_special_price($product_info['products_id'])) { 58 $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>'; 59 } else { 60 $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); 61 } 62 63 if (tep_not_null($product_info['products_model'])) { 64 $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>'; 65 } else { 66 $products_name = $product_info['products_name']; 67 } 68 69 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_REVIEWS_WRITE); 70 71 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params())); 72 ?> 73 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 74 <html <?php echo HTML_PARAMS; ?>> 75 <head> 76 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 77 <title><?php echo TITLE; ?></title> 78 <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> 79 <link rel="stylesheet" type="text/css" href="stylesheet.css"> 80 <script language="javascript"><!-- 81 function checkForm() { 82 var error = 0; 83 var error_message = "<?php echo JS_ERROR; ?>"; 84 85 var review = document.product_reviews_write.review.value; 86 87 if (review.length < <?php echo REVIEW_TEXT_MIN_LENGTH; ?>) { 88 error_message = error_message + "<?php echo JS_REVIEW_TEXT; ?>"; 89 error = 1; 90 } 91 92 if ((document.product_reviews_write.rating[0].checked) || (document.product_reviews_write.rating[1].checked) || (document.product_reviews_write.rating[2].checked) || (document.product_reviews_write.rating[3].checked) || (document.product_reviews_write.rating[4].checked)) { 93 } else { 94 error_message = error_message + "<?php echo JS_REVIEW_RATING; ?>"; 95 error = 1; 96 } 97 98 if (error == 1) { 99 alert(error_message); 100 return false; 101 } else { 102 return true; 103 } 104 } 105 106 function popupWindow(url) { 107 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150') 108 } 109 //--></script> 110 </head> 111 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> 112 <!-- header //--> 113 <?php require(DIR_WS_INCLUDES . 'header.php'); ?> 114 <!-- header_eof //--> 115 116 <!-- body //--> 117 <table border="0" width="100%" cellspacing="3" cellpadding="3"> 118 <tr> 119 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> 120 <!-- left_navigation //--> 121 <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> 122 <!-- left_navigation_eof //--> 123 </table></td> 124 <!-- body_text //--> 125 <td width="100%" valign="top"><?php echo tep_draw_form('product_reviews_write', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'action=process&products_id=' . $HTTP_GET_VARS['products_id']), 'post', 'onSubmit="return checkForm();"'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> 126 <tr> 127 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 128 <tr> 129 <td class="pageHeading" valign="top"><?php echo $products_name; ?></td> 130 <td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td> 131 </tr> 132 </table></td> 133 </tr> 134 <tr> 135 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> 136 </tr> 137 <?php 138 if ($messageStack->size('review') > 0) { 139 ?> 140 <tr> 141 <td><?php echo $messageStack->output('review'); ?></td> 142 </tr> 143 <tr> 144 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> 145 </tr> 146 <?php 147 } 148 ?> 149 <tr> 150 <td><table width="100%" border="0" cellspacing="0" cellpadding="2"> 151 <tr> 152 <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 153 <tr> 154 <td class="main"><?php echo '<b>' . SUB_TITLE_FROM . '</b> ' . tep_output_string_protected($customer['customers_firstname'] . ' ' . $customer['customers_lastname']); ?></td> 155 </tr> 156 <tr> 157 <td class="main"><b><?php echo SUB_TITLE_REVIEW; ?></b></td> 158 </tr> 159 <tr> 160 <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> 161 <tr class="infoBoxContents"> 162 <td><table border="0" width="100%" cellspacing="2" cellpadding="2"> 163 <tr> 164 <td class="main"><?php echo tep_draw_textarea_field('review', 'soft', 60, 15); ?></td> 165 </tr> 166 <tr> 167 <td class="smallText" align="right"><?php echo TEXT_NO_HTML; ?></td> 168 </tr> 169 <tr> 170 <td class="main"><?php echo '<b>' . SUB_TITLE_RATING . '</b> ' . TEXT_BAD . ' ' . tep_draw_radio_field('rating', '1') . ' ' . tep_draw_radio_field('rating', '2') . ' ' . tep_draw_radio_field('rating', '3') . ' ' . tep_draw_radio_field('rating', '4') . ' ' . tep_draw_radio_field('rating', '5') . ' ' . TEXT_GOOD; ?></td> 171 </tr> 172 </table></td> 173 </tr> 174 </table></td> 175 </tr> 176 <tr> 177 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> 178 </tr> 179 <tr> 180 <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> 181 <tr class="infoBoxContents"> 182 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 183 <tr> 184 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 185 <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params(array('reviews_id', 'action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td> 186 <td class="main" align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> 187 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> 188 </tr> 189 </table></td> 190 </tr> 191 </table></td> 192 </tr> 193 </table></td> 194 <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" align="right" valign="top"><table border="0" cellspacing="0" cellpadding="2"> 195 <tr> 196 <td align="center" class="smallText"> 197 <?php 198 if (tep_not_null($product_info['products_image'])) { 199 ?> 200 <script language="javascript"><!-- 201 document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>'); 202 //--></script> 203 <noscript> 204 <?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?> 205 </noscript> 206 <?php 207 } 208 209 echo '<p><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now') . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a></p>'; 210 ?> 211 </td> 212 </tr> 213 </table> 214 </td> 215 </table></td> 216 </tr> 217 </table></form></td> 218 <!-- body_text_eof //--> 219 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> 220 <!-- right_navigation //--> 221 <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> 222 <!-- right_navigation_eof //--> 223 </table></td> 224 </tr> 225 </table> 226 <!-- body_eof //--> 227 228 <!-- footer //--> 229 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> 230 <!-- footer_eof //--> 231 <br> 232 </body> 233 </html> 234 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 19:48:25 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |