[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/ -> wishlist.php (source)

   1  <?php
   2  /*

   3  $Id: wishlist.php 3 2006-05-27 04:59:07Z user $

   4    osCMax Power E-Commerce

   5    http://oscdox.com

   6  

   7    Copyright 2006 osCMax2005 osCMax, 2002 osCommerce

   8  

   9    Released under the GNU General Public License

  10  */
  11  
  12  // Most of this file is changed or moved to BTS - Basic Template System - format.

  13  // For adding in contribution or modification - parts of this file has been moved to: catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).

  14  //       catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).

  15  // (Sub 'fallback' with your current template to see if there is a template specific file.)

  16  
  17    require ('includes/application_top.php');
  18    require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_WISHLIST);
  19  
  20  /*******************************************************************

  21  ******* ADD PRODUCT TO WISHLIST IF PRODUCT ID IS REGISTERED ********

  22  *******************************************************************/
  23  
  24    if(tep_session_is_registered('wishlist_id')) {
  25      $wishList->add_wishlist($wishlist_id, $attributes_id);
  26  
  27      if(WISHLIST_REDIRECT == 'Yes') {
  28          tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $wishlist_id));
  29      } else {
  30          tep_session_unregister('wishlist_id');
  31      }
  32    }
  33  
  34  
  35  /*******************************************************************

  36  ****************** ADD PRODUCT TO SHOPPING CART ********************

  37  *******************************************************************/
  38  
  39    if (isset($HTTP_POST_VARS['add_wishprod'])) {
  40      if(isset($HTTP_POST_VARS['add_prod_x'])) {
  41          foreach ($HTTP_POST_VARS['add_wishprod'] as $value) {
  42              $product_id = tep_get_prid($value);
  43              $cart->add_cart($product_id, $cart->get_quantity(tep_get_uprid($product_id, $HTTP_POST_VARS['id'][$value]))+1, $HTTP_POST_VARS['id'][$value]);
  44          }
  45      }
  46    }
  47  
  48  
  49  /*******************************************************************

  50  ****************** DELETE PRODUCT FROM WISHLIST ********************

  51  *******************************************************************/
  52  
  53    if (isset($HTTP_POST_VARS['add_wishprod'])) {
  54      if(isset($HTTP_POST_VARS['delete_prod_x'])) {
  55          foreach ($HTTP_POST_VARS['add_wishprod'] as $value) {
  56              $wishList->remove($value);
  57          }
  58      }
  59    }
  60  
  61  
  62  /*******************************************************************

  63  ************* EMAIL THE WISHLIST TO MULTIPLE FRIENDS ***************

  64  *******************************************************************/
  65  
  66    if (isset($HTTP_POST_VARS['email_prod_x'])) {
  67  
  68          $errors = false;
  69          $guest_errors = "";
  70          $email_errors = "";
  71          $message_error = "";
  72  
  73          if(strlen($HTTP_POST_VARS['message']) < '1') {
  74              $error = true;
  75              $message_error .= "<div class=\"messageStackError\"><img src=\"images/icons/error.gif\" /> " . ERROR_MESSAGE . "</div>";
  76          }            
  77  
  78            if(tep_session_is_registered('customer_id')) {
  79              $customer_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
  80                $customer = tep_db_fetch_array($customer_query);
  81      
  82              $from_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
  83              $from_email = $customer['customers_email_address'];
  84              $subject = $customer['customers_firstname'] . ' ' . WISHLIST_EMAIL_SUBJECT;
  85              $link = HTTP_SERVER . DIR_WS_CATALOG . FILENAME_WISHLIST_PUBLIC . "?public_id=" . $customer_id;
  86      
  87          //REPLACE VARIABLES FROM DEFINE

  88              $arr1 = array('$from_name', '$link');
  89              $arr2 = array($from_name, $link);
  90              $replace = str_replace($arr1, $arr2, WISHLIST_EMAIL_LINK);
  91              $message = tep_db_prepare_input($HTTP_POST_VARS['message']);
  92              $body = $message . $replace;
  93          } else {
  94              if(strlen($_POST['your_name']) < '1') {
  95                  $error = true;
  96                  $guest_errors .= "<div class=\"messageStackError\"><img src=\"images/icons/error.gif\" /> " . ERROR_YOUR_NAME . "</div>";
  97              }
  98              if(strlen($_POST['your_email']) < '1') {
  99                  $error = true;
 100                  $guest_errors .= "<div class=\"messageStackError\"><img src=\"images/icons/error.gif\" /> " .ERROR_YOUR_EMAIL . "</div>";
 101              } elseif(!tep_validate_email($_POST['your_email'])) {
 102                  $error = true;
 103                  $guest_errors .= "<div class=\"messageStackError\"><img src=\"images/icons/error.gif\" /> " . ERROR_VALID_EMAIL . "</div>";
 104              }
 105  
 106              $from_name = stripslashes($_POST['your_name']);
 107              $from_email = $_POST['your_email'];
 108              $subject = $from_name . ' ' . WISHLIST_EMAIL_SUBJECT;
 109              $message = stripslashes($HTTP_POST_VARS['message']);
 110  
 111              $z = 0;
 112              $prods = "";
 113              foreach($HTTP_POST_VARS['prod_name'] as $name) {
 114                  $prods .= stripslashes($name) . "  " . stripslashes($HTTP_POST_VARS['prod_att'][$z]) . "\n" . $HTTP_POST_VARS['prod_link'][$z] . "\n\n";
 115                  $z++;
 116              }
 117              $body = $message . "\n\n" . $prods . "\n\n" . WISHLIST_EMAIL_GUEST;
 118            }
 119  
 120          //Check each posted name => email for errors.

 121      $j = 0;
 122      foreach($_POST['friend'] as $friendx) {
 123      // secure post

 124      $friendx = strip_tags($friendx);
 125  
 126      if($j == 0) {
 127      $friend = $_POST['friend'];
 128  
 129      // secure posts

 130      $x = 0;
 131      foreach ($friend as $value) {
 132          $friend[$x] = strip_tags($value);
 133          $x++;
 134       }
 135  
 136      $email = $_POST['email'];
 137      $x = 0;
 138      foreach ($email as $value) {
 139      $email[$x] = strip_tags($value);
 140      $x++;
 141     }
 142  
 143  
 144                  if($friend[0] == '' && $email[0] == '') {
 145                      $error = true;
 146                      $email_errors .= "<div class=\"messageStackError\"><img src=\"images/icons/error.gif\" /> " . ERROR_ONE_EMAIL . "</div>";
 147                  }
 148              }
 149  
 150              if(isset($friendx) && $friendx != '') {
 151                  if(strlen($email[$j]) < '1') {
 152                      $error = true;
 153                      $email_errors .= "<div class=\"messageStackError\"><img src=\"images/icons/error.gif\" /> " . ERROR_ENTER_EMAIL . "</div>";
 154                  } elseif(!tep_validate_email($email[$j])) {
 155                      $error = true;
 156                      $email_errors .= "<div class=\"messageStackError\"><img src=\"images/icons/error.gif\" /> " . ERROR_VALID_EMAIL . "</div>";
 157                  }
 158              }
 159  
 160              if(isset($email[$j]) && $email[$j] != '') {
 161                  if(strlen($friendx) < '1') {
 162                      $error = true;
 163                      $email_errors .= "<div class=\"messageStackError\"><img src=\"images/icons/error.gif\" /> " . ERROR_ENTER_NAME . "</div>";
 164                  }
 165              }
 166              $j++;
 167          }
 168          if($error == false) {
 169              $j = 0;
 170              foreach($HTTP_POST_VARS['friend'] as $friendx) {
 171                  if($friendx != '') {
 172                      tep_mail($friendx, $email[$j], $subject, $friendx . ",\n\n" . $body, $from_name, $from_email);
 173                  }
 174  
 175              //Clear Values

 176                  $friend[$j] = "";
 177                  $email[$j] = "";
 178                  $message = "";
 179  
 180                  $j++;
 181              }
 182  
 183              $messageStack->add('wishlist', WISHLIST_SENT, 'success');
 184          }
 185    }
 186  
 187  
 188  
 189    $breadcrumb->add(HEADING_TITLE, tep_href_link(FILENAME_WISHLIST, '', 'NONSSL'));
 190  
 191    $content = CONTENT_WISHLIST;
 192  
 193    include (bts_select('main', $content_template)); // BTSv1.5

 194  
 195  
 196    require (DIR_WS_INCLUDES . 'application_bottom.php'); 
 197    
 198  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7