customers.php
来自「全新且完善的强大网上商店系统」· PHP 代码 · 共 653 行 · 第 1/2 页
PHP
653 行
<?php
/*
[SOOBIC!] admin/customers.php
Version: 1.5
Author: Soolan (soolan@qq.com)
Copyright: soolan (www.soobic.com)
Last Modified: 2005/4/9 10:00
*/
if(!defined('IN_SOOLAN')) {
exit('Access Denied');
}
cpheader();
include ("admin/languages/".$language."/customers.php");
if(!$alloweditcustomer){
cpmsg("对不起,您的管理权限受限,不能进行此操作。");
}
$error = false;
$processed = false;
$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : (isset($HTTP_POST_VARS['action']) ? $HTTP_POST_VARS['action'] : ''));
if ($action) {
switch($action){
case 'new_specials':
case 'delete_specials':
$db->query("delete from $table_specials where specials_id = '" . (int)$HTTP_GET_VARS['sID']. "'");
cpmsg("Lansen! 厂家删除。",tep_href_link('admincp.php', 'act=specials&page=' . $HTTP_GET_VARS['page']));
break;
default:
}
}elseif($type){
switch($type){
case 'delete_specials':
cpmsg("本操作不可恢复,您确定要删除该特价商品?", tep_href_link('admincp.php', 'act=specials&page=' . $HTTP_GET_VARS['page'].'&sID='.$sID.'&action=delete_specials', 'NONSSL'), "form");
break;
case 'update':
$customers_id = dhtmlspecialchars($HTTP_POST_VARS['customers_id']);
$customers_firstname = dhtmlspecialchars($HTTP_POST_VARS['customers_firstname']);
$customers_lastname = dhtmlspecialchars($HTTP_POST_VARS['customers_lastname']);
$customers_email_address = dhtmlspecialchars($HTTP_POST_VARS['customers_email_address']);
$customers_telephone = dhtmlspecialchars($HTTP_POST_VARS['customers_telephone']);
$customers_fax = dhtmlspecialchars($HTTP_POST_VARS['customers_fax']);
$customers_newsletter = dhtmlspecialchars($HTTP_POST_VARS['customers_newsletter']);
$customers_gender = dhtmlspecialchars($HTTP_POST_VARS['customers_gender']);
$customers_dob = dhtmlspecialchars($HTTP_POST_VARS['customers_dob']);
$default_address_id = dhtmlspecialchars($HTTP_POST_VARS['default_address_id']);
$entry_street_address = dhtmlspecialchars($HTTP_POST_VARS['entry_street_address']);
$entry_suburb = dhtmlspecialchars($HTTP_POST_VARS['entry_suburb']);
$entry_postcode = dhtmlspecialchars($HTTP_POST_VARS['entry_postcode']);
$entry_city = dhtmlspecialchars($HTTP_POST_VARS['entry_city']);
$entry_country_id = dhtmlspecialchars($HTTP_POST_VARS['entry_country_id']);
$entry_company = dhtmlspecialchars($HTTP_POST_VARS['entry_company']);
$entry_state = dhtmlspecialchars($HTTP_POST_VARS['entry_state']);
if (isset($HTTP_POST_VARS['entry_zone_id'])) $entry_zone_id = dhtmlspecialchars($HTTP_POST_VARS['entry_zone_id']);
if (strlen($customers_firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
$error = true;
$entry_firstname_error = true;
} else {
$entry_firstname_error = false;
}
if (strlen($customers_lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
$error = true;
$entry_lastname_error = true;
} else {
$entry_lastname_error = false;
}
if (ACCOUNT_DOB == 'true') {
if (checkdate(substr(tep_date_raw($customers_dob), 4, 2), substr(tep_date_raw($customers_dob), 6, 2), substr(tep_date_raw($customers_dob), 0, 4))) {
$entry_date_of_birth_error = false;
} else {
$error = true;
$entry_date_of_birth_error = true;
}
}
if (strlen($customers_email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
$error = true;
$entry_email_address_error = true;
} else {
$entry_email_address_error = false;
}
if (!tep_validate_email($customers_email_address)) {
$error = true;
$entry_email_address_check_error = true;
} else {
$entry_email_address_check_error = false;
}
if (strlen($entry_street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
$error = true;
$entry_street_address_error = true;
} else {
$entry_street_address_error = false;
}
if (strlen($entry_postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
$error = true;
$entry_post_code_error = true;
} else {
$entry_post_code_error = false;
}
if (strlen($entry_city) < ENTRY_CITY_MIN_LENGTH) {
$error = true;
$entry_city_error = true;
} else {
$entry_city_error = false;
}
//echo $error==true ? 'ppp' : 'tttt';
//exit;
if ($entry_country_id == false) {
$error = true;
$entry_country_error = true;
} else {
$entry_country_error = false;
}
if (ACCOUNT_STATE == 'true') {
if ($entry_country_error == true) {
$entry_state_error = true;
} else {
$zone_id = 0;
$entry_state_error = false;
$check_query = $db->query("select count(*) as total from $table_zones where zone_country_id = '" . (int)$entry_country_id . "'");
$check_value = $db->fetch_array($check_query);
$entry_state_has_zones = ($check_value['total'] > 0);
if ($entry_state_has_zones == true) {
$zone_query = $db->query("select zone_id from $table_zones where zone_country_id = '" . (int)$entry_country_id . "' and zone_name = '" . addslashes($entry_state) . "'");
if ($db->num_rows($zone_query) == 1) {
$zone_values = $db->fetch_array($zone_query);
$entry_zone_id = $zone_values['zone_id'];
} else {
$error = true;
$entry_state_error = true;
}
} else {
if ($entry_state == false) {
$error = true;
$entry_state_error = true;
}
}
}
}
if (strlen($customers_telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
$error = true;
$entry_telephone_error = true;
} else {
$entry_telephone_error = false;
}
$check_email = $db->query("select customers_email_address from $table_customers where customers_email_address = '" . addslashes($customers_email_address) . "' and customers_id != '" . (int)$customers_id . "'");
if ($db->num_rows($check_email)) {
$error = true;
$entry_email_address_exists = true;
} else {
$entry_email_address_exists = false;
}
if ($error == false) {
if (ACCOUNT_GENDER == 'true') $db_customers_gender = "customers_gender = '".$customers_gender."',";
if (ACCOUNT_DOB == 'true') $db_customers_dob = "customers_dob = '".tep_date_raw($customers_dob)."',";
$db->query("update $table_customers set
customers_firstname = '$customers_firstname',
customers_lastname = '$customers_lastname',
customers_email_address = '$customers_email_address',
customers_telephone = '$customers_telephone',
customers_fax = '$customers_fax',
$db_customers_gender $db_customers_dob
customers_newsletter = '$customers_newsletter'
where customers_id = '" . (int)$customers_id . "'
");
$datetime=date("Y-m-d h:i:s",time());
$db->query("update $table_customers_info set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customers_id . "'");
if ($entry_zone_id > 0) $entry_state = '';
if (ACCOUNT_COMPANY == 'true') $db_entry_company = "entry_company = '".$entry_company."',";
if (ACCOUNT_SUBURB == 'true') $db_entry_suburb = "entry_suburb = '".tep_date_raw($entry_suburb)."',";
if (ACCOUNT_STATE == 'true') {
if ($entry_zone_id > 0) {
$db_entry_zone_id = "entry_zone_id = '".$entry_zone_id."',";
$db_entry_state = "entry_state = ''";
} else {
$db_entry_zone_id = '0';
$db_entry_state = "entry_state = '".$entry_state."',";
}
}
$db->query("update $table_address_book set
entry_firstname = '$customers_firstname',
entry_lastname = '$customers_lastname',
entry_street_address = '$entry_street_address',
entry_postcode = '$entry_postcode',
entry_city = '$entry_city',
$db_entry_company $db_entry_suburb
entry_country_id = '$entry_country_id'
where customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'
");
cpmsg("Lansen! 用户信息更新成功。",tep_href_link('admincp.php', 'act=customers&page=' . $HTTP_GET_VARS['page']));
} else if ($error == true) {
@extract($HTTP_POST_VARS);
$processed = true;
}
break;
case 'edit_customers':
$query = $db->query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from $table_customers c left join $table_address_book a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'");
@extract($db->fetch_array($query));
$newsletter = '<select name="customers_newsletter"><option value="1" '.($customers_newsletter=='1' ? "selected" :'').'>' .ENTRY_NEWSLETTER_YES . '</option><option value="0" '.($customers_newsletter=='0' ? "selected" :'').'>' .ENTRY_NEWSLETTER_NO. '</option></select>';
break;
default:
}
?>
<script language="javascript"><!--
function check_form() {
var error = 0;
var error_message = "<?php echo JS_ERROR; ?>";
var customers_firstname = document.customers.customers_firstname.value;
var customers_lastname = document.customers.customers_lastname.value;
<?php if (ACCOUNT_COMPANY == 'true') echo 'var entry_company = document.customers.entry_company.value;' . "\n"; ?>
<?php if (ACCOUNT_DOB == 'true') echo 'var customers_dob = document.customers.customers_dob.value;' . "\n"; ?>
var customers_email_address = document.customers.customers_email_address.value;
var entry_street_address = document.customers.entry_street_address.value;
var entry_postcode = document.customers.entry_postcode.value;
var entry_city = document.customers.entry_city.value;
var customers_telephone = document.customers.customers_telephone.value;
<?php if (ACCOUNT_GENDER == 'true') { ?>
if (document.customers.customers_gender[0].checked || document.customers.customers_gender[1].checked) {
} else {
error_message = error_message + "<?php echo JS_GENDER; ?>";
error = 1;
}
<?php } ?>
if (customers_firstname == "" || customers_firstname.length < <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>) {
error_message = error_message + "<?php echo JS_FIRST_NAME; ?>";
error = 1;
}
if (customers_lastname == "" || customers_lastname.length < <?php echo ENTRY_LAST_NAME_MIN_LENGTH; ?>) {
error_message = error_message + "<?php echo JS_LAST_NAME; ?>";
error = 1;
}
<?php if (ACCOUNT_DOB == 'true') { ?>
if (customers_dob == "" || customers_dob.length < <?php echo ENTRY_DOB_MIN_LENGTH; ?>) {
error_message = error_message + "<?php echo JS_DOB; ?>";
error = 1;
}
<?php } ?>
if (customers_email_address == "" || customers_email_address.length < <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH; ?>) {
error_message = error_message + "<?php echo JS_EMAIL_ADDRESS; ?>";
error = 1;
}
if (entry_street_address == "" || entry_street_address.length < <?php echo ENTRY_STREET_ADDRESS_MIN_LENGTH; ?>) {
error_message = error_message + "<?php echo JS_ADDRESS; ?>";
error = 1;
}
if (entry_postcode == "" || entry_postcode.length < <?php echo ENTRY_POSTCODE_MIN_LENGTH; ?>) {
error_message = error_message + "<?php echo JS_POST_CODE; ?>";
error = 1;
}
if (entry_city == "" || entry_city.length < <?php echo ENTRY_CITY_MIN_LENGTH; ?>) {
error_message = error_message + "<?php echo JS_CITY; ?>";
error = 1;
}
<?php
if (ACCOUNT_STATE == 'true') {
?>
if (document.customers.elements['entry_state'].type != "hidden") {
if (document.customers.entry_state.value == '' || document.customers.entry_state.value.length < <?php echo ENTRY_STATE_MIN_LENGTH; ?> ) {
error_message = error_message + "<?php echo JS_STATE; ?>";
error = 1;
}
}
<?php
}
?>
if (document.customers.elements['entry_country_id'].type != "hidden") {
if (document.customers.entry_country_id.value == 0) {
error_message = error_message + "<?php echo JS_COUNTRY; ?>";
error = 1;
}
}
if (customers_telephone == "" || customers_telephone.length < <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>) {
error_message = error_message + "<?php echo JS_TELEPHONE; ?>";
error = 1;
}
if (error == 1) {
alert(error_message);
return false;
} else {
return true;
}
}
//--></script>
<br>
<table cellspacing="0" cellpadding="0" border="0" width="95%" align="center">
<tr><td bgcolor="<?=BORDERCOLOR?>">
<table border="0" cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="100%">
<tr class="header"><td>特别提示</td></tr>
<tr bgcolor="<?=ALTBG1?>"><td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr><td><?=TEXT_SPECIALS_PRICE_TIP;?></td>
<td align="right" class="smallText"><?php echo '<a href="'.tep_href_link('admincp.php', 'act=customers&page=' . $page, 'NONSSL').'"><img src="admin/languages/'.$language.'/images/buttons/button_back.gif" alt="'.IMAGE_NEW_CATEGORY.'" border="0"></a> '; ?> </td>
</tr></table></td></tr></table></td></tr></table>
<br>
<form name="customers" <?php echo 'action="' . tep_href_link('admincp.php', 'act=customers&type=update', 'NONSSL') . '"'; ?> method="post" onSubmit="return check_form();">
<input type="hidden" name="default_address_id" value="<?=$customers_default_address_id;?>">
<input type="hidden" name="customers_id" value="<?=$customers_id;?>">
<table cellspacing="0" cellpadding="0" border="0" width="95%" align="center">
<tr><td bgcolor="<?=BORDERCOLOR?>">
<table border="0" cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="100%">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?