<?php
// [e-commerce cart operations module v.1.2.1]
// xantis.warp.cms - version 1.2
// (c) 2002 xantis - all rights reserved
// this code is registered and protected by international copyrights laws
//####### Register Globals !
extract($HTTP_ENV_VARS);
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
extract($HTTP_COOKIE_VARS);
extract($HTTP_SERVER_VARS);
//#########################
$ys = rawurldecode($ys);
$ys = base64_decode ($ys);
if ($ys == 'xshopcartoky_acc') {
$xnt_control_var = 'xnt2002warp.cms';
} //end if
if (empty($yfilename)) {
$yfilename = 'cart_op.php';
} //end if
require("lib_adv.php");
//#######################################
function xecomm_cart_add_ed () {
global $wxu, $wxp ;
global $arr_var_result, $var_result_size ;
global $quantity, $wpsid, $fitmid, $y_warp_xdate, $y_warp_xtime ;
global $yecomm_cart_add_ok, $y_warp_err_data_failure,$yecomm_max_qty,
$yecomm_cart_add_err_01, $yecomm_cart_add_err_02, $yecomm_cart_add_err_03,
$yecomm_cart_add_err_04, $yecomm_cart_add_err_05, $yecomm_cart_add_err_06,
$yecomm_cart_add_err_00 ;
global $yecomm_active, $warp_deny_acc_sect;
global $REQUEST_METHOD, $QUERY_STRING, $y_warp_direct_file_acc_msg_reff ;
$process_qty = trim(rawurldecode($quantity));
//--------------------------------------
$yx_process_crt_msg_oky = $yecomm_cart_add_ok;
$yx_process_crt_msg_err = $y_warp_err_data_failure;
$yx_process_crt_err = 'ok';
//--------------------------------------
//check request method
if ( ($REQUEST_METHOD <> 'POST') OR (!empty($QUERY_STRING)) ) {
if ($yx_process_crt_err == 'ok') {
$yx_process_crt_msg_err = $y_warp_direct_file_acc_msg_reff;
} //end if
$yx_process_crt_err = 'notok';
} //end if
//check if e-commerce active
if ($yecomm_active <> 'y') {
if ($yx_process_crt_err == 'ok') {
$yx_process_crt_msg_err = $warp_deny_acc_sect;
} //end if
$yx_process_crt_err = 'notok';
} //end if
//------------------------ product verify
xmysql_read_data_fl ("SELECT id FROM prod_items WHERE ( (id='$fitmid') AND (active='y') AND (e_comm='y') AND (price>'0') ) ");
$hlocx_prod_vfy = $arr_var_result[0];
//------------------------
//------------------------ get user auth
//read from users
xmysql_read_data_fl ("SELECT id FROM users WHERE ( (MD5(usr_name)='$wxu') AND (MD5(usr_pass)='$wxp') )");
$ylocal_prodmod_usr_id = $arr_var_result[0];
//------------------------
//check user id
if (empty($ylocal_prodmod_usr_id)) {
if ($yx_process_crt_err == 'ok') {
$yx_process_crt_msg_err = $yecomm_cart_add_err_00;
} //end if
$yx_process_crt_err = 'notok';
} //end if
//check product id
if (empty($hlocx_prod_vfy)) {
if ($yx_process_crt_err == 'ok') {
$yx_process_crt_msg_err = $y_warp_err_data_failure;
} //end if
$yx_process_crt_err = 'notok';
} //end if
//check other vars (wpsid, fitmid)
if ( (strlen($wpsid) < '32') OR (empty($fitmid)) ) {
if ($yx_process_crt_err == 'ok') {
$yx_process_crt_msg_err = $yecomm_cart_add_err_01;
} //end if
$yx_process_crt_err = 'notok';
} //end if
//check if numeric
if ( (!is_numeric($process_qty)) OR (eregi('x', $process_qty)) ) {
if ($yx_process_crt_err == 'ok') {
$yx_process_crt_msg_err = $yecomm_cart_add_err_02;
} //end if
$yx_process_crt_err = 'notok';
} //end if
//check positive
if ($process_qty < '0') {
if ($yx_process_crt_err == 'ok') {
$yx_process_crt_msg_err = $yecomm_cart_add_err_05;
} //end if
$yx_process_crt_err = 'notok';
} //end if
//check if overflow
if ($process_qty > $yecomm_max_qty) {
if ($yx_process_crt_err == 'ok') {
$yx_process_crt_msg_err = $yecomm_cart_add_err_03.' : '."$yecomm_max_qty";
} //end if
$yx_process_crt_err = 'notok';
} //end if
//check if integer
$process_qty = $process_qty + 0;
if (!is_int($process_qty)) {
if ($yx_process_crt_err == 'ok') {
$yx_process_crt_msg_err = $yecomm_cart_add_err_04;
} //end if
$yx_process_crt_err = 'notok';
} //end if
//--------------------------------------
//########################################## CART ADD, EDIT, REMOVE
if ($yx_process_crt_err == 'ok') {
//insert or update data
if ( ($process_qty > '0') AND ($process_qty <= $yecomm_max_qty) ) {
//count total items pet session and user
xmysql_count_data_fl ("SELECT COUNT(*) FROM prod_cart WHERE ( (w_sess='$wpsid') AND (u_id='$ylocal_prodmod_usr_id') ) ");
// $var_result_size
//check this item per session and user
xmysql_read_data_fl ("SELECT id FROM prod_cart WHERE ( (w_sess='$wpsid') AND (p_id='$fitmid') AND (u_id='$ylocal_prodmod_usr_id') ) ");
$arr_prev_cart = $arr_var_result;
//if this prod exist
if (empty($arr_prev_cart[0])) {
$hxl_maxx_pcart = 98;
} //end if
else {
$hxl_maxx_pcart = 99;
} //end else
//if ok max cart
if ($var_result_size <= $hxl_maxx_pcart) {
xmysql_write_data_fl ("DELETE FROM prod_cart WHERE ( (w_sess='$wpsid') AND (p_id='$fitmid') AND (u_id='$ylocal_prodmod_usr_id') ) ");
xmysql_write_data_fl ("INSERT INTO prod_cart (w_date, w_time, p_qty, w_sess, p_id, u_id) VALUES ('$y_warp_xdate', '$y_warp_xtime', '$process_qty', '$wpsid', '$fitmid', '$ylocal_prodmod_usr_id') ");
} //end if
else {
if ($yx_process_crt_err == 'ok') {
$yx_process_crt_msg_err = $yecomm_cart_add_err_06;
} //end if
$yx_process_crt_err = 'notok';
} //end else
} //end if
else {
xmysql_write_data_fl ("DELETE FROM prod_cart WHERE ( (w_sess='$wpsid') AND (p_id='$fitmid') AND (u_id='$ylocal_prodmod_usr_id') ) ");
} //end else
} //end if
//##########################################
//########################################## OUTPUT
//get items in cart
xmysql_read_data_fl ("SELECT p_qty FROM prod_cart WHERE ( (w_sess='$wpsid') AND (p_id='$fitmid') AND (u_id='$ylocal_prodmod_usr_id') ) ");
if (empty($arr_var_result[0])) {
$yx_local_cartadd_qty_isc = '0';
} //end if
else {
$yx_local_cartadd_qty_isc = $arr_var_result[0];
} //end else
//output
echo(
"&xcheck_load_controlvar=".rawurlencode('ok').
"&xcheck_data_controlvar=".rawurlencode("$yx_process_crt_err").
"&flash_form_text_err=".rawurlencode("$yx_process_crt_msg_err").
"&flash_form_text_oky=".rawurlencode("$yx_process_crt_msg_oky").
"&flash_form_cartinfo_num=".rawurlencode("$yx_local_cartadd_qty_isc").
"&"
);
//##########################################
} //end function
//----------------------------------------
if ($ys == 'xshopcartoky_acc') {
xecomm_cart_add_ed ();
} //end if
//----------------------------------------
//end of php code
?>