function add_cart($products_id, $qty = '1', $attributes = '', $notify = true)
 {
     global $new_products_id_in_cart, $customer_id, $_GET;
     $products_id = smn_get_uprid($products_id, $attributes);
     if ($notify == true) {
         $new_products_id_in_cart = $products_id;
         smn_session_register('new_products_id_in_cart');
     }
     if ($this->in_cart($products_id)) {
         $this->update_quantity($products_id, $qty, $attributes);
     } else {
         $this->contents[] = array($products_id);
         $this->contents[$products_id] = array('qty' => $qty);
         $this->contents[$products_id]['store_id'] = (int) $_GET['ID'];
         // insert into database
         if (smn_session_is_registered('customer_id')) {
             smn_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added, store_id) values ('" . (int) $customer_id . "', '" . smn_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "', '" . smn_db_input($_GET['ID']) . "')");
         }
         if (is_array($attributes)) {
             reset($attributes);
             while (list($option, $value) = each($attributes)) {
                 $this->contents[$products_id]['attributes'][$option] = $value;
                 // insert into database
                 if (smn_session_is_registered('customer_id')) {
                     smn_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, store_id) values ('" . (int) $customer_id . "', '" . smn_db_input($products_id) . "', '" . (int) $option . "', '" . (int) $value . "', '" . smn_db_input($_GET['ID']) . "')");
                 }
             }
         }
     }
     $this->cleanup();
     // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
     $this->cartID = $this->generate_cart_id();
 }
 function add_session($message, $type = 'error')
 {
     global $messageToStack;
     if (!smn_session_is_registered('messageToStack')) {
         smn_session_register('messageToStack');
         $messageToStack = array();
     }
     $messageToStack[] = array('text' => $message, 'type' => $type);
 }
Example #3
0
 function collect_posts()
 {
     global $_POST, $customer_id, $currencies, $cc_id;
     if ($_POST['gv_redeem_code']) {
         // get some info from the coupon table
         $coupon_query = smn_db_query("select coupon_id, coupon_amount, coupon_type, coupon_minimum_order,uses_per_coupon, uses_per_user, restrict_to_products,restrict_to_categories from " . TABLE_COUPONS . " where coupon_code='" . $_POST['gv_redeem_code'] . "' and coupon_active='Y'");
         $coupon_result = smn_db_fetch_array($coupon_query);
         if ($coupon_result['coupon_type'] != 'G') {
             if (smn_db_num_rows($coupon_query) == 0) {
                 smn_redirect(smn_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_NO_INVALID_REDEEM_COUPON), 'NONSSL'));
             }
             $date_query = smn_db_query("select coupon_start_date from " . TABLE_COUPONS . " where coupon_start_date <= now() and coupon_code='" . $_POST['gv_redeem_code'] . "'");
             if (smn_db_num_rows($date_query) == 0) {
                 smn_redirect(smn_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_INVALID_STARTDATE_COUPON), 'NONSSL'));
             }
             $date_query = smn_db_query("select coupon_expire_date from " . TABLE_COUPONS . " where coupon_expire_date >= now() and coupon_code='" . $_POST['gv_redeem_code'] . "'");
             if (smn_db_num_rows($date_query) == 0) {
                 smn_redirect(smn_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_INVALID_FINISDATE_COUPON), 'NONSSL'));
             }
             $coupon_count = smn_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id'] . "'");
             $coupon_count_customer = smn_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id'] . "' and customer_id = '" . $customer_id . "'");
             if (smn_db_num_rows($coupon_count) >= $coupon_result['uses_per_coupon'] && $coupon_result['uses_per_coupon'] > 0) {
                 smn_redirect(smn_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_INVALID_USES_COUPON . $coupon_result['uses_per_coupon'] . TIMES), 'NONSSL'));
             }
             if (smn_db_num_rows($coupon_count_customer) >= $coupon_result['uses_per_user'] && $coupon_result['uses_per_user'] > 0) {
                 smn_redirect(smn_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_INVALID_USES_USER_COUPON . $coupon_result['uses_per_user'] . TIMES), 'NONSSL'));
             }
             global $order, $ot_coupon, $currency;
             if (!smn_session_is_registered('cc_id')) {
                 smn_session_register('cc_id');
             }
             $cc_id = $coupon_result['coupon_id'];
             $coupon_amount = smn_round($ot_coupon->pre_confirmation_check($order->info['subtotal']), $currencies->currencies[$currency]['decimal_places']);
             // $cc_id
             $coupon_amount_out = $currencies->format($coupon_amount) . ' ';
             if ($coupon_result['coupon_minimum_order'] > 0) {
                 $coupon_amount_out .= 'on orders greater than ' . $currencies->format($coupon_result['coupon_minimum_order']);
             }
             if (!smn_session_is_registered('cc_id')) {
                 smn_session_register('cc_id');
             }
             $cc_id = $coupon_result['coupon_id'];
             if (strlen($cc_id) > 0 && $coupon_amount == 0) {
                 $err_msg = ERROR_REDEEMED_AMOUNT . ERROR_REDEEMED_AMOUNT_ZERO;
             } else {
                 $err_msg = ERROR_REDEEMED_AMOUNT . $coupon_amount_out;
             }
             smn_redirect(smn_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode($err_msg), 'NONSSL'));
         }
         // ENDIF valid coupon code
     }
     // ENDIF code entered
     // v5.13a If no code entered and coupon redeem button pressed, give an alarm
     if ($_POST['submit_redeem_coupon_x']) {
         smn_redirect(smn_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_NO_REDEEM_CODE), 'NONSSL'));
     }
 }
 function add_cart($products_id, $qty = '1', $attributes = '', $notify = true)
 {
     global $new_products_id_in_cart, $customer_id;
     $products_id_string = smn_get_uprid($products_id, $attributes);
     $products_id = smn_get_prid($products_id_string);
     if (defined('MAX_QTY_IN_CART') && MAX_QTY_IN_CART > 0 && (int) $qty > MAX_QTY_IN_CART) {
         $qty = MAX_QTY_IN_CART;
     }
     $store_id = $this->get_store_id($products_id);
     if (is_numeric($products_id) && is_numeric($qty)) {
         $check_product_query = smn_db_query("select store_id, products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'");
         $check_product = smn_db_fetch_array($check_product_query);
         if ($check_product !== false && $check_product['products_status'] == '1') {
             if ($notify == true) {
                 $new_products_id_in_cart = $products_id;
                 smn_session_register('new_products_id_in_cart');
             }
             if ($this->in_cart($products_id_string)) {
                 $this->update_quantity($products_id_string, $qty, $attributes, $check_product['store_id']);
             } else {
                 $this->contents[$products_id_string] = array('qty' => (int) $qty, 'store_id' => $check_product['store_id']);
                 // insert into database
                 if (smn_session_is_registered('customer_id')) {
                     smn_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (store_id, customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int) $check_product['store_id'] . "', '" . (int) $customer_id . "', '" . smn_db_input($products_id_string) . "', '" . (int) $qty . "', '" . date('Ymd') . "')");
                 }
                 if (is_array($attributes)) {
                     reset($attributes);
                     while (list($option, $value) = each($attributes)) {
                         $this->contents[$products_id_string]['attributes'][$option] = $value;
                         // insert into database
                         if (smn_session_is_registered('customer_id')) {
                             smn_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int) $customer_id . "', '" . smn_db_input($products_id_string) . "', '" . (int) $option . "', '" . (int) $value . "')");
                         }
                     }
                 }
             }
             $this->cleanup();
             // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
             $this->cartID = $this->generate_cart_id();
         }
     }
 }
Example #5
0
 function confirmation()
 {
     global $cartID, $cart_PayPal_IPN_ID, $customer_id, $languages_id, $order, $order_total_modules, $store_id, $cart;
     $insert_order = true;
     if ($insert_order == true) {
         $order_totals = array();
         if (is_array($order_total_modules->modules)) {
             reset($order_total_modules->modules);
             while (list(, $value) = each($order_total_modules->modules)) {
                 $class = substr($value, 0, strrpos($value, '.'));
                 if ($GLOBALS[$class]->enabled) {
                     for ($i = 0, $n = sizeof($GLOBALS[$class]->output); $i < $n; $i++) {
                         if (smn_not_null($GLOBALS[$class]->output[$i]['title']) && smn_not_null($GLOBALS[$class]->output[$i]['text'])) {
                             $order_totals[] = array('code' => $GLOBALS[$class]->code, 'title' => $GLOBALS[$class]->output[$i]['title'], 'text' => $GLOBALS[$class]->output[$i]['text'], 'value' => $GLOBALS[$class]->output[$i]['value'], 'sort_order' => $GLOBALS[$class]->sort_order);
                         }
                     }
                 }
             }
         }
         if (ALLOW_STORE_PAYMENT == 'true') {
             $sql_data_array = array('store_id' => $store_id, 'customers_id' => $customer_id, 'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'customers_company' => $order->customer['company'], 'customers_street_address' => $order->customer['street_address'], 'customers_city' => $order->customer['city'], 'customers_postcode' => $order->customer['postcode'], 'customers_state' => $order->customer['state'], 'customers_country' => $order->customer['country']['title'], 'customers_telephone' => $order->customer['telephone'], 'customers_email_address' => $order->customer['email_address'], 'customers_address_format_id' => $order->customer['format_id'], 'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'], 'delivery_company' => $order->delivery['company'], 'delivery_street_address' => $order->delivery['street_address'], 'delivery_city' => $order->delivery['city'], 'delivery_postcode' => $order->delivery['postcode'], 'delivery_state' => $order->delivery['state'], 'delivery_country' => $order->delivery['country']['title'], 'delivery_address_format_id' => $order->delivery['format_id'], 'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'], 'billing_company' => $order->billing['company'], 'billing_street_address' => $order->billing['street_address'], 'billing_city' => $order->billing['city'], 'billing_postcode' => $order->billing['postcode'], 'billing_state' => $order->billing['state'], 'billing_country' => $order->billing['country']['title'], 'billing_address_format_id' => $order->billing['format_id'], 'payment_method' => $order->info['payment_method'], 'cc_type' => $order->info['cc_type'], 'cc_owner' => $order->info['cc_owner'], 'cc_number' => $order->info['cc_number'], 'cc_expires' => $order->info['cc_expires'], 'date_purchased' => 'now()', 'orders_status' => $order->info['order_status'], 'currency' => $order->info['currency'], 'currency_value' => $order->info['currency_value']);
             //+1.4
             if ($update_order) {
                 smn_db_perform(TABLE_ORDERS, $sql_data_array, 'update', 'orders_id = "' . (int) $order_id . '"');
                 $insert_id = (int) $order_id;
             } else {
                 //-1.4
                 smn_db_perform(TABLE_ORDERS, $sql_data_array);
                 $insert_id = smn_db_insert_id();
             }
             //1.4
             $orders_invoice_id = $insert_id;
             for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
                 $sql_data_array = array('orders_id' => $insert_id, 'title' => $order_totals[$i]['title'], 'text' => $order_totals[$i]['text'], 'value' => $order_totals[$i]['value'], 'class' => $order_totals[$i]['code'], 'sort_order' => $order_totals[$i]['sort_order']);
                 smn_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
             }
             //+1.4
             $sql_data_array = array('orders_id' => $insert_id, 'orders_status_id' => $order->info['order_status'], 'date_added' => 'now()', 'customer_notified' => '0', 'comments' => $order->info['comments']);
             smn_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
             //-1.4
             for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
                 if ($order->products[$i]['products_store_id'] == $store_id) {
                     $sql_data_array = array('orders_id' => $insert_id, 'products_id' => smn_get_prid($order->products[$i]['id']), 'products_model' => $order->products[$i]['model'], 'products_name' => $order->products[$i]['name'], 'products_price' => $order->products[$i]['price'], 'final_price' => $order->products[$i]['final_price'], 'products_tax' => $order->products[$i]['tax'], 'products_quantity' => $order->products[$i]['qty']);
                     smn_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
                     $order_products_id = smn_db_insert_id();
                     $attributes_exist = '0';
                     if (isset($order->products[$i]['attributes'])) {
                         $attributes_exist = '1';
                         for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
                             if (DOWNLOAD_ENABLED == 'true') {
                                 $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename\n\t\t\t\t\t\t\t\t\t\t\t   from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\t\t\t\t\t\t\t\t\t\t\t   left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n\t\t\t\t\t\t\t\t\t\t\t   on pa.products_attributes_id=pad.products_attributes_id\n\t\t\t\t\t\t\t\t\t\t\t   where pa.products_id = '" . $order->products[$i]['id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t   and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t   and pa.options_id = popt.products_options_id\n\t\t\t\t\t\t\t\t\t\t\t   and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t   and pa.options_values_id = poval.products_options_values_id\n\t\t\t\t\t\t\t\t\t\t\t   and popt.language_id = '" . $languages_id . "'\n\t\t\t\t\t\t\t\t\t\t\t   and poval.language_id = '" . $languages_id . "'";
                                 $attributes = smn_db_query($attributes_query);
                             } else {
                                 $attributes = smn_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
                             }
                             $attributes_values = smn_db_fetch_array($attributes);
                             $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'products_options' => $attributes_values['products_options_name'], 'products_options_values' => $attributes_values['products_options_values_name'], 'options_values_price' => $attributes_values['options_values_price'], 'price_prefix' => $attributes_values['price_prefix']);
                             smn_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
                             if (DOWNLOAD_ENABLED == 'true' && isset($attributes_values['products_attributes_filename']) && smn_not_null($attributes_values['products_attributes_filename'])) {
                                 $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'orders_products_filename' => $attributes_values['products_attributes_filename'], 'download_maxdays' => $attributes_values['products_attributes_maxdays'], 'download_count' => $attributes_values['products_attributes_maxcount']);
                                 smn_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
                             }
                         }
                     }
                 }
             }
         } else {
             $store_list = $cart->get_store_list();
             $orders_invoice_id = '';
             for ($k = 0; $k < sizeof($store_list); $k++) {
                 $sql_data_array = array('store_id' => $store_list[$k], 'customers_id' => $customer_id, 'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'customers_company' => $order->customer['company'], 'customers_street_address' => $order->customer['street_address'], 'customers_city' => $order->customer['city'], 'customers_postcode' => $order->customer['postcode'], 'customers_state' => $order->customer['state'], 'customers_country' => $order->customer['country']['title'], 'customers_telephone' => $order->customer['telephone'], 'customers_email_address' => $order->customer['email_address'], 'customers_address_format_id' => $order->customer['format_id'], 'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'], 'delivery_company' => $order->delivery['company'], 'delivery_street_address' => $order->delivery['street_address'], 'delivery_city' => $order->delivery['city'], 'delivery_postcode' => $order->delivery['postcode'], 'delivery_state' => $order->delivery['state'], 'delivery_country' => $order->delivery['country']['title'], 'delivery_address_format_id' => $order->delivery['format_id'], 'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'], 'billing_company' => $order->billing['company'], 'billing_street_address' => $order->billing['street_address'], 'billing_city' => $order->billing['city'], 'billing_postcode' => $order->billing['postcode'], 'billing_state' => $order->billing['state'], 'billing_country' => $order->billing['country']['title'], 'billing_address_format_id' => $order->billing['format_id'], 'payment_method' => $order->info['payment_method'], 'cc_type' => $order->info['cc_type'], 'cc_owner' => $order->info['cc_owner'], 'cc_number' => $order->info['cc_number'], 'cc_expires' => $order->info['cc_expires'], 'date_purchased' => 'now()', 'orders_status' => $order->info['order_status'], 'currency' => $order->info['currency'], 'currency_value' => $order->info['currency_value']);
                 //+1.4
                 if ($update_order) {
                     smn_db_perform(TABLE_ORDERS, $sql_data_array, 'update', 'orders_id = "' . (int) $order_id . '"');
                     $insert_id = (int) $order_id;
                 } else {
                     //-1.4
                     smn_db_perform(TABLE_ORDERS, $sql_data_array);
                     $insert_id = smn_db_insert_id();
                 }
                 //1.4
                 for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
                     $sql_data_array = array('orders_id' => $insert_id, 'title' => $order_totals[$i]['title'], 'text' => $order_totals[$i]['text'], 'value' => $order_totals[$i]['value'], 'class' => $order_totals[$i]['code'], 'sort_order' => $order_totals[$i]['sort_order']);
                     smn_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
                 }
                 //+1.4
                 $sql_data_array = array('orders_id' => $insert_id, 'orders_status_id' => $order->info['order_status'], 'date_added' => 'now()', 'customer_notified' => '0', 'comments' => $order->info['comments']);
                 smn_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
                 //-1.4
                 for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
                     if ($order->products[$i]['products_store_id'] == $store_list[$k]) {
                         $sql_data_array = array('orders_id' => $insert_id, 'products_id' => smn_get_prid($order->products[$i]['id']), 'products_model' => $order->products[$i]['model'], 'products_name' => $order->products[$i]['name'], 'products_price' => $order->products[$i]['price'], 'final_price' => $order->products[$i]['final_price'], 'products_tax' => $order->products[$i]['tax'], 'products_quantity' => $order->products[$i]['qty']);
                         smn_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
                         $order_products_id = smn_db_insert_id();
                         $attributes_exist = '0';
                         if (isset($order->products[$i]['attributes'])) {
                             $attributes_exist = '1';
                             for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
                                 if (DOWNLOAD_ENABLED == 'true') {
                                     $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename\n\t\t\t\t\t\t\t\t\t\t\t   from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\t\t\t\t\t\t\t\t\t\t\t   left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n\t\t\t\t\t\t\t\t\t\t\t   on pa.products_attributes_id=pad.products_attributes_id\n\t\t\t\t\t\t\t\t\t\t\t   where pa.products_id = '" . $order->products[$i]['id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t   and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t   and pa.options_id = popt.products_options_id\n\t\t\t\t\t\t\t\t\t\t\t   and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t   and pa.options_values_id = poval.products_options_values_id\n\t\t\t\t\t\t\t\t\t\t\t   and popt.language_id = '" . $languages_id . "'\n\t\t\t\t\t\t\t\t\t\t\t   and poval.language_id = '" . $languages_id . "'";
                                     $attributes = smn_db_query($attributes_query);
                                 } else {
                                     $attributes = smn_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
                                 }
                                 $attributes_values = smn_db_fetch_array($attributes);
                                 $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'products_options' => $attributes_values['products_options_name'], 'products_options_values' => $attributes_values['products_options_values_name'], 'options_values_price' => $attributes_values['options_values_price'], 'price_prefix' => $attributes_values['price_prefix']);
                                 smn_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
                                 if (DOWNLOAD_ENABLED == 'true' && isset($attributes_values['products_attributes_filename']) && smn_not_null($attributes_values['products_attributes_filename'])) {
                                     $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'orders_products_filename' => $attributes_values['products_attributes_filename'], 'download_maxdays' => $attributes_values['products_attributes_maxdays'], 'download_count' => $attributes_values['products_attributes_maxcount']);
                                     smn_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
                                 }
                             }
                         }
                     }
                 }
                 $sql_data_array = array('orders_invoice_id' => $orders_invoice_id, 'orders_id' => $insert_id);
                 smn_db_perform(TABLE_ORDERS_INVOICE, $sql_data_array);
                 $orders_invoice_id = smn_db_insert_id();
             }
         }
         smn_session_register('cart_PayPal_IPN_ID');
         // Terra register globals fix
         $_SESSION['cart_PayPal_IPN_ID'] = $cartID . '-' . $orders_invoice_id;
     }
     return false;
 }
                }
            }
        } else {
            smn_session_register('sendto');
        }
        $sendto = $_POST['address'];
        $check_address_query = smn_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int) $customer_id . "' and address_book_id = '" . (int) $sendto . "'");
        $check_address = smn_db_fetch_array($check_address_query);
        if ($check_address['total'] == '1') {
            if ($reset_shipping == true) {
                smn_session_unregister('shipping');
            }
            smn_redirect(smn_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'NONSSL'));
        } else {
            smn_session_unregister('sendto');
        }
    } else {
        if (!smn_session_is_registered('sendto')) {
            smn_session_register('sendto');
        }
        $sendto = $customer_default_address_id;
        smn_redirect(smn_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'NONSSL'));
    }
}
// if no shipping destination address was selected, use their own address as default
if (!smn_session_is_registered('sendto')) {
    $sendto = $customer_default_address_id;
}
$breadcrumb->add(NAVBAR_TITLE_1, smn_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'NONSSL'));
$breadcrumb->add(NAVBAR_TITLE_2, smn_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'NONSSL'));
$addresses_count = smn_count_customer_address_book_entries();
Example #7
0
<?php

/*
  Copyright (c) 2002 - 2006 SystemsManager.Net

  SystemsManager Technologies
  oscMall System Version 4
  http://www.systemsmanager.net
  
  Portions Copyright (c) 2002 osCommerce
  
  This source file is subject to version 2.0 of the GPL license,   
  that is bundled with this package in the file LICENSE. If you
  did not receive a copy of the oscMall System license and are unable 
  to obtain it through the world-wide-web, please send a note to    
  license@systemsmanager.net so we can mail you a copy immediately.
*/
global $page_name;
$switch_store = 'TRUE';
smn_session_unregister('switch_store_id');
smn_session_register('switch_store_id');
$switch_store_id = intval($_GET['newID']);
if ($store_id == 1) {
    smn_redirect(smn_href_link(FILENAME_GOTO_STORE, 'newID=' . $switch_store_id));
}
$breadcrumb->add(NAVBAR_TITLE, smn_href_link(FILENAME_THANK_YOU));
            smn_session_register('customer_zone_id');
        }
        //CREATE STORE IN THE DATABASE.....
        // systemsmanager begin - Dec 5, 2005
        $new_store = new store();
        $new_store->set_store_type($new_store_type);
        $new_store->set_customers_id($customer_id);
        $new_store->set_store_name($new_store_name);
        $new_store->set_store_description($store_description);
        $new_store->set_store_category($store_catagory);
        $new_store->set_store_logo('store_image');
        $customer_store_id = $new_store->create_store();
        smn_session_register('customer_store_id');
        $error_text = $new_store->put_logo_image();
        if ($error_text != '') {
            smn_session_register('error_text');
        }
        $new_store->put_store_description();
        $new_store->put_store_category();
        $new_store->put_store_admin();
        $new_store->put_store_data();
        $new_store->put_store_cost();
        $new_store->put_store_products();
        if (ALLOW_STORE_SITE_TEXT == 'true') {
            $new_store->put_store_language('english');
        }
        $new_store->send_store_email($gender);
        smn_redirect(smn_href_link(FILENAME_CREATE_STORE_ACCOUNT_SUCCESS, '', 'NONSSL'));
    }
}
$breadcrumb->add(NAVBAR_TITLE, smn_href_link(FILENAME_CREATE_STORE_ACCOUNT, '', 'NONSSL'));
            }
        } else {
            smn_session_register('billto');
        }
        $billto = $_POST['address'];
        $check_address_query = smn_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $customer_id . "' and address_book_id = '" . $billto . "'");
        $check_address = smn_db_fetch_array($check_address_query);
        if ($check_address['total'] == '1') {
            if ($reset_payment == true) {
                smn_session_unregister('payment');
            }
            smn_redirect(smn_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'NONSSL'));
        } else {
            smn_session_unregister('billto');
        }
        // no addresses to select from - customer decided to keep the current assigned address
    } else {
        if (!smn_session_is_registered('billto')) {
            smn_session_register('billto');
        }
        $billto = $customer_default_address_id;
        smn_redirect(smn_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'NONSSL'));
    }
}
// if no billing destination address was selected, use their own address as default
if (!smn_session_is_registered('billto')) {
    $billto = $customer_default_address_id;
}
$breadcrumb->add(NAVBAR_TITLE_1, smn_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'NONSSL'));
$breadcrumb->add(NAVBAR_TITLE_2, smn_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'NONSSL'));
$addresses_count = smn_count_customer_address_book_entries();
            define($text_contents['text_key'], $text_contents['text_content']);
        }
    }
} else {
    $free_shipping = false;
}
// process the selected shipping method
if (isset($_POST['action']) && $_POST['action'] == 'process') {
    if (!smn_session_is_registered('comments')) {
        smn_session_register('comments');
    }
    if (smn_not_null($_POST['comments'])) {
        $comments = smn_db_prepare_input($_POST['comments']);
    }
    if (!smn_session_is_registered('shipping')) {
        smn_session_register('shipping');
    }
    if (smn_count_shipping_modules() > 0 || $free_shipping == true) {
        if (isset($_POST['shipping']) && strpos($_POST['shipping'], '_')) {
            $shipping = $_POST['shipping'];
            list($module, $method) = explode('_', $shipping);
            if (is_object(${$module}) || $shipping == 'free_free') {
                if ($shipping == 'free_free') {
                    $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
                    $quote[0]['methods'][0]['cost'] = '0';
                } else {
                    $quote = $shipping_modules->quote($method, $module);
                }
                if (isset($quote['error'])) {
                    smn_session_unregister('shipping');
                } else {
Example #11
0
 function pre_confirmation_check()
 {
     global $payment, $order, $credit_covers, $customer_id;
     if (MODULE_ORDER_TOTAL_INSTALLED) {
         $this->modules = explode(';', MODULE_ORDER_TOTAL_INSTALLED);
         $total_deductions = 0;
         reset($this->modules);
         $order_total = $order->info['total'];
         while (list(, $value) = each($this->modules)) {
             $class = substr($value, 0, strrpos($value, '.'));
             $order_total = $this->get_order_total_main($class, $order_total);
             if ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) {
                 $total_deductions = $total_deductions + $GLOBALS[$class]->pre_confirmation_check($order_total);
                 $order_total = $order_total - $GLOBALS[$class]->pre_confirmation_check($order_total);
             }
         }
         $gv_query = smn_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . $customer_id . "'");
         $gv_result = smn_db_fetch_array($gv_query);
         $gv_payment_amount = $gv_result['amount'];
         //        if ($order->info['total'] - $total_deductions <= 0 ) {
         if ($order->info['total'] - $gv_payment_amount <= 0) {
             if (!smn_session_is_registered('credit_covers')) {
                 smn_session_register('credit_covers');
             }
             $credit_covers = true;
         } else {
             // belts and suspenders to get rid of credit_covers variable if it gets set once and they put something else in the cart
             if (smn_session_is_registered('credit_covers')) {
                 smn_session_unregister('credit_covers');
             }
         }
     }
 }
Example #12
0
if (!$error && smn_session_is_registered('customer_id')) {
    // Update redeem status
    $gv_query = smn_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 . "')");
    $gv_update = smn_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $coupon['coupon_id'] . "'");
    smn_gv_account_update($customer_id, $gv_id);
    smn_session_unregister('gv_id');
}
if (smn_session_is_registered('customer_id') && $voucher_not_redeemed) {
    $gv_id = $coupon['coupon_id'];
    $gv_query = smn_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 . "')");
    $gv_update = smn_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $coupon['coupon_id'] . "'");
    smn_gv_account_update($customer_id, $gv_id);
    $error = false;
} elseif ($voucher_not_redeemed) {
    if (!smn_session_is_registered('floating_gv_code')) {
        smn_session_register('floating_gv_code');
        //}
        $floating_gv_code = $_GET['gv_no'];
        $gv_error_message = TEXT_NEEDS_TO_LOGIN;
    } else {
        $gv_error_message = TEXT_INVALID_GV;
    }
} else {
    $gv_error_message = TEXT_INVALID_GV;
}
$message = $gv_error_message;
if (smn_session_is_registered('floating_gv_code')) {
    $gv_query = smn_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");
    // check if coupon exist
    if (smn_db_num_rows($gv_query) > 0) {
        $coupon = smn_db_fetch_array($gv_query);
Example #13
0
         $entry_password_error = false;
     }
 }
 if ($error == false) {
     //===============================================================================================
     $store_monthly_costs = smn_set_store_cost($new_store_type);
     $check_new_store_type = smn_set_store_type($new_store_type);
     $store_products_id = smn_set_products_id($new_store_type);
     //CREATE STORE IN THE DATABASE.....
     if ($_GET['action'] == 'update') {
         smn_session_register('customers_id');
         $customer_info = new customer($customers_id);
         $store_info = new store((int) $_GET['sID']);
     } else {
         if (!smn_session_is_registered('cart') && !is_object($cart)) {
             smn_session_register('cart');
             $cart = new shoppingCart();
         }
         $customer_info = new customer();
         $store_info = new store();
     }
     $customer_info->set_firstname($firstname);
     $customer_info->set_lastname($lastname);
     $customer_info->set_email_address($email_address);
     $customer_info->set_telephone($telephone);
     $customer_info->set_fax($fax);
     $customer_info->set_newsletter($newsletter);
     $customer_info->set_gender($gender);
     //    $customer_info->set_dob($dob);
     $customer_info->set_street_address($street_address);
     $customer_info->set_postcode($postal_code);
              if (ACCOUNT_STATE == 'true') {
                if ($a_zone_id > 0) {
                  $sql_data_array['affiliate_zone_id'] = $a_zone_id;
                  $sql_data_array['affiliate_state'] = '';
                } else {
                  $sql_data_array['affiliate_zone_id'] = '0';
                  $sql_data_array['affiliate_state'] = $a_state;
                }
              }*/
        $sql_data_array = array('affiliate_customer_id' => $customer_id, 'affiliate_payment_check' => $a_payment_check, 'affiliate_payment_paypal' => $a_payment_paypal, 'affiliate_payment_bank_name' => $a_payment_bank_name, 'affiliate_payment_bank_branch_number' => $a_payment_bank_branch_number, 'affiliate_payment_bank_swift_code' => $a_payment_bank_swift_code, 'affiliate_payment_bank_account_name' => $a_payment_bank_account_name, 'affiliate_payment_bank_account_number' => $a_payment_bank_account_number, 'affiliate_homepage' => $a_homepage, 'affiliate_agb' => '1');
        if (ACCOUNT_COMPANY == 'true') {
            $sql_data_array['affiliate_company_taxid'] = $a_company_taxid;
        }
        if (ACCOUNT_SUBURB == 'true') {
            $sql_data_array['affiliate_suburb'] = $a_suburb;
        }
        $affiliate_id = affiliate_insert($sql_data_array, $HTTP_SESSION_VARS['affiliate_ref']);
        $aemailbody = MAIL_AFFILIATE_HEADER . "\n" . MAIL_AFFILIATE_ID . $affiliate_id . "\n" . MAIL_AFFILIATE_USERNAME . $a_email_address . "\n" . MAIL_AFFILIATE_PASSWORD . $a_password . "\n\n" . MAIL_AFFILIATE_LINK . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_AFFILIATE . "\n\n" . MAIL_AFFILIATE_FOOTER;
        smn_mail($a_firstname . ' ' . $a_lastname, $a_email_address, MAIL_AFFILIATE_SUBJECT, nl2br($aemailbody), $store->get_store_owner(), AFFILIATE_EMAIL_ADDRESS);
        smn_session_register('affiliate_id');
        $affiliate_email = $a_email_address;
        $affiliate_name = $a_firstname . ' ' . $a_lastname;
        smn_session_register('affiliate_email');
        smn_session_register('affiliate_name');
        smn_redirect(smn_href_link(FILENAME_AFFILIATE_SIGNUP_OK, '', 'NONSSL'));
    }
}
$breadcrumb->add(NAVBAR_TITLE, smn_href_link(FILENAME_AFFILIATE_SIGNUP, '', 'NONSSL'));
?>
 
    // verify the selected billing address
    if (is_array($billto) && empty($billto) || is_numeric($billto)) {
        $check_address_query = smn_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int) $customer_id . "' and address_book_id = '" . (int) $billto . "'");
        $check_address = smn_db_fetch_array($check_address_query);
        if ($check_address['total'] != '1') {
            $billto = $customer_default_address_id;
            if (smn_session_is_registered('payment')) {
                smn_session_unregister('payment');
            }
        }
    }
}
require DIR_WS_CLASSES . 'order.php';
$order = new order();
require DIR_WS_CLASSES . 'order_total.php';
$order_total_modules = new order_total();
$order_total_modules->clear_posts();
if (!smn_session_is_registered('comments')) {
    smn_session_register('comments');
}
if (isset($HTTP_POST_VARS['comments']) && smn_not_null($HTTP_POST_VARS['comments'])) {
    $comments = smn_db_prepare_input($HTTP_POST_VARS['comments']);
}
$total_weight = $cart->show_weight();
$total_count = $cart->count_contents();
$total_count = $cart->count_contents_virtual();
// load all enabled payment modules
require DIR_WS_CLASSES . 'payment.php';
$payment_modules = new payment();
$breadcrumb->add(NAVBAR_TITLE_1, smn_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'NONSSL'));
$breadcrumb->add(NAVBAR_TITLE_2, smn_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'NONSSL'));
     $attributes_values = smn_db_fetch_array($attributes);
     if (strstr($attributes_values['products_options_name'], 'Stream')) {
         $content_type = 'stream_product';
     }
     if ($content_type == 'stream_product') {
         $start_day = getdate();
         $day = $start_day['mday'];
         $month = $start_day['mon'];
         $year = $start_day['year'];
         $time_entry = strftime('%d', mktime(0, 0, 0, $month, $day, $year)) . '-' . strftime('%m', mktime(0, 0, 0, $month, $day, $year)) . '-' . strftime('%Y', mktime(0, 0, 0, $month, $day, $year));
         $streaming_query = smn_db_query("select * from " . TABLE_STREAMING_PRODUCTS_INFO . " where products_id = '" . $use_products_id . "'");
         if (smn_db_num_rows($streaming_query)) {
             $streaming_values = smn_db_fetch_array($streaming_query);
         }
         if (!smn_session_is_registered('authorization_code')) {
             smn_session_register('authorization_code');
         }
         $random = rand();
         $string = md5($random);
         $authorization_code = substr($string, 20);
         $sql_data_array = array('customer_id' => $customer_id, 'products_id' => $order->products[$i]['id'], 'purchase_id' => $authorization_code, 'time_entry' => $time_entry, 'time_expire' => (int) $order->products[$i]['time_expire'], 'total_click' => 0, 'total_click_allowed' => (int) $order->products[$i]['total_click_allowed']);
         smn_db_perform(TABLE_STREAMING_PRODUCTS, $sql_data_array);
     }
     $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'products_options' => $attributes_values['products_options_name'], 'products_options_values' => $attributes_values['products_options_values_name'], 'options_values_price' => $attributes_values['options_values_price'], 'price_prefix' => $attributes_values['price_prefix']);
     smn_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
     if (DOWNLOAD_ENABLED == 'true' && isset($attributes_values['products_attributes_filename']) && smn_not_null($attributes_values['products_attributes_filename'])) {
         $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'orders_products_filename' => $attributes_values['products_attributes_filename'], 'download_maxdays' => $attributes_values['products_attributes_maxdays'], 'download_count' => $attributes_values['products_attributes_maxcount']);
         smn_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
     }
     $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];
 }
 /*Added the code to get the shpping charges of each module for each store,by Cimi*/
 if (ALLOW_STORE_PAYMENT == 'false') {
     $quotes_store = $shipping_modules->quote_store();
 }
 if (!smn_session_is_registered('comments')) {
     smn_session_register('comments');
 }
 if (smn_not_null($_POST['comments'])) {
     $comments = smn_db_prepare_input($_POST['comments']);
 }
 if (!smn_session_is_registered('shipping')) {
     smn_session_register('shipping');
 }
 /*Register the session shipping_store,By Cimi*/
 if (!smn_session_is_registered('shipping_store')) {
     smn_session_register('shipping_store');
 }
 if (smn_count_shipping_modules() > 0 || $free_shipping == true) {
     if (isset($_POST['shipping']) && strpos($_POST['shipping'], '_')) {
         $shipping = $_POST['shipping'];
         list($module, $method) = explode('_', $shipping);
         if (is_object(${$module}) || $shipping == 'free_free') {
             if ($shipping == 'free_free') {
                 $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
                 $quote[0]['methods'][0]['cost'] = '0';
             } else {
                 $quote = $shipping_modules->quote($method, $module);
             }
             if (isset($quote['error'])) {
                 smn_session_unregister('shipping');
                 /*Unregister the session shipping_store,By Cimi*/
Example #18
0
        } else {
            if (smn_session_is_registered('password_forgotten')) {
                smn_session_unregister('password_forgotten');
            }
            $login_id = $check_admin['login_id'];
            $store_id = $check_admin['store_id'];
            $login_groups_id = $check_admin['login_groups_id'];
            $login_firstname = $check_admin['login_firstname'];
            $login_email_address = $check_admin['login_email_address'];
            $login_logdate = $check_admin['login_logdate'];
            $login_lognum = $check_admin['login_lognum'];
            $login_modified = $check_admin['login_modified'];
            smn_session_register('login_id');
            smn_session_register('store_id');
            smn_session_register('login_groups_id');
            smn_session_register('login_first_name');
            //$date_now = date('Ymd');
            smn_db_query("update " . TABLE_ADMIN . " set admin_logdate = now(), admin_lognum = admin_lognum+1 where admin_id = '" . $login_id . "'");
            echo '{ success: true, redirectUrl: "' . smn_href_link(FILENAME_DEFAULT) . '" }';
            exit;
        }
    }
    echo '{ success: false, errorMsg: "' . $jQuery->jsonHtmlPrepare(TEXT_LOGIN_ERROR) . '" }';
    exit;
}
require DIR_WS_LANGUAGES . $language . '/' . FILENAME_LOGIN;
$submitButton = $jQuery->getPluginClass('button');
$submitButton->setID('submitButton');
$submitButton->setType('submit');
$submitButton->setText('Login');
$content_page = basename($_SERVER['PHP_SELF']);
  to obtain it through the world-wide-web, please send a note to    
  license@systemsmanager.net so we can mail you a copy immediately.
*/
require 'includes/application_top.php';
$current_boxes = DIR_FS_ADMIN . DIR_WS_BOXES;
if ($_GET['action']) {
    switch ($_GET['action']) {
        case 'check_password':
            $check_pass_query = smn_db_query("select admin_password as confirm_password from " . TABLE_ADMIN . " where admin_id = '" . $_POST['id_info'] . "'");
            $check_pass = smn_db_fetch_array($check_pass_query);
            // Check that password is good
            if (!smn_validate_password($_POST['password_confirmation'], $check_pass['confirm_password'])) {
                smn_redirect(smn_href_link(FILENAME_ADMIN_ACCOUNT, 'action=check_account&error=password'));
            } else {
                //$confirm = 'confirm_account';
                smn_session_register('confirm_account');
                $confirm_account = '1';
                smn_redirect(smn_href_link(FILENAME_ADMIN_ACCOUNT, 'action=edit_process'));
            }
            break;
        case 'save_account':
            $admin_id = smn_db_prepare_input($_POST['id_info']);
            $admin_email_address = smn_db_prepare_input($_POST['admin_email_address']);
            $stored_email[] = 'NONE';
            $check_email_query = smn_db_query("select admin_email_address from " . TABLE_ADMIN . " where admin_id <> " . $admin_id . "");
            while ($check_email = smn_db_fetch_array($check_email_query)) {
                $stored_email[] = $check_email['admin_email_address'];
            }
            if (in_array($_POST['admin_email_address'], $stored_email)) {
                smn_redirect(smn_href_link(FILENAME_ADMIN_ACCOUNT, 'action=edit_process&error=email'));
            } else {
        if (isset($_POST['store'])) {
            smn_session_unregister('store_id');
            $store_id = $_POST['store'];
            smn_session_register('store_id');
            smn_redirect(smn_href_link(basename($PHP_SELF)));
        }
    } else {
        $super_user = '******';
        if (!smn_session_is_registered('super_user')) {
            smn_session_register('super_user');
        }
        if (intval($_GET['ID']) != intval($switch_store_id)) {
            smn_redirect(smn_href_link(FILENAME_LOGOFF));
        }
        $store_id = $check['store_id'];
        smn_session_register('store_id');
    }
    $filename = basename($PHP_SELF);
    if ($filename != FILENAME_DEFAULT && $filename != FILENAME_FORBIDEN && $filename != FILENAME_LOGOFF && $filename != FILENAME_ADMIN_ACCOUNT && $filename != FILENAME_POPUP_IMAGE && $filename != 'packingslip.php' && $filename != 'invoice.php') {
        $db_file_query = smn_db_query("select admin_files_name, admin_groups_id from " . TABLE_ADMIN_FILES . " where FIND_IN_SET( '" . $login_groups_id . "', admin_groups_id) and admin_files_name = '" . $filename . "'");
        if (!smn_db_num_rows($db_file_query)) {
            //smn_redirect(smn_href_link(FILENAME_FORBIDEN));
        } else {
            $db_file = smn_db_fetch_array($db_file_query);
        }
    }
}
// Check login and file access
if (basename($PHP_SELF) != FILENAME_LOGOFF && basename($PHP_SELF) != FILENAME_LOGIN && basename($PHP_SELF) != FILENAME_PASSWORD_FORGOTTEN) {
    if (!smn_session_is_registered('login_id')) {
        smn_session_unregister('store_id');
        }
    }
} elseif (isset($_GET['manufacturers_id'])) {
    $manufacturers_query = smn_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int) $_GET['manufacturers_id'] . "'");
    if (smn_db_num_rows($manufacturers_query)) {
        $manufacturers = smn_db_fetch_array($manufacturers_query);
        $breadcrumb->add($manufacturers['manufacturers_name'], smn_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $_GET['manufacturers_id']));
    }
}
$affiliate_clientdate = date("Y-m-d H:i:s");
$affiliate_clientbrowser = $_SERVER["HTTP_USER_AGENT"];
$affiliate_clientip = $_SERVER["REMOTE_ADDR"];
$affiliate_clientreferer = $_SERVER["HTTP_REFERER"];
if (!$HTTP_SESSION_VARS['affiliate_ref']) {
    smn_session_register('affiliate_ref');
    smn_session_register('affiliate_clickthroughs_id');
    if ($_GET['ref'] || $_POST['ref']) {
        if ($_GET['ref']) {
            $affiliate_ref = $_GET['ref'];
        }
        if ($_POST['ref']) {
            $affiliate_ref = $_POST['ref'];
        }
        if ($_GET['products_id']) {
            $affiliate_products_id = $set_product_id;
        }
        if ($_POST['products_id']) {
            $affiliate_products_id = $_POST['products_id'];
        }
        if ($_GET['affiliate_banner_id']) {
            $affiliate_banner_id = $_GET['affiliate_banner_id'];
            
                    $date_now = date('Ymd');
            
                    smn_db_query("update " . TABLE_AFFILIATE . " set affiliate_date_of_last_logon = now(), affiliate_number_of_logons = affiliate_number_of_logons + 1 where affiliate_id = '" . $affiliate_id . "'");*/
            if (SESSION_RECREATE == 'True') {
                smn_session_recreate();
            }
            $check_country_query = smn_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'] . "'");
            $check_country = smn_db_fetch_array($check_country_query);
            $affiliate_id = $check_affiliate['affiliate_id'];
            smn_session_register('affiliate_id');
            $customer_id = $check_customer['customers_id'];
            $customer_default_address_id = $check_customer['customers_default_address_id'];
            $customer_first_name = $check_customer['customers_firstname'];
            $customer_country_id = $check_country['entry_country_id'];
            $customer_zone_id = $check_country['entry_zone_id'];
            smn_session_register('customer_id');
            smn_session_register('customer_default_address_id');
            smn_session_register('customer_first_name');
            smn_session_register('customer_country_id');
            smn_session_register('customer_zone_id');
            smn_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 . "'");
            $cart->restore_contents();
            smn_redirect(smn_href_link(FILENAME_AFFILIATE_SUMMARY, '', 'NONSSL'));
        }
    }
}
$breadcrumb->add(NAVBAR_TITLE, smn_href_link(FILENAME_AFFILIATE, '', 'NONSSL'));
?>
 
  
  Portions Copyright (c) 2002 osCommerce
  
  This source file is subject to version 2.0 of the GPL license,   
  that is bundled with this package in the file LICENSE. If you
  did not receive a copy of the oscMall System license and are unable 
  to obtain it through the world-wide-web, please send a note to    
  license@systemsmanager.net so we can mail you a copy immediately.
*/
require 'includes/application_top.php';
if (isset($_GET['action']) && $_GET['action'] == 'process') {
    $email_address = smn_db_prepare_input($_POST['email_address']);
    $firstname = smn_db_prepare_input($_POST['firstname']);
    $log_times = $_POST['log_times'] + 1;
    if ($log_times >= 4) {
        smn_session_register('password_forgotten');
    }
    // Check if email exists
    $check_admin_query = smn_db_query("select admin_id as check_id, admin_firstname as check_firstname, admin_lastname as check_lastname, admin_email_address as check_email_address from " . TABLE_ADMIN . " where admin_email_address = '" . smn_db_input($email_address) . "'");
    if (!smn_db_num_rows($check_admin_query)) {
        $_GET['login'] = '******';
    } else {
        $check_admin = smn_db_fetch_array($check_admin_query);
        if ($check_admin['check_firstname'] != $firstname) {
            $_GET['login'] = '******';
        } else {
            $_GET['login'] = '******';
            function randomize()
            {
                $salt = "ABCDEFGHIJKLMNOPQRSTUVWXWZabchefghjkmnpqrstuvwxyz0123456789";
                srand((double) microtime() * 1000000);