[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/ -> login.php (source)

   1  <?php
   2  /*

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

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

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

  14  // 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).

  15  //       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).

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

  17  
  18    require ('includes/application_top.php');
  19  
  20  // redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled (or the session has not started)

  21    if ($session_started == false) {
  22      tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
  23    }
  24  
  25    require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_LOGIN);
  26  
  27    $error = false;
  28  // BOF: MOD - PWA 0.70 :

  29    if($HTTP_GET_VARS['login'] == 'fail') {
  30      $fail_reason = (!empty($HTTP_GET_VARS['reason'])) ? urldecode($HTTP_GET_VARS['reason']): TEXT_LOGIN_ERROR;
  31      $messageStack->add('login', $fail_reason);
  32    }
  33  // EOF: MOD - PWA 0.70 :

  34    if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
  35      $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
  36      $password = tep_db_prepare_input($HTTP_POST_VARS['password']);
  37  
  38  // Check if email exists

  39  // LINE CHANGED: MOD - Separate Pricing per Customer

  40  //  $check_customer_query = tep_db_query("select customers_id, customers_firstname, customers_password, customers_email_address, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");

  41      $check_customer_query = tep_db_query("select customers_id, customers_firstname, customers_group_id, customers_password, customers_email_address, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");
  42      if (!tep_db_num_rows($check_customer_query)) {
  43        $error = true;
  44      } else {
  45        $check_customer = tep_db_fetch_array($check_customer_query);
  46  // Check that password is good

  47        if (!tep_validate_password($password, $check_customer['customers_password'])) {
  48          $error = true;
  49        } else {
  50          if (SESSION_RECREATE == 'True') {
  51            tep_session_recreate();
  52          }
  53  // BOF: MOD - Separate Pricing Per Customer: choice for logging in under any customer_group_id

  54  // note that tax rates depend on your registered address!

  55          if ($_GET['skip'] != 'true' && $_POST['email_address'] == SPPC_TOGGLE_LOGIN_PASSWORD ) {
  56            $existing_customers_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id ");
  57            echo '<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">';
  58            print ("\n<html ");
  59            echo HTML_PARAMS; 
  60            print (">\n<head>\n<title>Choose a Customer Group</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
  61            echo CHARSET;
  62            print ("\"\n<base href=\"");
  63            echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG;
  64            print ("\">\n<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\">\n");
  65            echo '<body bgcolor="#ffffff" style="margin:0">';
  66            print ("\n<table border=\"0\" width=\"100%\" height=\"100%\">\n<tr>\n<td style=\"vertical-align: middle\" align=\"middle\">\n");
  67            echo tep_draw_form('login', tep_href_link(FILENAME_LOGIN, 'action=process&skip=true', 'SSL'));
  68            print ("\n<table border=\"0\" bgcolor=\"#f1f9fe\" cellspacing=\"10\" style=\"border: 1px solid #7b9ebd;\">\n<tr>\n<td class=\"main\">\n");
  69            $index = 0;
  70            while ($existing_customers =  tep_db_fetch_array($existing_customers_query)) {
  71              $existing_customers_array[] = array("id" => $existing_customers['customers_group_id'], "text" => "&#160;".$existing_customers['customers_group_name']."&#160;");
  72              ++$index;
  73            }
  74            print ("<h1>Choose a Customer Group</h1>\n</td>\n</tr>\n<tr>\n<td align=\"center\">\n");
  75            echo tep_draw_pull_down_menu('new_customers_group_id', $existing_customers_array, $check_customer['customers_group_id']);
  76            print ("\n<tr>\n<td class=\"main\">&#160;<br />\n&#160;");
  77            print ("<input type=\"hidden\" name=\"email_address\" value=\"".$_POST['email_address']."\">");
  78            print ("<input type=\"hidden\" name=\"password\" value=\"".$_POST['password']."\">\n</td>\n</tr>\n<tr>\n<td align=\"right\">\n");
  79            echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE);
  80            print ("</td>\n</tr>\n</table>\n</form>\n</td>\n</tr>\n</table>\n</body>\n</html>\n");
  81            exit;
  82          }
  83  // EOF: MOD - Separate Pricing Per Customer: choice for logging in under any customer_group_id

  84          $check_country_query = tep_db_query("select entry_country_id, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$check_customer['customers_id'] . "' and address_book_id = '" . (int)$check_customer['customers_default_address_id'] . "'");
  85          $check_country = tep_db_fetch_array($check_country_query);
  86  
  87          $customer_id = $check_customer['customers_id'];
  88          $customer_default_address_id = $check_customer['customers_default_address_id'];
  89          $customer_first_name = $check_customer['customers_firstname'];
  90  // BOF: MOD - Separate Pricing per Customer

  91          if ($_GET['skip'] == 'true' && $_POST['email_address'] == SPPC_TOGGLE_LOGIN_PASSWORD && isset($_POST['new_customers_group_id']))  {
  92            $sppc_customer_group_id = $_POST['new_customers_group_id'] ;
  93            $check_customer_group_tax = tep_db_query("select customers_group_show_tax, customers_group_tax_exempt from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" .(int)$_POST['new_customers_group_id'] . "'");
  94          } else {
  95            $sppc_customer_group_id = $check_customer['customers_group_id'];
  96            $check_customer_group_tax = tep_db_query("select customers_group_show_tax, customers_group_tax_exempt from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" .(int)$check_customer['customers_group_id'] . "'");
  97          }
  98          $customer_group_tax = tep_db_fetch_array($check_customer_group_tax);
  99          $sppc_customer_group_show_tax = (int)$customer_group_tax['customers_group_show_tax'];
 100          $sppc_customer_group_tax_exempt = (int)$customer_group_tax['customers_group_tax_exempt'];
 101  // EOF: MOD - Separate Pricing per Customer

 102          $customer_country_id = $check_country['entry_country_id'];
 103          $customer_zone_id = $check_country['entry_zone_id'];
 104          tep_session_register('customer_id');
 105          tep_session_register('customer_default_address_id');
 106          tep_session_register('customer_first_name');
 107  // BOF: MOD - Separate Pricing per Customer

 108          tep_session_register('sppc_customer_group_id');
 109          tep_session_register('sppc_customer_group_show_tax');
 110          tep_session_register('sppc_customer_group_tax_exempt');
 111  // EOF: MOD - Separate Pricing per Customer

 112          tep_session_register('customer_country_id');
 113          tep_session_register('customer_zone_id');
 114  
 115          tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_of_last_logon = now(), customers_info_number_of_logons = customers_info_number_of_logons+1 where customers_info_id = '" . (int)$customer_id . "'");
 116  
 117  // BOF - MOD: CREDIT CLASS Gift Voucher Contribution

 118  // add these new codes:

 119          if (tep_session_is_registered('floating_gv_code')) {
 120            $gv_query = tep_db_query("SELECT c.coupon_id, c.coupon_amount, IF(rt.coupon_id>0, 'true', 'false') AS redeemed FROM ". TABLE_COUPONS ." c LEFT JOIN ". TABLE_COUPON_REDEEM_TRACK." rt USING(coupon_id), ". TABLE_COUPON_EMAIL_TRACK ." et WHERE c.coupon_code = '". $floating_gv_code ."' AND c.coupon_id = et.coupon_id");
 121            // check if coupon exist

 122            if (tep_db_num_rows($gv_query) >0) {
 123              $coupon = tep_db_fetch_array($gv_query);
 124              // check if coupon_id exist and coupon not redeemed

 125              if($coupon['coupon_id']>0 && $coupon['redeemed'] == 'false') {
 126                tep_session_unregister('floating_gv_code');
 127                $gv_query = tep_db_query("insert into  " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, customer_id, redeem_date, redeem_ip) values ('" . $coupon['coupon_id'] . "', '" . $customer_id . "', now(),'" . $REMOTE_ADDR . "')");
 128                $gv_update = tep_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $coupon['coupon_id'] . "'");
 129                tep_gv_account_update($customer_id, $coupon['coupon_id']);
 130              }
 131            }
 132          }
 133  // EOF - MOD: CREDIT CLASS Gift Voucher Contribution

 134  
 135  // restore cart contents

 136          $cart->restore_contents();
 137  
 138  //BOF: MOD - Wishlist 3.5

 139  // restore wishlist to sesssion

 140          $wishList->restore_wishlist();
 141  //EOF: MOD - Wishlist 3.5

 142  
 143          if (sizeof($navigation->snapshot) > 0) {
 144            $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);
 145            $navigation->clear_snapshot();
 146            tep_redirect($origin_href);
 147          } else {
 148            tep_redirect(tep_href_link(FILENAME_DEFAULT));
 149          }
 150        }
 151      }
 152    }
 153  
 154    if ($error == true) {
 155      $messageStack->add('login', TEXT_LOGIN_ERROR);
 156    }
 157  
 158    $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 159  
 160    $content = CONTENT_LOGIN;
 161    $javascript = $content . '.js';
 162  
 163    include (bts_select('main', $content_template)); // BTSv1.5

 164  
 165    require (DIR_WS_INCLUDES . 'application_bottom.php');
 166  ?>


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