[ Index ]
 

Code source de osCommerce 2.2ms2-060817

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/catalog/ -> tell_a_friend.php (source)

   1  <?php
   2  /*
   3    $Id: $
   4  
   5    osCommerce, Open Source E-Commerce Solutions
   6    http://www.oscommerce.com
   7  
   8    Copyright (c) 2006 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') && (ALLOW_GUEST_TO_TELL_A_FRIEND == 'false')) {
  16      $navigation->set_snapshot();
  17      tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  18    }
  19  
  20    $valid_product = false;
  21    if (isset($HTTP_GET_VARS['products_id'])) {
  22      $product_info_query = tep_db_query("select pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
  23      if (tep_db_num_rows($product_info_query)) {
  24        $valid_product = true;
  25  
  26        $product_info = tep_db_fetch_array($product_info_query);
  27      }
  28    }
  29  
  30    if ($valid_product == false) {
  31      tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
  32    }
  33  
  34    require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_TELL_A_FRIEND);
  35  
  36    if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
  37      $error = false;
  38  
  39      $to_email_address = tep_db_prepare_input($HTTP_POST_VARS['to_email_address']);
  40      $to_name = tep_db_prepare_input($HTTP_POST_VARS['to_name']);
  41      $from_email_address = tep_db_prepare_input($HTTP_POST_VARS['from_email_address']);
  42      $from_name = tep_db_prepare_input($HTTP_POST_VARS['from_name']);
  43      $message = tep_db_prepare_input($HTTP_POST_VARS['message']);
  44  
  45      if (empty($from_name)) {
  46        $error = true;
  47  
  48        $messageStack->add('friend', ERROR_FROM_NAME);
  49      }
  50  
  51      if (!tep_validate_email($from_email_address)) {
  52        $error = true;
  53  
  54        $messageStack->add('friend', ERROR_FROM_ADDRESS);
  55      }
  56  
  57      if (empty($to_name)) {
  58        $error = true;
  59  
  60        $messageStack->add('friend', ERROR_TO_NAME);
  61      }
  62  
  63      if (!tep_validate_email($to_email_address)) {
  64        $error = true;
  65  
  66        $messageStack->add('friend', ERROR_TO_ADDRESS);
  67      }
  68  
  69      if ($error == false) {
  70        $email_subject = sprintf(TEXT_EMAIL_SUBJECT, $from_name, STORE_NAME);
  71        $email_body = sprintf(TEXT_EMAIL_INTRO, $to_name, $from_name, $product_info['products_name'], STORE_NAME) . "\n\n";
  72  
  73        if (tep_not_null($message)) {
  74          $email_body .= $message . "\n\n";
  75        }
  76  
  77        $email_body .= sprintf(TEXT_EMAIL_LINK, tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'], 'NONSSL', false)) . "\n\n" .
  78                       sprintf(TEXT_EMAIL_SIGNATURE, STORE_NAME . "\n" . HTTP_SERVER . DIR_WS_CATALOG . "\n");
  79  
  80        tep_mail($to_name, $to_email_address, $email_subject, $email_body, $from_name, $from_email_address);
  81  
  82        $messageStack->add_session('header', sprintf(TEXT_EMAIL_SUCCESSFUL_SENT, $product_info['products_name'], tep_output_string_protected($to_name)), 'success');
  83  
  84        tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
  85      }
  86    } elseif (tep_session_is_registered('customer_id')) {
  87      $account_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
  88      $account = tep_db_fetch_array($account_query);
  89  
  90      $from_name = $account['customers_firstname'] . ' ' . $account['customers_lastname'];
  91      $from_email_address = $account['customers_email_address'];
  92    }
  93  
  94    $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_TELL_A_FRIEND, 'products_id=' . $HTTP_GET_VARS['products_id']));
  95  ?>
  96  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  97  <html <?php echo HTML_PARAMS; ?>>
  98  <head>
  99  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 100  <title><?php echo TITLE; ?></title>
 101  <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
 102  <link rel="stylesheet" type="text/css" href="stylesheet.css">
 103  </head>
 104  <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
 105  <!-- header //-->
 106  <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
 107  <!-- header_eof //-->
 108  
 109  <!-- body //-->
 110  <table border="0" width="100%" cellspacing="3" cellpadding="3">
 111    <tr>
 112      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
 113  <!-- left_navigation //-->
 114  <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
 115  <!-- left_navigation_eof //-->
 116      </table></td>
 117  <!-- body_text //-->
 118      <td width="100%" valign="top"><?php echo tep_draw_form('email_friend', tep_href_link(FILENAME_TELL_A_FRIEND, 'action=process&products_id=' . $HTTP_GET_VARS['products_id'])); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
 119        <tr>
 120          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 121            <tr>
 122              <td class="pageHeading"><?php echo sprintf(HEADING_TITLE, $product_info['products_name']); ?></td>
 123              <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_contact_us.gif', sprintf(HEADING_TITLE, $product_info['products_name']), HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 124            </tr>
 125          </table></td>
 126        </tr>
 127        <tr>
 128          <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 129        </tr>
 130  <?php
 131    if ($messageStack->size('friend') > 0) {
 132  ?>
 133        <tr>
 134          <td><?php echo $messageStack->output('friend'); ?></td>
 135        </tr>
 136        <tr>
 137          <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 138        </tr>
 139  <?php
 140    }
 141  ?>
 142        <tr>
 143          <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
 144            <tr>
 145              <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
 146                <tr>
 147                  <td class="main"><b><?php echo FORM_TITLE_CUSTOMER_DETAILS; ?></b></td>
 148                  <td class="inputRequirement" align="right"><?php echo FORM_REQUIRED_INFORMATION; ?></td>
 149                </tr>
 150              </table></td>
 151            </tr>
 152            <tr>
 153              <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
 154                <tr class="infoBoxContents">
 155                  <td><table border="0" cellspacing="0" cellpadding="2">
 156                    <tr>
 157                      <td class="main"><?php echo FORM_FIELD_CUSTOMER_NAME; ?></td>
 158                      <td class="main"><?php echo tep_draw_input_field('from_name'); ?></td>
 159                    </tr>
 160                    <tr>
 161                      <td class="main"><?php echo FORM_FIELD_CUSTOMER_EMAIL; ?></td>
 162                      <td class="main"><?php echo tep_draw_input_field('from_email_address'); ?></td>
 163                    </tr>
 164                  </table></td>
 165                </tr>
 166              </table></td>
 167            </tr>
 168            <tr>
 169              <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 170            </tr>
 171            <tr>
 172              <td class="main"><b><?php echo FORM_TITLE_FRIEND_DETAILS; ?></b></td>
 173            </tr>
 174            <tr>
 175              <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
 176                <tr class="infoBoxContents">
 177                  <td><table border="0" cellspacing="0" cellpadding="2">
 178                    <tr>
 179                      <td class="main"><?php echo FORM_FIELD_FRIEND_NAME; ?></td>
 180                      <td class="main"><?php echo tep_draw_input_field('to_name') . '&nbsp;<span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>'; ?></td>
 181                    </tr>
 182                    <tr>
 183                      <td class="main"><?php echo FORM_FIELD_FRIEND_EMAIL; ?></td>
 184                      <td class="main"><?php echo tep_draw_input_field('to_email_address') . '&nbsp;<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>'; ?></td>
 185                    </tr>
 186                  </table></td>
 187                </tr>
 188              </table></td>
 189            </tr>
 190            <tr>
 191              <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 192            </tr>
 193            <tr>
 194              <td class="main"><b><?php echo FORM_TITLE_FRIEND_MESSAGE; ?></b></td>
 195            </tr>
 196            <tr>
 197              <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
 198                <tr class="infoBoxContents">
 199                  <td><?php echo tep_draw_textarea_field('message', 'soft', 40, 8); ?></td>
 200                </tr>
 201              </table></td>
 202            </tr>
 203          </table></td>
 204        </tr>
 205        <tr>
 206          <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 207        </tr>
 208        <tr>
 209          <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
 210            <tr class="infoBoxContents">
 211              <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
 212                <tr>
 213                  <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
 214                  <td><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
 215                  <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
 216                  <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
 217                </tr>
 218              </table></td>
 219            </tr>
 220          </table></td>
 221        </tr>
 222      </table></form></td>
 223  <!-- body_text_eof //-->
 224      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
 225  <!-- right_navigation //-->
 226  <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
 227  <!-- right_navigation_eof //-->
 228      </table></td>
 229    </tr>
 230  </table>
 231  <!-- body_eof //-->
 232  
 233  <!-- footer //-->
 234  <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
 235  <!-- footer_eof //-->
 236  <br>
 237  </body>
 238  </html>
 239  <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>


Généré le : Mon Nov 26 19:48:25 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics