function amSessionRegister($strSessionVar, $value = '') { if (!amSessionIsRegistered($strSessionVar)) { vam_session_register($strSessionVar); $GLOBALS[$strSessionVar] = $value; } }
function vam_get_customer_status_value($customer_id) { if (isset($_SESSION['customer_id'])) { $customer_status_query = vam_db_query("select c.customers_status, c.member_flag, c.customers_personal_discount, cs.customers_status_id, cs.customers_status_name, cs.customers_status_public, cs.customers_status_show_price, cs_customers_status_min_order, cs.customers_status_max_order, cs.customers_status_show_price_tax, cs.customers_status_image, cs.customers_status_discount, cs.customers_status_ot_discount_flag, cs.customers_status_ot_discount, cs.customers_status_graduated_prices, cs.customers_status_cod_permission, cs.customers_status_cc_permission, cs.customers_status_bt_permission FROM " . TABLE_CUSTOMERS . " as c left join " . TABLE_CUSTOMERS_STATUS . " as cs on customers_status = customers_status_id where c.customers_id='" . $_SESSION['customer_id'] . "' and cs.language_id = '" . $_SESSION['languages_id'] . "'"); } else { $customer_status_query = vam_db_query("select cs.customers_status_id, cs.customers_status_name, cs.customers_status_public, cs.customers_status_show_price, cs_customers_status_min_order, cs.customers_status_max_order, cs.customers_status_show_price_tax, cs.customers_status_image, cs.customers_status_discount, cs.customers_status_ot_discount_flag, cs.customers_status_ot_discount, cs.customers_status_graduated_prices FROM " . TABLE_CUSTOMERS_STATUS . " as cs where cs.customers_status_id='" . DEFAULT_CUSTOMERS_STATUS_ID_GUEST . "' and cs.language_id = '" . $_SESSION['languages_id'] . "'"); $customer_status_value['customers_status'] = DEFAULT_CUSTOMERS_STATUS_ID_GUEST; } $customer_status_value = vam_db_fetch_array($customer_status_query); vam_session_register('customer_status_value'); return $customer_status_value; }
$message = new message(); //Must be included after ci_message.class.php: require_once DIR_FS_ADMIN_CLASSES . 'ci_cip_manager.class.php'; $cip_manager = new cip_manager($current_path); require_once DIR_FS_ADMIN_FUNCTIONS . 'contrib_installer.php'; //set_current_path: //if (defined('DIR_FS_CIP')) $current_path=DIR_FS_CIP; //This must protect contrib_dir parameter if (isset($_REQUEST['contrib_dir']) && $_REQUEST['action'] == 'install' && $_REQUEST['cip'] == $cip_manager->ci_cip() && is_dir($_REQUEST['contrib_dir'])) { $current_path = $_REQUEST['contrib_dir']; } if (strstr($current_path, '..') or !is_dir($current_path) or defined(DIR_FS_CIP) && !preg_match('/^/' . DIR_FS_CIP, $current_path)) { $current_path = DIR_FS_CIP; } if (!vam_session_is_registered('current_path')) { vam_session_register('current_path'); } $current_path = str_replace('//', '/', $current_path); // Nessesary for self-install. We redirect from init_contrib_installer.php with this patameters: if (!defined(DIR_FS_CIP) && $_REQUEST['contrib_dir']) { define('DIR_FS_CIP', $_REQUEST['contrib_dir']); } //Check if ontrib Installer installed: if (DIR_FS_CIP == 'DIR_FS_CIP') { vam_redirect(vam_href_link(INIT_CONTRIB_INSTALLER)); } //Check if self-install was made: if ($_REQUEST['cip'] != $cip_manager->ci_cip() && $_REQUEST['contrib_dir'] && !$cip_manager->is_ci_installed()) { vam_redirect(vam_href_link(INIT_CONTRIB_INSTALLER)); } $cip_manager->check_action($_REQUEST['action']);
function vam_collect_posts() { global $coupon_no, $REMOTE_ADDR, $vamPrice, $cc_id; if (!$REMOTE_ADDR) { $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; } if ($_POST['gv_redeem_code']) { $gv_query = vam_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'"); $gv_result = vam_db_fetch_array($gv_query); if (vam_db_num_rows($gv_query) != 0) { $redeem_query = vam_db_query("select * from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $gv_result['coupon_id'] . "'"); if (vam_db_num_rows($redeem_query) != 0 && $gv_result['coupon_type'] == 'G') { vam_redirect(vam_href_link(FILENAME_SHOPPING_CART, 'info_message=' . urlencode(ERROR_NO_INVALID_REDEEM_GV), 'SSL')); } } else { vam_redirect(vam_href_link(FILENAME_SHOPPING_CART, 'info_message=' . urlencode(ERROR_NO_INVALID_REDEEM_GV), 'SSL')); } // GIFT CODE G START if ($gv_result['coupon_type'] == 'G') { $gv_amount = $gv_result['coupon_amount']; // Things to set // ip address of claimant // customer id of claimant // date // redemption flag // now update customer account with gv_amount $gv_amount_query = vam_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . $_SESSION['customer_id'] . "'"); $customer_gv = false; $total_gv_amount = $gv_amount; if ($gv_amount_result = vam_db_fetch_array($gv_amount_query)) { $total_gv_amount = $gv_amount_result['amount'] + $gv_amount; $customer_gv = true; } $gv_update = vam_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $gv_result['coupon_id'] . "'"); $gv_redeem = vam_db_query("insert into " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, customer_id, redeem_date, redeem_ip) values ('" . $gv_result['coupon_id'] . "', '" . $_SESSION['customer_id'] . "', now(),'" . $REMOTE_ADDR . "')"); if ($customer_gv) { // already has gv_amount so update $gv_update = vam_db_query("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $total_gv_amount . "' where customer_id = '" . $_SESSION['customer_id'] . "'"); } else { // no gv_amount so insert $gv_insert = vam_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $_SESSION['customer_id'] . "', '" . $total_gv_amount . "')"); } vam_redirect(vam_href_link(FILENAME_SHOPPING_CART, 'info_message=' . urlencode(REDEEMED_AMOUNT . $vamPrice->Format($gv_amount, true, 0, true)), 'SSL')); } else { if (vam_db_num_rows($gv_query) == 0) { vam_redirect(vam_href_link(FILENAME_SHOPPING_CART, 'info_message=' . urlencode(ERROR_NO_INVALID_REDEEM_COUPON), 'SSL')); } $date_query = vam_db_query("select coupon_start_date from " . TABLE_COUPONS . " where coupon_start_date <= now() and coupon_code='" . $_POST['gv_redeem_code'] . "'"); if (vam_db_num_rows($date_query) == 0) { vam_redirect(vam_href_link(FILENAME_SHOPPING_CART, 'info_message=' . urlencode(ERROR_INVALID_STARTDATE_COUPON), 'SSL')); } $date_query = vam_db_query("select coupon_expire_date from " . TABLE_COUPONS . " where coupon_expire_date >= now() and coupon_code='" . $_POST['gv_redeem_code'] . "'"); if (vam_db_num_rows($date_query) == 0) { vam_redirect(vam_href_link(FILENAME_SHOPPING_CART, 'info_message=' . urlencode(ERROR_INVALID_FINISDATE_COUPON), 'SSL')); } $coupon_count = vam_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $gv_result['coupon_id'] . "'"); $coupon_count_customer = vam_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $gv_result['coupon_id'] . "' and customer_id = '" . $_SESSION['customer_id'] . "'"); if (vam_db_num_rows($coupon_count) >= $gv_result['uses_per_coupon'] && $gv_result['uses_per_coupon'] > 0) { vam_redirect(vam_href_link(FILENAME_SHOPPING_CART, 'info_message=' . urlencode(ERROR_INVALID_USES_COUPON . $gv_result['uses_per_coupon'] . TIMES), 'SSL')); } if (vam_db_num_rows($coupon_count_customer) >= $gv_result['uses_per_user'] && $gv_result['uses_per_user'] > 0) { vam_redirect(vam_href_link(FILENAME_SHOPPING_CART, 'info_message=' . urlencode(ERROR_INVALID_USES_USER_COUPON . $gv_result['uses_per_user'] . TIMES), 'SSL')); } if ($gv_result['coupon_type'] == 'S') { $coupon_amount = $order->info['shipping_cost']; } else { $coupon_amount = $gv_result['coupon_amount'] . ' '; } if ($gv_result['coupon_type'] == 'P') { $coupon_amount = $gv_result['coupon_amount'] . '% '; } if ($gv_result['coupon_minimum_order'] > 0) { $coupon_amount .= 'on orders greater than ' . $gv_result['coupon_minimum_order']; } if (!vam_session_is_registered('cc_id')) { vam_session_register('cc_id'); } //Fred - this was commented out before $_SESSION['cc_id'] = $gv_result['coupon_id']; //Fred ADDED, set the global and session variable vam_redirect(vam_href_link(FILENAME_SHOPPING_CART, 'info_message=' . urlencode(REDEEMED_COUPON), 'SSL')); } } if ($_POST['submit_redeem_x'] && $gv_result['coupon_type'] == 'G') { vam_redirect(vam_href_link(FILENAME_SHOPPING_CART, 'info_message=' . urlencode(ERROR_NO_REDEEM_CODE), 'SSL')); } }