function address()
{
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'GET':
            $r_data = get_consignee_list($_SESSION['user_id']);
            return $r_data;
            break;
        case 'DELETE':
            $consignee_id = intval($_GET['id']);
            if (drop_consignee($consignee_id)) {
                $r_data = 'Delete Address Success!';
            } else {
                $r_data = 'Delete Address Failed!';
            }
            return $r_data;
            break;
        case 'POST':
            $address = array('user_id' => $_SESSION['user_id'], 'address_id' => intval($_POST['address_id']), 'country' => isset($_POST['country']) ? intval($_POST['country']) : 0, 'province' => isset($_POST['province']) ? intval($_POST['province']) : 0, 'city' => isset($_POST['city']) ? intval($_POST['city']) : 0, 'district' => isset($_POST['district']) ? intval($_POST['district']) : 0, 'address' => isset($_POST['address']) ? compile_str(trim($_POST['address'])) : '', 'consignee' => isset($_POST['consignee']) ? compile_str(trim($_POST['consignee'])) : '', 'email' => isset($_POST['email']) ? compile_str(trim($_POST['email'])) : '', 'tel' => isset($_POST['tel']) ? compile_str(make_semiangle(trim($_POST['tel']))) : '', 'mobile' => isset($_POST['mobile']) ? compile_str(make_semiangle(trim($_POST['mobile']))) : '', 'best_time' => isset($_POST['best_time']) ? compile_str(trim($_POST['best_time'])) : '', 'sign_building' => isset($_POST['sign_building']) ? compile_str(trim($_POST['sign_building'])) : '', 'zipcode' => isset($_POST['zipcode']) ? compile_str(make_semiangle(trim($_POST['zipcode']))) : '');
            if (update_address($address)) {
                $r_data = 'Update Address Success!';
            } else {
                $r_data = 'Update Address Failed!';
            }
            return $r_data;
            break;
        default:
            return 'This API can not support ' . $_SERVER['REQUEST_METHOD'] . ' method';
            break;
    }
}
Example #2
0
function autosave_address($info, &$address = NULL)
{
    format_address($address);
    verify_address($error, $address);
    if ($error) {
        return $error;
    }
    $save_type = isset($address['save_type']) ? $address['save_type'] : 0;
    switch ($save_type) {
        case 'new':
            if (find_similar_addresses($info, $address)) {
                return "Similar address found.";
            } else {
                create_new_address($info, $address);
            }
            break;
        case 'edit':
            update_address($info, $address);
            break;
        default:
            if (find_similar_addresses($info, $address)) {
                update_address($info, $address);
            } else {
                create_new_address($info, $address);
            }
    }
    return true;
}
Example #3
0
    $smarty->assign('shop_country', $_CFG['shop_country']);
    $smarty->assign('shop_province', get_regions(1, $_CFG['shop_country']));
    $smarty->assign('province_list', $province_list);
    $smarty->assign('address', $address_id);
    $smarty->assign('city_list', $city_list);
    $smarty->assign('district_list', $district_list);
    $smarty->assign('currency_format', $_CFG['currency_format']);
    $smarty->assign('integral_scale', $_CFG['integral_scale']);
    $smarty->assign('name_of_region', array($_CFG['name_of_region_1'], $_CFG['name_of_region_2'], $_CFG['name_of_region_3'], $_CFG['name_of_region_4']));
    $smarty->display('user_transaction.dwt');
} elseif ($action == 'act_edit_address') {
    include_once ROOT_PATH . 'includes/lib_transaction.php';
    include_once ROOT_PATH . 'languages/' . $_CFG['lang'] . '/shopping_flow.php';
    $smarty->assign('lang', $_LANG);
    $address = array('user_id' => $user_id, 'address_id' => intval($_POST['address_id']), 'country' => isset($_POST['country']) ? intval($_POST['country']) : 0, 'province' => isset($_POST['province']) ? intval($_POST['province']) : 0, 'city' => isset($_POST['city']) ? intval($_POST['city']) : 0, 'district' => isset($_POST['district']) ? intval($_POST['district']) : 0, 'address' => isset($_POST['address']) ? trim($_POST['address']) : '', 'consignee' => isset($_POST['consignee']) ? trim($_POST['consignee']) : '', 'email' => isset($_POST['email']) ? trim($_POST['email']) : '', 'tel' => isset($_POST['tel']) ? make_semiangle(trim($_POST['tel'])) : '', 'mobile' => isset($_POST['mobile']) ? make_semiangle(trim($_POST['mobile'])) : '', 'best_time' => isset($_POST['best_time']) ? trim($_POST['best_time']) : '', 'sign_building' => isset($_POST['sign_building']) ? trim($_POST['sign_building']) : '', 'zipcode' => isset($_POST['zipcode']) ? make_semiangle(trim($_POST['zipcode'])) : '');
    if (update_address($address)) {
        show_message($_LANG['edit_address_success'], $_LANG['address_list_lnk'], 'user.php?act=address_list');
    }
} elseif ($action == 'drop_consignee') {
    include_once 'includes/lib_transaction.php';
    $consignee_id = intval($_GET['id']);
    if (drop_consignee($consignee_id)) {
        ecs_header("Location: user.php?act=address_list\n");
        exit;
    } else {
        show_message($_LANG['del_address_false']);
    }
} elseif ($action == 'collection_list') {
    include_once ROOT_PATH . 'includes/lib_clips.php';
    $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
    $record_count = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('collect_goods') . " WHERE user_id='{$user_id}' ORDER BY add_time DESC");
Example #4
0
function action_act_edit_address()
{
    $user = $GLOBALS['user'];
    $_CFG = $GLOBALS['_CFG'];
    $_LANG = $GLOBALS['_LANG'];
    $smarty = $GLOBALS['smarty'];
    $db = $GLOBALS['db'];
    $ecs = $GLOBALS['ecs'];
    $user_id = $_SESSION['user_id'];
    include_once ROOT_PATH . 'includes/lib_transaction.php';
    include_once ROOT_PATH . 'languages/' . $_CFG['lang'] . '/shopping_flow.php';
    $smarty->assign('lang', $_LANG);
    $address = array('user_id' => $user_id, 'address_id' => intval($_POST['address_id']), 'country' => isset($_POST['country']) ? intval($_POST['country']) : 0, 'province' => isset($_POST['province']) ? intval($_POST['province']) : 0, 'city' => isset($_POST['city']) ? intval($_POST['city']) : 0, 'district' => isset($_POST['district']) ? intval($_POST['district']) : 0, 'address' => isset($_POST['address']) ? compile_str(trim($_POST['address'])) : '', 'consignee' => isset($_POST['consignee']) ? compile_str(trim($_POST['consignee'])) : '', 'email' => isset($_POST['email']) ? compile_str(trim($_POST['email'])) : '', 'tel' => isset($_POST['tel']) ? compile_str(make_semiangle(trim($_POST['tel']))) : '', 'mobile' => isset($_POST['mobile']) ? compile_str(make_semiangle(trim($_POST['mobile']))) : '', 'best_time' => isset($_POST['best_time']) ? compile_str(trim($_POST['best_time'])) : '', 'sign_building' => isset($_POST['sign_building']) ? compile_str(trim($_POST['sign_building'])) : '', 'zipcode' => isset($_POST['zipcode']) ? compile_str(make_semiangle(trim($_POST['zipcode']))) : '');
    if (update_address($address)) {
        show_message($_LANG['edit_address_success'], $_LANG['address_list_lnk'], 'user.php?act=address_list');
    }
}
Example #5
0
 *                                                                          
 *
 *  Copyright 2013-2014, Geek Zoo Studio
 *  http://www.ecmobile.cn/license.html
 *
 *  HQ China:
 *    2319 Est.Tower Van Palace 
 *    No.2 Guandongdian South Street 
 *    Beijing , China
 *
 *  U.S. Office:
 *    One Park Place, Elmira College, NY, 14901, USA
 *
 *  QQ Group:   329673575
 *  BBS:        bbs.ecmobile.cn
 *  Fax:        +86-10-6561-5510
 *  Mail:       info@geek-zoo.com
 */
define('INIT_NO_USERS', true);
require EC_PATH . '/includes/init.php';
GZ_Api::authSession();
include_once EC_PATH . '/includes/lib_transaction.php';
include_once ROOT_PATH . 'languages/' . $_CFG['lang'] . '/shopping_flow.php';
$address = _POST('address', array());
$address['address_id'] = $address['id'];
unset($address['id']);
$address['user_id'] = $_SESSION['user_id'];
$address['defalut'] = 1;
$address['default'] = 1;
$a = update_address($address);
GZ_Api::outPut(array());
        setcookie("sessionID", session_id(), time() + 31436000);
        //one year
        echo "<script>window.location='products.php';</script>";
    }
} else {
    session_start();
}
require_once '../lib-common.php';
require_once 'user_shipping_functions.php';
if (!SEC_inGroup('Logged-in Users')) {
    echo "You must be logged in, inorder to see this page.";
    exit;
}
echo COM_siteHeader();
if (isset($_POST['update_shipping_address'])) {
    $error = update_address(COM_applyFilter($_GET['id']));
} else {
    if (isset($_POST['add_shipping_address'])) {
        $error = add_shipping_address($_USER['uid']);
    } else {
        if (isset($_POST['delete_shipping_address'])) {
            $error = delete_shipping_address(COM_applyFilter($_GET['id']), "index.php?op=shipping_address");
        } else {
            if (isset($_GET['delete_id'])) {
                $error = delete_shipping_address(COM_applyFilter($_GET['delete_id']), "index.php?op=shipping_address");
            } else {
                $error = "";
            }
        }
    }
}
Example #7
0
	public function act_edit_address (){
		checkLogin();	
		include_once(RPC_ROOT . 'includes/lib_transaction_ec.php');
		$user_id = intval($_SESSION['user_id']);
		$address = array(
			'user_id'    => $user_id,
			'address_id' => intval($_GET['address_id']),
			'country'    => isset($_GET['country'])   ? intval($_GET['country'])  : 0,
			'province'   => isset($_GET['province'])  ? intval($_GET['province']) : 0,
			'city'       => isset($_GET['city'])      ? intval($_GET['city'])     : 0,
			'district'   => isset($_GET['district'])  ? intval($_GET['district']) : 0,
			'email'      => isset($_GET['email'])     ? trim($_GET['email'])      : '',
			'tel'        => isset($_GET['tel'])       ? make_semiangle(trim($_GET['tel'])) : '',
			'mobile'     => isset($_GET['mobile'])    ? make_semiangle(trim($_GET['mobile'])) : '',
			'best_time'  => isset($_GET['best_time']) ? trim($_GET['best_time'])  : '',
			'zipcode'       => isset($_GET['zipcode'])       ? make_semiangle(trim($_GET['zipcode'])) : '',
		);
		if(EC_CHARSET == 'utf-8'){
			$address['address'] = isset($_GET['address'])   ? gbktoutf8(trim($_GET['address'])) : '';
			$address['consignee'] = isset($_GET['consignee']) ? gbktoutf8(trim($_GET['consignee']))  : '';
			$address['sign_building'] = isset($_GET['sign_building']) ? gbktoutf8(trim($_GET['sign_building'])) : '';
		}else{
			$address['address'] = isset($_GET['address'])   ? utf8togbk(trim($_GET['address'])) : '';
			$address['consignee'] = isset($_GET['consignee']) ? utf8togbk(trim($_GET['consignee']))  : '';
			$address['sign_building'] = isset($_GET['sign_building']) ? utf8togbk(trim($_GET['sign_building'])) : '';
		}
		$default = isset($_GET['default']) ? trim($_GET['default'])  : false;
		
		if (update_address($address,$default))
		{
			$msg = rpcLang('user.php', 'address_update_success');
			$code = '0';
		}else
		{
			$msg = rpcLang('user.php', 'address_update_failure');
			$code = '1';
		}
		jsonExit("{\"status\":\"$msg\",\"code\":\"$code\"}");
	}
 $db_conn = open_db_conn();
 if (is_null($db_conn)) {
     $return_value["status"] = false;
     $return_value["reason"] = "Database Error";
 } else {
     if (authorize_request($party_id, $auth_token, $db_conn, $return_value)) {
         // Validate zip code
         if (strlen($addr_zip) != 5 || !preg_match("/[0-9]{5}/", $addr_zip)) {
             $return_value["status"] = false;
             $return_value["reason"] = "Invalid ZIP code";
         } else {
             if (!validate_state($addr_state)) {
                 $return_value["status"] = false;
                 $return_value["reason"] = "Invalid State";
             } else {
                 if (!update_address($party_id, $addr_house_num, $addr_street, $addr_apt, $addr_city, $addr_state, $addr_zip, $db_conn)) {
                     $return_value["status"] = false;
                     $return_value["reason"] = "Database Error";
                 } else {
                     $return_value["status"] = true;
                     $return_value["addr_house_num"] = $addr_house_num;
                     $return_value["addr_street"] = $addr_street;
                     $return_value["addr_apt"] = $addr_apt;
                     $return_value["addr_city"] = $addr_city;
                     $return_value["addr_state"] = $addr_state;
                     $return_value["addr_zip"] = $addr_zip;
                 }
             }
         }
     }
 }
Example #9
0
File: user.php Project: qgz/ecshop
        echo '<script language=javascript>alert("联系电话不可为空!");history.go(-1);</script>';
        exit;
    }
    if (empty($_POST['mobile'])) {
        echo '<script language=javascript>alert("联系手机不可为空!");history.go(-1);</script>';
        exit;
    }
    if (empty($_POST['email'])) {
        echo '<script language=javascript>alert("电子邮箱不可为空!");history.go(-1);</script>';
        exit;
    }
    /*
     * 保存收货人信息
     */
    $consignee = array('user_id' => $_SESSION['user_id'], 'address_id' => empty($_POST['address_id']) ? 0 : intval($_POST['address_id']), 'consignee' => empty($_POST['consignee']) ? '' : trim($_POST['consignee']), 'country' => empty($_POST['country']) ? '' : $_POST['country'], 'province' => empty($_POST['province']) ? '' : $_POST['province'], 'city' => empty($_POST['city']) ? '' : $_POST['city'], 'district' => empty($_POST['district']) ? '' : $_POST['district'], 'email' => empty($_POST['email']) ? '' : $_POST['email'], 'address' => empty($_POST['address']) ? '' : $_POST['address'], 'zipcode' => empty($_POST['zipcode']) ? '' : make_semiangle(trim($_POST['zipcode'])), 'tel' => empty($_POST['tel']) ? '' : make_semiangle(trim($_POST['tel'])), 'mobile' => empty($_POST['mobile']) ? '' : make_semiangle(trim($_POST['mobile'])), 'sign_building' => empty($_POST['sign_building']) ? '' : $_POST['sign_building'], 'best_time' => empty($_POST['best_time']) ? '' : $_POST['best_time']);
    $result = update_address($consignee);
    if ($result) {
        echo '<script language=javascript>alert("增加收货地址成功");location.href="user.php?act=address_list";</script>';
    } else {
        echo '<script language=javascript>alert("增加收货地址失败");history.go(-1);</script>';
    }
    if ($_SESSION['user_id'] > 0) {
        $smarty->assign('user_name', $_SESSION['user_name']);
    }
} elseif ($act == 'drop_address') {
    include_once 'includes/lib_transaction.php';
    $consignee_id = intval($_GET['id']);
    if (drop_consignee($consignee_id)) {
        ecs_header("Location: user.php?act=address_list\n");
        exit;
    }
Example #10
0
    $function = $values['function'];
}
switch ($function) {
    case 'add_address':
        include_once __DIR__ . '/customers/add_address.php';
        $responseArray['response'] = add_address($values);
        $responseArray['message'] = 'Address added';
        break;
    case 'get_addresses':
        include_once __DIR__ . '/customers/get_addresses.php';
        $responseArray['response'] = get_addresses($values);
        $responseArray['message'] = 'Addresses got';
        break;
    case 'update_address':
        include_once __DIR__ . '/customers/update_address.php';
        $responseArray['response'] = update_address($values);
        $responseArray['message'] = 'Address updated';
        break;
    case 'add_user':
        include_once __DIR__ . '/customers/add_user.php';
        $responseArray['response'] = add_user($values);
        $responseArray['message'] = 'User successfully added';
        break;
    case 'get_users':
        include_once __DIR__ . '/customers/get_users.php';
        $responseArray['response'] = get_users($values);
        $responseArray['message'] = 'Users successfully read';
        break;
    case 'update_user':
        include_once __DIR__ . '/customers/update_user.php';
        $responseArray['response'] = update_user($values);
Example #11
0
    $smarty->assign('currency_format', $_CFG['currency_format']);
    $smarty->assign('integral_scale', $_CFG['integral_scale']);
    $smarty->assign('name_of_region', array($_CFG['name_of_region_1'], $_CFG['name_of_region_2'], $_CFG['name_of_region_3'], $_CFG['name_of_region_4']));
    $smarty->display('user_transaction.dwt');
} elseif ($action == 'xiugai') {
    $address_id = intval($_REQUEST['id']);
    $xiugai = $db->getAll("SELECT address_id,province,city,district,address,zipcode,tel,consignee,is_first FROM " . $ecs->table('user_address') . " WHERE address_id='{$address_id}'");
    echo json_encode($xiugai);
    exit;
    // print_r($xiugai);
} elseif ($action == 'act_edit_address') {
    include_once ROOT_PATH . 'includes/lib_transaction.php';
    include_once ROOT_PATH . 'languages/' . $_CFG['lang'] . '/shopping_flow.php';
    $smarty->assign('lang', $_LANG);
    $address = array('user_id' => $user_id, 'address_id' => intval($_POST['address_id']), 'country' => isset($_POST['country']) ? intval($_POST['country']) : 0, 'province' => isset($_POST['province']) ? intval($_POST['province']) : 0, 'city' => isset($_POST['city']) ? intval($_POST['city']) : 0, 'district' => isset($_POST['district']) ? intval($_POST['district']) : 0, 'address' => isset($_POST['address']) ? compile_str(trim($_POST['address'])) : '', 'consignee' => isset($_POST['consignee']) ? compile_str(trim($_POST['consignee'])) : '', 'email' => isset($_POST['email']) ? compile_str(trim($_POST['email'])) : '', 'tel' => isset($_POST['tel']) ? compile_str(make_semiangle(trim($_POST['tel']))) : '', 'zipcode' => isset($_POST['zipcode']) ? compile_str(make_semiangle(trim($_POST['zipcode']))) : '', 'is_first' => isset($_POST['is_first']) ? intval($_POST['is_first']) : 1);
    $flag = update_address($address);
    if ($flag == 2) {
        show_message('最多只能添加' . ADDRESS_NUM . '条收货地址', $_LANG['address_list_lnk'], 'user.php?act=address_list');
    } else {
        if ($flag == 1) {
            show_message($_LANG['edit_address_success'], $_LANG['address_list_lnk'], 'user.php?act=address_list');
        }
    }
} elseif ($action == 'drop_consignee') {
    include_once 'includes/lib_transaction.php';
    $consignee_id = intval($_GET['id']);
    if (drop_consignee($consignee_id)) {
        ecs_header("Location: user.php?act=address_list\n");
        exit;
    } else {
        show_message($_LANG['del_address_false']);
Example #12
0
    $district_list = get_regions(3, $consignee['city']);
    $smarty->assign('country_list', get_regions());
    $smarty->assign('province_list', $province_list);
    $smarty->assign('address', $address_id);
    $smarty->assign('city_list', $city_list);
    $smarty->assign('district_list', $district_list);
    $smarty->assign('consignee', $consignee);
    $smarty->assign('back_url', "flow.php");
    $smarty->display('edit_consignee.dwt');
    exit;
} elseif ($_REQUEST['act'] == 'act_edit_consignee') {
    include_once ROOT_PATH . 'includes/lib_transaction.php';
    include_once ROOT_PATH . 'languages/' . $_CFG['lang'] . '/shopping_flow.php';
    $smarty->assign('lang', $_LANG);
    $address = array('user_id' => $_SESSION['user_id'], 'address_id' => intval($_POST['address_id']), 'address_type' => intval($_POST['address_type']), 'country' => isset($_POST['country']) ? intval($_POST['country']) : 1, 'province' => isset($_POST['province']) ? intval($_POST['province']) : 0, 'city' => isset($_POST['city']) ? intval($_POST['city']) : 0, 'district' => isset($_POST['district']) ? intval($_POST['district']) : 0, 'address' => isset($_POST['address']) ? compile_str(trim($_POST['address'])) : '', 'consignee' => isset($_POST['consignee']) ? compile_str(trim($_POST['consignee'])) : '', 'email' => isset($_POST['email']) ? compile_str(trim($_POST['email'])) : '', 'tel' => isset($_POST['tel']) ? compile_str(make_semiangle(trim($_POST['tel']))) : '', 'mobile' => isset($_POST['mobile']) ? compile_str(make_semiangle(trim($_POST['mobile']))) : '', 'best_time' => isset($_POST['best_time']) ? compile_str(trim($_POST['best_time'])) : '', 'sign_building' => isset($_POST['sign_building']) ? compile_str(trim($_POST['sign_building'])) : '', 'zipcode' => isset($_POST['zipcode']) ? compile_str(make_semiangle(trim($_POST['zipcode']))) : '');
    if ($address_id = update_address($address)) {
        //hhs_header('location:flow.php?step=address_list');
        hhs_header('location:flow.php?step=checkout&address_id=' . $address_id);
        //show_message($_LANG['edit_address_success'], $_LANG['address_list_lnk'], 'user.php?act=address_list');
    }
} elseif ($_REQUEST['step'] == 'checkout') {
    /*------------------------------------------------------ */
    //-- 订单确认
    /*------------------------------------------------------ */
    include_once 'includes/lib_transaction.php';
    if ($_REQUEST['address_id']) {
        $smarty->assign('address_id', $_REQUEST['address_id']);
        $consignee = get_user_address($_REQUEST['address_id']);
        $sql = "update " . $hhs->table('users') . " set address_id=" . $_REQUEST['address_id'] . " where user_id=" . $_SESSION['user_id'];
        $db->query($sql);
        $_SESSION['flow_consignee'] = stripslashes_deep($consignee);